adding a wait on the decode thread when no frames are available

Review URL: http://webrtc-codereview.appspot.com/246009

git-svn-id: http://webrtc.googlecode.com/svn/trunk@807 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
mikhal@webrtc.org 2011-10-25 00:20:54 +00:00
parent a412924c0e
commit f31826e17b
4 changed files with 16 additions and 4 deletions

View File

@ -18,6 +18,7 @@ namespace webrtc
{
// Error codes
#define VCM_FRAME_NOT_READY 3
#define VCM_REQUEST_SLI 2
#define VCM_MISSING_CALLBACK 1
#define VCM_OK 0

View File

@ -1071,7 +1071,9 @@ VideoCodingModuleImpl::Decode(WebRtc_UWord16 maxWaitTimeMs)
}
}
if (frame != NULL)
if (frame == NULL)
return VCM_FRAME_NOT_READY;
else
{
CriticalSectionScoped cs(_receiveCritSect);

View File

@ -14,8 +14,8 @@
#include "vie_channel.h"
#include "vie_defines.h"
#include "critical_section_wrapper.h"
#include "event_wrapper.h"
#include "rtp_rtcp.h"
#include "udp_transport.h"
#include "video_coding.h"
@ -37,7 +37,7 @@
namespace webrtc
{
static const int kDecoderThreadWaitPeriod = 3; // wait 3 ms
// ----------------------------------------------------------------------------
// Constructor
// ----------------------------------------------------------------------------
@ -77,6 +77,7 @@ ViEChannel::ViEChannel(WebRtc_Word32 channelId, WebRtc_Word32 engineId,
_decoderReset(true),
_waitForKeyFrame(false),
_ptrDecodeThread(NULL),
_vieDecodeEvent(*EventWrapper::Create()),
_ptrSrtpModuleEncryption(NULL),
_ptrSrtpModuleDecryption(NULL),
_ptrExternalEncryption(NULL),
@ -261,11 +262,13 @@ ViEChannel::~ViEChannel()
RtpRtcp::DestroyRtpRtcp(rtpRtcp);
_simulcastRtpRtcp.erase(it);
}
_vieDecodeEvent.Set();
if (_ptrDecodeThread)
{
StopDecodeThread();
}
delete &_vieDecodeEvent;
delete &_vieReceiver;
delete &_vieSender;
delete &_vieSync;
@ -3092,7 +3095,11 @@ bool ViEChannel::ChannelDecodeThreadFunction(void* obj)
bool ViEChannel::ChannelDecodeProcess()
{
// Decode is blocking, but sleep some time anyway to not get a spin
_vcm.Decode(50);
int ret = _vcm.Decode(50);
if (ret == VCM_FRAME_NOT_READY) {
// TODO (mikhal): Add trigger by incoming packet.
_vieDecodeEvent.Wait(kDecoderThreadWaitPeriod);
}
if ((TickTime::Now() - _vcmRTTReported).Milliseconds() > 1000)
{

View File

@ -42,6 +42,7 @@ namespace webrtc
{
class CriticalSectionWrapper;
class Encryption;
class EventWrapper;
class ProcessThread;
class RtpRtcp;
class ThreadWrapper;
@ -471,6 +472,7 @@ private:
// Decoder
ThreadWrapper* _ptrDecodeThread;
EventWrapper& _vieDecodeEvent;
//SRTP - using seperate pointers for encryption and decryption to support
// simultaneous operations.