diff --git a/lib/dtsc.cpp b/lib/dtsc.cpp index 11762845..9999b7cf 100644 --- a/lib/dtsc.cpp +++ b/lib/dtsc.cpp @@ -206,6 +206,10 @@ bool DTSC::Stream::hasAudio(){ return metadata.isMember("audio"); } +void DTSC::Stream::setBufferTime(unsigned int ms){ + buffertime = ms; +} + /// Returns a packed DTSC packet, ready to sent over the network. std::string & DTSC::Stream::outPacket(unsigned int num){ static std::string emptystring; @@ -261,7 +265,7 @@ void DTSC::Stream::advanceRings(){ //increase buffer size if no keyframes available or too little time available timeBuffered = buffers[keyframes[keyframes.size() - 1].b]["time"].asInt() - buffers[keyframes[0].b]["time"].asInt(); } - if (((buffercount > 1) && (keyframes.size() < 2)) || (timeBuffered < buffertime)){ + if (buffercount > 1 && (keyframes.size() < 2 || timeBuffered < buffertime)){ buffercount++; } } @@ -272,6 +276,8 @@ DTSC::Ring::Ring(unsigned int v){ b = v; waiting = false; starved = false; + updated = false; + playCount = 0; } /// Requests a new Ring, which will be created and added to the internal Ring list. @@ -316,13 +322,13 @@ void DTSC::Stream::updateRingHeaders(){ } } -unsigned int DSTSC::Stream::msSeek(unsigned int ms) { +unsigned int DTSC::Stream::msSeek(unsigned int ms) { for( std::deque::iterator it = keyframes.begin(); it != keyframes.end(); it++ ) { if( buffers[it->b]["time"].asInt( ) < ms ) { return it->b; } } - ///\todo Send PauseMark + return keyframes[keyframes.size()-1].b; } /// Properly cleans up the object for erasing. diff --git a/lib/dtsc.h b/lib/dtsc.h index 2855809b..a7329f3e 100644 --- a/lib/dtsc.h +++ b/lib/dtsc.h @@ -102,6 +102,7 @@ namespace DTSC { volatile bool waiting; ///< If true, this Ring is currently waiting for a buffer fill. volatile bool starved; ///< If true, this Ring can no longer receive valid data. volatile bool updated; ///< If true, this Ring should write a new header. + volatile int playCount; }; /// Holds temporary data for a DTSC stream and provides functions to utilize it. @@ -127,6 +128,7 @@ namespace DTSC { void dropRing(Ring * ptr); void updateHeaders(); unsigned int msSeek(unsigned int ms); + void setBufferTime(unsigned int ms); private: std::deque buffers; std::set rings; diff --git a/lib/json.cpp b/lib/json.cpp index 68596e90..9bc421d8 100644 --- a/lib/json.cpp +++ b/lib/json.cpp @@ -476,6 +476,7 @@ std::string & JSON::Value::toNetPacked(){ //check if this is legal if (myType != OBJECT){ fprintf(stderr, "Error: Only objects may be NetPacked!\n"); + abort(); return emptystring; } //if sneaky storage doesn't contain correct data, re-calculate it