void advanceOutputBufferTo(OutputBuffer * cb, PlayerControl * pc, int * previous, int * currentChunkSent, MetadataChunk * currentChunk, int to) { while(cb->begin!=to) { handleMetadata(cb, pc, previous, currentChunkSent, currentChunk); cb->begin++; if(cb->begin>=buffered_chunks) { cb->begin = 0; } } }
void PasteServiceBase::InitReply (QNetworkReply *reply) { connect (reply, SIGNAL (finished ()), this, SLOT (handleFinished ())); connect (reply, SIGNAL (metaDataChanged ()), this, SLOT (handleMetadata ())); connect (reply, SIGNAL (error (QNetworkReply::NetworkError)), this, SLOT (handleError ())); }
void Plugin::Paste (const QString& text, QObject *entry) { QNetworkRequest req (QUrl ("http://paste.pocoo.org/")); req.setHeader (QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); req.setRawHeader ("Referer", "http://paste.pocoo.org/"); QByteArray data = "code="; data += text.toUtf8 ().toPercentEncoding (); data += "&language=text&webpage="; req.setHeader (QNetworkRequest::ContentLengthHeader, data.size ()); QNetworkReply *reply = Proxy_->GetNetworkAccessManager ()->post (req, data); connect (reply, SIGNAL (metaDataChanged ()), this, SLOT (handleMetadata ())); Reply2Entry_ [reply] = entry; }
GSVWrapper::GSVWrapper(QObject *parent): QObject(parent) { setVerbose(false); myThread = new QThread(); moveToThread(myThread); printThreads(); myThread->start(); // Connect signals QObject::connect(¤tPanorama, SIGNAL(zoomLevelReady(int)), this, SLOT(panoramasZoomLevelReady(int))); QObject::connect(this, SIGNAL(newRequest()), this, SLOT(processQueue()), Qt::QueuedConnection); QObject::connect(&networkhandler, SIGNAL(networkState(int,QString)), this, SLOT(networkStateChanged(int,QString)), Qt::QueuedConnection); QObject::connect(&networkhandler, SIGNAL(tileReady(QImage, QString, int, int)), this, SLOT(imageDataReady(QImage, QString, int, int))); QObject::connect(&networkhandler, SIGNAL(metaReady(QString, QString)), this, SLOT(handleMetadata(QString, QString)), Qt::QueuedConnection); QObject::connect(this, SIGNAL(getTile(QString,QString,int,int,int,int)), &networkhandler, SLOT(getTile(QString,QString,int,int,int,int)), Qt::QueuedConnection); // Error signals QObject::connect(&filehandler, SIGNAL(fileHandlerError(int,QString)), this, SLOT(handleFileError(int,QString)), Qt::QueuedConnection); QObject::connect(&networkhandler, SIGNAL(networkHandlerError(int,QString)), this, SLOT(handleNetworkError(int,QString)), Qt::QueuedConnection); }
void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb) { int pause = 0; int quit = 0; int bbp = buffered_before_play; int doCrossFade = 0; int crossFadeChunks = 0; int fadePosition; int nextChunk = -1; int test; int decodeWaitedOn = 0; char silence[CHUNK_SIZE] = { 0 }; int previousMetadataChunk = -1; MetadataChunk currentMetadataChunk; int currentChunkSent = 1; int end; int next = -1; // fprintf(stderr,"In decode.c decodeParent func :\r\n"); if(waitOnDecode(pc,dc,cb,&decodeWaitedOn)<0) return; pc->elapsedTime = 0; pc->state = PLAYER_STATE_PLAY; pc->play = 0; kill(getppid(),SIGUSR1); while(mpm_get_id(MPM_DECODE)>0 && cb->end-cb->begin<bbp && cb->end!=buffered_chunks-1 && dc->state!=DECODE_STATE_STOP) { processDecodeInput(); if(quit) return; playSilenceOrSleep(); } while(!quit) { processDecodeInput(); handleDecodeStart(); handleMetadata(cb, pc, &previousMetadataChunk, ¤tChunkSent, ¤tMetadataChunk); if(dc->state==DECODE_STATE_STOP && pc->queueState==PLAYER_QUEUE_FULL && pc->queueLockState==PLAYER_QUEUE_UNLOCKED) { next = cb->end; dc->start = 1; pc->queueState = PLAYER_QUEUE_DECODE; kill(getppid(),SIGUSR1); } if(next>=0 && doCrossFade==0 && !dc->start && dc->state!=DECODE_STATE_START) { nextChunk = -1; if(isCurrentAudioFormat(&(cb->audioFormat))) { doCrossFade = 1; crossFadeChunks = calculateCrossFadeChunks(pc, &(cb->audioFormat)); if(!crossFadeChunks || pc->crossFade>=dc->totalTime) { doCrossFade = -1; } } else doCrossFade = -1; } /* copy thse to locale variables to prevent any potential race conditions and weirdness */ end = cb->end; if(pause) my_usleep(10000); else if(cb->begin!=end && cb->begin!=next) { if(doCrossFade==1 && next>=0 && ((next>cb->begin && (fadePosition=next-cb->begin) <=crossFadeChunks) || (cb->begin>next && (fadePosition=next-cb->begin+ buffered_chunks)<=crossFadeChunks))) { if(nextChunk<0) { crossFadeChunks = fadePosition; } test = end; if(end < cb->begin) test+=buffered_chunks; nextChunk = cb->begin+crossFadeChunks; if(nextChunk<test) { if(nextChunk>=buffered_chunks) { nextChunk -= buffered_chunks; } pcm_mix(cb->chunks+cb->begin*CHUNK_SIZE, cb->chunks+nextChunk* CHUNK_SIZE, cb->chunkSize[ cb->begin], cb->chunkSize[ nextChunk], &(cb->audioFormat), ((float)fadePosition)/ crossFadeChunks); if(cb->chunkSize[nextChunk]> cb->chunkSize[cb->begin] ) { cb->chunkSize[cb->begin] = cb->chunkSize [nextChunk]; } } else { if(dc->state==DECODE_STATE_STOP) { doCrossFade = -1; } else continue; } } pc->elapsedTime = cb->times[cb->begin]; pc->bitRate = cb->bitRate[cb->begin]; pcm_volumeChange(cb->chunks+cb->begin* CHUNK_SIZE, cb->chunkSize[cb->begin], &(cb->audioFormat), pc->softwareVolume); if(playAudio(cb->chunks+cb->begin*CHUNK_SIZE, cb->chunkSize[cb->begin])<0) { quit = 1; } if( cb->begin+1 >= buffered_chunks ) { cb->begin = 0; } else cb->begin++; } else if(next==cb->begin) { if(doCrossFade==1 && nextChunk>=0) { nextChunk = cb->begin+crossFadeChunks; test = cb->end; if(end < cb->begin) test+=buffered_chunks; if(nextChunk<test) { if(nextChunk>=buffered_chunks) { nextChunk -= buffered_chunks; } advanceOutputBufferTo(cb, pc, &previousMetadataChunk, ¤tChunkSent, ¤tMetadataChunk, nextChunk); } } while(pc->queueState==PLAYER_QUEUE_DECODE || pc->queueLockState==PLAYER_QUEUE_LOCKED) { processDecodeInput(); if(quit) { quitDecode(pc,dc); return; } fprintf(stderr,"In decode.c decodeParent while loop with my_usleep\r\n"); // my_usleep(10000); } if(pc->queueState!=PLAYER_QUEUE_PLAY) { quit = 1; break; } else { next = -1; if(waitOnDecode(pc,dc,cb,&decodeWaitedOn)<0) { return; } nextChunk = -1; doCrossFade = 0; crossFadeChunks = 0; pc->queueState = PLAYER_QUEUE_EMPTY; kill(getppid(),SIGUSR1); } } else if(mpm_get_id(MPM_DECODE)<=0 || (dc->state==DECODE_STATE_STOP && !dc->start)) { quit = 1; break; } else { if(playAudio(silence, CHUNK_SIZE) < 0) quit = 1; } } quitDecode(pc,dc); }
void RTMP::handlePacket(const RTMPPacket& packet) { const PacketType t = packet.header.packetType; log_debug("Received %s", t); switch (t) { case PACKET_TYPE_CHUNK_SIZE: handleChangeChunkSize(*this, packet); break; case PACKET_TYPE_BYTES_READ: break; case PACKET_TYPE_CONTROL: handleControl(*this, packet); break; case PACKET_TYPE_SERVERBW: handleServerBW(*this, packet); break; case PACKET_TYPE_CLIENTBW: handleClientBW(*this, packet); break; case PACKET_TYPE_AUDIO: if (!m_mediaChannel) m_mediaChannel = packet.header.channel; break; case PACKET_TYPE_VIDEO: if (!m_mediaChannel) m_mediaChannel = packet.header.channel; break; case PACKET_TYPE_FLEX_STREAM_SEND: LOG_ONCE(log_unimpl(_("unsupported packet received"))); break; case PACKET_TYPE_FLEX_SHARED_OBJECT: LOG_ONCE(log_unimpl(_("unsupported packet received"))); break; case PACKET_TYPE_FLEX_MESSAGE: { LOG_ONCE(log_unimpl(_("partially supported packet %s received"))); _messageQueue.push_back(packet.buffer); break; } case PACKET_TYPE_METADATA: handleMetadata(*this, payloadData(packet), payloadSize(packet)); break; case PACKET_TYPE_SHARED_OBJECT: LOG_ONCE(log_unimpl(_("packet %s received"))); break; case PACKET_TYPE_INVOKE: _messageQueue.push_back(packet.buffer); break; case PACKET_TYPE_FLV: _flvQueue.push_back(packet.buffer); break; default: log_error(_("Unknown packet %s received"), t); } }