Merge branch 'oggLib' of github.com:DDVTECH/libmist into oggLib

Conflicts:
	lib/Makefile.am
	lib/ogg.cpp

Ogg completed further
This commit is contained in:
Oswald de Bruin 2013-06-14 16:30:55 +02:00 committed by Erik Zandvliet
parent 7810c9428d
commit 8cae5f1fc6
3 changed files with 121 additions and 2 deletions

View file

@ -1,5 +1,5 @@
lib_LTLIBRARIES=libmist-1.0.la
libmist_1_0_la_SOURCES=amf.h amf.cpp auth.h auth.cpp base64.h base64.cpp config.h config.cpp dtsc.h dtsc.cpp flv_tag.h flv_tag.cpp http_parser.h http_parser.cpp json.h json.cpp procs.h procs.cpp rtmpchunks.h rtmpchunks.cpp socket.h socket.cpp mp4.h mp4.cpp ftp.h ftp.cpp filesystem.h filesystem.cpp stream.h stream.cpp timing.h timing.cpp ts_packet.cpp ts_packet.h converter.cpp converter.h ogg.h ogg.cpp
libmist_1_0_la_SOURCES=amf.h amf.cpp auth.h auth.cpp base64.h base64.cpp config.h config.cpp dtsc.h dtsc.cpp flv_tag.h flv_tag.cpp http_parser.h http_parser.cpp json.h json.cpp procs.h procs.cpp rtmpchunks.h rtmpchunks.cpp socket.h socket.cpp mp4.h mp4.cpp ftp.h ftp.cpp filesystem.h filesystem.cpp stream.h stream.cpp timing.h timing.cpp ts_packet.cpp ts_packet.h converter.cpp converter.h ogg.h ogg.cpp theora.cpp theora.h
libmist_1_0_la_LDFLAGS = -version-info 5:1:2
libmist_1_0_la_CPPFLAGS=$(DEPS_CFLAGS) $(global_CFLAGS)
libmist_1_0_la_LIBADD=$(DEPS_LIBS) $(CLOCK_LIB)
@ -8,4 +8,4 @@ pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = mist-1.0.pc
library_includedir=$(includedir)/mist-1.0/mist
library_include_HEADERS = amf.h auth.h base64.h config.h dtsc.h flv_tag.h http_parser.h json.h procs.h rtmpchunks.h socket.h mp4.h ftp.h filesystem.h stream.h timing.h nal.h ts_packet.h converter.h ogg.h
library_include_HEADERS = amf.h auth.h base64.h config.h dtsc.h flv_tag.h http_parser.h json.h procs.h rtmpchunks.h socket.h mp4.h ftp.h filesystem.h stream.h timing.h nal.h ts_packet.h converter.h ogg.h theora.h

100
lib/theora.cpp Normal file
View file

@ -0,0 +1,100 @@
#include<theora.h>
#include<stdlib.h>
#include<string.h>
#include <arpa/inet.h>
namespace theora{
bool header::checkDataSize(unsigned int size){
if (size > datasize){
void* tmp = realloc(data,size);
if (tmp){
data = (char*)tmp;
datasize = size;
return true;
}else{
return false;
}
}else{
return true;
}
}
/// Gets the 32 bits integer at the given index.
/// Attempts to resize the data pointer if the index is out of range.
/// Returns zero if resizing failed.
uint32_t header::getInt32(size_t index){
/*if (index + 3 >= datasize){
if ( !reserve(index, 0, 4)){
return 0;
}
setInt32(0, index);
}*/
uint32_t result;
memcpy((char*) &result, data + index, 4);
return ntohl(result);
}
header::header(){
data = NULL;
datasize = 0;
}
bool header::read(char* newData, unsigned int length){
if (length < 7){
return false;
}
if(memcmp(newData+1, "theora", 6)!=0){
return false;
}
switch(newData[0]){
case 0x80:
//if (length != 42) return false;
break;
case 0x81:
break;
case 0x82:
break;
default:
return false;
break;
};
if (checkDataSize(length)){
memcpy(data, newData, length);
}else{
return false;
}
return true;
}
int header::getHeaderType(){
switch(data[0]){
case 0x80:
return 0;
break;
case 0x81:
return 1;
break;
case 0x82:
return 2;
break;
default:
return -1;
break;
};
}
long unsigned int header::getFRN(){
if (getHeaderType() == 0){
return getInt32(22);
}
return 0;
}
long unsigned int header::getFRD(){
if (getHeaderType() == 0){
return getInt32(26);
}
return 0;
}
}

19
lib/theora.h Normal file
View file

@ -0,0 +1,19 @@
#include<sys/types.h>
#include<stdint.h>
namespace theora{
class header{
public:
header();
bool read(char* newData, unsigned int length);
int getHeaderType();
long unsigned int getFRN();
long unsigned int getFRD();
protected:
uint32_t getInt32(size_t index);
private:
char* data;
unsigned int datasize;
bool checkDataSize(unsigned int size);
};
}