From 37df1716de3727f6ce28a52b5452812f73040e80 Mon Sep 17 00:00:00 2001 From: Oswald Auguste de Bruin Date: Mon, 15 Jul 2013 16:24:43 +0200 Subject: [PATCH] Added vorbis functionality --- lib/Makefile.am | 4 ++-- lib/vorbis.cpp | 34 ++++++++++++++++++++++++++++++++++ lib/vorbis.h | 16 ++++++++++++++++ 3 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 lib/vorbis.cpp create mode 100644 lib/vorbis.h diff --git a/lib/Makefile.am b/lib/Makefile.am index 41c0c207..22c1f7cd 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -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 theora.cpp theora.h +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 vorbis.cpp vorbis.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 theora.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 vorbis.h diff --git a/lib/vorbis.cpp b/lib/vorbis.cpp new file mode 100644 index 00000000..9b58fb77 --- /dev/null +++ b/lib/vorbis.cpp @@ -0,0 +1,34 @@ +#include"vorbis.h" +#include +#include +#include + +namespace vorbis{ + header::header(){ + data = NULL; + datasize = 0; + } + 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; + } + } + + bool header::read(char* newData, unsigned int length){ + if (checkDataSize(length)){ + memcpy(data, newData, length); + }else{ + return false; + } + return true; + } +} diff --git a/lib/vorbis.h b/lib/vorbis.h new file mode 100644 index 00000000..194bc812 --- /dev/null +++ b/lib/vorbis.h @@ -0,0 +1,16 @@ +#pragma once +#include +#include +#include + +namespace vorbis{ + class header{ + public: + header(); + bool read(char* newData, unsigned int length); + private: + char* data; + unsigned int datasize; + bool checkDataSize(unsigned int size); + }; +}