From f09b2588047fda6b092ee616e303c0086bf80cd6 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Mon, 2 Dec 2013 11:05:50 +0100 Subject: [PATCH] Removed duplicate DTSC::Track::getIdentifier function, added DTSC::Stream::addMeta function. --- lib/dtsc.cpp | 10 +++++++++- lib/dtsc.h | 2 +- lib/dtscmeta.cpp | 22 +--------------------- 3 files changed, 11 insertions(+), 23 deletions(-) diff --git a/lib/dtsc.cpp b/lib/dtsc.cpp index 922aef39..8bcd03db 100644 --- a/lib/dtsc.cpp +++ b/lib/dtsc.cpp @@ -121,7 +121,7 @@ bool DTSC::Stream::parsePacket(Socket::Buffer & buffer){ unsigned int i = 0; std::string wholepacket = buffer.remove(len + 8); JSON::Value meta = JSON::fromDTMI((unsigned char*)wholepacket.c_str() + 8, len, i); - metadata = Meta(meta); + addMeta(meta); //recursively calls itself until failure or data packet instead of header return parsePacket(buffer); } @@ -205,6 +205,14 @@ void DTSC::Stream::resetStream(){ keyframes.clear(); } +/// Adds a set of metadata to the steam. +/// This is implemented by simply replacing the current metadata. +/// This effectively resets the stream. +void DTSC::Stream::addMeta(JSON::Value & newMeta){ + metadata = Meta(newMeta); +} + +/// Adds a single DTSC packet to the stream, updating the internal metadata if needed. void DTSC::Stream::addPacket(JSON::Value & newPack){ long long unsigned int now = Util::getMS(); livePos newPos; diff --git a/lib/dtsc.h b/lib/dtsc.h index 632bc062..caa23c95 100644 --- a/lib/dtsc.h +++ b/lib/dtsc.h @@ -197,7 +197,6 @@ namespace DTSC { std::deque keys; std::deque parts; Key & getKey(int keyNum); - std::string getIdentifier(); void reset(); }; @@ -314,6 +313,7 @@ namespace DTSC { std::map buffers; std::map > keyframes; void addPacket(JSON::Value & newPack); + void addMeta(JSON::Value & newMeta); datatype datapointertype; unsigned int buffercount; unsigned int buffertime; diff --git a/lib/dtscmeta.cpp b/lib/dtscmeta.cpp index 3cb988f5..bcb58d6a 100644 --- a/lib/dtscmeta.cpp +++ b/lib/dtscmeta.cpp @@ -311,31 +311,11 @@ namespace DTSC { std::string readOnlyTrack::getIdentifier(){ std::stringstream result; if (type == ""){ - result << "Metadata_" << trackID; + result << "metadata_" << trackID; return result.str(); } result << type << "_"; result << codec << "_"; - result << (bps / 1024) << "kbit_"; - if (type == "audio"){ - result << channels << "ch_"; - result << rate << "hz"; - }else if (type == "video"){ - result << width << "x" << height << "_"; - result << (double)fpks / 1000 << "fps"; - } - return result.str(); - } - - std::string Track::getIdentifier(){ - std::stringstream result; - if (type == ""){ - result << "Metadata_" << trackID; - return result.str(); - } - result << type << "_"; - result << codec << "_"; - result << (bps / 1024) << "kbit_"; if (type == "audio"){ result << channels << "ch_"; result << rate << "hz";