From 7cc92aaf3767ab459cf8a42e5eef50ad555e3e90 Mon Sep 17 00:00:00 2001 From: "pbos@webrtc.org" Date: Wed, 11 Feb 2015 09:03:15 +0000 Subject: [PATCH] Use WebRtcVideoRenderFrame for texture frames. Removes buffer/texture path separation inside WebRtcVideoEngine and DeliverTextureFrame(). This unifies frame delivery with WebRtcVideoEngine2 which is expected to automagically work with texture frames after this change. BUG=1788 R=magjed@webrtc.org Review URL: https://webrtc-codereview.appspot.com/38069005 Cr-Commit-Position: refs/heads/master@{#8326} git-svn-id: http://webrtc.googlecode.com/svn/trunk@8326 4adac7df-926f-26a2-2b94-8c16560cd09d --- talk/media/webrtc/webrtcvideoengine.cc | 19 +++---------------- talk/media/webrtc/webrtcvideoframe.cc | 10 +++++++++- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/talk/media/webrtc/webrtcvideoengine.cc b/talk/media/webrtc/webrtcvideoengine.cc index 32de61c20..56ee28c3c 100644 --- a/talk/media/webrtc/webrtcvideoengine.cc +++ b/talk/media/webrtc/webrtcvideoengine.cc @@ -394,26 +394,13 @@ class WebRtcRenderAdapter : public webrtc::ExternalRenderer { if (!renderer_) { return 0; } - if (webrtc_frame.native_handle() == NULL) { - WebRtcVideoRenderFrame cricket_frame(&webrtc_frame, elapsed_time_ms); - return renderer_->RenderFrame(&cricket_frame) ? 0 : -1; - } else { - return DeliverTextureFrame( - webrtc_frame.native_handle(), - webrtc_frame.render_time_ms() * rtc::kNumNanosecsPerMillisec, - elapsed_time_ms * rtc::kNumNanosecsPerMillisec); - } + + WebRtcVideoRenderFrame cricket_frame(&webrtc_frame, elapsed_time_ms); + return renderer_->RenderFrame(&cricket_frame) ? 0 : -1; } virtual bool IsTextureSupported() { return true; } - int DeliverTextureFrame(void* handle, int64 time_stamp, int64 elapsed_time) { - WebRtcTextureVideoFrame video_frame( - static_cast(handle), width_, height_, - elapsed_time, time_stamp); - return renderer_->RenderFrame(&video_frame); - } - unsigned int width() { rtc::CritScope cs(&crit_); return width_; diff --git a/talk/media/webrtc/webrtcvideoframe.cc b/talk/media/webrtc/webrtcvideoframe.cc index 35337e348..e99930c14 100644 --- a/talk/media/webrtc/webrtcvideoframe.cc +++ b/talk/media/webrtc/webrtcvideoframe.cc @@ -32,6 +32,7 @@ #include "libyuv/planar_functions.h" #include "talk/media/base/videocapturer.h" #include "talk/media/base/videocommon.h" +#include "talk/media/webrtc/webrtctexturevideoframe.h" #include "webrtc/base/logging.h" #include "webrtc/video_frame.h" @@ -453,7 +454,7 @@ int32 WebRtcVideoRenderFrame::GetVPitch() const { } void* WebRtcVideoRenderFrame::GetNativeHandle() const { - return NULL; + return frame_->native_handle(); } size_t WebRtcVideoRenderFrame::GetPixelWidth() const { @@ -487,6 +488,13 @@ webrtc::VideoRotation WebRtcVideoRenderFrame::GetVideoRotation() const { // This can be fixed by making webrtc::I420VideoFrame reference counted, or // adding a similar shallow copy function to it. VideoFrame* WebRtcVideoRenderFrame::Copy() const { + if (frame_->native_handle() != NULL) { + return new WebRtcTextureVideoFrame( + static_cast(frame_->native_handle()), + static_cast(frame_->width()), + static_cast(frame_->height()), GetElapsedTime(), + GetTimeStamp()); + } WebRtcVideoFrame* new_frame = new WebRtcVideoFrame(); new_frame->InitToEmptyBuffer(frame_->width(), frame_->height(), 1, 1, GetElapsedTime(), GetTimeStamp());