From 35ee722f81499bb1c19f96de728713b35e801598 Mon Sep 17 00:00:00 2001 From: Erik Zandvliet Date: Thu, 28 Nov 2013 11:08:46 +0100 Subject: [PATCH] Added ID and comment header support for theora and vorbis --- lib/dtsc.h | 3 +++ lib/dtscmeta.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/lib/dtsc.h b/lib/dtsc.h index a3119105..279d3710 100644 --- a/lib/dtsc.h +++ b/lib/dtsc.h @@ -178,6 +178,9 @@ namespace DTSC { int width; int height; int fpks; + //vorbis and theora only + std::string idHeader; + std::string commentHeader; }; class Track : public readOnlyTrack { diff --git a/lib/dtscmeta.cpp b/lib/dtscmeta.cpp index 1172e037..18ea01ef 100644 --- a/lib/dtscmeta.cpp +++ b/lib/dtscmeta.cpp @@ -166,6 +166,10 @@ namespace DTSC { height = trackRef["height"].asInt(); fpks = trackRef["fpks"].asInt(); } + if (codec == "vorbis" || codec == "theora"){ + idHeader = trackRef["idheader"].asString(); + commentHeader = trackRef["commentheader"].asString(); + } } Track::Track(){} @@ -186,6 +190,8 @@ namespace DTSC { width = rhs.width; height = rhs.height; fpks = rhs.fpks; + idHeader = rhs.idHeader; + commentHeader = rhs.commentHeader; if (rhs.fragments && rhs.fragLen){ fragments = std::deque(rhs.fragments, rhs.fragments + rhs.fragLen); } @@ -229,6 +235,10 @@ namespace DTSC { height = trackRef["height"].asInt(); fpks = trackRef["fpks"].asInt(); } + if (codec == "vorbis" || codec == "theora"){ + idHeader = trackRef["idheader"].asString(); + commentHeader = trackRef["commentheader"].asString(); + } } void Track::update(JSON::Value & pack){ @@ -459,6 +469,10 @@ namespace DTSC { }else if (type == "video"){ result += 48; } + if (codec == "vorbis" || codec == "theora"){ + result += 15 + idHeader.size();//idheader + result += 20 + commentHeader.size();//commentheader + } return result; } @@ -472,6 +486,10 @@ namespace DTSC { }else if (type == "video"){ result += 48; } + if (codec == "vorbis" || codec == "theora"){ + result += 15 + idHeader.size();//idheader + result += 20 + commentHeader.size();//commentheader + } return result; } @@ -522,6 +540,14 @@ namespace DTSC { conn.SendNow("\000\004fpks\001", 7); conn.SendNow(convertLongLong(fpks), 8); } + if (codec == "vorbis" || codec == "theora"){ + conn.SendNow("\000\010idheader\002", 11); + conn.SendNow(convertInt(idHeader.size()), 4); + conn.SendNow(idHeader); + conn.SendNow("\000\015commentheader\002", 16); + conn.SendNow(convertInt(commentHeader.size()), 4); + conn.SendNow(commentHeader); + } conn.SendNow("\000\000\356", 3);//End this track Object } @@ -578,6 +604,14 @@ namespace DTSC { conn.SendNow("\000\004fpks\001", 7); conn.SendNow(convertLongLong(fpks), 8); } + if (codec == "vorbis" || codec == "theora"){ + conn.SendNow("\000\010idheader\002", 11); + conn.SendNow(convertInt(idHeader.size()), 4); + conn.SendNow(idHeader); + conn.SendNow("\000\015commentheader\002", 16); + conn.SendNow(convertInt(commentHeader.size()), 4); + conn.SendNow(commentHeader); + } conn.SendNow("\000\000\356", 3);//End this track Object } @@ -670,6 +704,10 @@ namespace DTSC { result["height"] = height; result["fpks"] = fpks; } + if (codec == "vorbis" || codec == "theora"){ + result["idheader"] = idHeader; + result["commentheader"] = commentHeader; + } return result; } @@ -713,6 +751,10 @@ namespace DTSC { result["height"] = height; result["fpks"] = fpks; } + if (codec == "vorbis" || codec == "theora"){ + result["idheader"] = idHeader; + result["commentheader"] = commentHeader; + } return result; }