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:
@@ -18,6 +18,7 @@ namespace webrtc
|
|||||||
{
|
{
|
||||||
|
|
||||||
// Error codes
|
// Error codes
|
||||||
|
#define VCM_FRAME_NOT_READY 3
|
||||||
#define VCM_REQUEST_SLI 2
|
#define VCM_REQUEST_SLI 2
|
||||||
#define VCM_MISSING_CALLBACK 1
|
#define VCM_MISSING_CALLBACK 1
|
||||||
#define VCM_OK 0
|
#define VCM_OK 0
|
||||||
|
|||||||
@@ -1071,7 +1071,9 @@ VideoCodingModuleImpl::Decode(WebRtc_UWord16 maxWaitTimeMs)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (frame != NULL)
|
if (frame == NULL)
|
||||||
|
return VCM_FRAME_NOT_READY;
|
||||||
|
else
|
||||||
{
|
{
|
||||||
CriticalSectionScoped cs(_receiveCritSect);
|
CriticalSectionScoped cs(_receiveCritSect);
|
||||||
|
|
||||||
|
|||||||
@@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
#include "vie_channel.h"
|
#include "vie_channel.h"
|
||||||
#include "vie_defines.h"
|
#include "vie_defines.h"
|
||||||
|
|
||||||
#include "critical_section_wrapper.h"
|
#include "critical_section_wrapper.h"
|
||||||
|
#include "event_wrapper.h"
|
||||||
#include "rtp_rtcp.h"
|
#include "rtp_rtcp.h"
|
||||||
#include "udp_transport.h"
|
#include "udp_transport.h"
|
||||||
#include "video_coding.h"
|
#include "video_coding.h"
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
namespace webrtc
|
namespace webrtc
|
||||||
{
|
{
|
||||||
|
static const int kDecoderThreadWaitPeriod = 3; // wait 3 ms
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// Constructor
|
// Constructor
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -77,6 +77,7 @@ ViEChannel::ViEChannel(WebRtc_Word32 channelId, WebRtc_Word32 engineId,
|
|||||||
_decoderReset(true),
|
_decoderReset(true),
|
||||||
_waitForKeyFrame(false),
|
_waitForKeyFrame(false),
|
||||||
_ptrDecodeThread(NULL),
|
_ptrDecodeThread(NULL),
|
||||||
|
_vieDecodeEvent(*EventWrapper::Create()),
|
||||||
_ptrSrtpModuleEncryption(NULL),
|
_ptrSrtpModuleEncryption(NULL),
|
||||||
_ptrSrtpModuleDecryption(NULL),
|
_ptrSrtpModuleDecryption(NULL),
|
||||||
_ptrExternalEncryption(NULL),
|
_ptrExternalEncryption(NULL),
|
||||||
@@ -261,11 +262,13 @@ ViEChannel::~ViEChannel()
|
|||||||
RtpRtcp::DestroyRtpRtcp(rtpRtcp);
|
RtpRtcp::DestroyRtpRtcp(rtpRtcp);
|
||||||
_simulcastRtpRtcp.erase(it);
|
_simulcastRtpRtcp.erase(it);
|
||||||
}
|
}
|
||||||
|
_vieDecodeEvent.Set();
|
||||||
if (_ptrDecodeThread)
|
if (_ptrDecodeThread)
|
||||||
{
|
{
|
||||||
StopDecodeThread();
|
StopDecodeThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete &_vieDecodeEvent;
|
||||||
delete &_vieReceiver;
|
delete &_vieReceiver;
|
||||||
delete &_vieSender;
|
delete &_vieSender;
|
||||||
delete &_vieSync;
|
delete &_vieSync;
|
||||||
@@ -3092,7 +3095,11 @@ bool ViEChannel::ChannelDecodeThreadFunction(void* obj)
|
|||||||
bool ViEChannel::ChannelDecodeProcess()
|
bool ViEChannel::ChannelDecodeProcess()
|
||||||
{
|
{
|
||||||
// Decode is blocking, but sleep some time anyway to not get a spin
|
// 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)
|
if ((TickTime::Now() - _vcmRTTReported).Milliseconds() > 1000)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ namespace webrtc
|
|||||||
{
|
{
|
||||||
class CriticalSectionWrapper;
|
class CriticalSectionWrapper;
|
||||||
class Encryption;
|
class Encryption;
|
||||||
|
class EventWrapper;
|
||||||
class ProcessThread;
|
class ProcessThread;
|
||||||
class RtpRtcp;
|
class RtpRtcp;
|
||||||
class ThreadWrapper;
|
class ThreadWrapper;
|
||||||
@@ -471,6 +472,7 @@ private:
|
|||||||
|
|
||||||
// Decoder
|
// Decoder
|
||||||
ThreadWrapper* _ptrDecodeThread;
|
ThreadWrapper* _ptrDecodeThread;
|
||||||
|
EventWrapper& _vieDecodeEvent;
|
||||||
|
|
||||||
//SRTP - using seperate pointers for encryption and decryption to support
|
//SRTP - using seperate pointers for encryption and decryption to support
|
||||||
// simultaneous operations.
|
// simultaneous operations.
|
||||||
|
|||||||
Reference in New Issue
Block a user