diff --git a/src/io.cpp b/src/io.cpp index 57fe1c71..cf6fe2b4 100644 --- a/src/io.cpp +++ b/src/io.cpp @@ -408,10 +408,25 @@ namespace Mist { //If the track is declined, stop here if (trackState[tid] == FILL_DEC) { INFO_MSG("Track %lu Declined", tid); + preBuffer[tid].clear(); return; } + //Not accepted yet? Buffer. + if (trackState[tid] != FILL_ACC) { + preBuffer[tid].push_back(packet); + }else{ + while (preBuffer[tid].size()){ + bufferSinglePacket(preBuffer[tid].front(), myMeta); + preBuffer[tid].pop_front(); + } + bufferSinglePacket(packet, myMeta); + } + } + + void negotiationProxy::bufferSinglePacket(DTSC::Packet & packet, DTSC::Meta & myMeta){ + //Store the trackid for easier access + unsigned long tid = packet.getTrackId(); //This update needs to happen whether the track is accepted or not. - ///\todo Figure out how to act with declined track here bool isKeyframe = false; if (myMeta.tracks[tid].type == "video") { if (packet.hasMember("keyframe") && packet.getFlag("keyframe")) { @@ -462,10 +477,6 @@ namespace Mist { if (!pagesByTrack.count(tid) || pagesByTrack[tid].size() == 0){ return; } - //At this point we can stop parsing when the track is not accepted - if (trackState[tid] != FILL_ACC) { - return; - } //Check if the correct page is opened if (!curPageNum.count(tid) || nextPageNum != curPageNum[tid]) { diff --git a/src/io.h b/src/io.h index 707484fb..813473d1 100644 --- a/src/io.h +++ b/src/io.h @@ -32,6 +32,7 @@ namespace Mist { void bufferNext(DTSC::Packet & pack, DTSC::Meta & myMeta); void bufferFinalize(unsigned long tid, DTSC::Meta &myMeta); void bufferLivePacket(DTSC::Packet & packet, DTSC::Meta & myMeta); + void bufferSinglePacket(DTSC::Packet & packet, DTSC::Meta & myMeta); bool isBuffered(unsigned long tid, unsigned long keyNum); unsigned long bufferedOnPage(unsigned long tid, unsigned long keyNum); @@ -47,6 +48,7 @@ namespace Mist { std::map metaPages;///< For each track, holds the page that describes which dataPages are mapped std::map curPageNum;///< For each track, holds the number page that is currently being written. std::map curPage;///< For each track, holds the page that is currently being written. + std::map > preBuffer;///< For each track, holds to-be-buffered packets. IPC::sharedClient userClient;///< Shared memory used for connection to Mixer process.