Now compiles with DTSC multibitrate library.

This commit is contained in:
Thulinma 2013-06-25 15:42:09 +02:00
parent d1dc4943de
commit 2644e9575e
8 changed files with 40 additions and 43 deletions

View file

@ -50,6 +50,7 @@ namespace Buffer {
///\brief A function running in a thread to handle a new user connection.
///\param v_usr The user that is connected.
void handleUser(void * v_usr){
std::set<int> newSelect;
user * usr = (user*)v_usr;
thisStream->addUser(usr);
#if DEBUG >= 5
@ -65,7 +66,7 @@ namespace Buffer {
while (usr->S.connected()){
Util::sleep(5); //sleep 5ms
if ( !usr->myRing->playCount || !usr->Send()){
if ( !usr->myRing->playCount || !usr->Send(newSelect)){
if (usr->myRing->updated){
Stream::get()->getReadLock();
usr->S.SendNow(Stream::get()->getStream()->metadata.toNetPacked());
@ -110,21 +111,24 @@ namespace Buffer {
thisStream->saveStats(usr->MyStr, usr->tmpStats);
break;
}
case 't': {
newSelect.clear();
std::string tmp = usr->S.Received().get().substr(2);
while (tmp != ""){
newSelect.insert(atoi(tmp.substr(0,tmp.find(' ')).c_str()));
if (tmp.find(' ') != std::string::npos){
tmp.erase(0,tmp.find(' ')+1);
}else{
tmp = "";
}
}
break;
}
case 's': { //second-seek
unsigned int ms = JSON::Value(usr->S.Received().get().substr(2)).asInt();
usr->myRing->waiting = false;
usr->myRing->starved = false;
usr->myRing->b = thisStream->getStream()->msSeek(ms);
if (usr->myRing->playCount > 0){
usr->myRing->playCount = 0;
}
break;
}
case 'f': { //frame-seek
unsigned int frameno = JSON::Value(usr->S.Received().get().substr(2)).asInt();
usr->myRing->waiting = false;
usr->myRing->starved = false;
usr->myRing->b = thisStream->getStream()->frameSeek(frameno);
usr->myRing->b = thisStream->getStream()->msSeek(ms, newSelect);
if (usr->myRing->playCount > 0){
usr->myRing->playCount = 0;
}
@ -176,7 +180,6 @@ namespace Buffer {
if (((now - timeDiff) >= lastPacket) || (lastPacket - (now - timeDiff) > 15000)){
thisStream->getWriteLock();
if (thisStream->getStream()->parsePacket(inBuffer)){
thisStream->getStream()->outPacket(0);
lastPacket = thisStream->getStream()->getTime();
if ((now - timeDiff - lastPacket) > 15000 || (now - timeDiff - lastPacket < -15000)){
timeDiff = now - lastPacket;
@ -208,7 +211,6 @@ namespace Buffer {
do{
thisStream->getWriteLock();
if (thisStream->getStream()->parsePacket(thisStream->getIPInput().Received())){
thisStream->getStream()->outPacket(0);
thisStream->dropWriteLock(true);
packed_parsed = true;
}else{

View file

@ -178,13 +178,6 @@ namespace Buffer {
///\brief Drops a previously obtained write lock.
///\param newPacketsAvailable Whether new packets are available to update the index.
void Stream::dropWriteLock(bool newPacketsAvailable){
if (newPacketsAvailable){
if (Strm->getPacket(0).isMember("keyframe")){
stats_mutex.lock();
Strm->updateHeaders();
stats_mutex.unlock();
}
}
rw_mutex.lock();
writers--;
rw_mutex.unlock();

View file

@ -68,7 +68,7 @@ namespace Buffer {
///\brief Try to send the current buffer.
///
///\return True if the send was succesful, false otherwise.
bool user::Send(){
bool user::Send(std::set<int> & allowedTracks){
if ( !myRing){
return false;
} //no ring!
@ -105,11 +105,11 @@ namespace Buffer {
if (doSend(Stream::get()->getStream()->outPacket(myRing->b).c_str(), Stream::get()->getStream()->outPacket(myRing->b).length())){
//switch to next buffer
currsend = 0;
if (myRing->b <= 0){
if (Stream::get()->getStream()->isNewest(myRing->b)){
myRing->waiting = true;
return false;
} //no next buffer? go in waiting mode.
myRing->b--;
myRing->b = Stream::get()->getStream()->getNext(myRing->b, allowedTracks);
if (Stream::get()->getStream()->getPacket(myRing->b).isMember("keyframe") && myRing->playCount > 0){
myRing->playCount--;
if ( !myRing->playCount){

View file

@ -51,6 +51,6 @@ namespace Buffer {
/// Has a side effect of dropping the connection if send will never complete.
bool doSend(const char * ptr, int len);
/// Try to send data to this user. Disconnects if any problems occur.
bool Send();
bool Send(std::set<int> & allowedTracks);
};
}