From 36e086e0e27657992210918541c5d5fb6906c4ee Mon Sep 17 00:00:00 2001 From: Thulinma Date: Tue, 8 May 2012 19:19:42 +0200 Subject: [PATCH] Convert to autotools build system for cleanness (part1). --- Buffer/Makefile | 23 - Buffer/play1000kbit.sh | 5 - Buffer/playh264.sh | 9 - Connector_HTTP/Makefile | 26 - Connector_RAW/Makefile | 23 - Connector_RTMP/Makefile | 27 - Connector_RTSP/Makefile | 25 - Connector_RTSP/compile_remarks.txt | 25 - Connector_RTSP/main.cpp | 299 --------- Connector_RTSP/rtp.h | 9 - Connector_RTSP/rtsp_notes | 79 --- Connector_TS/Makefile | 26 - Connector_TS/main.cpp | 364 ----------- Controller/Makefile | 30 - Makefile | 38 -- Makefile.am | 2 + configure.ac | 39 ++ lib/Makefile.am | 15 + {util => lib}/amf.cpp | 0 {util => lib}/amf.h | 0 {util => lib}/auth.cpp | 0 {util => lib}/auth.h | 0 {util => lib}/base64.cpp | 0 {util => lib}/base64.h | 0 {util => lib}/config.cpp | 4 +- {util => lib}/config.h | 0 {util => lib}/crypto.cpp | 0 {util => lib}/crypto.h | 0 {util => lib}/dtsc.cpp | 0 {util => lib}/dtsc.h | 0 {util => lib}/flv_tag.cpp | 0 {util => lib}/flv_tag.h | 0 {util => lib}/http_parser.cpp | 0 {util => lib}/http_parser.h | 0 {util => lib}/json.cpp | 0 {util => lib}/json.h | 0 {util => lib}/md5.cpp | 0 {util => lib}/md5.h | 0 {util => lib}/procs.cpp | 0 {util => lib}/procs.h | 0 {util => lib}/rtmpchunks.cpp | 0 {util => lib}/rtmpchunks.h | 0 {util => lib}/socket.cpp | 0 {util => lib}/socket.h | 0 {util => lib}/tinythread.cpp | 0 {util => lib}/tinythread.h | 0 src/Makefile.am | 13 + .../analysers/abst_analyser.cpp | 0 .../analysers/amf_analyser.cpp | 0 .../analysers/dtsc_analyser.cpp | 0 .../analysers/flv_analyser.cpp | 0 .../analysers/httpbox_analyser.cpp | 0 .../analysers/rtmp_analyser.cpp | 0 .../analysers/rtp_analyser.cpp | 0 .../main.cpp => src/analysers/ts_analyser.cpp | 0 Buffer/main.cpp => src/buffer.cpp | 2 +- Buffer/stats.cpp => src/buffer_stats.cpp | 2 +- Buffer/stats.h => src/buffer_stats.h | 0 Buffer/stream.cpp => src/buffer_stream.cpp | 2 +- Buffer/stream.h => src/buffer_stream.h | 6 +- Buffer/user.cpp => src/buffer_user.cpp | 4 +- Buffer/user.h => src/buffer_user.h | 8 +- Connector_HTTP/main.cpp => src/conn_http.cpp | 32 +- Connector_RAW/main.cpp => src/conn_raw.cpp | 2 +- Connector_RTMP/main.cpp => src/conn_rtmp.cpp | 10 +- Controller/main.cpp => src/controller.cpp | 16 +- .../main.cpp => src/converters/dtsc2flv.cpp | 0 .../main.cpp => src/converters/flv2dtsc.cpp | 0 {util => src}/server_setup.cpp | 4 +- tools/ABST_Parser/Makefile | 19 - tools/AMF_Tester/Makefile | 19 - tools/DTSC2FLV/Makefile | 23 - tools/DTSC_Analyser/Makefile | 23 - tools/FLV2DTSC/Makefile | 20 - tools/FLV_Analyser/Makefile | 23 - tools/HTTP_Box_Parser/Makefile | 19 - tools/RTMP_Parser/Makefile | 20 - tools/spawntest/Makefile | 20 - tools/spawntest/main.cpp | 26 - tools/spawntest/test.sh | 6 - tools/spawntest/testpipein.sh | 5 - tools/spawntest/testpipeout.sh | 6 - util/MP4/Makefile | 18 - util/MP4/box.cpp | 123 ---- util/MP4/box_abst.cpp | 227 ------- util/MP4/box_afra.cpp | 75 --- util/MP4/box_afrt.cpp | 104 ---- util/MP4/box_amhp.cpp | 63 -- util/MP4/box_asrt.cpp | 87 --- util/MP4/box_avcC.cpp | 87 --- util/MP4/box_dinf.cpp | 43 -- util/MP4/box_dref.cpp | 58 -- util/MP4/box_esds.cpp | 55 -- util/MP4/box_ftyp.cpp | 39 -- util/MP4/box_hdlr.cpp | 59 -- util/MP4/box_hmhd.cpp | 57 -- util/MP4/box_includes.h | 37 -- util/MP4/box_mdat.cpp | 29 - util/MP4/box_mdhd.cpp | 88 --- util/MP4/box_mdia.cpp | 51 -- util/MP4/box_mfhd.cpp | 39 -- util/MP4/box_minf.cpp | 51 -- util/MP4/box_moof.cpp | 51 -- util/MP4/box_moov.cpp | 51 -- util/MP4/box_mvex.cpp | 51 -- util/MP4/box_mvhd.cpp | 113 ---- util/MP4/box_nmhd.cpp | 28 - util/MP4/box_rtmp.cpp | 89 --- util/MP4/box_smhd.cpp | 29 - util/MP4/box_stbl.cpp | 51 -- util/MP4/box_stco.cpp | 58 -- util/MP4/box_stsc.cpp | 63 -- util/MP4/box_stsd.cpp | 59 -- util/MP4/box_stts.cpp | 60 -- util/MP4/box_tfhd.cpp | 88 --- util/MP4/box_tkhd.cpp | 117 ---- util/MP4/box_traf.cpp | 51 -- util/MP4/box_trak.cpp | 51 -- util/MP4/box_trex.cpp | 59 -- util/MP4/box_trun.cpp | 68 -- util/MP4/box_url.cpp | 23 - util/MP4/box_vmhd.cpp | 45 -- util/MP4/interface.cpp | 589 ------------------ util/MP4/main.cpp | 13 - version.sh | 5 + 125 files changed, 125 insertions(+), 4475 deletions(-) delete mode 100644 Buffer/Makefile delete mode 100755 Buffer/play1000kbit.sh delete mode 100755 Buffer/playh264.sh delete mode 100644 Connector_HTTP/Makefile delete mode 100644 Connector_RAW/Makefile delete mode 100644 Connector_RTMP/Makefile delete mode 100644 Connector_RTSP/Makefile delete mode 100644 Connector_RTSP/compile_remarks.txt delete mode 100644 Connector_RTSP/main.cpp delete mode 100644 Connector_RTSP/rtp.h delete mode 100644 Connector_RTSP/rtsp_notes delete mode 100644 Connector_TS/Makefile delete mode 100644 Connector_TS/main.cpp delete mode 100644 Controller/Makefile delete mode 100644 Makefile create mode 100644 Makefile.am create mode 100644 configure.ac create mode 100644 lib/Makefile.am rename {util => lib}/amf.cpp (100%) rename {util => lib}/amf.h (100%) rename {util => lib}/auth.cpp (100%) rename {util => lib}/auth.h (100%) rename {util => lib}/base64.cpp (100%) rename {util => lib}/base64.h (100%) rename {util => lib}/config.cpp (95%) rename {util => lib}/config.h (100%) rename {util => lib}/crypto.cpp (100%) rename {util => lib}/crypto.h (100%) rename {util => lib}/dtsc.cpp (100%) rename {util => lib}/dtsc.h (100%) rename {util => lib}/flv_tag.cpp (100%) rename {util => lib}/flv_tag.h (100%) rename {util => lib}/http_parser.cpp (100%) rename {util => lib}/http_parser.h (100%) rename {util => lib}/json.cpp (100%) rename {util => lib}/json.h (100%) rename {util => lib}/md5.cpp (100%) rename {util => lib}/md5.h (100%) rename {util => lib}/procs.cpp (100%) rename {util => lib}/procs.h (100%) rename {util => lib}/rtmpchunks.cpp (100%) rename {util => lib}/rtmpchunks.h (100%) rename {util => lib}/socket.cpp (100%) rename {util => lib}/socket.h (100%) rename {util => lib}/tinythread.cpp (100%) rename {util => lib}/tinythread.h (100%) create mode 100644 src/Makefile.am rename tools/ABST_Parser/main.cpp => src/analysers/abst_analyser.cpp (100%) rename tools/AMF_Tester/main.cpp => src/analysers/amf_analyser.cpp (100%) rename tools/DTSC_Analyser/main.cpp => src/analysers/dtsc_analyser.cpp (100%) rename tools/FLV_Analyser/main.cpp => src/analysers/flv_analyser.cpp (100%) rename tools/HTTP_Box_Parser/main.cpp => src/analysers/httpbox_analyser.cpp (100%) rename tools/RTMP_Parser/main.cpp => src/analysers/rtmp_analyser.cpp (100%) rename tools/RTP_Parser/main.cpp => src/analysers/rtp_analyser.cpp (100%) rename tools/TS_Analyser/main.cpp => src/analysers/ts_analyser.cpp (100%) rename Buffer/main.cpp => src/buffer.cpp (99%) rename Buffer/stats.cpp => src/buffer_stats.cpp (95%) rename Buffer/stats.h => src/buffer_stats.h (100%) rename Buffer/stream.cpp => src/buffer_stream.cpp (99%) rename Buffer/stream.h => src/buffer_stream.h (97%) rename Buffer/user.cpp => src/buffer_user.cpp (97%) rename Buffer/user.h => src/buffer_user.h (94%) rename Connector_HTTP/main.cpp => src/conn_http.cpp (96%) rename Connector_RAW/main.cpp => src/conn_raw.cpp (96%) rename Connector_RTMP/main.cpp => src/conn_rtmp.cpp (99%) rename Controller/main.cpp => src/controller.cpp (98%) rename tools/DTSC2FLV/main.cpp => src/converters/dtsc2flv.cpp (100%) rename tools/FLV2DTSC/main.cpp => src/converters/flv2dtsc.cpp (100%) rename {util => src}/server_setup.cpp (97%) delete mode 100644 tools/ABST_Parser/Makefile delete mode 100644 tools/AMF_Tester/Makefile delete mode 100644 tools/DTSC2FLV/Makefile delete mode 100644 tools/DTSC_Analyser/Makefile delete mode 100644 tools/FLV2DTSC/Makefile delete mode 100644 tools/FLV_Analyser/Makefile delete mode 100644 tools/HTTP_Box_Parser/Makefile delete mode 100644 tools/RTMP_Parser/Makefile delete mode 100644 tools/spawntest/Makefile delete mode 100644 tools/spawntest/main.cpp delete mode 100755 tools/spawntest/test.sh delete mode 100755 tools/spawntest/testpipein.sh delete mode 100755 tools/spawntest/testpipeout.sh delete mode 100644 util/MP4/Makefile delete mode 100644 util/MP4/box.cpp delete mode 100644 util/MP4/box_abst.cpp delete mode 100644 util/MP4/box_afra.cpp delete mode 100644 util/MP4/box_afrt.cpp delete mode 100644 util/MP4/box_amhp.cpp delete mode 100644 util/MP4/box_asrt.cpp delete mode 100644 util/MP4/box_avcC.cpp delete mode 100644 util/MP4/box_dinf.cpp delete mode 100644 util/MP4/box_dref.cpp delete mode 100644 util/MP4/box_esds.cpp delete mode 100644 util/MP4/box_ftyp.cpp delete mode 100644 util/MP4/box_hdlr.cpp delete mode 100644 util/MP4/box_hmhd.cpp delete mode 100644 util/MP4/box_includes.h delete mode 100644 util/MP4/box_mdat.cpp delete mode 100644 util/MP4/box_mdhd.cpp delete mode 100644 util/MP4/box_mdia.cpp delete mode 100644 util/MP4/box_mfhd.cpp delete mode 100644 util/MP4/box_minf.cpp delete mode 100644 util/MP4/box_moof.cpp delete mode 100644 util/MP4/box_moov.cpp delete mode 100644 util/MP4/box_mvex.cpp delete mode 100644 util/MP4/box_mvhd.cpp delete mode 100644 util/MP4/box_nmhd.cpp delete mode 100644 util/MP4/box_rtmp.cpp delete mode 100644 util/MP4/box_smhd.cpp delete mode 100644 util/MP4/box_stbl.cpp delete mode 100644 util/MP4/box_stco.cpp delete mode 100644 util/MP4/box_stsc.cpp delete mode 100644 util/MP4/box_stsd.cpp delete mode 100644 util/MP4/box_stts.cpp delete mode 100644 util/MP4/box_tfhd.cpp delete mode 100644 util/MP4/box_tkhd.cpp delete mode 100644 util/MP4/box_traf.cpp delete mode 100644 util/MP4/box_trak.cpp delete mode 100644 util/MP4/box_trex.cpp delete mode 100644 util/MP4/box_trun.cpp delete mode 100644 util/MP4/box_url.cpp delete mode 100644 util/MP4/box_vmhd.cpp delete mode 100644 util/MP4/interface.cpp delete mode 100644 util/MP4/main.cpp create mode 100755 version.sh diff --git a/Buffer/Makefile b/Buffer/Makefile deleted file mode 100644 index 58ee5b2f..00000000 --- a/Buffer/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -SRC = main.cpp ../util/json.cpp ../util/socket.cpp ../util/dtsc.cpp ../util/tinythread.cpp user.cpp stats.cpp stream.cpp -OBJ = $(SRC:.cpp=.o) -OUT = MistBuffer -INCLUDES = -DEBUG = 4 -OPTIMIZE = -g -CCFLAGS = -Wall -Wextra -funsigned-char $(OPTIMIZE) -DDEBUG=$(DEBUG) -CC = $(CROSS)g++ -LD = $(CROSS)ld -AR = $(CROSS)ar -LIBS = -lpthread -.SUFFIXES: .cpp -.PHONY: clean default -default: $(OUT) -.cpp.o: - $(CC) $(INCLUDES) $(CCFLAGS) $(LIBS) -c $< -o $@ -$(OUT): $(OBJ) - $(CC) $(LIBS) -o ../bin/$(OUT) $(OBJ) -clean: - rm -rf $(OBJ) ../bin/$(OUT) Makefile.bak *~ -install: $(OUT) - cp -f ../bin/$(OUT) /usr/bin/ - diff --git a/Buffer/play1000kbit.sh b/Buffer/play1000kbit.sh deleted file mode 100755 index f8ff8b22..00000000 --- a/Buffer/play1000kbit.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -ffmpeg -re -i "$1" -b 1024000 -ar 11025 -f flv - 2> /dev/null | ./Buffer 500 $2 - - - diff --git a/Buffer/playh264.sh b/Buffer/playh264.sh deleted file mode 100755 index 4ec9510f..00000000 --- a/Buffer/playh264.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -#ffmpeg -y -i "$1" -acodec libfaac -ar 44100 -vcodec libx264 -b 1000k -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -i_qfactor 0.71 -keyint_min 25 -b_strategy 1 -g 150 -r 20 -f flv - 2> /dev/null | ./Server_PLS 500 - - - -#ffmpeg -y -i "$1" -ar 44100 -vcodec libx264 -b 1000k -g 150 -r 20 -f flv - | ./Buffer 500 - -ffmpeg -i "$1" -re -strict experimental -acodec aac -ar 11025 -vcodec libx264 -b 700k -vpre libx264-lossless_ultrafast -refs 1 -bf 0 -g 150 -f flv - 2> /dev/null | ./DDV_Buffer 500 $2 - diff --git a/Connector_HTTP/Makefile b/Connector_HTTP/Makefile deleted file mode 100644 index 3d30eb53..00000000 --- a/Connector_HTTP/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -SRC = main.cpp ../util/socket.cpp ../util/http_parser.cpp ../util/flv_tag.cpp ../util/amf.cpp ../util/dtsc.cpp ../util/config.cpp ../util/base64.cpp ../util/json.cpp -OBJ = $(SRC:.cpp=.o) -OUT = MistConnHTTP -INCLUDES = -DEBUG = 4 -OPTIMIZE = -g -CCFLAGS = -Wall -Wextra -funsigned-char $(OPTIMIZE) -DDEBUG=$(DEBUG) -DVERSION=$(VERSION) -VERSION = `git describe --tags` -CC = $(CROSS)g++ -LD = $(CROSS)ld -AR = $(CROSS)ar -LIBS= -.SUFFIXES: .cpp -.PHONY: clean default -default: cversion $(OUT) -.cpp.o: - $(CC) $(INCLUDES) $(CCFLAGS) $(LIBS) -c $< -o $@ -$(OUT): $(OBJ) - $(CC) $(LIBS) -o ../bin/$(OUT) $(OBJ) -clean: - rm -rf $(OBJ) ../bin/$(OUT) Makefile.bak *~ -install: $(OUT) - cp -f ../bin/$(OUT) /usr/bin/ -cversion: - rm -rf ../util/config.o - diff --git a/Connector_RAW/Makefile b/Connector_RAW/Makefile deleted file mode 100644 index 1e3aa1bc..00000000 --- a/Connector_RAW/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -SRC = main.cpp ../util/socket.cpp -OBJ = $(SRC:.cpp=.o) -OUT = MistConnRAW -INCLUDES = -DEBUG = 4 -OPTIMIZE = -g -CCFLAGS = -Wall -Wextra -funsigned-char $(OPTIMIZE) -DDEBUG=$(DEBUG) -CC = $(CROSS)g++ -LD = $(CROSS)ld -AR = $(CROSS)ar -LIBS= -.SUFFIXES: .cpp -.PHONY: clean default -default: $(OUT) -.cpp.o: - $(CC) $(INCLUDES) $(CCFLAGS) $(LIBS) -c $< -o $@ -$(OUT): $(OBJ) - $(CC) $(LIBS) -o ../bin/$(OUT) $(OBJ) -clean: - rm -rf $(OBJ) ../bin/$(OUT) Makefile.bak *~ -install: $(OUT) - cp -f ../bin/$(OUT) /usr/bin/ - diff --git a/Connector_RTMP/Makefile b/Connector_RTMP/Makefile deleted file mode 100644 index 7f6ab177..00000000 --- a/Connector_RTMP/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -SRC = main.cpp ../util/socket.cpp ../util/flv_tag.cpp ../util/amf.cpp ../util/rtmpchunks.cpp ../util/crypto.cpp ../util/config.cpp ../util/dtsc.cpp -OBJ = $(SRC:.cpp=.o) -OUT = MistConnRTMP -INCLUDES = -STATIC = -DEBUG = 4 -OPTIMIZE = -g -CCFLAGS = -Wall -Wextra -funsigned-char $(OPTIMIZE) -DDEBUG=$(DEBUG) -DVERSION=$(VERSION) -CC = $(CROSS)g++ -LD = $(CROSS)ld -AR = $(CROSS)ar -VERSION = `git describe --tags` -LIBS = -lssl -lcrypto -.SUFFIXES: .cpp -.PHONY: clean default -default: cversion $(OUT) -.cpp.o: - $(CC) $(INCLUDES) $(CCFLAGS) -c $< -o $@ -$(OUT): $(OBJ) - $(CC) -o ../bin/$(OUT) $(OBJ) $(STATIC) $(LIBS) -clean: - rm -rf $(OBJ) ../bin/$(OUT) Makefile.bak *~ -install: $(OUT) - cp -f ../bin/$(OUT) /usr/bin/ -cversion: - rm -rf ../util/config.o - diff --git a/Connector_RTSP/Makefile b/Connector_RTSP/Makefile deleted file mode 100644 index 9a96197b..00000000 --- a/Connector_RTSP/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -SRC = main.cpp ../util/socket.cpp ../util/http_parser.cpp ../util/flv_tag.cpp ../util/amf.cpp ../util/util.cpp ../util/dtsc.cpp -OBJ = $(SRC:.cpp=.o) -OUT = Connector_RTSP -INCLUDES = $(shell pkg-config --cflags jrtplib) -DEBUG = 4 -OPTIMIZE = -g -CCFLAGS = -Wall -Wextra -funsigned-char $(OPTIMIZE) -DDEBUG=$(DEBUG) -CC = $(CROSS)g++ -LD = $(CROSS)ld -AR = $(CROSS)ar -LIBS = $(shell pkg-config --libs jrtplib) -.SUFFIXES: .cpp -.PHONY: clean default -default: $(OUT) -.cpp.o: - $(CC) $(INCLUDES) $(CCFLAGS) $(LIBS) -c $< -o $@ -$(OUT): $(OBJ) - $(CC) -o $(OUT) $(OBJ) $(LIBS) -clean: - rm -rf $(OBJ) $(OUT) Makefile.bak *~ -run-test: $(OUT) - rm -rf ./meh - mkfifo ./meh - cat ./meh & - nc -l -p 554 -e './$(OUT) 2>./meh' diff --git a/Connector_RTSP/compile_remarks.txt b/Connector_RTSP/compile_remarks.txt deleted file mode 100644 index be943b3d..00000000 --- a/Connector_RTSP/compile_remarks.txt +++ /dev/null @@ -1,25 +0,0 @@ -example for installing to ../usr (use DESTDIR=/tmp, /usr/local or whatever you want) -$ DESTDIR="${PWD%/*}/usr" - -building jthread (as local user, no root required): -$ cd $somedir -$ wget http://research.edm.uhasselt.be/jori/jthread/jthread-1.3.1.tar.gz -$ tar xvf jthread-1.3.1.tar.gz && cd jthread-1.3.1 -$ cmake -DCMAKE_INSTALL_PREFIX:PATH="$DESTDIR" -$ make && make install - -AFTER building jthread -$ cd $somedir -$ wget http://research.edm.uhasselt.be/jori/jrtplib/jrtplib-3.9.1.tar.bz2 -$ tar xf jrtplib-3.9.1.tar.bz2 && cd jrtplib-3.9.1 -$ cmake -DCMAKE_INSTALL_PREFIX:PATH="$DESTDIRr" -DADDITIONAL_INCLUDE_DIRS:STRING="$DESTDIR/include" -$ make -j8 -Modify $DESTDIR/usr/lib/pkgconfig/jrtplib.pc such that it looks like (subst $DESTDIR accordingly): - Libs: -L$DESTDIR/lib/ -ljrtp -ljthread -lpthread -$ make install - -building Connector_RTSP: -$ PKG_CONFIG_PATH=$DESTDIR/lib/pkgconfig make - -Running Connector_RTSP: -$ LD_LIBRARY_PATH="$DESTDIR/lib:$LD_LIBRARY_PATH" ./Connector_RTSP diff --git a/Connector_RTSP/main.cpp b/Connector_RTSP/main.cpp deleted file mode 100644 index 71171ab0..00000000 --- a/Connector_RTSP/main.cpp +++ /dev/null @@ -1,299 +0,0 @@ -/// \file Connector_RTSP/main.cpp -/// Contains the main code for the RTSP Connector - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../util/socket.h" -#include "../util/flv_tag.h" -#include "../util/http_parser.h" -//JRTPLIB -#include "rtp.h" - -/// Reads a single NALU from std::cin. Expected is H.264 Bytestream format. -/// Function was used as a way of debugging data. FLV does not contain all the metadata we need, so we had to try different approaches. -/// \return The Nalu data. -/// \todo Throw this function away when everything works, it is not needed. -std::string ReadNALU( ) { - static char Separator[3] = { (char)0x00, (char)0x00, (char)0x01 }; - std::string Buffer; - std::string Result; - do { - Buffer += std::cin.get(); - } while ( std::cin.good() && ( Buffer.find( Separator,0,3 ) == std::string::npos ) ); - if( !std::cin.good() ) { return ""; } - Result = Buffer.substr(0, Buffer.find( Separator,0,3 ) ); - while( *(Result.end() - 1) == (char)0x00 ) { Result.erase( Result.end() - 1 ); } - if( Result.size() == 0 ) { Result = ReadNALU( ); } - return Result; -} - -/// The main function of the connector. -/// Used by server_setup.cpp in the bottom of the file, to start up the Connector. -/// This function contains the while loop the accepts connections, and sends them data. -/// \param conn A connection with the client. -int RTSP_Handler( Socket::Connection conn ) { - /// \todo Convert this to DTSC::DTMI, with an additional DTSC::Stream/ - FLV::Tag tag;// Temporary tag buffer for incoming video data. - bool PlayVideo = false; - bool PlayAudio = true; - //JRTPlib Objects to handle the RTP connection, which runs "parallel" to RTSP. - jrtplib::RTPSession VideoSession; - jrtplib::RTPSessionParams VideoParams; - jrtplib::RTPUDPv6TransmissionParams VideoTransParams; - std::string PreviousRequest = ""; - std::string streamname; - Socket::Connection ss(-1); - HTTP::Parser HTTP_R, HTTP_S; - //Some clients appear to expect a single request per connection. Don't know which ones. - bool PerRequest = false; - //The main loop of the function - while(conn.connected() && !FLV::Parse_Error) { - if( HTTP_R.Read(conn ) ) { - //send Debug info to stderr. - //send the appropriate responses on RTSP Commands. - fprintf( stderr, "REQUEST:\n%s\n", HTTP_R.BuildRequest().c_str() ); - HTTP_S.protocol = "RTSP/1.0"; - if( HTTP_R.method == "OPTIONS" ) { - //Always return the requested CSeq value. - HTTP_S.SetHeader( "CSeq", HTTP_R.GetHeader( "CSeq" ).c_str() ); - //The minimal set of options required for RTSP, add new options here as well if we want to support these. - HTTP_S.SetHeader( "Public", "OPTIONS, DESCRIBE, SETUP, TEARDOWN, PLAY" ); - //End the HTTP body, IMPORTANT!! Connection hangs otherwise!! - HTTP_S.SetBody( "\r\n\r\n" ); - fprintf( stderr, "RESPONSE:\n%s\n", HTTP_S.BuildResponse( "200", "OK" ).c_str() ); - conn.write( HTTP_S.BuildResponse( "200", "OK" ) ); - } else if ( HTTP_R.method == "DESCRIBE" ) { - ///\todo Implement DESCRIBE option. - //Don't know if a 501 response is seen as valid. If it is, don't bother changing it. - if( HTTP_R.GetHeader( "Accept" ).find( "application/sdp" ) == std::string::npos ) { - fprintf( stderr, "RESPONSE:\n%s\n", HTTP_S.BuildResponse( "501", "Not Implemented" ).c_str() ); - conn.write( HTTP_S.BuildResponse( "501", "Not Implemented" ) ); - } else { - HTTP_S.SetHeader( "CSeq", HTTP_R.GetHeader( "CSeq" ).c_str() ); - HTTP_S.SetHeader( "Content-Type", "application/sdp" ); - /// \todo Retrieve presence of video and audio data, and process into response. Can now easily be done through DTSC::DTMI - /// \todo Retrieve Packetization mode ( is 0 for now ). I suppose this is the H264 packetization mode. Can maybe be retrieved from the docs on H64. - /// \todo Send a valid SDP file. - /// \todo Add audio to SDP file. - //This is just a dummy with data that was supposedly right for our teststream. - //SDP Docs: http://tools.ietf.org/html/rfc4566 - HTTP_S.SetBody( "v=0\r\n" //protocol version - "o=- 0 0 IN IP4 ddvtech.com\r\n" //originator and session identifier (5.2): - //username sess-id sess-version nettype addrtype unicast-addr - //"-": no concept of User IDs, nettype IN(ternet) - //IP4: following address is a FQDN for IPv4 - "s=Fifa Test\r\n" //session name (5.3) - //"c" - destination is specified in SETUP per rfc2326 C.1.7, set null as recommended - "c=IN IP4 0.0.0.0\r\n" //connection information -- not required if included in all media - //nettype addrtype connection-address - "t=0 0\r\n" //time the session is active: start-time stop-time; "0 0"=permanent session - "a=recvonly\r\n"//zero or more session attribute lines - "m=video 0 RTP/AVP 98\r\n"//media name and transport address: media port proto fmt ... - "a=control:" + HTTP_R.url + "\r\n"//rfc2326 C.1.1, URL for aggregate control on session level - "a=rtpmap:98 H264/90000\r\n"//rfc2326 C.1.3, dynamic payload type; see also http://tools.ietf.org/html/rfc1890#section-5 - "a=fmtp:98 packetization-mode=0"//codec-specific parameters - "\r\n\r\n");//m=audio 0 RTP/AAP 96\r\na=control:rtsp://localhost/fifa/audio\r\na=rtpmap:96 mpeg4-generic/16000/2\r\n\r\n"); - //important information when supporting multiple streams http://tools.ietf.org/html/rfc2326#appendix-C.3 - fprintf( stderr, "RESPONSE:\n%s\n", HTTP_S.BuildResponse( "200", "OK" ).c_str() ); - conn.write( HTTP_S.BuildResponse( "200", "OK" ) ); - } - } else if ( HTTP_R.method == "SETUP" ) { - bool setup_session = false;//whether a session should be setup or not - std::string temp = HTTP_R.GetHeader("Transport"); - //Extract the random UTP pair for video data ( RTP/RTCP) - int ClientRTPLoc = temp.find( "client_port=" ) + 12; - int PortSpacer = temp.find( "-", ClientRTPLoc ); - int RTPClientPort = atoi( temp.substr( ClientRTPLoc, ( PortSpacer - ClientRTPLoc ) ).c_str() ); - if( HTTP_S.GetHeader( "Session" ) != "" ) { - //Return an error if a second client tries to connect with an already running stream. - fprintf( stderr, "RESPONSE:\n%s\n", HTTP_S.BuildResponse( "459", "Aggregate Operation Not Allowed" ).c_str() ); - conn.write( HTTP_S.BuildResponse( "459", "Aggregate Operation Not Allowed" ) ); - } else { - do{ - if (!ss.connected()){ - /// \todo Put stream name-to-file mapping in a separate util file or even class - streamname = std::string(HTTP_R.url.c_str()); - unsigned int slash_pos = streamname.rfind('/'); - if (slash_pos != std::string::npos) streamname.erase(0, slash_pos); - for (std::string::iterator i=streamname.begin(); i != streamname.end(); ++i){ - if (*i == '?'){ - streamname.erase(i, streamname.end()); - break; - } - if (!isalpha(*i) && !isdigit(*i) && *i != '_'){ - streamname.erase(i); - --i; - }else{ - *i = tolower(*i); - } - } - streamname = "/tmp/shared_socket_" + streamname; - ss = Socket::Connection(streamname); - if (!ss.connected()){ - streamname = ""; - HTTP_R.BuildResponse("404", "Not Found"); - break; //skip the session below - } - } - setup_session = true; - }while(0); - } - if (setup_session) { - HTTP_S.SetHeader( "CSeq", HTTP_R.GetHeader( "CSeq" ).c_str() ); - HTTP_S.SetHeader( "Session", time(NULL) ); - /// \todo Add support for audio -// if( HTTP_R.url.find( "audio" ) != std::string::npos ) { -// HTTP_S.SetHeader( "Transport", HTTP_R.GetHeader( "Transport" ) + ";server_port=50002-50003" ); -// } else { - //Stub data for testing purposes. This should now be extracted somehow from DTSC::DTMI - VideoParams.SetOwnTimestampUnit( ( 1.0 / 29.917 ) * 90000.0 ); - VideoParams.SetMaximumPacketSize( 10000 ); - //create a JRTPlib session - int VideoStatus; - uint16_t pbase; - //after 20 retries, just give up, most ports are likely in use - int retries = 20; - do { - //pick the right port here in the range 5000 to 5000 + 2 * 500 = 6000 - pbase = 5000 + 2 * (rand() % 500); - VideoTransParams.SetPortbase( pbase ); - VideoStatus = VideoSession.Create( VideoParams, &VideoTransParams, jrtplib::RTPTransmitter::IPv6UDPProto ); - } while(VideoStatus < 0 && --retries > 0); - if( VideoStatus < 0 ) { - std::cerr << "Video session could not be created: " << jrtplib::RTPGetErrorString( VideoStatus ) << std::endl; - exit( -1 ); - } else { - std::cerr << "Created video session using ports " << pbase << " and " << (pbase+1) << "\n"; - } - //send video data - std::stringstream transport; - transport << HTTP_R.GetHeader( "Transport" ) << ";server_port=" << pbase << "-" << (pbase+1); - HTTP_S.SetHeader( "Transport", transport.str() ); - - /// \todo Connect with clients other than localhost - uint8_t localip[32]; - int status = inet_pton( AF_INET6, conn.getHost().c_str(), localip ) ; - //Debug info - std::cerr << "Status: " << status << "\n"; - jrtplib::RTPIPv6Address addr(localip,RTPClientPort); - - //add the destination address to the VideoSession - VideoStatus = VideoSession.AddDestination(addr); - if (VideoStatus < 0) { - std::cerr << "Destination could not be set: " << jrtplib::RTPGetErrorString(VideoStatus) << std::endl; - exit(-1); - } else { - std::cerr << "Destination Set\n"; - } - //Stub data for testing purposes. - //Payload type should confirm with the SDP File. 98 == H264 / AVC - VideoSession.SetDefaultPayloadType(98); - VideoSession.SetDefaultMark(false); - //We have no idea if this timestamp has to correspond with the OwnTimeStampUnit() above. - VideoSession.SetDefaultTimestampIncrement( ( 1.0 / 29.917 ) * 90000 ); -// } - HTTP_S.SetBody( "\r\n\r\n" ); - fprintf( stderr, "RESPONSE:\n%s\n", HTTP_S.BuildResponse( "200", "OK" ).c_str() ); - conn.write( HTTP_S.BuildResponse( "200", "OK" ) ); - } - } else if( HTTP_R.method == "PLAY" ) { - if( HTTP_R.GetHeader( "Range" ).substr(0,4) != "npt=" ) { - //We do not support this, whatever it is. Not needed for minimal compliance. - fprintf( stderr, "RESPONSE:\n%s\n", HTTP_S.BuildResponse( "501", "Not Implemented" ).c_str() ); - conn.write( HTTP_S.BuildResponse( "501", "Not Implemented" ) ); - } else { - //Initializes for actual streaming over the SETUP connection. - HTTP_S.SetHeader( "CSeq", HTTP_R.GetHeader( "CSeq" ).c_str() ); - HTTP_S.SetHeader( "Session", HTTP_R.GetHeader( "Session" ) ); - HTTP_S.SetHeader( "Range", HTTP_R.GetHeader( "Range" ) ); - HTTP_S.SetHeader( "RTP-Info", "url=" + HTTP_R.url + ";seq=0;rtptime=0" ); - HTTP_S.SetBody( "\r\n\r\n" ); - fprintf( stderr, "RESPONSE:\n%s\n", HTTP_S.BuildResponse( "200", "OK" ).c_str() ); - conn.write( HTTP_S.BuildResponse( "200", "OK" ) ); - //Used further down, to start streaming video. - //PlayAudio = true; - PlayVideo = true; - } - } else if( HTTP_R.method == "TEARDOWN" ) { - //If we were sending any stream data at this point, stop it, but keep the setup. - HTTP_S.SetHeader( "CSeq", HTTP_R.GetHeader( "CSeq" ).c_str() ); - HTTP_S.SetBody( "\r\n\r\n" ); - fprintf( stderr, "RESPONSE:\n%s\n", HTTP_S.BuildResponse( "200", "OK" ).c_str() ); - conn.write( HTTP_S.BuildResponse( "200", "OK" ) ); - //PlayAudio = false; - PlayVideo = false; - } else { - //We do not implement other commands ( yet ) - fprintf( stderr, "RESPONSE:\n%s\n", HTTP_S.BuildResponse( "501", "Not Implemented" ).c_str() ); - conn.write( HTTP_S.BuildResponse( "501", "Not Implemented" ) ); - } - HTTP_R.Clean(); - HTTP_S.Clean(); - if( PerRequest ) { - conn.close(); - } - } - if( PlayVideo ) { - bool no_data_ignore = false; - std::string VideoBuf; - ss.canRead(); - switch (ss.ready()) { - case -1: - std::cerr << "Buffer socket is disconnected\n"; - break; - case 0://not ready - no_data_ignore = true; - break; - default: - ///\todo Make it work! - DTSC::Stream ds; - ss.spool(); - if (ds.parsePacket(ss.Received())){ - VideoBuf = ds.lastData(); - }else{ - std::cerr << "Failed to parse packet" << std::endl; - no_data_ignore = true;//perhaps corrupt? - } - break; - } - if(no_data_ignore){}else if( VideoBuf == "" ) { - //videobuffer is empty, no more data. - jrtplib::RTPTime delay = jrtplib::RTPTime(10.0); - VideoSession.BYEDestroy(delay,"Out of data",11); - conn.close(); - std::cerr << "Buffer empty - closing connection" << std::endl; - } else { - //Send a single NALU (H264 block) here. - VideoSession.SendPacket( VideoBuf.c_str(), VideoBuf.size(), 98, false, ( 1.0 / 29.917 ) * 90000 ); - //we can add delays here as follows: - //don't know if these are nescecary or not, but good for testing nonetheless -// jrtplib::RTPTime delay( ( 1.0 / 29.917 ) * 90000 ); -// jrtplib::RTPTime::Wait( delay ); - } - } - } - return 0; -} - -//Set Default Port -#define DEFAULT_PORT 554 -//Set the function that should be forked for each client -#define MAINHANDLER RTSP_Handler -//Set the section in the Config file, though we will not use this yet -#define CONFIGSECT RTSP -//Include the main functionality, as well as fork support and everything. -#include "../util/server_setup.cpp" diff --git a/Connector_RTSP/rtp.h b/Connector_RTSP/rtp.h deleted file mode 100644 index 92617ea6..00000000 --- a/Connector_RTSP/rtp.h +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - diff --git a/Connector_RTSP/rtsp_notes b/Connector_RTSP/rtsp_notes deleted file mode 100644 index 1cd93dba..00000000 --- a/Connector_RTSP/rtsp_notes +++ /dev/null @@ -1,79 +0,0 @@ -Port 554 TCP - -RTSP/1.0 xxx reason - 100 Continue - 200 OK - 300 Multiple Choices - 301 Moved Permanently - 303 See Other - 400 Bad Request - 500 Internal Server Error - 501 Not Implemented - - -Need to support: - Connection: keep-alive - Content-Length: 0 (default) - Content-Type: ran/dom - Content-Language: en - Content-Encoding: leave out! - Transport: RTP/AVP;unicast;client_port=4588-4589;server_port=6256-6257 - Public: SETUP, TEARDOWN, OPTIONS, DESCRIBE, PLAY - RTP-Info: url=rtmp://localhost/blaat - Unsupported: random (reply with same as require header!) - - Session: ignore! - Transport: RTP/AVP;unicast;client_port=4588-4589 - Require: random - - - -SETUP: - SETUP rtsp://localhost/blaat RTSP/1.0 - Transport: RTP/AVP;unicast;client_port=4588-4589 - - RTSP/1.0 200 OK - Transport: RTP/AVP;unicast;client_port=4588-4589;server_port=6256-6257 - -TEARDOWN: - TEARDOWN rtsp://localhost/blaat RTSP/1.0 - - RTSP/1.0 200 OK - -OPTIONS: - OPTIONS * RTSP/1.0 - Require: koekjes - - RTSP/1.0 200 OK - Unsupported: koekjes - Public: SETUP, TEARDOWN, OPTIONS, DESCRIBE, PLAY - -DESCRIBE: - DESCRIBE rtsp://server.example.com/fizzle/foo RTSP/1.0 - Accept: application/sdp, application/rtsl, application/mheg - - RTSP/1.0 200 OK - Content-Type: application/sdp - Content-Length: xxx - - v=0 - o=- 0 0 IN IP4 ddvtech.com - s=PLSServer - c=IN IP4 0.0.0.0 - a=recvonly - t=0 0 - m=video 0 RTP/AVP 98 - a=rtpmap:98 H264/90000 - m=audio 0 RTP/AVP 99 - a=rtpmap:99 MPEG4-GENERIC/11025/1 - -PLAY: - PLAY rtsp://audio.example.com/meeting.en RTSP/1.0 - Range: clock=19961108T142300Z-19961108T143520Z - - RTSP/1.0 200 OK - - -jRTPlib docs: http://research.edm.uhasselt.be/jori/jrtplib/documentation/index.html - - diff --git a/Connector_TS/Makefile b/Connector_TS/Makefile deleted file mode 100644 index 889e385b..00000000 --- a/Connector_TS/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -SRC = main.cpp ../util/socket.cpp ../util/http_parser.cpp ../util/flv_tag.cpp ../util/amf.cpp ../util/dtsc.cpp ../util/config.cpp ../util/base64.cpp -OBJ = $(SRC:.cpp=.o) -OUT = DDV_Conn_TS -INCLUDES = -DEBUG = 4 -OPTIMIZE = -g -CCFLAGS = -Wall -Wextra -funsigned-char $(OPTIMIZE) -DDEBUG=$(DEBUG) -CC = $(CROSS)g++ -LD = $(CROSS)ld -AR = $(CROSS)ar -LIBS= -.SUFFIXES: .cpp -.PHONY: clean default -default: $(OUT) -.cpp.o: - $(CC) $(INCLUDES) $(CCFLAGS) $(LIBS) -c $< -o $@ -$(OUT): $(OBJ) - $(CC) $(LIBS) -o $(OUT) $(OBJ) -clean: - rm -rf $(OBJ) $(OUT) Makefile.bak *~ -install: $(OUT) - -service HTTP_Conn stop - cp -f ./$(OUT) /usr/bin/ - cp -f ./HTTP_Conn /etc/init.d/ - service HTTP_Conn start - diff --git a/Connector_TS/main.cpp b/Connector_TS/main.cpp deleted file mode 100644 index c2d4baea..00000000 --- a/Connector_TS/main.cpp +++ /dev/null @@ -1,364 +0,0 @@ -/// \file Connector_TS/main.cpp -/// Contains the main code for the TS Connector -/// \todo Check data to be sent for video -/// \todo Handle audio packets - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../util/socket.h" -#include "../util/dtsc.h" - -/// A simple class to create a single Transport Packet -class Transport_Packet { - public: - Transport_Packet( bool PacketStart = false, int PID = 0x100 ); - void SetPayload( char * Payload, int PayloadLen, int Offset = 13 ); - void SetPesHeader( int Offset = 4, int MsgLen = 0xFFFF, int Current = 0, int Previous = 0 ); - void Write( ); - void Write( Socket::Connection conn ); - void SetContinuityCounter( int Counter ); - void SetMessageLength( int MsgLen ); - void SetAdaptationField( double TimeStamp = 0 ); - void CreatePAT( int ContinuityCounter ); - void CreatePMT( int ContinuityCounter ); - private: - int PID;///< PID of this packet - char Buffer[188];///< The actual data -};//Transport Packet - -/// Get the current time in milliseconds -/// \return Current time in milliseconds -unsigned int getNowMS() { - timeval t; - gettimeofday(&t, 0); - return t.tv_sec + t.tv_usec/1000; -} - -/// The constructor -/// \param PacketStart Start of a new sequence -/// \param PID The PID for this packet -Transport_Packet::Transport_Packet( bool PacketStart, int PID ) { - (*this).PID = PID; - Buffer[0] = (char)0x47; - Buffer[1] = ( PacketStart ? (char)0x40 : 0 ) + (( PID & 0xFF00 ) >> 8 ); - Buffer[2] = ( PID & 0x00FF ); - Buffer[3] = (char)0x10; -} - -/// Sets the length of the message -/// \param MsgLen the new length of the message -void Transport_Packet::SetMessageLength( int MsgLen ) { - Buffer[8] = ( MsgLen & 0xFF00 ) >> 8; - Buffer[9] = ( MsgLen & 0xFF ); -} - -/// Sets the Continuity Counter of a packet -/// \param Counter The new Continuity Counter -void Transport_Packet::SetContinuityCounter( int Counter ) { - Buffer[3] = ( Buffer[3] & 0xF0 ) + ( Counter & 0x0F ); -} - -/// Writes a PES header with length and PTS/DTS -/// \param Offset Offset of the PES header in the packet -/// \param MsgLen Length of the PES data -/// \param Current The PTS of this PES packet -/// \param Previous The DTS of this PES packet -void Transport_Packet::SetPesHeader( int Offset, int MsgLen, int Current, int Previous ) { - Current = Current * 27000; - Previous = Previous * 27000; - Buffer[Offset] = (char)0x00; - Buffer[Offset+1] = (char)0x00; - Buffer[Offset+2] = (char)0x01; - Buffer[Offset+3] = (char)0xE0; - Buffer[Offset+4] = ( MsgLen & 0xFF00 ) >> 8; - Buffer[Offset+5] = ( MsgLen & 0x00FF ); - Buffer[Offset+6] = (char)0x80; - Buffer[Offset+7] = (char)0xC0; - Buffer[Offset+8] = (char)0x0A; - Buffer[Offset+9] = (char)0x30 + ( (Current & 0xC0000000 ) >> 29 ) + (char)0x01; - Buffer[Offset+10] = ( ( ( Current & 0x3FFF8000 ) >> 14 ) & 0xFF00 ) >> 8; - Buffer[Offset+11] = ( ( ( Current & 0x3FFF8000 ) >> 14 ) & 0x00FF ) + (char)0x01; - Buffer[Offset+12] = ( ( ( Current & 0x00007FFF ) << 1 ) & 0xFF00 ) >> 8; - Buffer[Offset+13] = ( ( ( Current & 0x00007FFF ) << 1 ) & 0x00FF ) + (char)0x01; - Buffer[Offset+14] = (char)0x10 + ( (Previous & 0xC0000000 ) >> 29 ) + (char)0x01; - Buffer[Offset+15] = ( ( ( Previous & 0x3FFF8000 ) >> 14 ) & 0xFF00 ) >> 8; - Buffer[Offset+16] = ( ( ( Previous & 0x3FFF8000 ) >> 14 ) & 0x00FF ) + (char)0x01; - Buffer[Offset+17] = ( ( ( Previous & 0x00007FFF ) << 1 ) & 0xFF00 ) >> 8; - Buffer[Offset+18] = ( ( ( Previous & 0x00007FFF ) << 1 ) & 0x00FF ) + (char)0x01; -} - -/// Creates an adapatation field -/// \param TimeStamp the current PCR -void Transport_Packet::SetAdaptationField( double TimeStamp ) { - TimeStamp = TimeStamp * 27000; - int Extension = (int)TimeStamp % 300; - int Base = (int)TimeStamp / 300; - Buffer[3] = ( Buffer[3] & 0x0F ) + 0x30; - Buffer[4] = (char)0x07; - Buffer[5] = (char)0x10; - Buffer[6] = ( ( Base >> 1 ) & 0xFF000000 ) >> 24; - Buffer[7] = ( ( Base >> 1 ) & 0x00FF0000 ) >> 16; - Buffer[8] = ( ( Base >> 1 ) & 0x0000FF00 ) >> 8; - Buffer[9] = ( ( Base >> 1 ) & 0x000000FF ); - Buffer[10] = ( ( Extension & 0x0100) >> 8 ) + ( ( Base & 0x00000001 ) << 7 ) + (char)0x7E; - Buffer[11] = ( Extension & 0x00FF); -} - -/// Writes data into the payload of our packet -/// The data to be written is of lenght min( PayLoadLen, 188 - Offset ) -/// \param Payload The data to write -/// \param PayLoadLen The length of the data -/// \param Offset The offset in the packet payload -void Transport_Packet::SetPayload( char * Payload, int PayloadLen, int Offset ) { - memcpy( &Buffer[Offset], Payload, std::min( PayloadLen, 188-Offset ) ); -} - -/// Creates a default PAT packet -/// Sets up the complete packet -/// \param ContinuityCounter The Continuity Counter for this packet -void Transport_Packet::CreatePAT( int ContinuityCounter ) { - Buffer[3] = (char)0x10 + ContinuityCounter; - Buffer[4] = (char)0x00; - Buffer[5] = (char)0x00; - Buffer[6] = (char)0xB0; - Buffer[7] = (char)0x0D; - Buffer[8] = (char)0x00; - Buffer[9] = (char)0x01; - Buffer[10] = (char)0xC1; - Buffer[11] = (char)0x00; - Buffer[12] = (char)0x00; - Buffer[13] = (char)0x00; - Buffer[14] = (char)0x01; - Buffer[15] = (char)0xF0; - Buffer[16] = (char)0x00; - - Buffer[17] = (char)0x2A; - Buffer[18] = (char)0xB1; - Buffer[19] = (char)0x04; - Buffer[20] = (char)0xB2; - for(int i = 21; i < 188; i++ ) { - Buffer[i] = (char)0xFF; - } -} - -/// Creates a default PMT packet -/// Sets up the complete packet -/// \param ContinuityCounter The Continuity Counter for this packet -void Transport_Packet::CreatePMT( int ContinuityCounter ) { - Buffer[3] = (char)0x10 + ContinuityCounter; - Buffer[4] = (char)0x00; - Buffer[5] = (char)0x02; - Buffer[6] = (char)0xB0; - Buffer[7] = (char)0x17; - Buffer[8] = (char)0x00; - Buffer[9] = (char)0x01; - Buffer[10] = (char)0xC1; - Buffer[11] = (char)0x00; - Buffer[12] = (char)0x00; - Buffer[13] = (char)0xE1; - Buffer[14] = (char)0x00; - Buffer[15] = (char)0xF0; - Buffer[16] = (char)0x00; - Buffer[17] = (char)0x1B; - Buffer[18] = (char)0xE1; - Buffer[19] = (char)0x00; - Buffer[20] = (char)0xF0; - Buffer[21] = (char)0x00; - Buffer[22] = (char)0x03; - Buffer[23] = (char)0xE1; - Buffer[24] = (char)0x01; - Buffer[25] = (char)0xF0; - Buffer[26] = (char)0x00; - - Buffer[27] = (char)0x4E; - Buffer[28] = (char)0x59; - Buffer[29] = (char)0x3D; - Buffer[30] = (char)0x1E; - - for(int i = 31; i < 188; i++ ) { - Buffer[i] = (char)0xFF; - } -} - -/// Sends a default PAT -/// \param conn The connection with the client -void SendPAT( Socket::Connection conn ) { - static int ContinuityCounter = 0; - Transport_Packet TS; - TS = Transport_Packet( true, 0 ); - TS.CreatePAT( ContinuityCounter ); - TS.Write( conn ); - ContinuityCounter = ( ContinuityCounter + 1 ) & 0x0F; -} - -/// Sends a default PMT -/// \param conn The connection with the client -void SendPMT( Socket::Connection conn ) { - static int ContinuityCounter = 0; - Transport_Packet TS; - TS = Transport_Packet( true, 0x1000 ); - TS.CreatePMT( ContinuityCounter ); - TS.Write( conn ); - ContinuityCounter = ( ContinuityCounter + 1 ) & 0x0F; -} - -/// Wraps one or more NALU packets into transport packets -/// \param tag The FLV Tag -std::vector WrapNalus( DTSC::DTMI Tag ) { - static int ContinuityCounter = 0; - static int Previous_Tag = 0; - static int First_PCR = getNowMS(); - static int Previous_PCR = 0; - static char LeadIn[4] = { (char)0x00, (char)0x00, (char)0x00, (char)0x001 }; - int Current_PCR; - int Current_Tag; - std::string Data = Tag.getContentP("data")->StrValue(); - - int Offset = 0; - Transport_Packet TS; - int Sent = 0; - - int PacketAmount = ceil( ( ( Data.size() - (188 - 35 ) ) / 184 ) + 1 );//Minus first packet, + round up and first packet. - std::vector Result; - TS = Transport_Packet( true, 0x100 ); - TS.SetContinuityCounter( ContinuityCounter ); - ContinuityCounter = ( ( ContinuityCounter + 1 ) & 0x0F ); - Current_PCR = getNowMS(); - Current_Tag = Tag.getContentP("time")->NumValue(); - if( true ) { //Current_PCR - Previous_PCR >= 1 ) { - TS.SetAdaptationField( Current_PCR - First_PCR ); - Offset = 8; - Previous_PCR = Current_PCR; - } - TS.SetPesHeader( 4 + Offset, Data.size() , Current_Tag, Previous_Tag ); - Previous_Tag = Current_Tag; - TS.SetPayload( LeadIn, 4, 23 + Offset ); - TS.SetPayload( &Data[16], 157 - Offset, 27 + Offset ); - Sent = 157 - Offset; - Result.push_back( TS ); - while( Sent + 176 < Data.size() ) { -// for( int i = 0; i < (PacketAmount - 1); i++ ) { - TS = Transport_Packet( false, 0x100 ); - TS.SetContinuityCounter( ContinuityCounter ); - ContinuityCounter = ( ( ContinuityCounter + 1 ) & 0x0F ); - Current_PCR = getNowMS(); - Offset = 0; - if( true ) { //Current_PCR - Previous_PCR >= 1 ) { - TS.SetAdaptationField( Current_PCR - First_PCR ); - Offset = 8; - Previous_PCR = Current_PCR; - } - TS.SetPayload( &Data[16 + Sent], 184 - Offset, 4 + Offset ); - Sent += 184 - Offset; - Result.push_back( TS ); - } - if( Sent < ( Data.size() ) ) { - Current_PCR = getNowMS(); - Offset = 0; - if( true ) { //now - Previous_PCR >= 5 ) { - TS.SetAdaptationField( Current_PCR - First_PCR ); - Offset = 8; - Previous_PCR = Current_PCR; - } - std::cerr << "Wrapping packet: last packet length\n"; - std::cerr << "\tTotal:\t\t" << Data.size() << "\n"; - std::cerr << "\tSent:\t\t" << Sent << "\n"; - int To_Send = ( Data.size() ) - Sent; - std::cerr << "\tTo Send:\t" << To_Send << "\n"; - std::cerr << "\tStuffing:\t" << 176 - To_Send << "\n"; - char Stuffing = (char)0xFF; - for( int i = 0; i < ( 176 - To_Send ); i++ ) { - TS.SetPayload( &Stuffing, 1, 4 + Offset + i ); - } - TS.SetPayload( &Data[16 + Sent], 176 - To_Send , 4 + Offset + ( 176 - To_Send ) ); - Result.push_back( TS ); - } - return Result; -} - -/// Writes a packet to STDOUT -void Transport_Packet::Write( ) { - for( int i = 0; i < 188; i++ ) { std::cout << Buffer[i]; } -} - -/// Writes a packet onto a connection -/// \param conn The connection with the client -void Transport_Packet::Write( Socket::Connection conn ) { -// conn.write( Buffer, 188 ); - for( int i = 0; i < 188; i++ ) { std::cout << Buffer[i]; } -} - -/// The main function of the connector -/// \param conn A connection with the client -int TS_Handler( Socket::Connection conn ) { - DTSC::Stream stream; -// FLV::Tag tag;///< Temporary tag buffer for incoming video data. - bool inited = false; - bool firstvideo = true; - Socket::Connection ss(-1); - int zet = 0; - while(conn.connected()) {// && !FLV::Parse_Error) { - if( !inited ) { - ss = Socket::Connection("/tmp/shared_socket_fifa"); - if (!ss.connected()){ - #if DEBUG >= 1 - fprintf(stderr, "Could not connect to server!\n"); - #endif - conn.close(); - break; - } - #if DEBUG >= 3 - fprintf(stderr, "Everything connected, starting to send video data...\n"); - #endif - inited = true; - } - - switch (ss.ready()){ - case -1: - conn.close(); - #if DEBUG >= 1 - fprintf(stderr, "Source socket is disconnected.\n"); - #endif - break; - case 0: break;//not ready yet - default: - ss.spool(); - if ( stream.parsePacket( ss.Received() ) ) { - if( stream.lastType() == DTSC::VIDEO ) { - fprintf(stderr, "Video contains NALU\n" ); - SendPAT( conn ); - SendPMT( conn ); - std::vector AllNalus = WrapNalus( stream.getPacket(0) ); - for( int i = 0; i < AllNalus.size( ); i++ ) { - AllNalus[i].Write( conn ); - } - std::cerr << "Item: " << ++zet << "\n"; - } - if( stream.lastType() == DTSC::AUDIO ) { -// if( ( tag.data[ 11 ] == 0xAF ) && ( tag.data[ 12 ] == 0x01 ) ) { - fprintf(stderr, "Audio Contains Raw AAC\n"); -// } - } - } - break; - } - } - return 0; -} - -#define DEFAULT_PORT 8888 -#define MAINHANDLER TS_Handler -#define CONFIGSECT TS -#include "../util/server_setup.cpp" diff --git a/Controller/Makefile b/Controller/Makefile deleted file mode 100644 index 7116b261..00000000 --- a/Controller/Makefile +++ /dev/null @@ -1,30 +0,0 @@ -SRC = main.cpp ../util/json.cpp ../util/socket.cpp ../util/http_parser.cpp ../util/md5.cpp ../util/config.cpp ../util/procs.cpp ../util/base64.cpp ../util/auth.cpp -OBJ = $(SRC:.cpp=.o) -OUT = MistController -INCLUDES = -DEBUG = 4 -OPTIMIZE = -g -VERSION = `git describe --tags` -COMPILED_USERNAME = testuser -COMPILED_PASSWORD = 179ad45c6ce2cb97cf1029e212046e81 -#COMPILED_PASSWORD = testpass -CCFLAGS = -Wall -Wextra -funsigned-char $(OPTIMIZE) -DDEBUG=$(DEBUG) -DCOMPILED_USERNAME=$(COMPILED_USERNAME) -DCOMPILED_PASSWORD=$(COMPILED_PASSWORD) -DVERSION=$(VERSION) -INSTALL = install -CC = $(CROSS)g++ -LD = $(CROSS)ld -AR = $(CROSS)ar -LIBS = -lssl -lcrypto -.SUFFIXES: .cpp -.PHONY: clean default -default: cversion $(OUT) -.cpp.o: - $(CC) $(INCLUDES) $(CCFLAGS) -c $< -o $@ -$(OUT): $(OBJ) - $(CC) -o ../bin/$(OUT) $(OBJ) $(LIBS) -clean: - rm -rf $(OBJ) ../bin/$(OUT) Makefile.bak *~ -cversion: - rm -rf ../util/config.o -install: $(OUT) - $(INSTALL) -D ./$(OUT) $(DESTDIR)/usr/bin/$(OUT) - diff --git a/Makefile b/Makefile deleted file mode 100644 index 6d6faf3c..00000000 --- a/Makefile +++ /dev/null @@ -1,38 +0,0 @@ -default: client -.PHONY: client client-debug client-clean clean release-install debug-install install docs - -prepare: - mkdir -p ./bin - cp -f *.html ./bin/ -client-debug: prepare - cd Connector_HTTP; $(MAKE) - cd Connector_RTMP; $(MAKE) - cd Connector_RAW; $(MAKE) - cd Buffer; $(MAKE) - cd Controller; $(MAKE) - cd tools/FLV2DTSC; $(MAKE) -client: client-debug -client-clean: - cd Connector_HTTP; $(MAKE) clean - cd Connector_RTMP; $(MAKE) clean - cd Connector_RAW; $(MAKE) clean - cd Buffer; $(MAKE) clean - cd Controller; $(MAKE) clean - cd tools/FLV2DTSC; $(MAKE) clean -clean: client-clean - rm -rf ./bin -client-release: prepare - cd Connector_HTTP; $(MAKE) DEBUG=0 OPTIMIZE=-O2 - cd Connector_RTMP; $(MAKE) DEBUG=0 OPTIMIZE=-O2 - cd Connector_RAW; $(MAKE) DEBUG=0 OPTIMIZE=-O2 - cd Buffer; $(MAKE) DEBUG=0 OPTIMIZE=-O2 - cd Controller; $(MAKE) DEBUG=0 OPTIMIZE=-O2 - cd tools/FLV2DTSC; $(MAKE) DEBUG=0 OPTIMIZE=-O2 -release: client-release -release-install: client-clean client-release - cp ./bin/Mist* /usr/bin/ -debug-install: client-clean client-debug - cp ./bin/Mist* /usr/bin/ -install: debug-install -docs: - doxygen ./Doxyfile > /dev/null diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 00000000..6cf1b795 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,2 @@ +SUBDIRS=lib src +EXTRA_DIST=server.html diff --git a/configure.ac b/configure.ac new file mode 100644 index 00000000..1bce87ef --- /dev/null +++ b/configure.ac @@ -0,0 +1,39 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_PREREQ([2.60]) +m4_include([version.m4]) +AC_INIT(MistServer, VERSION_NUMBER, contact@ddvtech.com) +AC_CONFIG_SRCDIR([src/buffer.cpp]) +AM_INIT_AUTOMAKE + +# Checks for programs. +AC_PROG_CXX +AC_PROG_CC + +# Checks for libraries. +AC_PROG_RANLIB + +# Checks for header files. +AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h stdint.h stdlib.h string.h sys/socket.h sys/time.h unistd.h]) + +# Checks for typedefs, structures, and compiler characteristics. +AC_HEADER_STDBOOL +AC_C_INLINE +AC_TYPE_INT32_T +AC_TYPE_PID_T +AC_TYPE_SIZE_T +AC_TYPE_UINT32_T +AC_TYPE_UINT64_T +AC_TYPE_UINT8_T + +# Checks for library functions. +AC_FUNC_FORK +AC_FUNC_MALLOC +AC_FUNC_REALLOC +AC_CHECK_FUNCS([dup2 gettimeofday memset mkdir socket strerror]) + +AC_CONFIG_FILES([Makefile + lib/Makefile + src/Makefile]) +AC_OUTPUT diff --git a/lib/Makefile.am b/lib/Makefile.am new file mode 100644 index 00000000..76d5de1c --- /dev/null +++ b/lib/Makefile.am @@ -0,0 +1,15 @@ +noinst_LIBRARIES=libamf.a libauth.a libbase64.a libconfig.a libcrypto.a libdtsc.a libflv_tag.a libhttp_parser.a libjson.a libmd5.a libprocs.a librtmpchunks.a libsocket.a libtinythread.a +libamf_a_SOURCES=amf.h amf.cpp +libauth_a_SOURCES=auth.h auth.cpp +libbase64_a_SOURCES=base64.h base64.cpp +libconfig_a_SOURCES=config.h config.cpp +libcrypto_a_SOURCES=crypto.h crypto.cpp +libdtsc_a_SOURCES=dtsc.h dtsc.cpp +libflv_tag_a_SOURCES=flv_tag.h flv_tag.cpp +libhttp_parser_a_SOURCES=http_parser.h http_parser.cpp +libjson_a_SOURCES=json.h json.cpp +libmd5_a_SOURCES=md5.h md5.cpp +libprocs_a_SOURCES=procs.h procs.cpp +librtmpchunks_a_SOURCES=rtmpchunks.h rtmpchunks.cpp +libsocket_a_SOURCES=socket.h socket.cpp +libtinythread_a_SOURCES=tinythread.h tinythread.cpp diff --git a/util/amf.cpp b/lib/amf.cpp similarity index 100% rename from util/amf.cpp rename to lib/amf.cpp diff --git a/util/amf.h b/lib/amf.h similarity index 100% rename from util/amf.h rename to lib/amf.h diff --git a/util/auth.cpp b/lib/auth.cpp similarity index 100% rename from util/auth.cpp rename to lib/auth.cpp diff --git a/util/auth.h b/lib/auth.h similarity index 100% rename from util/auth.h rename to lib/auth.h diff --git a/util/base64.cpp b/lib/base64.cpp similarity index 100% rename from util/base64.cpp rename to lib/base64.cpp diff --git a/util/base64.h b/lib/base64.h similarity index 100% rename from util/base64.h rename to lib/base64.h diff --git a/util/config.cpp b/lib/config.cpp similarity index 95% rename from util/config.cpp rename to lib/config.cpp index b7533fc3..f2d9fe17 100644 --- a/util/config.cpp +++ b/lib/config.cpp @@ -53,7 +53,7 @@ void Util::Config::parseArgs(int argc, char ** argv){ case 'd': daemon_mode = true; break; case 'u': username = optarg; break; case 'v': - printf("%s\n", TOSTRING(VERSION)); + printf("%s\n", TOSTRING(PACKAGE_VERSION)); exit(1); break; case 'h': @@ -63,7 +63,7 @@ void Util::Config::parseArgs(int argc, char ** argv){ printf("Options: -h[elp], -?, -v[ersion], -n[odaemon], -d[aemon], -p[ort] VAL, -i[nterface] VAL, -u[sername] VAL\n"); printf("Defaults:\n interface: %s\n port: %i\n daemon mode: %s\n username: %s\n", interface.c_str(), listen_port, doingdaemon.c_str(), username.c_str()); printf("Username root means no change to UID, no matter what the UID is.\n"); - printf("This is %s version %s\n", argv[0], TOSTRING(VERSION)); + printf("This is %s version %s\n", argv[0], TOSTRING(PACKAGE_VERSION)); exit(1); break; } diff --git a/util/config.h b/lib/config.h similarity index 100% rename from util/config.h rename to lib/config.h diff --git a/util/crypto.cpp b/lib/crypto.cpp similarity index 100% rename from util/crypto.cpp rename to lib/crypto.cpp diff --git a/util/crypto.h b/lib/crypto.h similarity index 100% rename from util/crypto.h rename to lib/crypto.h diff --git a/util/dtsc.cpp b/lib/dtsc.cpp similarity index 100% rename from util/dtsc.cpp rename to lib/dtsc.cpp diff --git a/util/dtsc.h b/lib/dtsc.h similarity index 100% rename from util/dtsc.h rename to lib/dtsc.h diff --git a/util/flv_tag.cpp b/lib/flv_tag.cpp similarity index 100% rename from util/flv_tag.cpp rename to lib/flv_tag.cpp diff --git a/util/flv_tag.h b/lib/flv_tag.h similarity index 100% rename from util/flv_tag.h rename to lib/flv_tag.h diff --git a/util/http_parser.cpp b/lib/http_parser.cpp similarity index 100% rename from util/http_parser.cpp rename to lib/http_parser.cpp diff --git a/util/http_parser.h b/lib/http_parser.h similarity index 100% rename from util/http_parser.h rename to lib/http_parser.h diff --git a/util/json.cpp b/lib/json.cpp similarity index 100% rename from util/json.cpp rename to lib/json.cpp diff --git a/util/json.h b/lib/json.h similarity index 100% rename from util/json.h rename to lib/json.h diff --git a/util/md5.cpp b/lib/md5.cpp similarity index 100% rename from util/md5.cpp rename to lib/md5.cpp diff --git a/util/md5.h b/lib/md5.h similarity index 100% rename from util/md5.h rename to lib/md5.h diff --git a/util/procs.cpp b/lib/procs.cpp similarity index 100% rename from util/procs.cpp rename to lib/procs.cpp diff --git a/util/procs.h b/lib/procs.h similarity index 100% rename from util/procs.h rename to lib/procs.h diff --git a/util/rtmpchunks.cpp b/lib/rtmpchunks.cpp similarity index 100% rename from util/rtmpchunks.cpp rename to lib/rtmpchunks.cpp diff --git a/util/rtmpchunks.h b/lib/rtmpchunks.h similarity index 100% rename from util/rtmpchunks.h rename to lib/rtmpchunks.h diff --git a/util/socket.cpp b/lib/socket.cpp similarity index 100% rename from util/socket.cpp rename to lib/socket.cpp diff --git a/util/socket.h b/lib/socket.h similarity index 100% rename from util/socket.h rename to lib/socket.h diff --git a/util/tinythread.cpp b/lib/tinythread.cpp similarity index 100% rename from util/tinythread.cpp rename to lib/tinythread.cpp diff --git a/util/tinythread.h b/lib/tinythread.h similarity index 100% rename from util/tinythread.h rename to lib/tinythread.h diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 00000000..dd0322b2 --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,13 @@ +outdir=../bin +out_PROGRAMS=MistBuffer MistController MistConnRAW MistConnRTMP MistConnHTTP +AM_LDFLAGS=-L../lib +MistBuffer_SOURCES=buffer.cpp buffer_stats.cpp buffer_user.cpp buffer_stream.cpp +MistBuffer_LDADD=-ljson -lsocket -ldtsc -ltinythread -lpthread +MistController_SOURCES=controller.cpp +MistController_LDADD=-ljson -lsocket -lprocs -lmd5 -lconfig -lhttp_parser -lauth -lbase64 -lssl -lcrypto +MistConnRAW_SOURCES=conn_raw.cpp +MistConnRAW_LDADD=-lsocket +MistConnRTMP_SOURCES=conn_rtmp.cpp +MistConnRTMP_LDADD=-lsocket -ldtsc -lrtmpchunks -lflv_tag -lconfig -lamf -lssl -lcrypto +MistConnHTTP_SOURCES=conn_http.cpp +MistConnHTTP_LDADD=-lsocket diff --git a/tools/ABST_Parser/main.cpp b/src/analysers/abst_analyser.cpp similarity index 100% rename from tools/ABST_Parser/main.cpp rename to src/analysers/abst_analyser.cpp diff --git a/tools/AMF_Tester/main.cpp b/src/analysers/amf_analyser.cpp similarity index 100% rename from tools/AMF_Tester/main.cpp rename to src/analysers/amf_analyser.cpp diff --git a/tools/DTSC_Analyser/main.cpp b/src/analysers/dtsc_analyser.cpp similarity index 100% rename from tools/DTSC_Analyser/main.cpp rename to src/analysers/dtsc_analyser.cpp diff --git a/tools/FLV_Analyser/main.cpp b/src/analysers/flv_analyser.cpp similarity index 100% rename from tools/FLV_Analyser/main.cpp rename to src/analysers/flv_analyser.cpp diff --git a/tools/HTTP_Box_Parser/main.cpp b/src/analysers/httpbox_analyser.cpp similarity index 100% rename from tools/HTTP_Box_Parser/main.cpp rename to src/analysers/httpbox_analyser.cpp diff --git a/tools/RTMP_Parser/main.cpp b/src/analysers/rtmp_analyser.cpp similarity index 100% rename from tools/RTMP_Parser/main.cpp rename to src/analysers/rtmp_analyser.cpp diff --git a/tools/RTP_Parser/main.cpp b/src/analysers/rtp_analyser.cpp similarity index 100% rename from tools/RTP_Parser/main.cpp rename to src/analysers/rtp_analyser.cpp diff --git a/tools/TS_Analyser/main.cpp b/src/analysers/ts_analyser.cpp similarity index 100% rename from tools/TS_Analyser/main.cpp rename to src/analysers/ts_analyser.cpp diff --git a/Buffer/main.cpp b/src/buffer.cpp similarity index 99% rename from Buffer/main.cpp rename to src/buffer.cpp index 050c0373..17f04b78 100644 --- a/Buffer/main.cpp +++ b/src/buffer.cpp @@ -12,7 +12,7 @@ #include #include #include -#include "stream.h" +#include "buffer_stream.h" /// Holds all code unique to the Buffer. namespace Buffer{ diff --git a/Buffer/stats.cpp b/src/buffer_stats.cpp similarity index 95% rename from Buffer/stats.cpp rename to src/buffer_stats.cpp index db93db65..e63f6a06 100644 --- a/Buffer/stats.cpp +++ b/src/buffer_stats.cpp @@ -1,4 +1,4 @@ -#include "stats.h" +#include "buffer_stats.h" #include //for atoi() Buffer::Stats::Stats(){ diff --git a/Buffer/stats.h b/src/buffer_stats.h similarity index 100% rename from Buffer/stats.h rename to src/buffer_stats.h diff --git a/Buffer/stream.cpp b/src/buffer_stream.cpp similarity index 99% rename from Buffer/stream.cpp rename to src/buffer_stream.cpp index 571a7fba..986115e1 100644 --- a/Buffer/stream.cpp +++ b/src/buffer_stream.cpp @@ -1,4 +1,4 @@ -#include "stream.h" +#include "buffer_stream.h" /// Stores the globally equal reference. Buffer::Stream * Buffer::Stream::ref = 0; diff --git a/Buffer/stream.h b/src/buffer_stream.h similarity index 97% rename from Buffer/stream.h rename to src/buffer_stream.h index a4fa0fc4..016a1d5f 100644 --- a/Buffer/stream.h +++ b/src/buffer_stream.h @@ -1,8 +1,8 @@ #pragma once #include -#include "../util/tinythread.h" -#include "../util/json.h" -#include "user.h" +#include "../lib/tinythread.h" +#include "../lib/json.h" +#include "buffer_user.h" namespace Buffer{ class Stream{ diff --git a/Buffer/user.cpp b/src/buffer_user.cpp similarity index 97% rename from Buffer/user.cpp rename to src/buffer_user.cpp index d0b79898..bdb481a7 100644 --- a/Buffer/user.cpp +++ b/src/buffer_user.cpp @@ -1,5 +1,5 @@ -#include "user.h" -#include "stream.h" +#include "buffer_user.h" +#include "buffer_stream.h" #include int Buffer::user::UserCount = 0; diff --git a/Buffer/user.h b/src/buffer_user.h similarity index 94% rename from Buffer/user.h rename to src/buffer_user.h index b1cb6558..607f2549 100644 --- a/Buffer/user.h +++ b/src/buffer_user.h @@ -1,9 +1,9 @@ #pragma once #include -#include "stats.h" -#include "../util/dtsc.h" -#include "../util/socket.h" -#include "../util/tinythread.h" +#include "buffer_stats.h" +#include "../lib/dtsc.h" +#include "../lib/socket.h" +#include "../lib/tinythread.h" namespace Buffer{ /// Holds connected users. diff --git a/Connector_HTTP/main.cpp b/src/conn_http.cpp similarity index 96% rename from Connector_HTTP/main.cpp rename to src/conn_http.cpp index 3767eecb..090f0901 100644 --- a/Connector_HTTP/main.cpp +++ b/src/conn_http.cpp @@ -11,14 +11,13 @@ #include #include #include -#include "../util/socket.h" -#include "../util/http_parser.h" -#include "../util/json.h" -#include "../util/dtsc.h" -#include "../util/flv_tag.h" -#include "../util/MP4/interface.cpp" -#include "../util/base64.h" -#include "../util/amf.h" +#include "../lib/socket.h" +#include "../lib/http_parser.h" +#include "../lib/json.h" +#include "../lib/dtsc.h" +#include "../lib/flv_tag.h" +#include "../lib/base64.h" +#include "../lib/amf.h" /// Holds everything unique to HTTP Connector. namespace Connector_HTTP{ @@ -29,7 +28,18 @@ namespace Connector_HTTP{ std::queue Flash_FragBuffer;/// 0) && !Flash_FragBuffer.empty()){ HTTP_S.Clean(); HTTP_S.SetHeader("Content-Type","video/mp4"); - HTTP_S.SetBody(Interface::mdatFold(Flash_FragBuffer.front())); + HTTP_S.SetBody(mdatFold(Flash_FragBuffer.front())); Flash_FragBuffer.pop(); HTTP_S.SendResponse(conn, "200", "OK");//schrijf de HTTP response header Flash_RequestPending--; @@ -323,4 +333,4 @@ namespace Connector_HTTP{ #define DEFAULT_PORT 8080 #define MAINHANDLER Connector_HTTP::Connector_HTTP #define CONFIGSECT HTTP -#include "../util/server_setup.cpp" +#include "server_setup.cpp" diff --git a/Connector_RAW/main.cpp b/src/conn_raw.cpp similarity index 96% rename from Connector_RAW/main.cpp rename to src/conn_raw.cpp index 5ef11a50..1085923c 100644 --- a/Connector_RAW/main.cpp +++ b/src/conn_raw.cpp @@ -2,7 +2,7 @@ /// Contains the main code for the RAW connector. #include -#include "../util/socket.h" +#include "../lib/socket.h" /// Contains the main code for the RAW connector. /// Expects a single commandline argument telling it which stream to connect to, diff --git a/Connector_RTMP/main.cpp b/src/conn_rtmp.cpp similarity index 99% rename from Connector_RTMP/main.cpp rename to src/conn_rtmp.cpp index 649ec02c..c47175f9 100644 --- a/Connector_RTMP/main.cpp +++ b/src/conn_rtmp.cpp @@ -11,10 +11,10 @@ #include #include #include -#include "../util/socket.h" -#include "../util/flv_tag.h" -#include "../util/amf.h" -#include "../util/rtmpchunks.h" +#include "../lib/socket.h" +#include "../lib/flv_tag.h" +#include "../lib/amf.h" +#include "../lib/rtmpchunks.h" /// Holds all functions and data unique to the RTMP Connector namespace Connector_RTMP{ @@ -505,4 +505,4 @@ void Connector_RTMP::parseAMFCommand(AMF::Object & amfdata, int messagetype, int #define DEFAULT_PORT 1935 #define MAINHANDLER Connector_RTMP::Connector_RTMP #define CONFIGSECT RTMP -#include "../util/server_setup.cpp" +#include "server_setup.cpp" diff --git a/Controller/main.cpp b/src/controller.cpp similarity index 98% rename from Controller/main.cpp rename to src/controller.cpp index 0494842a..073cde0a 100644 --- a/Controller/main.cpp +++ b/src/controller.cpp @@ -21,13 +21,13 @@ #include #include #include -#include "../util/socket.h" -#include "../util/http_parser.h" -#include "../util/md5.h" -#include "../util/json.h" -#include "../util/procs.h" -#include "../util/config.h" -#include "../util/auth.h" +#include "../lib/socket.h" +#include "../lib/http_parser.h" +#include "../lib/md5.h" +#include "../lib/json.h" +#include "../lib/procs.h" +#include "../lib/config.h" +#include "../lib/auth.h" #define UPLINK_INTERVAL 30 @@ -209,7 +209,7 @@ void CheckConfig(JSON::Value & in, JSON::Value & out){ } } out = in; - out["version"] = TOSTRING(VERSION); + out["version"] = TOSTRING(PACKAGE_VERSION); } bool streamsEqual(JSON::Value & one, JSON::Value & two){ diff --git a/tools/DTSC2FLV/main.cpp b/src/converters/dtsc2flv.cpp similarity index 100% rename from tools/DTSC2FLV/main.cpp rename to src/converters/dtsc2flv.cpp diff --git a/tools/FLV2DTSC/main.cpp b/src/converters/flv2dtsc.cpp similarity index 100% rename from tools/FLV2DTSC/main.cpp rename to src/converters/flv2dtsc.cpp diff --git a/util/server_setup.cpp b/src/server_setup.cpp similarity index 97% rename from util/server_setup.cpp rename to src/server_setup.cpp index 8f8cfad4..902ffa7e 100644 --- a/util/server_setup.cpp +++ b/src/server_setup.cpp @@ -15,8 +15,8 @@ #endif -#include "socket.h" //Socket library -#include "config.h" //utilities for config management +#include "../lib/socket.h" //Socket library +#include "../lib/config.h" //utilities for config management #include #include #include diff --git a/tools/ABST_Parser/Makefile b/tools/ABST_Parser/Makefile deleted file mode 100644 index 6dd89381..00000000 --- a/tools/ABST_Parser/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -SRC = main.cpp -OBJ = $(SRC:.cpp=.o) -OUT = Box_Parser -INCLUDES = -CCFLAGS = -Wall -Wextra -funsigned-char -g -CC = $(CROSS)g++ -LD = $(CROSS)ld -AR = $(CROSS)ar -LIBS = -lssl -lcrypto -.SUFFIXES: .cpp -.PHONY: clean default -default: $(OUT) -.cpp.o: - $(CC) $(INCLUDES) $(CCFLAGS) -c $< -o $@ -$(OUT): $(OBJ) - $(CC) $(LIBS) -o $(OUT) $(OBJ) -clean: - rm -rf $(OBJ) $(OUT) Makefile.bak *~ - diff --git a/tools/AMF_Tester/Makefile b/tools/AMF_Tester/Makefile deleted file mode 100644 index afefa38c..00000000 --- a/tools/AMF_Tester/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -SRC = main.cpp ../../util/amf.cpp -OBJ = $(SRC:.cpp=.o) -OUT = AMFtest -INCLUDES = -CCFLAGS = -Wall -Wextra -funsigned-char -g -CC = $(CROSS)g++ -LD = $(CROSS)ld -AR = $(CROSS)ar -LIBS = -lssl -lcrypto -.SUFFIXES: .cpp -.PHONY: clean default -default: $(OUT) -.cpp.o: - $(CC) $(INCLUDES) $(CCFLAGS) -c $< -o $@ -$(OUT): $(OBJ) - $(CC) $(LIBS) -o $(OUT) $(OBJ) -clean: - rm -rf $(OBJ) $(OUT) Makefile.bak *~ - diff --git a/tools/DTSC2FLV/Makefile b/tools/DTSC2FLV/Makefile deleted file mode 100644 index 23d86bbf..00000000 --- a/tools/DTSC2FLV/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -SRC = main.cpp ../../util/flv_tag.cpp ../../util/dtsc.cpp ../../util/amf.cpp ../../util/socket.cpp -OBJ = $(SRC:.cpp=.o) -OUT = DDV_DTSC2FLV -INCLUDES = -DEBUG = 4 -OPTIMIZE = -g -CCFLAGS = -Wall -Wextra -funsigned-char $(OPTIMIZE) -DDEBUG=$(DEBUG) -CC = $(CROSS)g++ -LD = $(CROSS)ld -AR = $(CROSS)ar -LIBS = -.SUFFIXES: .cpp -.PHONY: clean default -default: $(OUT) -.cpp.o: - $(CC) $(INCLUDES) $(CCFLAGS) $(LIBS) -c $< -o $@ -$(OUT): $(OBJ) - $(CC) $(LIBS) -o $(OUT) $(OBJ) -clean: - rm -rf $(OBJ) $(OUT) Makefile.bak *~ -install: $(OUT) - cp -f ./$(OUT) /usr/bin/ - diff --git a/tools/DTSC_Analyser/Makefile b/tools/DTSC_Analyser/Makefile deleted file mode 100644 index ad834129..00000000 --- a/tools/DTSC_Analyser/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -SRC = main.cpp ../../util/dtsc.cpp -OBJ = $(SRC:.cpp=.o) -OUT = DTSC_Info -INCLUDES = -DEBUG = 4 -OPTIMIZE = -g -CCFLAGS = -Wall -Wextra -funsigned-char $(OPTIMIZE) -DDEBUG=$(DEBUG) -CC = $(CROSS)g++ -LD = $(CROSS)ld -AR = $(CROSS)ar -LIBS = -.SUFFIXES: .cpp -.PHONY: clean default -default: $(OUT) -.cpp.o: - $(CC) $(INCLUDES) $(CCFLAGS) $(LIBS) -c $< -o $@ -$(OUT): $(OBJ) - $(CC) $(LIBS) -o $(OUT) $(OBJ) -clean: - rm -rf $(OBJ) $(OUT) Makefile.bak *~ -install: $(OUT) - cp -f ./$(OUT) /usr/bin/ - diff --git a/tools/FLV2DTSC/Makefile b/tools/FLV2DTSC/Makefile deleted file mode 100644 index 87e30d40..00000000 --- a/tools/FLV2DTSC/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -SRC = main.cpp ../../util/flv_tag.cpp ../../util/dtsc.cpp ../../util/amf.cpp ../../util/socket.cpp -OBJ = $(SRC:.cpp=.o) -OUT = MistFLV2DTSC -INCLUDES = -DEBUG = 4 -OPTIMIZE = -g -CCFLAGS = -Wall -Wextra -funsigned-char $(OPTIMIZE) -DDEBUG=$(DEBUG) -CC = $(CROSS)g++ -LD = $(CROSS)ld -AR = $(CROSS)ar -LIBS = -.SUFFIXES: .cpp -.PHONY: clean default -default: $(OUT) -.cpp.o: - $(CC) $(INCLUDES) $(CCFLAGS) $(LIBS) -c $< -o $@ -$(OUT): $(OBJ) - $(CC) $(LIBS) -o ../../bin/$(OUT) $(OBJ) -clean: - rm -rf $(OBJ) ../../bin/$(OUT) Makefile.bak *~ diff --git a/tools/FLV_Analyser/Makefile b/tools/FLV_Analyser/Makefile deleted file mode 100644 index 81b2e2fa..00000000 --- a/tools/FLV_Analyser/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -SRC = main.cpp ../../util/flv_tag.cpp ../../util/dtsc.cpp ../../util/amf.cpp ../../util/socket.cpp -OBJ = $(SRC:.cpp=.o) -OUT = FLV_Info -INCLUDES = -DEBUG = 4 -OPTIMIZE = -g -CCFLAGS = -Wall -Wextra -funsigned-char $(OPTIMIZE) -DDEBUG=$(DEBUG) -CC = $(CROSS)g++ -LD = $(CROSS)ld -AR = $(CROSS)ar -LIBS = -.SUFFIXES: .cpp -.PHONY: clean default -default: $(OUT) -.cpp.o: - $(CC) $(INCLUDES) $(CCFLAGS) $(LIBS) -c $< -o $@ -$(OUT): $(OBJ) - $(CC) $(LIBS) -o $(OUT) $(OBJ) -clean: - rm -rf $(OBJ) $(OUT) Makefile.bak *~ -install: $(OUT) - cp -f ./$(OUT) /usr/bin/ - diff --git a/tools/HTTP_Box_Parser/Makefile b/tools/HTTP_Box_Parser/Makefile deleted file mode 100644 index 3a44d0cd..00000000 --- a/tools/HTTP_Box_Parser/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -SRC = main.cpp ../../util/flv_tag.cpp ../../util/http_parser.cpp ../../util/socket.cpp -OBJ = $(SRC:.cpp=.o) -OUT = Box_Parser -INCLUDES = -CCFLAGS = -Wall -Wextra -funsigned-char -g -CC = $(CROSS)g++ -LD = $(CROSS)ld -AR = $(CROSS)ar -LIBS = -lssl -lcrypto -.SUFFIXES: .cpp -.PHONY: clean default -default: $(OUT) -.cpp.o: - $(CC) $(INCLUDES) $(CCFLAGS) -c $< -o $@ -$(OUT): $(OBJ) - $(CC) $(LIBS) -o $(OUT) $(OBJ) -clean: - rm -rf $(OBJ) $(OUT) Makefile.bak *~ - diff --git a/tools/RTMP_Parser/Makefile b/tools/RTMP_Parser/Makefile deleted file mode 100644 index d1303ddf..00000000 --- a/tools/RTMP_Parser/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -SRC = main.cpp ../../util/amf.cpp ../../util/rtmpchunks.cpp ../../util/crypto.cpp ../../util/flv_tag.cpp ../../util/socket.cpp ../../util/dtsc.cpp -OBJ = $(SRC:.cpp=.o) -OUT = RTMP_Parser -INCLUDES = -STATIC = -CCFLAGS = -Wall -Wextra -funsigned-char -g -CC = $(CROSS)g++ -LD = $(CROSS)ld -AR = $(CROSS)ar -LIBS = -lssl -lcrypto -.SUFFIXES: .cpp -.PHONY: clean default -default: $(OUT) -.cpp.o: - $(CC) $(INCLUDES) $(CCFLAGS) -c $< -o $@ -$(OUT): $(OBJ) - $(CC) -o $(OUT) $(OBJ) $(STATIC) $(LIBS) -clean: - rm -rf $(OBJ) $(OUT) Makefile.bak *~ - diff --git a/tools/spawntest/Makefile b/tools/spawntest/Makefile deleted file mode 100644 index f18a81c4..00000000 --- a/tools/spawntest/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -SRC = main.cpp ../../util/util.cpp -OBJ = $(SRC:.cpp=.o) -OUT = spawntest -INCLUDES = -DEBUG = 4 -OPTIMIZE = -g -CCFLAGS = -Wall -Wextra -funsigned-char $(OPTIMIZE) -DDEBUG=$(DEBUG) -CC = $(CROSS)g++ -LD = $(CROSS)ld -AR = $(CROSS)ar -LIBS = -.SUFFIXES: .cpp -.PHONY: clean default -default: $(OUT) -.cpp.o: - $(CC) $(INCLUDES) $(CCFLAGS) $(LIBS) -c $< -o $@ -$(OUT): $(OBJ) - $(CC) $(LIBS) -o $(OUT) $(OBJ) -clean: - rm -rf $(OBJ) $(OUT) Makefile.bak *~ diff --git a/tools/spawntest/main.cpp b/tools/spawntest/main.cpp deleted file mode 100644 index c1aa9468..00000000 --- a/tools/spawntest/main.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/// \file spawntest/main.cpp -/// Contains a testing program for the Util::Proc utility class. - -#include -#include -#include "../../util/util.h" //Process utility - -/// Sleeps a maximum of five seconds, each second being interruptable by a signal. -void sleepFive(){ - sleep(1); sleep(1); sleep(1); sleep(1); sleep(1); -} - -/// Testing program for Util::Proc utility class. -int main(){ - Util::Procs::Start("number1", "./test.sh Koekjes"); - sleepFive(); - Util::Procs::Start("number2", "./testpipein.sh", "./testpipeout.sh"); - sleepFive(); - Util::Procs::Start("number3", "./infitest.sh"); - sleepFive(); - Util::Procs::Stop("number3"); - Util::Procs::Start("number4", "./infitest.sh", "./testpipeout.sh"); - sleepFive(); - Util::Procs::Stop("number4"); - return 0; -}//main diff --git a/tools/spawntest/test.sh b/tools/spawntest/test.sh deleted file mode 100755 index 9e0603d4..00000000 --- a/tools/spawntest/test.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -echo "I am a test!" -echo "I was called as $0" -echo "My first param is $1" -echo "Exiting now..." diff --git a/tools/spawntest/testpipein.sh b/tools/spawntest/testpipein.sh deleted file mode 100755 index bd54fdd1..00000000 --- a/tools/spawntest/testpipein.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -echo "Sending something through the pipe..." 1>&2 -echo "something" -echo "Exiting pipewriter" 1>&2 diff --git a/tools/spawntest/testpipeout.sh b/tools/spawntest/testpipeout.sh deleted file mode 100755 index 7c7c6cec..00000000 --- a/tools/spawntest/testpipeout.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -echo "Reading stdin..." -read meh -echo "I read $meh" -echo "Exiting pipereader now..." diff --git a/util/MP4/Makefile b/util/MP4/Makefile deleted file mode 100644 index 4ff1d185..00000000 --- a/util/MP4/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -SRC = box_abst.cpp box_afra.cpp box_afrt.cpp box_amhp.cpp box_asrt.cpp box_avcC.cpp box.cpp box_dinf.cpp box_dref.cpp box_esds.cpp box_ftyp.cpp box_hdlr.cpp box_hmhd.cpp box_mdat.cpp box_mdhd.cpp box_mdia.cpp box_mfhd.cpp box_minf.cpp box_moof.cpp box_moov.cpp box_mvex.cpp box_mvhd.cpp box_nmhd.cpp box_rtmp.cpp box_smhd.cpp box_stbl.cpp box_stco.cpp box_stsc.cpp box_stsd.cpp box_stts.cpp box_tfhd.cpp box_tkhd.cpp box_traf.cpp box_trak.cpp box_trex.cpp box_trun.cpp box_url.cpp box_vmhd.cpp interface.cpp main.cpp -OBJ = $(SRC:.cpp=.o) -OUT = Boxtest -INCLUDES = -CCFLAGS = -Wall -Wextra -funsigned-char -g -CC = $(CROSS)g++ -LD = $(CROSS)ld -AR = $(CROSS)ar -LIBS = -.SUFFIXES: .cpp -.PHONY: clean default -default: $(OUT) -.cpp.o: - $(CC) $(INCLUDES) $(CCFLAGS) $(LIBS) -c $< -o $@ -$(OUT): $(OBJ) - $(CC) $(LIBS) -o $(OUT) $(OBJ) -clean: - rm -rf $(OBJ) $(OUT) Makefile.bak *~ diff --git a/util/MP4/box.cpp b/util/MP4/box.cpp deleted file mode 100644 index 9f790b7f..00000000 --- a/util/MP4/box.cpp +++ /dev/null @@ -1,123 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class Box { - public: - Box(); - Box(uint32_t BoxType); - Box(uint8_t * Content, uint32_t length); - ~Box(); - void SetBoxType(uint32_t BoxType); - uint32_t GetBoxType(); - void SetPayload(uint32_t Size, uint8_t * Data, uint32_t Index = 0); - uint32_t GetPayloadSize(); - uint8_t * GetPayload(); - uint8_t * GetPayload(uint32_t Index, uint32_t & Size); - uint32_t GetBoxedDataSize(); - uint8_t * GetBoxedData( ); - static uint8_t * uint32_to_uint8( uint32_t data ); - static uint8_t * uint16_to_uint8( uint16_t data ); - static uint8_t * uint8_to_uint8( uint8_t data ); - void ResetPayload( ); - private: - uint8_t * Payload; - uint32_t PayloadSize; -};//Box Class - -Box::Box() { - Payload = (uint8_t *)malloc(8); - PayloadSize = 0; -} - -Box::Box(uint32_t BoxType) { - Payload = (uint8_t *)malloc(8); - SetBoxType(BoxType); - PayloadSize = 0; -} - -Box::Box(uint8_t * Content, uint32_t length) { - PayloadSize = length-8; - Payload = (uint8_t *)malloc(length); - memcpy(Payload, Content, length); -} - -Box::~Box() { - if (Payload) free(Payload); -} - -void Box::SetBoxType(uint32_t BoxType) { - ((unsigned int*)Payload)[1] = htonl(BoxType); -} - -uint32_t Box::GetBoxType() { - return ntohl(((unsigned int*)Payload)[1]); -} - -void Box::SetPayload(uint32_t Size, uint8_t * Data, uint32_t Index) { - if ( Index + Size > PayloadSize ) { - PayloadSize = Index + Size; - ((unsigned int*)Payload)[0] = htonl(PayloadSize+8); - Payload = (uint8_t *)realloc(Payload, PayloadSize + 8); - } - memcpy(Payload + 8 + Index, Data, Size); -} - -uint32_t Box::GetPayloadSize() { - return PayloadSize; -} - -uint8_t * Box::GetPayload() { - return Payload+8; -} - -uint8_t * Box::GetPayload(uint32_t Index, uint32_t & Size) { - if(Index > PayloadSize) {Size = 0;} - if(Index + Size > PayloadSize) { Size = PayloadSize - Index; } - return Payload + 8 + Index; -} - -uint32_t Box::GetBoxedDataSize() { - return ntohl(((unsigned int*)Payload)[0]); -} - -uint8_t * Box::GetBoxedData( ) { - return Payload; -} - - -uint8_t * Box::uint32_to_uint8( uint32_t data ) { - uint8_t * temp = new uint8_t[4]; - temp[0] = (data >> 24) & 0x000000FF; - temp[1] = (data >> 16 ) & 0x000000FF; - temp[2] = (data >> 8 ) & 0x000000FF; - temp[3] = (data ) & 0x000000FF; - return temp; -} - -uint8_t * Box::uint16_to_uint8( uint16_t data ) { - uint8_t * temp = new uint8_t[2]; - temp[0] = (data >> 8) & 0x00FF; - temp[1] = (data ) & 0x00FF; - return temp; -} - -uint8_t * Box::uint8_to_uint8( uint8_t data ) { - uint8_t * temp = new uint8_t[1]; - temp[0] = data; - return temp; -} - -void Box::ResetPayload( ) { - PayloadSize = 0; - Payload = (uint8_t *)realloc(Payload, PayloadSize + 8); - ((unsigned int*)Payload)[0] = htonl(0); -} diff --git a/util/MP4/box_abst.cpp b/util/MP4/box_abst.cpp deleted file mode 100644 index 238679ee..00000000 --- a/util/MP4/box_abst.cpp +++ /dev/null @@ -1,227 +0,0 @@ -#pragma once -#include "box.cpp" -#include -#include - - -struct abst_serverentry { - std::string ServerBaseUrl; -};//abst_serverentry - -struct abst_qualityentry { - std::string QualityModifier; -};//abst_qualityentry - -class Box_abst { - public: - Box_abst( ); - ~Box_abst(); - Box * GetBox(); - void SetBootstrapVersion( uint32_t Version = 1 ); - void SetProfile( uint8_t Profile = 0 ); - void SetLive( bool Live = true ); - void SetUpdate( bool Update = false ); - void SetTimeScale( uint32_t Scale = 1000 ); - void SetMediaTime( uint32_t Time = 0 ); - void SetSMPTE( uint32_t Smpte = 0 ); - void SetMovieIdentifier( std::string Identifier = "" ); - void SetDRM( std::string Drm = "" ); - void SetMetaData( std::string MetaData = "" ); - void AddServerEntry( std::string Url = "", uint32_t Offset = 0 ); - void AddQualityEntry( std::string Quality = "", uint32_t Offset = 0 ); - void AddSegmentRunTable( Box * newSegment, uint32_t Offset = 0 ); - void AddFragmentRunTable( Box * newFragment, uint32_t Offset = 0 ); - void SetVersion( bool NewVersion = 0 ); - void WriteContent( ); - private: - void SetDefaults( ); - void SetReserved( ); - uint32_t curBootstrapInfoVersion; - uint8_t curProfile; - bool isLive; - bool isUpdate; - bool Version; - uint32_t curTimeScale; - uint32_t curMediatime;//write as uint64_t - uint32_t curSMPTE;//write as uint64_t - std::string curMovieIdentifier; - std::string curDRM; - std::string curMetaData; - std::vector Servers; - std::vector Qualities; - std::vector SegmentRunTables; - std::vector FragmentRunTables; - Box * Container; -};//Box_ftyp Class - -Box_abst::Box_abst( ) { - Container = new Box( 0x61627374 ); - SetDefaults( ); -} - -Box_abst::~Box_abst() { - delete Container; -} - -Box * Box_abst::GetBox() { - return Container; -} - -void Box_abst::SetBootstrapVersion( uint32_t Version ) { - curBootstrapInfoVersion = Version; -} - -void Box_abst::SetProfile( uint8_t Profile ) { - curProfile = Profile; -} - -void Box_abst::SetLive( bool Live ) { - isLive = Live; -} - -void Box_abst::SetUpdate( bool Update ) { - isUpdate = Update; -} - -void Box_abst::SetTimeScale( uint32_t Scale ) { - curTimeScale = Scale; -} - -void Box_abst::SetMediaTime( uint32_t Time ) { - curMediatime = Time; -} - -void Box_abst::SetSMPTE( uint32_t Smpte ) { - curSMPTE = Smpte; -} - -void Box_abst::SetMovieIdentifier( std::string Identifier ) { - curMovieIdentifier = Identifier; -} - -void Box_abst::SetDRM( std::string Drm ) { - curDRM = Drm; -} - -void Box_abst::SetMetaData( std::string MetaData ) { - curMetaData = MetaData; -} - -void Box_abst::AddServerEntry( std::string Url, uint32_t Offset ) { - if(Offset >= Servers.size()) { - Servers.resize(Offset+1); - } - Servers[Offset].ServerBaseUrl = Url; -} - -void Box_abst::AddQualityEntry( std::string Quality, uint32_t Offset ) { - if(Offset >= Qualities.size()) { - Qualities.resize(Offset+1); - } - Qualities[Offset].QualityModifier = Quality; -} - -void Box_abst::AddSegmentRunTable( Box * newSegment, uint32_t Offset ) { - if( Offset >= SegmentRunTables.size() ) { - SegmentRunTables.resize(Offset+1); - } - if( SegmentRunTables[Offset] ) { - delete SegmentRunTables[Offset]; - } - SegmentRunTables[Offset] = newSegment; -} - -void Box_abst::AddFragmentRunTable( Box * newFragment, uint32_t Offset ) { - if( Offset >= FragmentRunTables.size() ) { - FragmentRunTables.resize(Offset+1); - } - if( FragmentRunTables[Offset] ) { - delete FragmentRunTables[Offset]; - } - FragmentRunTables[Offset] = newFragment; -} - -void Box_abst::SetDefaults( ) { - SetProfile( ); - SetLive( ); - SetUpdate( ); - SetTimeScale( ); - SetMediaTime( ); - SetSMPTE( ); - SetMovieIdentifier( ); - SetDRM( ); - SetMetaData( ); - SetVersion( ); -} - -void Box_abst::SetVersion( bool NewVersion) { - Version = NewVersion; -} - -void Box_abst::SetReserved( ) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0)); -} - -void Box_abst::WriteContent( ) { - Box * current; - std::string serializedServers = ""; - std::string serializedQualities = ""; - std::string serializedSegments = ""; - std::string serializedFragments = ""; - int SegmentAmount = 0; - int FragmentAmount = 0; - uint8_t * temp = new uint8_t[1]; - - Container->ResetPayload( ); - SetReserved( ); - - for( uint32_t i = 0; i < Servers.size(); i++ ) { - serializedServers.append(Servers[i].ServerBaseUrl.c_str()); - serializedServers += '\0'; - } - for( uint32_t i = 0; i < Qualities.size(); i++ ) { - serializedQualities.append(Qualities[i].QualityModifier.c_str()); - serializedQualities += '\0'; - } - for( uint32_t i = 0; i < SegmentRunTables.size(); i++ ) { - current=SegmentRunTables[i]; - if( current ) { - SegmentAmount ++; - serializedSegments.append((char*)current->GetBoxedData(),current->GetBoxedDataSize()); - } - } - for( uint32_t i = 0; i < FragmentRunTables.size(); i++ ) { - current=FragmentRunTables[i]; - if( current ) { - FragmentAmount ++; - serializedFragments.append((char*)current->GetBoxedData(),current->GetBoxedDataSize()); - } - } - uint32_t OffsetServerEntryCount = 29 + curMovieIdentifier.size() + 1; - uint32_t OffsetQualityEntryCount = OffsetServerEntryCount + 1 + serializedServers.size(); - uint32_t OffsetDrmData = OffsetQualityEntryCount + 1 + serializedQualities.size(); - uint32_t OffsetMetaData = OffsetDrmData + curDRM.size() + 1; - uint32_t OffsetSegmentRuntableCount = OffsetMetaData + curMetaData.size() + 1; - uint32_t OffsetFragmentRuntableCount = OffsetSegmentRuntableCount + 1 + serializedSegments.size(); - - temp[0] = 0 + ( curProfile << 6 ) + ( (uint8_t)isLive << 7 ) + ( (uint8_t)isUpdate << 7 ); - - Container->SetPayload((uint32_t)serializedFragments.size(),(uint8_t*)serializedFragments.c_str(),OffsetFragmentRuntableCount+1); - Container->SetPayload((uint32_t)1,Box::uint8_to_uint8(FragmentAmount),OffsetFragmentRuntableCount); - Container->SetPayload((uint32_t)serializedSegments.size(),(uint8_t*)serializedSegments.c_str(),OffsetSegmentRuntableCount+1); - Container->SetPayload((uint32_t)1,Box::uint8_to_uint8(SegmentAmount),OffsetSegmentRuntableCount); - Container->SetPayload((uint32_t)curMetaData.size()+1,(uint8_t*)curMetaData.c_str(),OffsetMetaData); - Container->SetPayload((uint32_t)curDRM.size()+1,(uint8_t*)curDRM.c_str(),OffsetDrmData); - Container->SetPayload((uint32_t)serializedQualities.size(),(uint8_t*)serializedQualities.c_str(),OffsetQualityEntryCount+1); - Container->SetPayload((uint32_t)1,Box::uint8_to_uint8(Qualities.size()),OffsetQualityEntryCount); - Container->SetPayload((uint32_t)serializedServers.size(),(uint8_t*)serializedServers.c_str(),OffsetServerEntryCount+1); - Container->SetPayload((uint32_t)1,Box::uint8_to_uint8(Servers.size()),OffsetServerEntryCount); - Container->SetPayload((uint32_t)curMovieIdentifier.size()+1,(uint8_t*)curMovieIdentifier.c_str(),29);//+1 for \0-terminated string... - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(curSMPTE),25); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),21); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(curMediatime),17); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),13); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(curTimeScale),9); - Container->SetPayload((uint32_t)1,temp,8); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(curBootstrapInfoVersion),4); -} diff --git a/util/MP4/box_afra.cpp b/util/MP4/box_afra.cpp deleted file mode 100644 index 103c2c40..00000000 --- a/util/MP4/box_afra.cpp +++ /dev/null @@ -1,75 +0,0 @@ -#include "box.cpp" -#include - -struct afra_record { - uint32_t Time; - uint32_t Offset; -};//afra_record - -class Box_afra { - public: - Box_afra( ); - ~Box_afra(); - Box * GetBox(); - void SetTimeScale( uint32_t Scale = 1 ); - void AddEntry( uint32_t Time = 0, uint32_t SampleOffset = 0, uint32_t Offset = 0 ); - void WriteContent( ); - private: - void SetReserved( ); - void SetDefaults( ); - - Box * Container; - uint32_t CurrentTimeScale; - std::vector Entries; -};//Box_ftyp Class - -Box_afra::Box_afra( ) { - Container = new Box( 0x61667261 ); - SetReserved( ); - SetDefaults( ); -} - -Box_afra::~Box_afra() { - delete Container; -} - -Box * Box_afra::GetBox() { - return Container; -} - -void Box_afra::SetDefaults( ) { - SetTimeScale( ); -} - -void Box_afra::SetReserved( ) { - uint8_t * temp = new uint8_t[1]; - temp[0] = 0; - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),1); - Container->SetPayload((uint32_t)1,temp); -} - -void Box_afra::SetTimeScale( uint32_t Scale ) { - CurrentTimeScale = Scale; - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Scale),5); -} - -void Box_afra::AddEntry( uint32_t Time, uint32_t SampleOffset, uint32_t Offset ) { - if(Offset >= Entries.size()) { - Entries.resize(Offset+1); - } - Entries[Offset].Time = Time; - Entries[Offset].Offset = SampleOffset; -} - -void Box_afra::WriteContent( ) { - Container->ResetPayload(); - SetReserved( ); - if(!Entries.empty()) { - for(int32_t i = Entries.size() -1; i >= 0; i--) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Entries[i].Offset),(i*12)+21); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Entries[i].Time),(i*12)+17); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),(i*12)+13); - } - } - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Entries.size()),9); -} diff --git a/util/MP4/box_afrt.cpp b/util/MP4/box_afrt.cpp deleted file mode 100644 index 06ddece2..00000000 --- a/util/MP4/box_afrt.cpp +++ /dev/null @@ -1,104 +0,0 @@ -#include "box.cpp" -#include -#include - - -struct afrt_fragmentrunentry { - uint32_t FirstFragment; - uint32_t FirstFragmentTimestamp; //write as uint64_t - uint32_t FragmentDuration; - uint8_t DiscontinuityIndicator;//if FragmentDuration == 0 -};//afrt_fragmentrunentry - - -class Box_afrt { - public: - Box_afrt( ); - ~Box_afrt(); - Box * GetBox(); - void SetUpdate( bool Update = false ); - void SetTimeScale( uint32_t Scale = 1000 ); - void AddQualityEntry( std::string Quality = "", uint32_t Offset = 0 ); - void AddFragmentRunEntry( uint32_t FirstFragment = 0, uint32_t FirstFragmentTimestamp = 0, uint32_t FragmentsDuration = 1, uint8_t Discontinuity = 0, uint32_t Offset = 0 ); - void WriteContent( ); - private: - void SetDefaults( ); - bool isUpdate; - uint32_t curTimeScale; - std::vector QualitySegmentUrlModifiers; - std::vector FragmentRunEntryTable; - Box * Container; -};//Box_ftyp Class - -Box_afrt::Box_afrt( ) { - Container = new Box( 0x61667274 ); -} - -Box_afrt::~Box_afrt() { - delete Container; -} - -Box * Box_afrt::GetBox() { - return Container; -} - -void Box_afrt::SetUpdate( bool Update ) { - isUpdate = Update; -} - -void Box_afrt::AddQualityEntry( std::string Quality, uint32_t Offset ) { - if(Offset >= QualitySegmentUrlModifiers.size()) { - QualitySegmentUrlModifiers.resize(Offset+1); - } - QualitySegmentUrlModifiers[Offset] = Quality; -} - -void Box_afrt::AddFragmentRunEntry( uint32_t FirstFragment, uint32_t FirstFragmentTimestamp, uint32_t FragmentsDuration, uint8_t Discontinuity, uint32_t Offset ) { - if( Offset >= FragmentRunEntryTable.size() ) { - FragmentRunEntryTable.resize(Offset+1); - } - FragmentRunEntryTable[Offset].FirstFragment = FirstFragment; - FragmentRunEntryTable[Offset].FirstFragmentTimestamp = FirstFragmentTimestamp; - FragmentRunEntryTable[Offset].FragmentDuration = FragmentsDuration; - if( FragmentsDuration == 0) { - FragmentRunEntryTable[Offset].DiscontinuityIndicator = Discontinuity; - } -} - -void Box_afrt::SetDefaults( ) { - SetUpdate( ); - SetTimeScale( ); -} - -void Box_afrt::SetTimeScale( uint32_t Scale ) { - curTimeScale = Scale; -} - -void Box_afrt::WriteContent( ) { - std::string serializedQualities = ""; - std::string serializedFragmentEntries = ""; - Container->ResetPayload( ); - - for( uint32_t i = 0; i < QualitySegmentUrlModifiers.size(); i++ ) { - serializedQualities.append(QualitySegmentUrlModifiers[i].c_str()); - serializedQualities += '\0'; - } - for( uint32_t i = 0; i < FragmentRunEntryTable.size(); i ++ ) { - serializedFragmentEntries.append((char*)Box::uint32_to_uint8(FragmentRunEntryTable[i].FirstFragment),4); - serializedFragmentEntries.append((char*)Box::uint32_to_uint8(0),4); - serializedFragmentEntries.append((char*)Box::uint32_to_uint8(FragmentRunEntryTable[i].FirstFragmentTimestamp),4); - serializedFragmentEntries.append((char*)Box::uint32_to_uint8(FragmentRunEntryTable[i].FragmentDuration),4); - if(FragmentRunEntryTable[i].FragmentDuration == 0) { - serializedFragmentEntries.append((char*)Box::uint8_to_uint8(FragmentRunEntryTable[i].DiscontinuityIndicator),1); - } - } - - uint32_t OffsetFragmentRunEntryCount = 9 + serializedQualities.size(); - - Container->SetPayload((uint32_t)serializedFragmentEntries.size(),(uint8_t*)serializedFragmentEntries.c_str(),OffsetFragmentRunEntryCount+4); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(FragmentRunEntryTable.size()),OffsetFragmentRunEntryCount); - Container->SetPayload((uint32_t)serializedQualities.size(),(uint8_t*)serializedQualities.c_str(),9); - Container->SetPayload((uint32_t)1,Box::uint8_to_uint8(QualitySegmentUrlModifiers.size()),8); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(curTimeScale),4); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8((isUpdate ? 1 : 0))); -} diff --git a/util/MP4/box_amhp.cpp b/util/MP4/box_amhp.cpp deleted file mode 100644 index 761da82a..00000000 --- a/util/MP4/box_amhp.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include "box.cpp" -#include -#include - -struct amhp_record { - uint8_t HintTrackMode; - uint8_t Settings; - uint8_t TrailerDefaultSize; -};//stsc_record - -class Box_amhp { - public: - Box_amhp( ); - ~Box_amhp(); - Box * GetBox(); - void SetReserved( ); - void AddEntry( uint8_t HintTrackMode, uint8_t Settings, uint8_t TrailerDefaultSize, uint32_t Offset = 0 ); - void WriteContent( ); - private: - Box * Container; - - std::vector Entries; -};//Box_ftyp Class - -Box_amhp::Box_amhp( ) { - Container = new Box( 0x616D6870 ); - SetReserved(); -} - -Box_amhp::~Box_amhp() { - delete Container; -} - -Box * Box_amhp::GetBox() { - return Container; -} - -void Box_amhp::SetReserved( ) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0)); -} - -void Box_amhp::AddEntry( uint8_t HintTrackMode, uint8_t Settings, uint8_t TrailerDefaultSize, uint32_t Offset ) { - if(Offset >= Entries.size()) { - Entries.resize(Offset+1); - } - Entries[Offset].HintTrackMode = HintTrackMode; - Entries[Offset].Settings = Settings; - Entries[Offset].TrailerDefaultSize = TrailerDefaultSize; -} - - -void Box_amhp::WriteContent( ) { - Container->ResetPayload(); - SetReserved( ); - if(!Entries.empty()) { - for(int32_t i = Entries.size() -1; i >= 0; i--) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Entries[i].TrailerDefaultSize),(i*12)+16); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Entries[i].Settings),(i*12)+12); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Entries[i].HintTrackMode),(i*12)+8); - } - } - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Entries.size()),4); -} diff --git a/util/MP4/box_asrt.cpp b/util/MP4/box_asrt.cpp deleted file mode 100644 index cbc5ba31..00000000 --- a/util/MP4/box_asrt.cpp +++ /dev/null @@ -1,87 +0,0 @@ -#include "box.cpp" -#include -#include - -struct asrt_segmentrunentry { - uint32_t FirstSegment; - uint32_t FragmentsPerSegment; -};//abst_qualityentry - -class Box_asrt { - public: - Box_asrt( ); - ~Box_asrt(); - Box * GetBox(); - void SetUpdate( bool Update = false ); - void AddQualityEntry( std::string Quality = "", uint32_t Offset = 0 ); - void AddSegmentRunEntry( uint32_t FirstSegment = 0, uint32_t FragmentsPerSegment = 100, uint32_t Offset = 0 ); - void WriteContent( ); - void SetVersion( bool NewVersion = 0 ); - private: - void SetDefaults( ); - bool isUpdate; - bool Version; - std::vector QualitySegmentUrlModifiers; - std::vector SegmentRunEntryTable; - Box * Container; -};//Box_ftyp Class - -Box_asrt::Box_asrt( ) { - Container = new Box( 0x61737274 ); -} - -Box_asrt::~Box_asrt() { - delete Container; -} - -Box * Box_asrt::GetBox() { - return Container; -} - -void Box_asrt::SetUpdate( bool Update ) { - isUpdate = Update; -} - -void Box_asrt::AddQualityEntry( std::string Quality, uint32_t Offset ) { - if(Offset >= QualitySegmentUrlModifiers.size()) { - QualitySegmentUrlModifiers.resize(Offset+1); - } - QualitySegmentUrlModifiers[Offset] = Quality; -} - -void Box_asrt::AddSegmentRunEntry( uint32_t FirstSegment, uint32_t FragmentsPerSegment, uint32_t Offset ) { - if( Offset >= SegmentRunEntryTable.size() ) { - SegmentRunEntryTable.resize(Offset+1); - } - SegmentRunEntryTable[Offset].FirstSegment = FirstSegment; - SegmentRunEntryTable[Offset].FragmentsPerSegment = FragmentsPerSegment; -} - -void Box_asrt::SetVersion( bool NewVersion ) { - Version = NewVersion; -} - -void Box_asrt::SetDefaults( ) { - SetUpdate( ); -} - -void Box_asrt::WriteContent( ) { - std::string serializedQualities = ""; - Container->ResetPayload( ); - - for( uint32_t i = 0; i < QualitySegmentUrlModifiers.size(); i++ ) { - serializedQualities.append(QualitySegmentUrlModifiers[i].c_str()); - serializedQualities += '\0'; - } - - uint32_t OffsetSegmentRunEntryCount = 5 + serializedQualities.size(); - - for( uint32_t i = 0; i < SegmentRunEntryTable.size(); i ++ ) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(SegmentRunEntryTable[i].FragmentsPerSegment),(8*i)+OffsetSegmentRunEntryCount+8); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(SegmentRunEntryTable[i].FirstSegment),(8*i)+OffsetSegmentRunEntryCount+4); - } - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(SegmentRunEntryTable.size()),OffsetSegmentRunEntryCount); - Container->SetPayload((uint32_t)serializedQualities.size(),(uint8_t*)serializedQualities.c_str(),5); - Container->SetPayload((uint32_t)1,Box::uint8_to_uint8(QualitySegmentUrlModifiers.size()),4); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8((isUpdate ? 1 : 0))); -} diff --git a/util/MP4/box_avcC.cpp b/util/MP4/box_avcC.cpp deleted file mode 100644 index 2f021957..00000000 --- a/util/MP4/box_avcC.cpp +++ /dev/null @@ -1,87 +0,0 @@ -#include "box.cpp" -#include -#include - -class Box_avcC { - public: - Box_avcC( ); - ~Box_avcC(); - Box * GetBox(); - void SetDataReferenceIndex( uint16_t DataReferenceIndex = 1 ); - void SetWidth( uint16_t Width = 0 ); - void SetHeight( uint16_t Height = 0 ); - void SetResolution ( uint32_t Horizontal = 0x00480000, uint32_t Vertical = 0x00480000 ); - void SetFrameCount ( uint16_t FrameCount = 1 ); - void SetCompressorName ( std::string CompressorName = ""); - void SetDepth ( uint16_t Depth = 0x0018 ); - private: - Box * Container; - - void SetReserved( ); - void SetDefaults( ); -};//Box_ftyp Class - -Box_avcC::Box_avcC( ) { - Container = new Box( 0x61766343 ); - SetReserved(); - SetDefaults(); -} - -Box_avcC::~Box_avcC() { - delete Container; -} - -Box * Box_avcC::GetBox() { - return Container; -} - -void Box_avcC::SetDataReferenceIndex( uint16_t DataReferenceIndex ) { - Container->SetPayload((uint32_t)2,Box::uint16_to_uint8( DataReferenceIndex ),6); -} - -void Box_avcC::SetWidth( uint16_t Width ) { - Container->SetPayload((uint32_t)2,Box::uint16_to_uint8( Width ),24); -} - -void Box_avcC::SetHeight( uint16_t Height ) { - Container->SetPayload((uint32_t)2,Box::uint16_to_uint8( Height ),26); -} - -void Box_avcC::SetResolution ( uint32_t Horizontal, uint32_t Vertical ) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8( Vertical ),32); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8( Horizontal ),28); -} - -void Box_avcC::SetFrameCount ( uint16_t FrameCount ) { - Container->SetPayload((uint32_t)2,Box::uint16_to_uint8( FrameCount ),40); -} - -void Box_avcC::SetCompressorName ( std::string CompressorName ) { - uint8_t * Printable = new uint8_t[1]; - Printable[0] = std::min( (unsigned int)31, (unsigned int)CompressorName.size() ); - Container->SetPayload((uint32_t)Printable[0],(uint8_t*)CompressorName.c_str(),43); - Container->SetPayload((uint32_t)1, Printable ,42); -} - -void Box_avcC::SetDepth ( uint16_t Depth ) { - Container->SetPayload((uint32_t)2,Box::uint16_to_uint8( Depth ),74); -} - -void Box_avcC::SetReserved( ) { - Container->SetPayload((uint32_t)2,Box::uint16_to_uint8( (uint16_t)-1 ),76); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),36); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),20); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),16); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),12); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),8); - Container->SetPayload((uint32_t)4,Box::uint16_to_uint8(0),4); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0)); -} - -void Box_avcC::SetDefaults( ) { - SetWidth( ); - SetHeight( ); - SetDepth ( ); - SetFrameCount ( ); - SetResolution ( ); -} diff --git a/util/MP4/box_dinf.cpp b/util/MP4/box_dinf.cpp deleted file mode 100644 index d8d4d243..00000000 --- a/util/MP4/box_dinf.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include "box.cpp" -#include -#include - -class Box_dinf { - public: - Box_dinf(); - ~Box_dinf(); - Box * GetBox(); - void AddContent( Box * newcontent ); - void WriteContent( ); - private: - Box * Container; - - Box * Content; -};//Box_ftyp Class - -Box_dinf::Box_dinf( ) { - Container = new Box( 0x64696E66 ); -} - -Box_dinf::~Box_dinf() { - delete Container; -} - -Box * Box_dinf::GetBox() { - return Container; -} - -void Box_dinf::AddContent( Box * newcontent ) { - if(Content) { - delete Content; - Content = NULL; - } - Content = newcontent; -} - -void Box_dinf::WriteContent( ) { - Container->ResetPayload( ); - std::string serializedbox = ""; - serializedbox.append((char*)Content->GetBoxedData(),Content->GetBoxedDataSize()); - Container->SetPayload((uint32_t)serializedbox.size(),(uint8_t*)serializedbox.c_str()); -} diff --git a/util/MP4/box_dref.cpp b/util/MP4/box_dref.cpp deleted file mode 100644 index cc6a2f5a..00000000 --- a/util/MP4/box_dref.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include "box.cpp" -#include -#include - -class Box_dref { - public: - Box_dref(); - ~Box_dref(); - Box * GetBox(); - void AddContent( Box * newcontent, uint32_t offset = 0 ); - void WriteContent( ); - private: - Box * Container; - - void SetReserved( ); - std::vector Content; -};//Box_ftyp Class - -Box_dref::Box_dref( ) { - Container = new Box( 0x64726566 ); - SetReserved( ); -} - -Box_dref::~Box_dref() { - delete Container; -} - -Box * Box_dref::GetBox() { - return Container; -} - -void Box_dref::AddContent( Box * newcontent, uint32_t offset ) { - if( offset >= Content.size() ) { - Content.resize(offset+1); - } - if( Content[offset] ) { - delete Content[offset]; - } - Content[offset] = newcontent; -} - -void Box_dref::WriteContent( ) { - Container->ResetPayload( ); - Box * current; - std::string serializedbox = ""; - for( uint32_t i = 0; i < Content.size(); i++ ) { - current=Content[i]; - if( current ) { - serializedbox.append((char*)current->GetBoxedData(),current->GetBoxedDataSize()); - } - } - Container->SetPayload((uint32_t)serializedbox.size(),(uint8_t*)serializedbox.c_str(),4); - SetReserved( ); -} - -void Box_dref::SetReserved( ) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0)); -} diff --git a/util/MP4/box_esds.cpp b/util/MP4/box_esds.cpp deleted file mode 100644 index 7253f07d..00000000 --- a/util/MP4/box_esds.cpp +++ /dev/null @@ -1,55 +0,0 @@ -#include "box.cpp" -#include - -class Box_esds { - public: - Box_esds( ); - ~Box_esds(); - Box * GetBox(); - void SetDataReferenceIndex( uint16_t DataReferenceIndex = 1); - void SetChannelCount( uint16_t Count = 2 ); - void SetSampleSize( uint16_t Size = 16 ); - private: - Box * Container; - - void SetReserved( ); - void SetDefaults( ); -};//Box_ftyp Class - -Box_esds::Box_esds( ) { - Container = new Box( 0x65736473 ); - SetReserved(); - SetDefaults(); -} - -Box_esds::~Box_esds() { - delete Container; -} - -Box * Box_esds::GetBox() { - return Container; -} - -void Box_esds::SetDataReferenceIndex( uint16_t DataReferenceIndex ) { - Container->SetPayload((uint32_t)2,Box::uint16_to_uint8( DataReferenceIndex ),6); -} - -void Box_esds::SetChannelCount( uint16_t Count ) { - Container->SetPayload((uint32_t)2,Box::uint16_to_uint8( Count ),16); -} - -void Box_esds::SetSampleSize( uint16_t Size ) { - Container->SetPayload((uint32_t)2,Box::uint16_to_uint8( Size ),18); -} - -void Box_esds::SetReserved( ) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8( 0 ),20); - Container->SetPayload((uint32_t)2,Box::uint16_to_uint8( 0 ),4); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8( 0 )); -} - -void Box_esds::SetDefaults( ) { - SetSampleSize( ); - SetChannelCount( ); - SetDataReferenceIndex( ); -} diff --git a/util/MP4/box_ftyp.cpp b/util/MP4/box_ftyp.cpp deleted file mode 100644 index 97ba9c3a..00000000 --- a/util/MP4/box_ftyp.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "box.cpp" - -class Box_ftyp { - public: - Box_ftyp( ); - ~Box_ftyp(); - Box * GetBox(); - void SetMajorBrand( uint32_t MajorBrand = 0x66347620 ); - void SetMinorBrand( uint32_t MinorBrand = 0x1 ); - private: - void SetDefaults( ); - Box * Container; -};//Box_ftyp Class - -Box_ftyp::Box_ftyp( ) { - Container = new Box( 0x66747970 ); - SetDefaults( ); -} - -Box_ftyp::~Box_ftyp() { - delete Container; -} - -Box * Box_ftyp::GetBox() { - return Container; -} - -void Box_ftyp::SetMajorBrand( uint32_t MajorBrand ) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(MajorBrand)); -} - -void Box_ftyp::SetMinorBrand( uint32_t MinorBrand ) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(MinorBrand),4); -} - -void Box_ftyp::SetDefaults( ) { - SetMinorBrand( ); - SetMajorBrand( ); -} diff --git a/util/MP4/box_hdlr.cpp b/util/MP4/box_hdlr.cpp deleted file mode 100644 index 5926740c..00000000 --- a/util/MP4/box_hdlr.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include "box.cpp" -#include - -class Box_hdlr { - public: - Box_hdlr( ); - ~Box_hdlr(); - Box * GetBox(); - void SetHandlerType( uint32_t HandlerType = 0 ); - void SetName ( std::string Name = "" ); - private: - Box * Container; - void SetReserved( ); - void SetDefaults( ); - uint32_t CurrentHandlerType; -};//Box_ftyp Class - -Box_hdlr::Box_hdlr( ) { - Container = new Box( 0x68646C72 ); - CurrentHandlerType = 0; - SetReserved(); -} - -Box_hdlr::~Box_hdlr() { - delete Container; -} - -Box * Box_hdlr::GetBox() { - return Container; -} - -void Box_hdlr::SetReserved( ) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),20); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),16); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),12); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),4); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0)); -} - -void Box_hdlr::SetHandlerType( uint32_t HandlerType ) { - if( HandlerType != 0 ) { - CurrentHandlerType = HandlerType; - } - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(CurrentHandlerType),8); -} - -void Box_hdlr::SetName ( std::string Name ) { - char * tmp = new char[Name.size()+1]; - strcpy(tmp,Name.c_str()); - Container->ResetPayload(); - SetReserved(); - SetHandlerType(0); - Container->SetPayload((uint32_t)strlen(tmp)+1,(uint8_t*)tmp,24); -} - -void Box_hdlr::SetDefaults( ) { - SetName( ); - SetHandlerType( ); -} diff --git a/util/MP4/box_hmhd.cpp b/util/MP4/box_hmhd.cpp deleted file mode 100644 index 8733b822..00000000 --- a/util/MP4/box_hmhd.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include "box.cpp" - -class Box_hmhd { - public: - Box_hmhd( ); - ~Box_hmhd(); - Box * GetBox(); - void SetMaxPDUSize( uint16_t Size = 0 ); - void SetAvgPDUSize( uint16_t Size = 0 ); - void SetMaxBitRate( uint32_t Rate = 0 ); - void SetAvgBitRate( uint32_t Rate = 0 ); - private: - Box * Container; - void SetReserved( ); - void SetDefaults( ); -};//Box_ftyp Class - -Box_hmhd::Box_hmhd( ) { - Container = new Box( 0x686D6864 ); - SetDefaults(); - SetReserved(); -} - -Box_hmhd::~Box_hmhd() { - delete Container; -} - -Box * Box_hmhd::GetBox() { - return Container; -} - -void Box_hmhd::SetMaxPDUSize( uint16_t Size ) { - Container->SetPayload((uint32_t)2,Box::uint16_to_uint8(Size),4); -} - -void Box_hmhd::SetAvgPDUSize( uint16_t Size ) { - Container->SetPayload((uint32_t)2,Box::uint16_to_uint8(Size),6); -} - -void Box_hmhd::SetMaxBitRate( uint32_t Rate ) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Rate),8); -} - -void Box_hmhd::SetAvgBitRate( uint32_t Rate ) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Rate),12); -} - -void Box_hmhd::SetReserved( ) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),16); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0)); -} -void Box_hmhd::SetDefaults( ) { - SetAvgBitRate( ); - SetMaxBitRate( ); - SetAvgPDUSize( ); - SetMaxPDUSize( ); -} diff --git a/util/MP4/box_includes.h b/util/MP4/box_includes.h deleted file mode 100644 index 2b796702..00000000 --- a/util/MP4/box_includes.h +++ /dev/null @@ -1,37 +0,0 @@ -#include "box_abst.cpp" -#include "box_afra.cpp" -#include "box_afrt.cpp" -#include "box_amhp.cpp" -#include "box_asrt.cpp" -#include "box_avcC.cpp" -#include "box_dinf.cpp" -#include "box_dref.cpp" -#include "box_esds.cpp" -#include "box_ftyp.cpp" -#include "box_hdlr.cpp" -#include "box_hmhd.cpp" -#include "box_mdat.cpp" -#include "box_mdhd.cpp" -#include "box_mdia.cpp" -#include "box_mfhd.cpp" -#include "box_minf.cpp" -#include "box_moof.cpp" -#include "box_moov.cpp" -#include "box_mvex.cpp" -#include "box_mvhd.cpp" -#include "box_nmhd.cpp" -#include "box_rtmp.cpp" -#include "box_smhd.cpp" -#include "box_stbl.cpp" -#include "box_stco.cpp" -#include "box_stsc.cpp" -#include "box_stsd.cpp" -#include "box_stts.cpp" -#include "box_tfhd.cpp" -#include "box_tkhd.cpp" -#include "box_traf.cpp" -#include "box_trak.cpp" -#include "box_trex.cpp" -#include "box_trun.cpp" -#include "box_url.cpp" -#include "box_vmhd.cpp" diff --git a/util/MP4/box_mdat.cpp b/util/MP4/box_mdat.cpp deleted file mode 100644 index 258585aa..00000000 --- a/util/MP4/box_mdat.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "box.cpp" -#include -#include - -class Box_mdat { - public: - Box_mdat(); - ~Box_mdat(); - Box * GetBox(); - void SetContent( uint8_t * NewData, uint32_t DataLength , uint32_t offset = 0 ); - private: - Box * Container; -};//Box_ftyp Class - -Box_mdat::Box_mdat( ) { - Container = new Box( 0x6D646174 ); -} - -Box_mdat::~Box_mdat() { - delete Container; -} - -Box * Box_mdat::GetBox() { - return Container; -} - -void Box_mdat::SetContent( uint8_t * NewData, uint32_t DataLength , uint32_t Offset ) { - Container->SetPayload(DataLength,NewData,Offset); -} diff --git a/util/MP4/box_mdhd.cpp b/util/MP4/box_mdhd.cpp deleted file mode 100644 index ed143270..00000000 --- a/util/MP4/box_mdhd.cpp +++ /dev/null @@ -1,88 +0,0 @@ -#include "box.cpp" -#include - -#define SECONDS_DIFFERENCE 2082844800 - -class Box_mdhd { - public: - Box_mdhd( ); - ~Box_mdhd(); - Box * GetBox(); - void SetCreationTime( uint32_t TimeStamp = 0 ); - void SetModificationTime( uint32_t TimeStamp = 0 ); - void SetTimeScale( uint32_t TimeUnits = 0 ); - void SetDurationTime( uint32_t TimeUnits = 0 ); - void SetLanguage( uint8_t Firstchar = 'n', uint8_t Secondchar = 'l', uint8_t Thirdchar = 'd' ); - private: - void SetReserved(); - void SetDefaults(); - Box * Container; -};//Box_ftyp Class - -Box_mdhd::Box_mdhd( ) { - Container = new Box( 0x6D646864 ); -} - -Box_mdhd::~Box_mdhd() { - delete Container; -} - -Box * Box_mdhd::GetBox() { - return Container; -} - -void Box_mdhd::SetCreationTime( uint32_t TimeStamp ) { - uint32_t CreationTime; - if(!TimeStamp) { - CreationTime = time(NULL) + SECONDS_DIFFERENCE; - } else { - CreationTime = TimeStamp; - } - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(CreationTime),4); -} - -void Box_mdhd::SetModificationTime( uint32_t TimeStamp ) { - uint32_t ModificationTime; - if(!TimeStamp) { - ModificationTime = time(NULL) + SECONDS_DIFFERENCE; - } else { - ModificationTime = TimeStamp; - } - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(ModificationTime),8); -} - -void Box_mdhd::SetTimeScale( uint32_t TimeUnits ) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(TimeUnits),12); -} - -void Box_mdhd::SetDurationTime( uint32_t TimeUnits ) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(TimeUnits),16); -} - -void Box_mdhd::SetLanguage( uint8_t Firstchar, uint8_t Secondchar, uint8_t Thirdchar ) { - uint8_t FirstByte = 0; - uint8_t SecondByte = 0; - Firstchar -= 0x60; - Secondchar -= 0x60; - Thirdchar -= 0x60; - FirstByte += (Firstchar << 2); - FirstByte += (Secondchar >> 3); - SecondByte += (Secondchar << 5); - SecondByte += Thirdchar; - - Container->SetPayload((uint32_t)1,&SecondByte,21); - Container->SetPayload((uint32_t)1,&FirstByte,20); -} - -void Box_mdhd::SetReserved() { - Container->SetPayload((uint32_t)2,Box::uint16_to_uint8(0),22); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0)); -} - -void Box_mdhd::SetDefaults() { - SetLanguage(); - SetDurationTime(); - SetTimeScale(); - SetModificationTime(); - SetCreationTime(); -} diff --git a/util/MP4/box_mdia.cpp b/util/MP4/box_mdia.cpp deleted file mode 100644 index 553137a7..00000000 --- a/util/MP4/box_mdia.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include "box.cpp" -#include -#include - -class Box_mdia { - public: - Box_mdia(); - ~Box_mdia(); - Box * GetBox(); - void AddContent( Box * newcontent, uint32_t offset = 0 ); - void WriteContent( ); - private: - Box * Container; - - std::vector Content; -};//Box_ftyp Class - -Box_mdia::Box_mdia( ) { - Container = new Box( 0x6D646961 ); -} - -Box_mdia::~Box_mdia() { - delete Container; -} - -Box * Box_mdia::GetBox() { - return Container; -} - -void Box_mdia::AddContent( Box * newcontent, uint32_t offset ) { - if( offset >= Content.size() ) { - Content.resize(offset+1); - } - if( Content[offset] ) { - delete Content[offset]; - } - Content[offset] = newcontent; -} - -void Box_mdia::WriteContent( ) { - Container->ResetPayload( ); - Box * current; - std::string serializedbox = ""; - for( uint32_t i = 0; i < Content.size(); i++ ) { - current=Content[i]; - if( current ) { - serializedbox.append((char*)current->GetBoxedData(),current->GetBoxedDataSize()); - } - } - Container->SetPayload((uint32_t)serializedbox.size(),(uint8_t*)serializedbox.c_str()); -} diff --git a/util/MP4/box_mfhd.cpp b/util/MP4/box_mfhd.cpp deleted file mode 100644 index 2680ab0a..00000000 --- a/util/MP4/box_mfhd.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "box.cpp" - -class Box_mfhd { - public: - Box_mfhd( ); - ~Box_mfhd(); - Box * GetBox(); - void SetSequenceNumber( uint32_t SequenceNumber = 1 ); - private: - void SetDefaults( ); - void SetReserved( ); - Box * Container; -};//Box_ftyp Class - -Box_mfhd::Box_mfhd( ) { - Container = new Box( 0x6D666864 ); - SetDefaults( ); - SetReserved( ); -} - -Box_mfhd::~Box_mfhd() { - delete Container; -} - -Box * Box_mfhd::GetBox() { - return Container; -} - -void Box_mfhd::SetDefaults( ) { - SetSequenceNumber( ); -} - -void Box_mfhd::SetReserved( ) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0)); -} - -void Box_mfhd::SetSequenceNumber( uint32_t SequenceNumber ) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(SequenceNumber),4); -} diff --git a/util/MP4/box_minf.cpp b/util/MP4/box_minf.cpp deleted file mode 100644 index ebde6c56..00000000 --- a/util/MP4/box_minf.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include "box.cpp" -#include -#include - -class Box_minf { - public: - Box_minf(); - ~Box_minf(); - Box * GetBox(); - void AddContent( Box * newcontent, uint32_t offset = 0 ); - void WriteContent( ); - private: - Box * Container; - - std::vector Content; -};//Box_ftyp Class - -Box_minf::Box_minf( ) { - Container = new Box( 0x6D696E66 ); -} - -Box_minf::~Box_minf() { - delete Container; -} - -Box * Box_minf::GetBox() { - return Container; -} - -void Box_minf::AddContent( Box * newcontent, uint32_t offset ) { - if( offset >= Content.size() ) { - Content.resize(offset+1); - } - if( Content[offset] ) { - delete Content[offset]; - } - Content[offset] = newcontent; -} - -void Box_minf::WriteContent( ) { - Container->ResetPayload( ); - Box * current; - std::string serializedbox = ""; - for( uint32_t i = 0; i < Content.size(); i++ ) { - current=Content[i]; - if( current ) { - serializedbox.append((char*)current->GetBoxedData(),current->GetBoxedDataSize()); - } - } - Container->SetPayload((uint32_t)serializedbox.size(),(uint8_t*)serializedbox.c_str()); -} diff --git a/util/MP4/box_moof.cpp b/util/MP4/box_moof.cpp deleted file mode 100644 index 1b18a9e5..00000000 --- a/util/MP4/box_moof.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include "box.cpp" -#include -#include - -class Box_moof { - public: - Box_moof(); - ~Box_moof(); - Box * GetBox(); - void AddContent( Box * newcontent, uint32_t offset = 0 ); - void WriteContent( ); - private: - Box * Container; - - std::vector Content; -};//Box_ftyp Class - -Box_moof::Box_moof( ) { - Container = new Box( 0x6D6F6F66 ); -} - -Box_moof::~Box_moof() { - delete Container; -} - -Box * Box_moof::GetBox() { - return Container; -} - -void Box_moof::AddContent( Box * newcontent, uint32_t offset ) { - if( offset >= Content.size() ) { - Content.resize(offset+1); - } - if( Content[offset] ) { - delete Content[offset]; - } - Content[offset] = newcontent; -} - -void Box_moof::WriteContent( ) { - Container->ResetPayload( ); - Box * current; - std::string serializedbox = ""; - for( uint32_t i = 0; i < Content.size(); i++ ) { - current=Content[i]; - if( current ) { - serializedbox.append((char*)current->GetBoxedData(),current->GetBoxedDataSize()); - } - } - Container->SetPayload((uint32_t)serializedbox.size(),(uint8_t*)serializedbox.c_str()); -} diff --git a/util/MP4/box_moov.cpp b/util/MP4/box_moov.cpp deleted file mode 100644 index 84542977..00000000 --- a/util/MP4/box_moov.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include "box.cpp" -#include -#include - -class Box_moov { - public: - Box_moov(); - ~Box_moov(); - Box * GetBox(); - void AddContent( Box * newcontent, uint32_t offset = 0 ); - void WriteContent( ); - private: - Box * Container; - - std::vector Content; -};//Box_ftyp Class - -Box_moov::Box_moov( ) { - Container = new Box( 0x6D6F6F76 ); -} - -Box_moov::~Box_moov() { - delete Container; -} - -Box * Box_moov::GetBox() { - return Container; -} - -void Box_moov::AddContent( Box * newcontent, uint32_t offset ) { - if( offset >= Content.size() ) { - Content.resize(offset+1); - } - if( Content[offset] ) { - delete Content[offset]; - } - Content[offset] = newcontent; -} - -void Box_moov::WriteContent( ) { - Container->ResetPayload( ); - Box * current; - std::string serializedbox = ""; - for( uint32_t i = 0; i < Content.size(); i++ ) { - current=Content[i]; - if( current ) { - serializedbox.append((char*)current->GetBoxedData(),current->GetBoxedDataSize()); - } - } - Container->SetPayload((uint32_t)serializedbox.size(),(uint8_t*)serializedbox.c_str()); -} diff --git a/util/MP4/box_mvex.cpp b/util/MP4/box_mvex.cpp deleted file mode 100644 index 8d6725ac..00000000 --- a/util/MP4/box_mvex.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include "box.cpp" -#include -#include - -class Box_mvex { - public: - Box_mvex(); - ~Box_mvex(); - Box * GetBox(); - void AddContent( Box * newcontent, uint32_t offset = 0 ); - void WriteContent( ); - private: - Box * Container; - - std::vector Content; -};//Box_ftyp Class - -Box_mvex::Box_mvex( ) { - Container = new Box( 0x6D866578 ); -} - -Box_mvex::~Box_mvex() { - delete Container; -} - -Box * Box_mvex::GetBox() { - return Container; -} - -void Box_mvex::AddContent( Box * newcontent, uint32_t offset ) { - if( offset >= Content.size() ) { - Content.resize(offset+1); - } - if( Content[offset] ) { - delete Content[offset]; - } - Content[offset] = newcontent; -} - -void Box_mvex::WriteContent( ) { - Container->ResetPayload( ); - Box * current; - std::string serializedbox = ""; - for( uint32_t i = 0; i < Content.size(); i++ ) { - current=Content[i]; - if( current ) { - serializedbox.append((char*)current->GetBoxedData(),current->GetBoxedDataSize()); - } - } - Container->SetPayload((uint32_t)serializedbox.size(),(uint8_t*)serializedbox.c_str()); -} diff --git a/util/MP4/box_mvhd.cpp b/util/MP4/box_mvhd.cpp deleted file mode 100644 index 8055abe5..00000000 --- a/util/MP4/box_mvhd.cpp +++ /dev/null @@ -1,113 +0,0 @@ -#include "box.cpp" -#include - -#define SECONDS_DIFFERENCE 2082844800 - -class Box_mvhd { - public: - Box_mvhd( ); - ~Box_mvhd(); - Box * GetBox(); - void SetCreationTime( uint32_t TimeStamp = 0 ); - void SetModificationTime( uint32_t TimeStamp = 0 ); - void SetTimeScale( uint32_t TimeUnits = 1 ); - void SetDurationTime( uint32_t TimeUnits = 0 ); - void SetRate( uint32_t Rate = 0x00010000 ); - void SetVolume( uint16_t Volume = 0x0100 ); - void SetNextTrackID( uint32_t TrackID = 0xFFFFFFFF ); - private: - void SetReserved(); - void SetDefaults(); - Box * Container; - -};//Box_ftyp Class - -Box_mvhd::Box_mvhd( ) { - Container = new Box( 0x6D766864 ); - SetDefaults(); - SetReserved(); -} - -Box_mvhd::~Box_mvhd() { - delete Container; -} - -Box * Box_mvhd::GetBox() { - return Container; -} - -void Box_mvhd::SetCreationTime( uint32_t TimeStamp ) { - uint32_t CreationTime; - if(!TimeStamp) { - CreationTime = time(NULL) + SECONDS_DIFFERENCE; - } else { - CreationTime = TimeStamp; - } - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(CreationTime),4); -} - -void Box_mvhd::SetModificationTime( uint32_t TimeStamp ) { - uint32_t ModificationTime; - if(!TimeStamp) { - ModificationTime = time(NULL) + SECONDS_DIFFERENCE; - } else { - ModificationTime = TimeStamp; - } - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(ModificationTime),8); -} - -void Box_mvhd::SetTimeScale( uint32_t TimeUnits ) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(TimeUnits),12); -} - -void Box_mvhd::SetDurationTime( uint32_t TimeUnits ) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(TimeUnits),16); -} - -void Box_mvhd::SetRate( uint32_t Rate ) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Rate),20); -} - -void Box_mvhd::SetVolume( uint16_t Volume ) { - Container->SetPayload((uint32_t)4,Box::uint16_to_uint8(Volume),24); -} - -void Box_mvhd::SetNextTrackID( uint32_t TrackID ) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(TrackID),92); -} - -void Box_mvhd::SetReserved() { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),88); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),84); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),80); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),76); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),72); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),68); - - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0x40000000),64); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),60); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),56); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),52); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0x00010000),48); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),44); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),40); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),36); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0x00010000),32); - - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),28); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),24); - Container->SetPayload((uint32_t)4,Box::uint16_to_uint8(0),22); - - Container->SetPayload((uint32_t)4,Box::uint16_to_uint8(0)); -} - -void Box_mvhd::SetDefaults() { - SetCreationTime(); - SetModificationTime(); - SetDurationTime(); - SetNextTrackID(); - SetRate(); - SetVolume(); - SetTimeScale(); -} - diff --git a/util/MP4/box_nmhd.cpp b/util/MP4/box_nmhd.cpp deleted file mode 100644 index d874d1ed..00000000 --- a/util/MP4/box_nmhd.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "box.cpp" - -class Box_nmhd { - public: - Box_nmhd( ); - ~Box_nmhd(); - Box * GetBox(); - private: - Box * Container; - void SetReserved( ); -};//Box_ftyp Class - -Box_nmhd::Box_nmhd( ) { - Container = new Box( 0x6E6D6864 ); - SetReserved(); -} - -Box_nmhd::~Box_nmhd() { - delete Container; -} - -Box * Box_nmhd::GetBox() { - return Container; -} - -void Box_nmhd::SetReserved( ) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0)); -} diff --git a/util/MP4/box_rtmp.cpp b/util/MP4/box_rtmp.cpp deleted file mode 100644 index 980c7ef3..00000000 --- a/util/MP4/box_rtmp.cpp +++ /dev/null @@ -1,89 +0,0 @@ -#include "box.cpp" -#include - -class Box_rtmp { - public: - Box_rtmp( ); - ~Box_rtmp(); - Box * GetBox(); - void SetDataReferenceIndex( uint16_t NewIndex = 0 ); - void SetHintTrackVersion( uint16_t NewVersion = 1 ); - void SetHighestCompatibleVersion( uint16_t NewVersion = 1 ); - void SetMaxPacketSize( uint16_t NewSize = 0xFFFF ); - void AddContent( Box * newcontent ); - void WriteContent( ); - private: - void SetReserved( ); - void SetDefaults( ); - uint16_t CurrentReferenceIndex; - uint16_t CurrentHintTrackVersion; - uint16_t CurrentHighestCompatibleVersion; - uint16_t CurrentMaxPacketSize; - - Box * Container; - Box * Content; -};//Box_ftyp Class - -Box_rtmp::Box_rtmp( ) { - Container = new Box( 0x72746D70 ); - SetReserved(); - SetDefaults(); -} - -Box_rtmp::~Box_rtmp() { - delete Container; -} - -Box * Box_rtmp::GetBox() { - return Container; -} - -void Box_rtmp::SetReserved( ) { - Container->SetPayload((uint32_t)2,Box::uint16_to_uint8(CurrentMaxPacketSize),12); - Container->SetPayload((uint32_t)2,Box::uint16_to_uint8(CurrentHighestCompatibleVersion),10); - Container->SetPayload((uint32_t)2,Box::uint16_to_uint8(CurrentHintTrackVersion),8); - Container->SetPayload((uint32_t)2,Box::uint16_to_uint8(CurrentReferenceIndex),6); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),2); - Container->SetPayload((uint32_t)2,Box::uint16_to_uint8(0)); -} - -void Box_rtmp::SetDefaults( ) { - SetDataReferenceIndex( ); - SetHintTrackVersion( ); - SetHighestCompatibleVersion( ); - SetMaxPacketSize( ); -} - -void Box_rtmp::SetDataReferenceIndex( uint16_t NewIndex ) { - CurrentReferenceIndex = NewIndex; - Container->SetPayload((uint32_t)2,Box::uint16_to_uint8(NewIndex),6); -} -void Box_rtmp::SetHintTrackVersion( uint16_t NewVersion ) { - CurrentHintTrackVersion = NewVersion; - Container->SetPayload((uint32_t)2,Box::uint16_to_uint8(NewVersion),8); -} -void Box_rtmp::SetHighestCompatibleVersion( uint16_t NewVersion ) { - CurrentHighestCompatibleVersion = NewVersion; - Container->SetPayload((uint32_t)2,Box::uint16_to_uint8(NewVersion),10); -} - -void Box_rtmp::SetMaxPacketSize( uint16_t NewSize ) { - CurrentMaxPacketSize = NewSize; - Container->SetPayload((uint32_t)2,Box::uint16_to_uint8(NewSize),12); -} - -void Box_rtmp::AddContent( Box * newcontent ) { - if(Content) { - delete Content; - Content = NULL; - } - Content = newcontent; -} - -void Box_rtmp::WriteContent( ) { - Container->ResetPayload( ); - SetReserved( ); - std::string serializedbox = ""; - serializedbox.append((char*)Content->GetBoxedData(),Content->GetBoxedDataSize()); - Container->SetPayload((uint32_t)serializedbox.size(),(uint8_t*)serializedbox.c_str(),14); -} diff --git a/util/MP4/box_smhd.cpp b/util/MP4/box_smhd.cpp deleted file mode 100644 index 6b6f9d9f..00000000 --- a/util/MP4/box_smhd.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "box.cpp" - -class Box_smhd { - public: - Box_smhd( ); - ~Box_smhd(); - Box * GetBox(); - private: - Box * Container; - void SetReserved( ); -};//Box_ftyp Class - -Box_smhd::Box_smhd( ) { - Container = new Box( 0x736D6864 ); - SetReserved(); -} - -Box_smhd::~Box_smhd() { - delete Container; -} - -Box * Box_smhd::GetBox() { - return Container; -} - -void Box_smhd::SetReserved( ) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),4); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0)); -} diff --git a/util/MP4/box_stbl.cpp b/util/MP4/box_stbl.cpp deleted file mode 100644 index 44a8d129..00000000 --- a/util/MP4/box_stbl.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include "box.cpp" -#include -#include - -class Box_stbl { - public: - Box_stbl(); - ~Box_stbl(); - Box * GetBox(); - void AddContent( Box * newcontent, uint32_t offset = 0 ); - void WriteContent( ); - private: - Box * Container; - - std::vector Content; -};//Box_ftyp Class - -Box_stbl::Box_stbl( ) { - Container = new Box( 0x7374626C ); -} - -Box_stbl::~Box_stbl() { - delete Container; -} - -Box * Box_stbl::GetBox() { - return Container; -} - -void Box_stbl::AddContent( Box * newcontent, uint32_t offset ) { - if( offset >= Content.size() ) { - Content.resize(offset+1); - } - if( Content[offset] ) { - delete Content[offset]; - } - Content[offset] = newcontent; -} - -void Box_stbl::WriteContent( ) { - Container->ResetPayload( ); - Box * current; - std::string serializedbox = ""; - for( uint32_t i = 0; i < Content.size(); i++ ) { - current=Content[i]; - if( current ) { - serializedbox.append((char*)current->GetBoxedData(),current->GetBoxedDataSize()); - } - } - Container->SetPayload((uint32_t)serializedbox.size(),(uint8_t*)serializedbox.c_str()); -} diff --git a/util/MP4/box_stco.cpp b/util/MP4/box_stco.cpp deleted file mode 100644 index 434cede8..00000000 --- a/util/MP4/box_stco.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include "box.cpp" -#include -#include - -class Box_stco { - public: - Box_stco( ); - ~Box_stco(); - Box * GetBox(); - void AddOffset( uint32_t DataOffset, uint32_t Offset = 0 ); - void SetOffsets( std::vector NewOffsets ); - void WriteContent( ); - private: - Box * Container; - - void SetReserved( ); - std::vector Offsets; -};//Box_ftyp Class - -Box_stco::Box_stco( ) { - Container = new Box( 0x7374636F ); - SetReserved(); -} - -Box_stco::~Box_stco() { - delete Container; -} - -Box * Box_stco::GetBox() { - return Container; -} - -void Box_stco::SetReserved( ) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0)); -} - -void Box_stco::AddOffset( uint32_t DataOffset, uint32_t Offset ) { - if(Offset >= Offsets.size()) { - Offsets.resize(Offset+1); - } - Offsets[Offset] = DataOffset; -} - - -void Box_stco::WriteContent( ) { - Container->ResetPayload(); - SetReserved( ); - if(!Offsets.empty()) { - for(int32_t i = Offsets.size() -1; i >= 0; i--) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Offsets[i]),(i*4)+8); - } - } - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Offsets.size()),4); -} - -void Box_stco::SetOffsets( std::vector NewOffsets ) { - Offsets = NewOffsets; -} diff --git a/util/MP4/box_stsc.cpp b/util/MP4/box_stsc.cpp deleted file mode 100644 index ea8edd33..00000000 --- a/util/MP4/box_stsc.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include "box.cpp" -#include -#include - -struct stsc_record { - uint32_t FirstChunk; - uint32_t SamplesPerChunk; - uint32_t SampleDescIndex; -};//stsc_record - -class Box_stsc { - public: - Box_stsc( ); - ~Box_stsc(); - Box * GetBox(); - void SetReserved( ); - void AddEntry( uint32_t FirstChunk = 0, uint32_t SamplesPerChunk = 0, uint32_t SampleDescIndex = 0, uint32_t Offset = 0 ); - void WriteContent( ); - private: - Box * Container; - - std::vector Entries; -};//Box_ftyp Class - -Box_stsc::Box_stsc( ) { - Container = new Box( 0x73747363 ); - SetReserved(); -} - -Box_stsc::~Box_stsc() { - delete Container; -} - -Box * Box_stsc::GetBox() { - return Container; -} - -void Box_stsc::SetReserved( ) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0)); -} - -void Box_stsc::AddEntry( uint32_t FirstChunk, uint32_t SamplesPerChunk, uint32_t SampleDescIndex, uint32_t Offset ) { - if(Offset >= Entries.size()) { - Entries.resize(Offset+1); - } - Entries[Offset].FirstChunk = FirstChunk; - Entries[Offset].SamplesPerChunk = SamplesPerChunk; - Entries[Offset].SampleDescIndex = SampleDescIndex; -} - - -void Box_stsc::WriteContent( ) { - Container->ResetPayload(); - SetReserved( ); - if(!Entries.empty()) { - for(int32_t i = Entries.size() -1; i >= 0; i--) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Entries[i].SampleDescIndex),(i*12)+16); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Entries[i].SamplesPerChunk),(i*12)+12); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Entries[i].FirstChunk),(i*12)+8); - } - } - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Entries.size()),4); -} diff --git a/util/MP4/box_stsd.cpp b/util/MP4/box_stsd.cpp deleted file mode 100644 index 233fa584..00000000 --- a/util/MP4/box_stsd.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include "box.cpp" -#include -#include - -class Box_stsd { - public: - Box_stsd( ); - ~Box_stsd(); - Box * GetBox(); - void AddContent( Box * newcontent, uint32_t offset = 0 ); - void WriteContent(); - private: - Box * Container; - - void SetReserved(); - std::vector Content; -};//Box_ftyp Class - -Box_stsd::Box_stsd( ) { - Container = new Box( 0x73747364 ); - SetReserved(); -} - -Box_stsd::~Box_stsd() { - delete Container; -} - -Box * Box_stsd::GetBox() { - return Container; -} - -void Box_stsd::AddContent( Box * newcontent, uint32_t offset ) { - if( offset >= Content.size() ) { - Content.resize(offset+1); - } - if( Content[offset] ) { - delete Content[offset]; - } - Content[offset] = newcontent; -} - -void Box_stsd::SetReserved( ) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8( 1 ),4); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8( 0 ),0); -} - -void Box_stsd::WriteContent( ) { - Container->ResetPayload( ); - SetReserved( ); - Box * current; - std::string serializedbox = ""; - for( uint32_t i = 0; i < Content.size(); i++ ) { - current=Content[i]; - if( current ) { - serializedbox.append((char*)current->GetBoxedData(),current->GetBoxedDataSize()); - } - } - Container->SetPayload((uint32_t)serializedbox.size(),(uint8_t*)serializedbox.c_str(),8); -} diff --git a/util/MP4/box_stts.cpp b/util/MP4/box_stts.cpp deleted file mode 100644 index e16c42c0..00000000 --- a/util/MP4/box_stts.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include "box.cpp" -#include -#include - -struct stts_record { - uint32_t SampleCount; - uint32_t SampleDelta; -};//stsc_record - -class Box_stts { - public: - Box_stts( ); - ~Box_stts(); - Box * GetBox(); - void SetReserved( ); - void AddEntry( uint32_t SampleCount, uint32_t SampleDelta, uint32_t Offset = 0 ); - void WriteContent( ); - private: - Box * Container; - - std::vector Entries; -};//Box_ftyp Class - -Box_stts::Box_stts( ) { - Container = new Box( 0x73747473 ); - SetReserved(); -} - -Box_stts::~Box_stts() { - delete Container; -} - -Box * Box_stts::GetBox() { - return Container; -} - -void Box_stts::SetReserved( ) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0)); -} - -void Box_stts::AddEntry( uint32_t SampleCount, uint32_t SampleDelta, uint32_t Offset ) { - if(Offset >= Entries.size()) { - Entries.resize(Offset+1); - } - Entries[Offset].SampleCount = SampleCount; - Entries[Offset].SampleDelta = SampleDelta; -} - - -void Box_stts::WriteContent( ) { - Container->ResetPayload(); - SetReserved( ); - if(!Entries.empty()) { - for(int32_t i = Entries.size() -1; i >= 0; i--) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Entries[i].SampleDelta),(i*8)+12); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Entries[i].SampleCount),(i*8)+8); - } - } - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Entries.size()),4); -} diff --git a/util/MP4/box_tfhd.cpp b/util/MP4/box_tfhd.cpp deleted file mode 100644 index 57ed10dc..00000000 --- a/util/MP4/box_tfhd.cpp +++ /dev/null @@ -1,88 +0,0 @@ -#include "box.cpp" - -class Box_tfhd { - public: - Box_tfhd( ); - ~Box_tfhd(); - Box * GetBox(); - void SetTrackID( uint32_t TrackID = 0 ); - void SetBaseDataOffset( uint32_t Offset = 0 );//write as uint64_t - void SetSampleDescriptionIndex( uint32_t Index = 0 ); - void SetDefaultSampleDuration( uint32_t Duration = 0 ); - void SetDefaultSampleSize( uint32_t Size = 0 ); - void WriteContent( ); - private: - void SetDefaults( ); - uint32_t curTrackID; - uint32_t curBaseDataOffset; - uint32_t curSampleDescriptionIndex; - uint32_t curDefaultSampleDuration; - uint32_t curDefaultSampleSize; - Box * Container; -};//Box_ftyp Class - -Box_tfhd::Box_tfhd( ) { - Container = new Box( 0x74666864 ); - SetDefaults( ); -} - -Box_tfhd::~Box_tfhd() { - delete Container; -} - -Box * Box_tfhd::GetBox() { - return Container; -} - -void Box_tfhd::SetTrackID( uint32_t TrackID ) { - curTrackID = TrackID; -} - -void Box_tfhd::SetBaseDataOffset( uint32_t Offset ) { - curBaseDataOffset = Offset; -} - -void Box_tfhd::SetSampleDescriptionIndex( uint32_t Index ) { - curSampleDescriptionIndex = Index; -} - -void Box_tfhd::SetDefaultSampleDuration( uint32_t Duration ) { - curDefaultSampleDuration = Duration; -} - -void Box_tfhd::SetDefaultSampleSize( uint32_t Size ) { - curDefaultSampleSize = Size; -} - -void Box_tfhd::WriteContent( ) { - uint32_t curoffset; - uint32_t flags = 0 & ( curBaseDataOffset ? 0x1 : 0 ) & ( curSampleDescriptionIndex ? 0x2 : 0 ) & ( curDefaultSampleDuration ? 0x8 : 0 ) & ( curDefaultSampleSize ? 0x10 : 0 ); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(flags)); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(curTrackID),4); - curoffset = 8; - if( curBaseDataOffset ) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),curoffset); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(curBaseDataOffset),curoffset+4); - curoffset += 8; - } - if( curSampleDescriptionIndex ) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(curSampleDescriptionIndex),curoffset); - curoffset += 8; - } - if( curDefaultSampleDuration ) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(curDefaultSampleDuration),curoffset); - curoffset += 8; - } - if( curDefaultSampleSize ) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(curDefaultSampleSize),curoffset); - curoffset += 8; - } -} - -void Box_tfhd::SetDefaults( ) { - SetTrackID( ); - SetBaseDataOffset( ); - SetSampleDescriptionIndex( ); - SetDefaultSampleDuration( ); - SetDefaultSampleSize( ); -} diff --git a/util/MP4/box_tkhd.cpp b/util/MP4/box_tkhd.cpp deleted file mode 100644 index c8f5c1e7..00000000 --- a/util/MP4/box_tkhd.cpp +++ /dev/null @@ -1,117 +0,0 @@ -#include "box.cpp" -#include - -#define SECONDS_DIFFERENCE 2082844800 - -class Box_tkhd { - public: - Box_tkhd( ); - ~Box_tkhd(); - Box * GetBox(); - void SetCreationTime( uint32_t TimeStamp = 0 ); - void SetModificationTime( uint32_t TimeStamp = 0 ); - void SetDurationTime( uint32_t TimeUnits = 0 ); - void SetWidth( uint16_t Width = 0 ); - void SetHeight( uint16_t Height = 0 ); - void SetFlags( bool Bit0 = true, bool Bit1 = true, bool Bit2 = true ); - void SetVersion( uint32_t Version = 0 ); - void SetTrackID( uint32_t TrackID = 0 ); - private: - void SetReserved(); - void SetDefaults(); - Box * Container; - - uint32_t CurrentFlags; - uint32_t CurrentVersion; -};//Box_ftyp Class - -Box_tkhd::Box_tkhd( ) { - Container = new Box( 0x746B6864 ); - CurrentVersion = 0; - CurrentFlags = 0; -} - -Box_tkhd::~Box_tkhd() { - delete Container; -} - -Box * Box_tkhd::GetBox() { - return Container; -} - -void Box_tkhd::SetCreationTime( uint32_t TimeStamp ) { - uint32_t CreationTime; - if(!TimeStamp) { - CreationTime = time(NULL) + SECONDS_DIFFERENCE; - } else { - CreationTime = TimeStamp; - } - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(CreationTime),4); -} - -void Box_tkhd::SetModificationTime( uint32_t TimeStamp ) { - uint32_t ModificationTime; - if(!TimeStamp) { - ModificationTime = time(NULL) + SECONDS_DIFFERENCE; - } else { - ModificationTime = TimeStamp; - } - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(ModificationTime),8); -} - -void Box_tkhd::SetDurationTime( uint32_t TimeUnits ) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(TimeUnits),16); -} - -void Box_tkhd::SetReserved() { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0x40000000),68); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),64); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),60); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),56); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0x10000),52); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),48); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),44); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),40); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0x10000),36); - Container->SetPayload((uint32_t)4,Box::uint16_to_uint8(0),34); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),28); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),24); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),20); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0),12); -} - -void Box_tkhd::SetVersion( uint32_t Version ) { - if ( Version >= 2 ) { return; } - CurrentVersion = Version; - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8((CurrentVersion<<24)&(CurrentFlags))); -} - -void Box_tkhd::SetFlags( bool Bit0, bool Bit1, bool Bit2 ) { - CurrentFlags = (( Bit0 ? 0x80 : 0 ) + ( Bit1 ? 0x40 : 0 ) + ( Bit2 ? 0x20 : 0 )) << 16 ; - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8((CurrentVersion<<24)&(CurrentFlags))); -} - -void Box_tkhd::SetTrackID( uint32_t TrackID ) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(TrackID),12); -} - -void Box_tkhd::SetWidth( uint16_t Width ) { - uint32_t ResultWidth = ( Width << 16 ); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(ResultWidth),72); -} - -void Box_tkhd::SetHeight( uint16_t Height ) { - uint32_t ResultHeight = ( Height << 16 ); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(ResultHeight),76); -} - -void Box_tkhd::SetDefaults() { - SetHeight(); - SetWidth(); - SetCreationTime(); - SetModificationTime(); - SetDurationTime(); - SetFlags(); - SetVersion(); - SetTrackID(); -} diff --git a/util/MP4/box_traf.cpp b/util/MP4/box_traf.cpp deleted file mode 100644 index fb794578..00000000 --- a/util/MP4/box_traf.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include "box.cpp" -#include -#include - -class Box_traf { - public: - Box_traf(); - ~Box_traf(); - Box * GetBox(); - void AddContent( Box * newcontent, uint32_t offset = 0 ); - void WriteContent( ); - private: - Box * Container; - - std::vector Content; -};//Box_ftyp Class - -Box_traf::Box_traf( ) { - Container = new Box( 0x74726166 ); -} - -Box_traf::~Box_traf() { - delete Container; -} - -Box * Box_traf::GetBox() { - return Container; -} - -void Box_traf::AddContent( Box * newcontent, uint32_t offset ) { - if( offset >= Content.size() ) { - Content.resize(offset+1); - } - if( Content[offset] ) { - delete Content[offset]; - } - Content[offset] = newcontent; -} - -void Box_traf::WriteContent( ) { - Container->ResetPayload( ); - Box * current; - std::string serializedbox = ""; - for( uint32_t i = 0; i < Content.size(); i++ ) { - current=Content[i]; - if( current ) { - serializedbox.append((char*)current->GetBoxedData(),current->GetBoxedDataSize()); - } - } - Container->SetPayload((uint32_t)serializedbox.size(),(uint8_t*)serializedbox.c_str()); -} diff --git a/util/MP4/box_trak.cpp b/util/MP4/box_trak.cpp deleted file mode 100644 index b33bb5bd..00000000 --- a/util/MP4/box_trak.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include "box.cpp" -#include -#include - -class Box_trak { - public: - Box_trak(); - ~Box_trak(); - Box * GetBox(); - void AddContent( Box * newcontent, uint32_t offset = 0 ); - void WriteContent( ); - private: - Box * Container; - - std::vector Content; -};//Box_ftyp Class - -Box_trak::Box_trak( ) { - Container = new Box( 0x7472616B ); -} - -Box_trak::~Box_trak() { - delete Container; -} - -Box * Box_trak::GetBox() { - return Container; -} - -void Box_trak::AddContent( Box * newcontent, uint32_t offset ) { - if( offset >= Content.size() ) { - Content.resize(offset+1); - } - if( Content[offset] ) { - delete Content[offset]; - } - Content[offset] = newcontent; -} - -void Box_trak::WriteContent( ) { - Container->ResetPayload( ); - Box * current; - std::string serializedbox = ""; - for( uint32_t i = 0; i < Content.size(); i++ ) { - current=Content[i]; - if( current ) { - serializedbox.append((char*)current->GetBoxedData(),current->GetBoxedDataSize()); - } - } - Container->SetPayload((uint32_t)serializedbox.size(),(uint8_t*)serializedbox.c_str()); -} diff --git a/util/MP4/box_trex.cpp b/util/MP4/box_trex.cpp deleted file mode 100644 index 16369795..00000000 --- a/util/MP4/box_trex.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include "box.cpp" - -class Box_trex { - public: - Box_trex( ); - ~Box_trex(); - Box * GetBox(); - void SetTrackID( uint32_t Id = 0 ); - void SetSampleDescriptionIndex( uint32_t Index = 0 ); - void SetSampleDuration( uint32_t Duration = 0 ); - void SetSampleSize( uint32_t Size = 0 ); - private: - void SetReserved( ); - void SetDefaults( ); - Box * Container; -};//Box_ftyp Class - -Box_trex::Box_trex( ) { - Container = new Box( 0x74726578 ); - SetReserved( ); - SetDefaults( ); -} - -Box_trex::~Box_trex() { - delete Container; -} - -Box * Box_trex::GetBox() { - return Container; -} - -void Box_trex::SetDefaults( ) { - SetTrackID( ); - SetSampleDescriptionIndex( ); - SetSampleDuration( ); - SetSampleSize( ); -} - -void Box_trex::SetReserved( ) { - Container->SetPayload((uint32_t)2,Box::uint16_to_uint8(1),22); - Container->SetPayload((uint32_t)2,Box::uint16_to_uint8(0),20); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(0)); -} - -void Box_trex::SetTrackID( uint32_t Id ) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Id),4); -} - -void Box_trex::SetSampleDescriptionIndex( uint32_t Index ) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Index),8); -} - -void Box_trex::SetSampleDuration( uint32_t Duration ) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Duration),12); -} - -void Box_trex::SetSampleSize( uint32_t Size ) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(Size),16); -} diff --git a/util/MP4/box_trun.cpp b/util/MP4/box_trun.cpp deleted file mode 100644 index 1010f2da..00000000 --- a/util/MP4/box_trun.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include "box.cpp" -#include - -struct trun_sampleinformationstructure { - uint32_t SampleDuration; - uint32_t SampleSize; -}; - -class Box_trun { - public: - Box_trun( ); - ~Box_trun(); - Box * GetBox(); - void SetDataOffset( uint32_t Offset = 0 ); - void AddSampleInformation( uint32_t SampleDuration = 0, uint32_t SampleSize = 0, uint32_t Offset = 0 ); - void WriteContent( ); - private: - void SetDefaults( ); - bool setSampleDuration; - bool setSampleSize; - uint32_t curDataOffset; - std::vector SampleInfo; - Box * Container; -};//Box_ftyp Class - -Box_trun::Box_trun( ) { - Container = new Box( 0x74666864 ); - SetDefaults( ); -} - -Box_trun::~Box_trun() { - delete Container; -} - -Box * Box_trun::GetBox() { - return Container; -} - -void Box_trun::SetDataOffset( uint32_t Offset ) { - curDataOffset = Offset; -} - -void Box_trun::WriteContent( ) { - uint32_t curoffset; - uint32_t flags = 0 & ( curDataOffset ? 0x1 : 0 ) & ( setSampleDuration ? 0x100 : 0 ) & ( setSampleSize ? 0x200 : 0 ); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(flags)); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(SampleInfo.size()),4); - curoffset = 8; - if( curDataOffset ) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(curDataOffset),curoffset); - curoffset += 4; - } - for( uint32_t i = 0; i < SampleInfo.size(); i++ ) { - if( setSampleDuration ) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(SampleInfo[i].SampleDuration),curoffset); - curoffset += 4; - } - if( setSampleSize ) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(SampleInfo[i].SampleSize),curoffset); - curoffset += 4; - } - } -} - -void Box_trun::SetDefaults( ) { - setSampleDuration = false; - setSampleSize = false; -} diff --git a/util/MP4/box_url.cpp b/util/MP4/box_url.cpp deleted file mode 100644 index 8287f7c3..00000000 --- a/util/MP4/box_url.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "box.cpp" - -class Box_url { - public: - Box_url( ); - ~Box_url(); - Box * GetBox(); - private: - Box * Container; -};//Box_ftyp Class - -Box_url::Box_url( ) { - Container = new Box( 0x75726C20 ); - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(1)); -} - -Box_url::~Box_url() { - delete Container; -} - -Box * Box_url::GetBox() { - return Container; -} diff --git a/util/MP4/box_vmhd.cpp b/util/MP4/box_vmhd.cpp deleted file mode 100644 index 6dd5fb8e..00000000 --- a/util/MP4/box_vmhd.cpp +++ /dev/null @@ -1,45 +0,0 @@ -#include "box.cpp" - -class Box_vmhd { - public: - Box_vmhd( ); - ~Box_vmhd(); - Box * GetBox(); - void SetGraphicsMode( uint16_t GraphicsMode = 0 ); - void SetOpColor( uint16_t Red = 0, uint16_t Green = 0, uint16_t Blue = 0); - private: - Box * Container; - void SetReserved( ); - void SetDefaults( ); -};//Box_ftyp Class - -Box_vmhd::Box_vmhd( ) { - Container = new Box( 0x766D6864 ); - SetDefaults(); - SetReserved(); -} - -Box_vmhd::~Box_vmhd() { - delete Container; -} - -Box * Box_vmhd::GetBox() { - return Container; -} - -void Box_vmhd::SetGraphicsMode( uint16_t GraphicsMode ) { - Container->SetPayload((uint32_t)2,Box::uint16_to_uint8(GraphicsMode),8); -} -void Box_vmhd::SetOpColor( uint16_t Red, uint16_t Green, uint16_t Blue ) { - Container->SetPayload((uint32_t)2,Box::uint16_to_uint8(Blue),14); - Container->SetPayload((uint32_t)2,Box::uint16_to_uint8(Green),12); - Container->SetPayload((uint32_t)2,Box::uint16_to_uint8(Red),10); -} - -void Box_vmhd::SetReserved( ) { - Container->SetPayload((uint32_t)4,Box::uint32_to_uint8(1)); -} -void Box_vmhd::SetDefaults( ) { - SetOpColor(); - SetGraphicsMode(); -} diff --git a/util/MP4/interface.cpp b/util/MP4/interface.cpp deleted file mode 100644 index e567fb86..00000000 --- a/util/MP4/interface.cpp +++ /dev/null @@ -1,589 +0,0 @@ -#include "box_includes.h" - -#include - -class Interface { - public: - Interface(); - ~Interface(); - void link(); - uint32_t GetContentSize(); - uint8_t * GetContents(); - void SetWidth( uint16_t NewWidth ); - void SetHeight( uint16_t NewHeight ); - void SetDurationTime( uint32_t NewDuration, uint32_t Track ); - void SetTimeScale( uint32_t NewUnitsPerSecond, uint32_t Track ); - void AddSTTSEntry( uint32_t SampleCount, uint32_t SampleDelta, uint32_t Track ); - void EmptySTTS( uint32_t Track ); - void AddSTSCEntry( uint32_t FirstChunk, uint32_t SamplesPerChunk, uint32_t Track ); - void EmptySTSC( uint32_t Track ); - void SetOffsets( std::vector NewOffsets, uint32_t Track ); - void SetData( std::string data ); - std::string GenerateLiveBootstrap( uint32_t CurMediaTime ); - static std::string mdatFold(std::string data); - private: - void SetStaticDefaults(); - void UpdateContents(); - void WriteSTTS( uint32_t Track ); - void WriteSTSC( uint32_t Track ); - bool AllBoxesExist(); - uint16_t Width; - uint16_t Height; - std::vector Duration; - std::vector UnitsPerSecond; - std::vector sttsvide; - std::vector sttssoun; - std::vector stscvide; - std::vector stscsoun; - Box_ftyp * ftyp; - Box_moov * moov; - Box_mvhd * mvhd; - Box_trak * trak_vide; - Box_tkhd * tkhd_vide; - Box_mdia * mdia_vide; - Box_mdhd * mdhd_vide; - Box_hdlr * hdlr_vide; - Box_minf * minf_vide; - Box_vmhd * vmhd_vide; - Box_dinf * dinf_vide; - Box_dref * dref_vide; - Box_url * url_vide; - Box_stbl * stbl_vide; - Box_stts * stts_vide; - Box_stsc * stsc_vide; - Box_stco * stco_vide; - Box_stsd * stsd_vide; - Box_avcC * avcC_vide; - Box_trak * trak_soun; - Box_tkhd * tkhd_soun; - Box_mdia * mdia_soun; - Box_mdhd * mdhd_soun; - Box_hdlr * hdlr_soun; - Box_minf * minf_soun; - Box_smhd * smhd_soun; - Box_dinf * dinf_soun; - Box_dref * dref_soun; - Box_url * url_soun; - Box_stbl * stbl_soun; - Box_stts * stts_soun; - Box_stsc * stsc_soun; - Box_stco * stco_soun; - Box_stsd * stsd_soun; - Box_esds * esds_soun; - Box_rtmp * rtmp; - Box_amhp * amhp; - Box_mvex * mvex; - Box_trex * trex_vide; - Box_trex * trex_soun; - Box_afra * afra; - Box_abst * abst; - Box_asrt * asrt; - Box_afrt * afrt; - Box_moof * moof; - Box_mfhd * mfhd; - Box_traf * traf_vide; - Box_tfhd * tfhd_vide; - Box_trun * trun_vide; - Box_traf * traf_soun; - Box_tfhd * tfhd_soun; - Box_trun * trun_soun; -};//Interface class - -Interface::Interface() { - //Initializing local data - Width = 0; - Height = 0; - //Creating the boxes - ftyp = new Box_ftyp(); - moov = new Box_moov(); - mvhd = new Box_mvhd(); - trak_vide = new Box_trak(); - tkhd_vide = new Box_tkhd(); - mdia_vide = new Box_mdia(); - mdhd_vide = new Box_mdhd(); - hdlr_vide = new Box_hdlr(); - minf_vide = new Box_minf(); - vmhd_vide = new Box_vmhd(); - dinf_vide = new Box_dinf(); - dref_vide = new Box_dref(); - url_vide = new Box_url(); - stbl_vide = new Box_stbl(); - stts_vide = new Box_stts(); - stsc_vide = new Box_stsc(); - stco_vide = new Box_stco(); - stsd_vide = new Box_stsd(); - avcC_vide = new Box_avcC(); - trak_soun = new Box_trak(); - tkhd_soun = new Box_tkhd(); - mdia_soun = new Box_mdia(); - mdhd_soun = new Box_mdhd(); - hdlr_soun = new Box_hdlr(); - minf_soun = new Box_minf(); - smhd_soun = new Box_smhd(); - dinf_soun = new Box_dinf(); - dref_soun = new Box_dref(); - url_soun = new Box_url(); - stbl_soun = new Box_stbl(); - stts_soun = new Box_stts(); - stsc_soun = new Box_stsc(); - stco_soun = new Box_stco(); - stsd_soun = new Box_stsd(); - esds_soun = new Box_esds(); - rtmp = new Box_rtmp(); - amhp = new Box_amhp(); - mvex = new Box_mvex(); - trex_vide = new Box_trex(); - trex_soun = new Box_trex(); - afra = new Box_afra(); - abst = new Box_abst(); - asrt = new Box_asrt(); - afrt = new Box_afrt(); - moof = new Box_moof(); - mfhd = new Box_mfhd(); - traf_vide = new Box_traf(); - tfhd_vide = new Box_tfhd(); - trun_vide = new Box_trun(); - traf_soun = new Box_traf(); - tfhd_soun = new Box_tfhd(); - trun_soun = new Box_trun(); - //Set some values we already know won't change once the boxes have been created - SetStaticDefaults(); - //Linking all boxes - link( ); -} - -Interface::~Interface() { - //Deleting the boxes if they still exist. - if( trun_soun ) { delete trun_soun; trun_soun = NULL; } - if( tfhd_soun ) { delete tfhd_soun; tfhd_soun = NULL; } - if( traf_soun ) { delete traf_soun; traf_soun = NULL; } - if( trun_vide ) { delete trun_vide; trun_vide = NULL; } - if( tfhd_vide ) { delete tfhd_vide; tfhd_vide = NULL; } - if( traf_vide ) { delete traf_vide; traf_vide = NULL; } - if( mfhd ) { delete mfhd; mfhd = NULL; } - if( moof ) { delete moof; moof = NULL; } - if( afrt ) { delete afrt; afrt = NULL; } - if( asrt ) { delete asrt; asrt = NULL; } - if( abst ) { delete abst; abst = NULL; } - if( afra ) { delete afra; afra = NULL; } - if( trex_vide ) { delete trex_vide; trex_vide = NULL; } - if( trex_soun ) { delete trex_soun; trex_soun = NULL; } - if( mvex ) { delete mvex; mvex = NULL; } - if( amhp ) { delete amhp; amhp = NULL; } - if( rtmp ) { delete rtmp; rtmp = NULL; } - if( esds_soun ) { delete esds_soun; esds_soun = NULL; } - if( stsd_soun ) { delete stsd_soun; stsd_soun = NULL; } - if( stco_soun ) { delete stco_soun; stco_soun = NULL; } - if( stsc_soun ) { delete stsc_soun; stsc_soun = NULL; } - if( stts_soun ) { delete stts_soun; stts_soun = NULL; } - if( stbl_soun ) { delete stbl_soun; stbl_soun = NULL; } - if( url_soun ) { delete url_soun; url_soun = NULL; } - if( dref_soun ) { delete dref_soun; dref_soun = NULL; } - if( dinf_soun ) { delete dinf_soun; dinf_soun = NULL; } - if( minf_soun ) { delete minf_soun; minf_soun = NULL; } - if( hdlr_soun ) { delete hdlr_soun; hdlr_soun = NULL; } - if( mdhd_soun ) { delete mdhd_soun; mdhd_soun = NULL; } - if( mdia_soun ) { delete mdia_soun; mdia_soun = NULL; } - if( tkhd_soun ) { delete tkhd_soun; tkhd_soun = NULL; } - if( trak_soun ) { delete trak_soun; trak_soun = NULL; } - if( avcC_vide ) { delete avcC_vide; avcC_vide = NULL; } - if( stsd_vide ) { delete stsd_vide; stsd_vide = NULL; } - if( stco_vide ) { delete stco_vide; stco_vide = NULL; } - if( stsc_vide ) { delete stsc_vide; stsc_vide = NULL; } - if( stts_vide ) { delete stts_vide; stts_vide = NULL; } - if( stbl_vide ) { delete stbl_vide; stbl_vide = NULL; } - if( url_vide ) { delete url_vide; url_vide = NULL; } - if( dref_vide ) { delete dref_vide; dref_vide = NULL; } - if( dinf_vide ) { delete dinf_vide; dinf_vide = NULL; } - if( minf_vide ) { delete minf_vide; minf_vide = NULL; } - if( hdlr_vide ) { delete hdlr_vide; hdlr_vide = NULL; } - if( mdhd_vide ) { delete mdhd_vide; mdhd_vide = NULL; } - if( mdia_vide ) { delete mdia_vide; mdia_vide = NULL; } - if( tkhd_vide ) { delete tkhd_vide; tkhd_vide = NULL; } - if( trak_vide ) { delete trak_vide; trak_vide = NULL; } - if( mvhd ) { delete mvhd; mvhd = NULL; } - if( moov ) { delete moov; moov = NULL; } - if( ftyp ) { delete ftyp; ftyp = NULL; } -} - -void Interface::link( ) { - //Linking Video Track - stsd_vide->AddContent(avcC_vide->GetBox()); - stbl_vide->AddContent(stsd_vide->GetBox(),3); - stbl_vide->AddContent(stco_vide->GetBox(),2); - stbl_vide->AddContent(stsc_vide->GetBox(),1); - stbl_vide->AddContent(stts_vide->GetBox()); - dref_vide->AddContent(url_vide->GetBox()); - dinf_vide->AddContent(dref_vide->GetBox()); - minf_vide->AddContent(stbl_vide->GetBox(),2); - minf_vide->AddContent(dinf_vide->GetBox(),1); - minf_vide->AddContent(vmhd_vide->GetBox()); - mdia_vide->AddContent(minf_vide->GetBox(),2); - mdia_vide->AddContent(hdlr_vide->GetBox(),1); - mdia_vide->AddContent(mdhd_vide->GetBox()); - trak_vide->AddContent(mdia_vide->GetBox(),1); - trak_vide->AddContent(tkhd_vide->GetBox()); - - //Linking Sound Track - stsd_soun->AddContent(esds_soun->GetBox()); - stbl_soun->AddContent(stsd_soun->GetBox(),3); - stbl_soun->AddContent(stco_soun->GetBox(),2); - stbl_soun->AddContent(stsc_soun->GetBox(),1); - stbl_soun->AddContent(stts_soun->GetBox()); - dref_soun->AddContent(url_soun->GetBox()); - dinf_soun->AddContent(dref_soun->GetBox()); - minf_soun->AddContent(stbl_soun->GetBox(),2); - minf_soun->AddContent(dinf_soun->GetBox(),1); - minf_soun->AddContent(smhd_soun->GetBox()); - mdia_soun->AddContent(minf_soun->GetBox(),2); - mdia_soun->AddContent(hdlr_soun->GetBox(),1); - mdia_soun->AddContent(mdhd_soun->GetBox()); - trak_soun->AddContent(mdia_soun->GetBox(),1); - trak_soun->AddContent(tkhd_soun->GetBox()); - - //Linking mvex - mvex->AddContent(trex_soun->GetBox(),2); - mvex->AddContent(trex_vide->GetBox(),1); - - //Linking total file - moov->AddContent(mvex->GetBox(),3); - moov->AddContent(trak_soun->GetBox(),2); - moov->AddContent(trak_vide->GetBox(),1); - moov->AddContent(mvhd->GetBox()); - - rtmp->AddContent(amhp->GetBox()); - - //Linking ABST - abst->AddFragmentRunTable(afrt->GetBox()); - abst->AddSegmentRunTable(asrt->GetBox()); - - //Linking TRAF_SOUN - traf_soun->AddContent( trun_soun->GetBox(),1); - traf_soun->AddContent( tfhd_soun->GetBox() ); - - //Linking TRAF_vide - traf_vide->AddContent( trun_vide->GetBox(),1); - traf_vide->AddContent( tfhd_vide->GetBox() ); - - //Linking MOOF - moof->AddContent(traf_soun->GetBox(),2); - moof->AddContent(traf_vide->GetBox(),1); - moof->AddContent(mfhd->GetBox()); -} - -uint32_t Interface::GetContentSize( ) { - return ftyp->GetBox( )->GetBoxedDataSize( ) + moov->GetBox( )->GetBoxedDataSize( ) + rtmp->GetBox( )->GetBoxedDataSize( ); -} - -uint8_t * Interface::GetContents( ) { - uint8_t * Result = new uint8_t[GetContentSize( )]; - uint32_t Ftyp_Size = ftyp->GetBox( )->GetBoxedDataSize( ); - uint32_t Moov_Size = moov->GetBox( )->GetBoxedDataSize( ); - uint32_t Rtmp_Size = rtmp->GetBox( )->GetBoxedDataSize( ); - memcpy(Result,ftyp->GetBox( )->GetBoxedData( ),Ftyp_Size); - memcpy(&Result[Ftyp_Size],moov->GetBox( )->GetBoxedData( ),Moov_Size); - memcpy(&Result[Ftyp_Size+Moov_Size],rtmp->GetBox( )->GetBoxedData( ),Rtmp_Size); - return Result; -} - -void Interface::UpdateContents( ) { - if( !Width ) { fprintf(stderr,"WARNING: Width not set!\n"); } - if( !Height ) { fprintf(stderr,"WARNING: Height not set!\n"); } - if( !Duration.size() ) { fprintf(stderr,"WARNING: Duration not set!\n"); } - if( !UnitsPerSecond.size() ) { fprintf(stderr,"WARNING: Timescale not set!\n"); } - if( sttsvide.size() == 0 ) { - fprintf(stderr,"WARNING: No video stts available!\n"); - } else { WriteSTTS( 1 ); } - if( sttssoun.size() == 0 ) { - fprintf(stderr,"WARNING: No sound stts available!\n"); - } else { WriteSTTS( 2 ); } - if( stscvide.size() == 0 ) { - fprintf(stderr,"WARNING: No video stsc available!\n"); - } else { WriteSTSC( 1 ); } - if( stscsoun.size() == 0 ) { - fprintf(stderr,"WARNING: No sound stsc available!\n"); - } else { WriteSTSC( 2 ); } - stsd_vide->WriteContent( ); - stco_vide->WriteContent( ); - stsc_vide->WriteContent( ); - stts_vide->WriteContent( ); - stbl_vide->WriteContent( ); - dref_vide->WriteContent( ); - dinf_vide->WriteContent( ); - minf_vide->WriteContent( ); - mdia_vide->WriteContent( ); - - stsd_soun->WriteContent( ); - stco_soun->WriteContent( ); - stsc_soun->WriteContent( ); - stts_soun->WriteContent( ); - stbl_soun->WriteContent( ); - dref_soun->WriteContent( ); - dinf_soun->WriteContent( ); - minf_soun->WriteContent( ); - mdia_soun->WriteContent( ); - - trak_vide->WriteContent( ); - trak_soun->WriteContent( ); - - mvex->WriteContent( ); - moov->WriteContent( ); - - amhp->WriteContent( ); - rtmp->WriteContent( ); - - afrt->WriteContent( ); - asrt->WriteContent( ); - abst->WriteContent( ); - - trun_soun->WriteContent( ); - traf_soun->WriteContent( ); - - trun_vide->WriteContent( ); - traf_vide->WriteContent( ); - - moof->WriteContent( ); -} - -bool Interface::AllBoxesExist() { - return ( ftyp && moov && mvhd && trak_vide && tkhd_vide && mdia_vide && mdhd_vide && hdlr_vide && - minf_vide && vmhd_vide && dinf_vide && dref_vide && url_vide && stbl_vide && stts_vide && stsc_vide && - stco_vide && stsd_vide && avcC_vide && trak_soun && tkhd_soun && mdia_soun && mdhd_soun && hdlr_soun && - minf_soun && smhd_soun && dinf_soun && dref_soun && url_soun && stbl_soun && stts_soun && stsc_soun && - stco_soun && stsd_soun && esds_soun && rtmp && amhp && mvex && trex_vide && trex_soun && afrt && asrt - && abst && moof && mfhd && traf_vide && tfhd_vide && trun_vide && traf_soun && tfhd_soun && trun_soun ); -} - -void Interface::SetWidth( uint16_t NewWidth ) { - if( Width != NewWidth ) { - Width = NewWidth; - avcC_vide->SetWidth( Width ); - tkhd_vide->SetWidth( Width ); - } -} - -void Interface::SetHeight( uint16_t NewHeight ) { - if( Height != NewHeight ) { - Height = NewHeight; - avcC_vide->SetHeight( Height ); - tkhd_vide->SetHeight( Height ); - } -} - -void Interface::SetDurationTime( uint32_t NewDuration, uint32_t Track ) { - if( Duration.size() < Track ) { Duration.resize(Track+1); } - if( Duration[Track] != NewDuration ) { - Duration[Track] = NewDuration; - switch( Track ) { - case 0: - mvhd->SetDurationTime( Duration[Track] ); - break; - case 1: - mdhd_vide->SetDurationTime( Duration[Track] ); - tkhd_vide->SetDurationTime( Duration[Track] ); - break; - case 2: - mdhd_soun->SetDurationTime( Duration[Track] ); - tkhd_soun->SetDurationTime( Duration[Track] ); - break; - default: - fprintf( stderr, "WARNING, Setting Duration for track %d does have any effect\n", Track ); - break; - } - } -} -void Interface::SetTimeScale( uint32_t NewUnitsPerSecond, uint32_t Track ) { - if( UnitsPerSecond.size() < Track ) { UnitsPerSecond.resize(Track+1); } - if( UnitsPerSecond[Track] != NewUnitsPerSecond ) { - UnitsPerSecond[Track] = NewUnitsPerSecond; - switch(Track) { - case 0: - mvhd->SetTimeScale( UnitsPerSecond[Track] ); - break; - case 1: - mdhd_vide->SetTimeScale( UnitsPerSecond[Track] ); - break; - case 2: - mdhd_soun->SetTimeScale( UnitsPerSecond[Track] ); - break; - default: - fprintf( stderr, "WARNING, Setting Timescale for track %d does have any effect\n", Track ); - break; - } - } -} - -void Interface::SetStaticDefaults() { -// 'vide' = 0x76696465 - hdlr_vide->SetHandlerType( 0x76696465 ); - hdlr_vide->SetName( "Video Track" ); -// 'soun' = 0x736F756E - hdlr_soun->SetHandlerType( 0x736F756E ); - hdlr_vide->SetName( "Audio Track" ); -// Set Track ID's - tkhd_vide->SetTrackID( 1 ); - tkhd_soun->SetTrackID( 2 ); - trex_vide->SetTrackID( 1 ); - trex_soun->SetTrackID( 2 ); -// Set amhp entry - amhp->AddEntry( 1, 0, 0 ); -} - -void Interface::AddSTTSEntry( uint32_t SampleCount, uint32_t SampleDelta, uint32_t Track ) { - stts_record temp; - temp.SampleCount = SampleCount; - temp.SampleDelta = SampleDelta; - switch(Track) { - case 1: - sttsvide.push_back(temp); - break; - case 2: - sttssoun.push_back(temp); - break; - default: - fprintf( stderr, "WARNING: Track %d does not exist, STTS not added\n", Track ); - break; - } -} - -void Interface::EmptySTTS( uint32_t Track ) { - switch(Track) { - case 1: - sttsvide.clear(); - break; - case 2: - sttssoun.clear(); - break; - default: - fprintf( stderr, "WARNING: Track %d does not exist, STTS not cleared\n", Track ); - break; - } -} - -void Interface::WriteSTTS( uint32_t Track ) { - switch( Track ) { - case 1: - for( int i = sttsvide.size() -1; i > 0; i -- ) { - stts_vide->AddEntry(sttsvide[i].SampleCount,sttsvide[i].SampleDelta,i); - } - break; - case 2: - for( int i = sttssoun.size() -1; i > 0; i -- ) { - stts_soun->AddEntry(sttssoun[i].SampleCount,sttssoun[i].SampleDelta,i); - } - break; - default: - fprintf( stderr, "WARNING: Track %d does not exist, STTS not written\n", Track ); - break; - } -} - -void Interface::AddSTSCEntry( uint32_t FirstChunk, uint32_t SamplesPerChunk, uint32_t Track ) { - stsc_record temp; - temp.FirstChunk = FirstChunk; - temp.SamplesPerChunk = SamplesPerChunk; - temp.SampleDescIndex = 1; - switch(Track) { - case 1: - stscvide.push_back(temp); - break; - case 2: - stscsoun.push_back(temp); - break; - default: - fprintf( stderr, "WARNING: Track %d does not exist, STSC not added\n", Track ); - break; - } -} - -void Interface::EmptySTSC( uint32_t Track ) { - switch(Track) { - case 1: - stscvide.clear(); - break; - case 2: - stscsoun.clear(); - break; - default: - fprintf( stderr, "WARNING: Track %d does not exist, STSC not cleared\n", Track ); - break; - } -} - -void Interface::WriteSTSC( uint32_t Track ) { - switch( Track ) { - case 1: - for( int i = stscvide.size() -1; i > 0; i -- ) { - stsc_vide->AddEntry(stscvide[i].FirstChunk,stscvide[i].SamplesPerChunk,1,i); - } - break; - case 2: - for( int i = stscsoun.size() -1; i > 0; i -- ) { - stsc_soun->AddEntry(stscsoun[i].FirstChunk,stscsoun[i].SamplesPerChunk,1,i); - } - break; - default: - fprintf( stderr, "WARNING: Track %d does not exist, STSC not written\n", Track ); - break; - } -} - -void Interface::SetOffsets( std::vector NewOffsets, uint32_t Track ) { - switch( Track ) { - case 1: - stco_vide->SetOffsets( NewOffsets ); - break; - case 2: - stco_soun->SetOffsets( NewOffsets ); - break; - default: - fprintf( stderr, "WARNING: Track %d does not exist, Offsets not written\n", Track ); - break; - } -} - -std::string Interface::GenerateLiveBootstrap( uint32_t CurMediaTime ) { - //SetUpAFRT - afrt->SetUpdate(false); - afrt->SetTimeScale( 1000 ); - afrt->AddQualityEntry( "" ); - std::cerr << "Setting RunEntry on 4000 ms\n"; - afrt->AddFragmentRunEntry( 1, 0 , 4000 ); //FirstFragment, FirstFragmentTimestamp,Fragment Duration in milliseconds - afrt->WriteContent( ); - - //SetUpASRT - asrt->SetUpdate(false); - asrt->AddQualityEntry( "" ); - asrt->AddSegmentRunEntry( 1, 199 );//1 Segment, 199 Fragments - asrt->WriteContent( ); - - //SetUpABST - abst->SetBootstrapVersion( 1 ); - abst->SetProfile( 0 ); - abst->SetLive( true ); - abst->SetUpdate( false ); - abst->SetTimeScale( 1000 ); - abst->SetMediaTime( 0xFFFFFFFF ); - abst->SetSMPTE( 0 ); - abst->SetMovieIdentifier( "fifa" ); - abst->SetDRM( "" ); - abst->SetMetaData( "" ); - abst->AddServerEntry( "" ); - abst->AddQualityEntry( "" ); - abst->WriteContent( ); - - std::string Result; - Result.append( (char*)abst->GetBox( )->GetBoxedData( ), (int)abst->GetBox( )->GetBoxedDataSize( ) ); - return Result; -} - -std::string Interface::mdatFold(std::string data){ - std::string Result; - unsigned int t_int; - t_int = htonl(data.size()+8); - Result.append((char*)&t_int, 4); - t_int = htonl(0x6D646174); - Result.append((char*)&t_int, 4); - Result.append(data); - return Result; -} diff --git a/util/MP4/main.cpp b/util/MP4/main.cpp deleted file mode 100644 index 027ddb8d..00000000 --- a/util/MP4/main.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include "interface.h" - -int main( ) { - std::cout << "Creating Interface\n"; - Interface * file = new Interface(); - std::cout << "Interface created, start linking them\n"; - file->link(); - std::cout << "Linking finished, deleting boxes\n"; - delete file; - std::cout << "Interface deleted\n"; - return 0; -} diff --git a/version.sh b/version.sh new file mode 100755 index 00000000..671da00b --- /dev/null +++ b/version.sh @@ -0,0 +1,5 @@ +#!/bin/sh +if git describe --tags > version.tmp; then + echo "m4_define([VERSION_NUMBER], [`tr -d '\n' < version.tmp`])" > version.m4 +fi +rm version.tmp