OLD | NEW |
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" |
11 #include "base/callback_helpers.h" | 11 #include "base/callback_helpers.h" |
12 #include "base/location.h" | 12 #include "base/location.h" |
13 #include "base/trace_event/trace_event.h" | 13 #include "base/trace_event/trace_event.h" |
14 #include "content/renderer/media/webrtc/track_observer.h" | 14 #include "content/renderer/media/webrtc/track_observer.h" |
15 #include "media/base/bind_to_current_loop.h" | 15 #include "media/base/bind_to_current_loop.h" |
16 #include "media/base/timestamp_constants.h" | 16 #include "media/base/timestamp_constants.h" |
17 #include "media/base/video_frame.h" | 17 #include "media/base/video_frame.h" |
18 #include "media/base/video_util.h" | 18 #include "media/base/video_util.h" |
| 19 #include "third_party/webrtc/api/video/i420_buffer.h" |
19 #include "third_party/webrtc/media/base/videosinkinterface.h" | 20 #include "third_party/webrtc/media/base/videosinkinterface.h" |
20 | 21 |
21 namespace content { | 22 namespace content { |
22 | 23 |
23 namespace { | 24 namespace { |
24 | 25 |
25 media::VideoRotation WebRTCToMediaVideoRotation( | 26 media::VideoRotation WebRTCToMediaVideoRotation( |
26 webrtc::VideoRotation rotation) { | 27 webrtc::VideoRotation rotation) { |
27 switch (rotation) { | 28 switch (rotation) { |
28 case webrtc::kVideoRotation_0: | 29 case webrtc::kVideoRotation_0: |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 | 117 |
117 if (buffer->native_handle() != NULL) { | 118 if (buffer->native_handle() != NULL) { |
118 video_frame = static_cast<media::VideoFrame*>(buffer->native_handle()); | 119 video_frame = static_cast<media::VideoFrame*>(buffer->native_handle()); |
119 video_frame->set_timestamp(elapsed_timestamp); | 120 video_frame->set_timestamp(elapsed_timestamp); |
120 if (incoming_frame.rotation() != webrtc::kVideoRotation_0) { | 121 if (incoming_frame.rotation() != webrtc::kVideoRotation_0) { |
121 video_frame->metadata()->SetRotation( | 122 video_frame->metadata()->SetRotation( |
122 media::VideoFrameMetadata::ROTATION, | 123 media::VideoFrameMetadata::ROTATION, |
123 WebRTCToMediaVideoRotation(incoming_frame.rotation())); | 124 WebRTCToMediaVideoRotation(incoming_frame.rotation())); |
124 } | 125 } |
125 } else { | 126 } else { |
126 buffer = webrtc::I420Buffer::Rotate(incoming_frame.video_frame_buffer(), | 127 buffer = webrtc::I420Buffer::Rotate(*incoming_frame.video_frame_buffer(), |
127 incoming_frame.rotation()); | 128 incoming_frame.rotation()); |
128 | 129 |
129 gfx::Size size(buffer->width(), buffer->height()); | 130 gfx::Size size(buffer->width(), buffer->height()); |
130 | 131 |
131 // Make a shallow copy. Both |frame| and |video_frame| will share a single | 132 // Make a shallow copy. Both |frame| and |video_frame| will share a single |
132 // reference counted frame buffer. Const cast and hope no one will overwrite | 133 // reference counted frame buffer. Const cast and hope no one will overwrite |
133 // the data. | 134 // the data. |
134 // TODO(magjed): Update media::VideoFrame to support const data so we don't | 135 // TODO(magjed): Update media::VideoFrame to support const data so we don't |
135 // need to const cast here. | 136 // need to const cast here. |
136 video_frame = media::VideoFrame::WrapExternalYuvData( | 137 video_frame = media::VideoFrame::WrapExternalYuvData( |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 case webrtc::MediaStreamTrackInterface::kEnded: | 241 case webrtc::MediaStreamTrackInterface::kEnded: |
241 SetReadyState(blink::WebMediaStreamSource::kReadyStateEnded); | 242 SetReadyState(blink::WebMediaStreamSource::kReadyStateEnded); |
242 break; | 243 break; |
243 default: | 244 default: |
244 NOTREACHED(); | 245 NOTREACHED(); |
245 break; | 246 break; |
246 } | 247 } |
247 } | 248 } |
248 | 249 |
249 } // namespace content | 250 } // namespace content |
OLD | NEW |