bool VideoDecoderThread::work() { ScopeTimer timer(DecoderProfilingZone); if (m_bProcessingLastFrames) { // EOF received, but last frames still need to be decoded. handleEOF(); } else { // Standard decoding. VideoMsgPtr pMsg; { ScopeTimer timer(PacketWaitProfilingZone); pMsg = m_PacketQ.pop(true); } switch (pMsg->getType()) { case VideoMsg::PACKET: decodePacket(pMsg->getPacket()); break; case VideoMsg::END_OF_FILE: handleEOF(); m_bProcessingLastFrames = true; break; case VideoMsg::SEEK_DONE: handleSeekDone(pMsg); break; case VideoMsg::CLOSED: close(); break; default: pMsg->dump(); AVG_ASSERT(false); } } ThreadProfiler::get()->reset(); return true; }
bool AudioDecoderThread::work() { ScopeTimer timer(DecoderProfilingZone); VideoMsgPtr pMsg; { ScopeTimer timer(PacketWaitProfilingZone); pMsg = m_PacketQ.pop(true); } switch (pMsg->getType()) { case VideoMsg::PACKET: { AVPacket* pPacket = pMsg->getPacket(); switch(m_State) { case DECODING: decodePacket(pPacket); break; case SEEK_DONE: handleSeekDone(pPacket); break; case DISCARDING: discardPacket(pPacket); break; default: AVG_ASSERT(false); } av_free_packet(pPacket); delete pPacket; break; } case VideoMsg::SEEK_DONE: m_State = SEEK_DONE; m_SeekSeqNum = pMsg->getSeekSeqNum(); m_SeekTime = pMsg->getSeekTime(); break; case VideoMsg::END_OF_FILE: pushEOF(); break; case VideoMsg::CLOSED: m_MsgQ.clear(); stop(); break; default: pMsg->dump(); AVG_ASSERT(false); } ThreadProfiler::get()->reset(); return true; }