From b15bfd32d736a2ba790da5dadd57e4a63260b0c4 Mon Sep 17 00:00:00 2001 From: "wu@webrtc.org" Date: Wed, 31 Aug 2011 22:14:44 +0000 Subject: [PATCH] * Add the time_stamp as one parameter to the ViE ExternalRenderer interface. * Fix one issue in webrtcvideoengine where we should remove the renderer before adding a new one. Review URL: http://webrtc-codereview.appspot.com/137011 git-svn-id: http://webrtc.googlecode.com/svn/trunk@501 4adac7df-926f-26a2-2b94-8c16560cd09d --- src/video_engine/main/interface/vie_render.h | 3 ++- src/video_engine/main/source/vie_renderer.cc | 4 +++- .../main/test/AutoTest/source/vie_autotest_render.cc | 3 ++- .../source/talk/session/phone/webrtcvideoengine.cc | 6 ++++-- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/video_engine/main/interface/vie_render.h b/src/video_engine/main/interface/vie_render.h index ef2631daf..fdeae7fb6 100644 --- a/src/video_engine/main/interface/vie_render.h +++ b/src/video_engine/main/interface/vie_render.h @@ -40,7 +40,8 @@ public: unsigned int numberOfStreams) = 0; // This method is called when a new frame should be rendered. - virtual int DeliverFrame(unsigned char* buffer, int bufferSize) = 0; + virtual int DeliverFrame(unsigned char* buffer, int bufferSize, + unsigned int time_stamp) = 0; protected: virtual ~ExternalRenderer() {} diff --git a/src/video_engine/main/source/vie_renderer.cc b/src/video_engine/main/source/vie_renderer.cc index 7522d1ae0..70ffd06b9 100644 --- a/src/video_engine/main/source/vie_renderer.cc +++ b/src/video_engine/main/source/vie_renderer.cc @@ -236,7 +236,9 @@ WebRtc_Word32 ViEExternalRendererImpl::RenderFrame(const WebRtc_UWord32 streamId if(pConvertedFrame) { - _externalRenderer->DeliverFrame(pConvertedFrame->Buffer(), pConvertedFrame->Length()); + _externalRenderer->DeliverFrame(pConvertedFrame->Buffer(), + pConvertedFrame->Length(), + videoFrame.TimeStamp()); } return 0; } diff --git a/src/video_engine/main/test/AutoTest/source/vie_autotest_render.cc b/src/video_engine/main/test/AutoTest/source/vie_autotest_render.cc index f65192980..fe77f4e88 100644 --- a/src/video_engine/main/test/AutoTest/source/vie_autotest_render.cc +++ b/src/video_engine/main/test/AutoTest/source/vie_autotest_render.cc @@ -55,7 +55,8 @@ public: return 0; } - virtual int DeliverFrame(unsigned char* buffer, int bufferSize) + virtual int DeliverFrame(unsigned char* buffer, int bufferSize, + unsigned int time_stamp) { if (bufferSize != _width * _height * 3 / 2) { diff --git a/third_party_mods/libjingle/source/talk/session/phone/webrtcvideoengine.cc b/third_party_mods/libjingle/source/talk/session/phone/webrtcvideoengine.cc index cca79b011..f35153b83 100644 --- a/third_party_mods/libjingle/source/talk/session/phone/webrtcvideoengine.cc +++ b/third_party_mods/libjingle/source/talk/session/phone/webrtcvideoengine.cc @@ -61,7 +61,8 @@ class WebRtcRenderAdapter : public webrtc::ExternalRenderer { return renderer_->SetSize(width_, height_, 0) ? 0 : -1; } - virtual int DeliverFrame(unsigned char* buffer, int buffer_size) { + virtual int DeliverFrame(unsigned char* buffer, int buffer_size, + unsigned int time_stamp) { if (renderer_ == NULL) { return 0; } @@ -70,7 +71,7 @@ class WebRtcRenderAdapter : public webrtc::ExternalRenderer { // ViE expects the frame will be rendered ASAP. However, the libjingle // renderer may have its own internal delays. Can you disable the buffering // inside ViE and surface the timing information to this callback? - video_frame.Attach(buffer, buffer_size, width_, height_, 0, 0); + video_frame.Attach(buffer, buffer_size, width_, height_, 0, time_stamp); int ret = renderer_->RenderFrame(&video_frame) ? 0 : -1; uint8* buffer_temp; size_t buffer_size_temp; @@ -392,6 +393,7 @@ bool WebRtcVideoEngine::SetLocalRenderer(VideoRenderer* renderer) { if (local_renderer_.get()) { // If the renderer already set, stop it first vie_wrapper_->render()->StopRender(capture_id_); + vie_wrapper_->render()->RemoveRenderer(capture_id_); } local_renderer_.reset(new WebRtcRenderAdapter(renderer));