Commit c935fa23 authored by nisse's avatar nisse Committed by Commit bot

Delete only call to cricket::VideoFrame::Copy.

BUG=webrtc:5682

Review-Url: https://codereview.chromium.org/2068703002
Cr-Commit-Position: refs/heads/master@{#400649}
parent 3a991766
...@@ -72,6 +72,10 @@ MediaStreamRemoteVideoSource:: ...@@ -72,6 +72,10 @@ MediaStreamRemoteVideoSource::
RemoteVideoSourceDelegate::~RemoteVideoSourceDelegate() { RemoteVideoSourceDelegate::~RemoteVideoSourceDelegate() {
} }
namespace {
void DoNothing(const scoped_refptr<rtc::RefCountInterface>& ref) {}
} // anonymous
void MediaStreamRemoteVideoSource::RemoteVideoSourceDelegate::OnFrame( void MediaStreamRemoteVideoSource::RemoteVideoSourceDelegate::OnFrame(
const cricket::VideoFrame& incoming_frame) { const cricket::VideoFrame& incoming_frame) {
const base::TimeDelta incoming_timestamp = base::TimeDelta::FromMicroseconds( const base::TimeDelta incoming_timestamp = base::TimeDelta::FromMicroseconds(
...@@ -89,16 +93,19 @@ void MediaStreamRemoteVideoSource::RemoteVideoSourceDelegate::OnFrame( ...@@ -89,16 +93,19 @@ void MediaStreamRemoteVideoSource::RemoteVideoSourceDelegate::OnFrame(
incoming_timestamp - start_timestamp_; incoming_timestamp - start_timestamp_;
scoped_refptr<media::VideoFrame> video_frame; scoped_refptr<media::VideoFrame> video_frame;
if (incoming_frame.video_frame_buffer()->native_handle() != NULL) { scoped_refptr<webrtc::VideoFrameBuffer> buffer(
incoming_frame.video_frame_buffer());
if (buffer->native_handle() != NULL) {
video_frame = video_frame =
static_cast<media::VideoFrame*>( static_cast<media::VideoFrame*>(buffer->native_handle());
incoming_frame.video_frame_buffer()->native_handle());
video_frame->set_timestamp(elapsed_timestamp); video_frame->set_timestamp(elapsed_timestamp);
} else { } else {
const cricket::VideoFrame* frame = // Note that the GetCopyWithRotationApplied returns a pointer to a
incoming_frame.GetCopyWithRotationApplied(); // frame owned by incoming_frame.
buffer =
gfx::Size size(frame->width(), frame->height()); incoming_frame.GetCopyWithRotationApplied()->video_frame_buffer();
gfx::Size size(buffer->width(), buffer->height());
// Make a shallow copy. Both |frame| and |video_frame| will share a single // Make a shallow copy. Both |frame| and |video_frame| will share a single
// reference counted frame buffer. Const cast and hope no one will overwrite // reference counted frame buffer. Const cast and hope no one will overwrite
...@@ -107,17 +114,17 @@ void MediaStreamRemoteVideoSource::RemoteVideoSourceDelegate::OnFrame( ...@@ -107,17 +114,17 @@ void MediaStreamRemoteVideoSource::RemoteVideoSourceDelegate::OnFrame(
// need to const cast here. // need to const cast here.
video_frame = media::VideoFrame::WrapExternalYuvData( video_frame = media::VideoFrame::WrapExternalYuvData(
media::PIXEL_FORMAT_YV12, size, gfx::Rect(size), size, media::PIXEL_FORMAT_YV12, size, gfx::Rect(size), size,
frame->video_frame_buffer()->StrideY(), buffer->StrideY(),
frame->video_frame_buffer()->StrideU(), buffer->StrideU(),
frame->video_frame_buffer()->StrideV(), buffer->StrideV(),
const_cast<uint8_t*>(frame->video_frame_buffer()->DataY()), const_cast<uint8_t*>(buffer->DataY()),
const_cast<uint8_t*>(frame->video_frame_buffer()->DataU()), const_cast<uint8_t*>(buffer->DataU()),
const_cast<uint8_t*>(frame->video_frame_buffer()->DataV()), const_cast<uint8_t*>(buffer->DataV()),
elapsed_timestamp); elapsed_timestamp);
if (!video_frame) if (!video_frame)
return; return;
video_frame->AddDestructionObserver( // The bind ensures that we keep a reference to the underlying buffer.
base::Bind(&base::DeletePointer<cricket::VideoFrame>, frame->Copy())); video_frame->AddDestructionObserver(base::Bind(&DoNothing, buffer));
} }
video_frame->metadata()->SetTimeTicks( video_frame->metadata()->SetTimeTicks(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment