Removed duplicate DTSC::Track::getIdentifier function, added DTSC::Stream::addMeta function.

This commit is contained in:
Thulinma 2013-12-02 11:05:50 +01:00
parent eaaa2936b4
commit f09b258804
3 changed files with 11 additions and 23 deletions

View file

@ -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;

View file

@ -197,7 +197,6 @@ namespace DTSC {
std::deque<Key> keys;
std::deque<Part> parts;
Key & getKey(int keyNum);
std::string getIdentifier();
void reset();
};
@ -314,6 +313,7 @@ namespace DTSC {
std::map<livePos,JSON::Value> buffers;
std::map<int,std::set<livePos> > keyframes;
void addPacket(JSON::Value & newPack);
void addMeta(JSON::Value & newMeta);
datatype datapointertype;
unsigned int buffercount;
unsigned int buffertime;

View file

@ -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";