Added waitForMeta function to DTSC::Stream object.
This commit is contained in:
parent
ca07e477fe
commit
16343ed016
2 changed files with 24 additions and 0 deletions
23
lib/dtsc.cpp
23
lib/dtsc.cpp
|
@ -189,6 +189,29 @@ void DTSC::Stream::endStream(){
|
|||
}
|
||||
}
|
||||
|
||||
/// Blocks until either the stream has metadata available or the sourceSocket errors.
|
||||
/// This function is intended to be run before any commands are sent and thus will not throw away anything important.
|
||||
void DTSC::Stream::waitForMeta(Socket::Connection & sourceSocket){
|
||||
while ( !metadata && sourceSocket.connected()){
|
||||
//we have data? attempt to read header
|
||||
if (sourceSocket.Received().size()){
|
||||
//return value is ignore because we're not interested in data packets, just metadata.
|
||||
parsePacket(sourceSocket.Received());
|
||||
}
|
||||
//still no header? check for more data
|
||||
if ( !metadata){
|
||||
if (sourceSocket.spool()){
|
||||
//more received? attempt to read
|
||||
//return value is ignore because we're not interested in data packets, just metadata.
|
||||
parsePacket(sourceSocket.Received());
|
||||
}else{
|
||||
//nothing extra to receive? wait a bit and retry
|
||||
Util::sleep(5);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DTSC::Stream::addPacket(JSON::Value & newPack){
|
||||
bool updateMeta = false;
|
||||
long long unsigned int now = Util::getMS();
|
||||
|
|
|
@ -215,6 +215,7 @@ namespace DTSC {
|
|||
bool isNewest(DTSC::livePos & pos);
|
||||
DTSC::livePos getNext(DTSC::livePos & pos, std::set<int> & allowedTracks);
|
||||
void endStream();
|
||||
void waitForMeta(Socket::Connection & sourceSocket);
|
||||
private:
|
||||
std::map<livePos,JSON::Value> buffers;
|
||||
std::map<int,std::set<livePos> > keyframes;
|
||||
|
|
Loading…
Add table
Reference in a new issue