Added API to get receive side video delay.

BUG=1222

Review URL: https://webrtc-codereview.appspot.com/997004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@3294 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
mflodman@webrtc.org 2012-12-14 14:02:10 +00:00
parent 1c75918302
commit 4aee6b637d
6 changed files with 48 additions and 1 deletions

View File

@ -124,6 +124,11 @@ class WEBRTC_DLLEXPORT ViECodec {
unsigned int& key_frames,
unsigned int& delta_frames) const = 0;
// Estimate of the min required buffer time from the expected arrival time
// until rendering to get smooth playback.
virtual int GetReceiveSideDelay(const int video_channel,
int* delay_ms) const = 0;
// Gets the bitrate targeted by the video codec rate control in kbit/s.
virtual int GetCodecTargetBitrate(const int video_channel,
unsigned int* bitrate) const = 0;

View File

@ -231,6 +231,11 @@ void ViEAutoTest::ViECodecStandardTest() {
}
AutoTestSleep(kAutoTestSleepTimeMs);
// Verify the delay estimate is larger than 0.
int delay_ms = 0;
EXPECT_EQ(0, codec->GetReceiveSideDelay(video_channel, &delay_ms));
EXPECT_GT(delay_ms, 0);
EXPECT_EQ(0, base->StopSend(video_channel));
EXPECT_EQ(0, codec->DeregisterEncoderObserver(video_channel));
EXPECT_EQ(0, codec->DeregisterDecoderObserver(video_channel));

View File

@ -522,6 +522,10 @@ WebRtc_UWord32 ViEChannel::DiscardedPackets() const {
return vcm_.DiscardedPackets();
}
int ViEChannel::ReceiveDelay() const {
return vcm_.Delay();
}
WebRtc_Word32 ViEChannel::WaitForKeyFrame(bool wait) {
WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(engine_id_, channel_id_),
"%s(wait: %d)", __FUNCTION__, wait);

View File

@ -96,6 +96,9 @@ class ViEChannel
WebRtc_UWord32* num_delta_frames);
WebRtc_UWord32 DiscardedPackets() const;
// Returns the estimated delay in milliseconds.
int ReceiveDelay() const;
// Only affects calls to SetReceiveCodec done after this call.
WebRtc_Word32 WaitForKeyFrame(bool wait);

View File

@ -14,6 +14,7 @@
#include "engine_configurations.h" // NOLINT
#include "modules/video_coding/main/interface/video_coding.h"
#include "system_wrappers/interface/logging.h"
#include "system_wrappers/interface/trace.h"
#include "video_engine/include/vie_errors.h"
#include "video_engine/vie_capturer.h"
@ -446,7 +447,7 @@ int ViECodecImpl::GetReceiveCodecStastistics(const int video_channel,
unsigned int& delta_frames) const {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(video_channel: %d, codec_type: %d)", __FUNCTION__,
"%s(video_channel: %d)", __FUNCTION__,
video_channel);
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
@ -465,6 +466,33 @@ int ViECodecImpl::GetReceiveCodecStastistics(const int video_channel,
return 0;
}
int ViECodecImpl::GetReceiveSideDelay(const int video_channel,
int* delay_ms) const {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s(video_channel: %d)", __FUNCTION__, video_channel);
if (delay_ms == NULL) {
LOG_F(LS_ERROR) << "NULL pointer argument.";
return -1;
}
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
ViEChannel* vie_channel = cs.Channel(video_channel);
if (!vie_channel) {
WEBRTC_TRACE(kTraceError, kTraceVideo,
ViEId(shared_data_->instance_id(), video_channel),
"%s: No channel %d", __FUNCTION__, video_channel);
shared_data_->SetLastError(kViECodecInvalidChannelId);
return -1;
}
*delay_ms = vie_channel->ReceiveDelay();
if (*delay_ms < 0) {
return -1;
}
return 0;
}
int ViECodecImpl::GetCodecTargetBitrate(const int video_channel,
unsigned int* bitrate) const {
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,

View File

@ -49,6 +49,8 @@ class ViECodecImpl
virtual int GetReceiveCodecStastistics(const int video_channel,
unsigned int& key_frames,
unsigned int& delta_frames) const;
virtual int GetReceiveSideDelay(const int video_channel,
int* delay_ms) const;
virtual int GetCodecTargetBitrate(const int video_channel,
unsigned int* bitrate) const;
virtual unsigned int GetDiscardedPackets(const int video_channel) const;