Chromium Code Reviews

Side by Side Diff: content/renderer/media/webrtc/media_stream_remote_video_source.cc

Issue 1919283005: Eliminate calls to cricket::VideoFrame's GetNativeHandle, GetYPlane. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/media/webrtc/media_stream_remote_video_source.h" 5 #include "content/renderer/media/webrtc/media_stream_remote_video_source.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 75 matching lines...)
86 TRACE_EVENT1("webrtc", "RemoteVideoSourceDelegate::RenderFrame", 86 TRACE_EVENT1("webrtc", "RemoteVideoSourceDelegate::RenderFrame",
87 "Ideal Render Instant", render_time.ToInternalValue()); 87 "Ideal Render Instant", render_time.ToInternalValue());
88 88
89 CHECK_NE(media::kNoTimestamp(), incoming_timestamp); 89 CHECK_NE(media::kNoTimestamp(), incoming_timestamp);
90 if (start_timestamp_ == media::kNoTimestamp()) 90 if (start_timestamp_ == media::kNoTimestamp())
91 start_timestamp_ = incoming_timestamp; 91 start_timestamp_ = incoming_timestamp;
92 const base::TimeDelta elapsed_timestamp = 92 const base::TimeDelta elapsed_timestamp =
93 incoming_timestamp - start_timestamp_; 93 incoming_timestamp - start_timestamp_;
94 94
95 scoped_refptr<media::VideoFrame> video_frame; 95 scoped_refptr<media::VideoFrame> video_frame;
96 if (incoming_frame.GetNativeHandle() != NULL) { 96 if (incoming_frame.video_frame_buffer()->native_handle() != NULL) {
97 video_frame = 97 video_frame =
98 static_cast<media::VideoFrame*>(incoming_frame.GetNativeHandle()); 98 static_cast<media::VideoFrame*>(
99 incoming_frame.video_frame_buffer()->native_handle());
99 video_frame->set_timestamp(elapsed_timestamp); 100 video_frame->set_timestamp(elapsed_timestamp);
100 } else { 101 } else {
101 const cricket::VideoFrame* frame = 102 const cricket::VideoFrame* frame =
102 incoming_frame.GetCopyWithRotationApplied(); 103 incoming_frame.GetCopyWithRotationApplied();
103 104
104 gfx::Size size(frame->width(), frame->height()); 105 gfx::Size size(frame->width(), frame->height());
105 106
106 // Make a shallow copy. Both |frame| and |video_frame| will share a single 107 // Make a shallow copy. Both |frame| and |video_frame| will share a single
107 // reference counted frame buffer. Const cast and hope no one will overwrite 108 // reference counted frame buffer. Const cast and hope no one will overwrite
108 // the data. 109 // the data.
109 // TODO(magjed): Update media::VideoFrame to support const data so we don't 110 // TODO(magjed): Update media::VideoFrame to support const data so we don't
110 // need to const cast here. 111 // need to const cast here.
111 video_frame = media::VideoFrame::WrapExternalYuvData( 112 video_frame = media::VideoFrame::WrapExternalYuvData(
112 media::PIXEL_FORMAT_YV12, size, gfx::Rect(size), size, 113 media::PIXEL_FORMAT_YV12, size, gfx::Rect(size), size,
113 frame->GetYPitch(), frame->GetUPitch(), frame->GetVPitch(), 114 frame->video_frame_buffer()->StrideY(),
114 const_cast<uint8_t*>(frame->GetYPlane()), 115 frame->video_frame_buffer()->StrideU(),
115 const_cast<uint8_t*>(frame->GetUPlane()), 116 frame->video_frame_buffer()->StrideV(),
116 const_cast<uint8_t*>(frame->GetVPlane()), elapsed_timestamp); 117 const_cast<uint8_t*>(frame->video_frame_buffer()->DataY()),
118 const_cast<uint8_t*>(frame->video_frame_buffer()->DataU()),
119 const_cast<uint8_t*>(frame->video_frame_buffer()->DataV()),
120 elapsed_timestamp);
117 if (!video_frame) 121 if (!video_frame)
118 return; 122 return;
119 video_frame->AddDestructionObserver( 123 video_frame->AddDestructionObserver(
120 base::Bind(&base::DeletePointer<cricket::VideoFrame>, frame->Copy())); 124 base::Bind(&base::DeletePointer<cricket::VideoFrame>, frame->Copy()));
121 } 125 }
122 126
123 video_frame->metadata()->SetTimeTicks( 127 video_frame->metadata()->SetTimeTicks(
124 media::VideoFrameMetadata::REFERENCE_TIME, render_time); 128 media::VideoFrameMetadata::REFERENCE_TIME, render_time);
125 129
126 io_task_runner_->PostTask( 130 io_task_runner_->PostTask(
(...skipping 85 matching lines...)
212 case webrtc::MediaStreamTrackInterface::kEnded: 216 case webrtc::MediaStreamTrackInterface::kEnded:
213 SetReadyState(blink::WebMediaStreamSource::ReadyStateEnded); 217 SetReadyState(blink::WebMediaStreamSource::ReadyStateEnded);
214 break; 218 break;
215 default: 219 default:
216 NOTREACHED(); 220 NOTREACHED();
217 break; 221 break;
218 } 222 }
219 } 223 }
220 224
221 } // namespace content 225 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine