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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 | 81 |
82 // Non-square pixels are unsupported. | 82 // Non-square pixels are unsupported. |
83 DCHECK_EQ(frame->GetPixelWidth(), 1u); | 83 DCHECK_EQ(frame->GetPixelWidth(), 1u); |
84 DCHECK_EQ(frame->GetPixelHeight(), 1u); | 84 DCHECK_EQ(frame->GetPixelHeight(), 1u); |
85 | 85 |
86 // Make a shallow copy. Both |frame| and |video_frame| will share a single | 86 // Make a shallow copy. Both |frame| and |video_frame| will share a single |
87 // reference counted frame buffer. Const cast and hope no one will overwrite | 87 // reference counted frame buffer. Const cast and hope no one will overwrite |
88 // the data. | 88 // the data. |
89 // TODO(magjed): Update media::VideoFrame to support const data so we don't | 89 // TODO(magjed): Update media::VideoFrame to support const data so we don't |
90 // need to const cast here. | 90 // need to const cast here. |
| 91 scoped_ptr<cricket::VideoFrame> frame_copy(frame->Copy()); |
91 video_frame = media::VideoFrame::WrapExternalYuvData( | 92 video_frame = media::VideoFrame::WrapExternalYuvData( |
92 media::VideoFrame::YV12, size, gfx::Rect(size), size, | 93 media::VideoFrame::YV12, size, gfx::Rect(size), size, |
93 frame->GetYPitch(), frame->GetUPitch(), frame->GetVPitch(), | 94 frame->GetYPitch(), frame->GetUPitch(), frame->GetVPitch(), |
94 const_cast<uint8_t*>(frame->GetYPlane()), | 95 const_cast<uint8_t*>(frame->GetYPlane()), |
95 const_cast<uint8_t*>(frame->GetUPlane()), | 96 const_cast<uint8_t*>(frame->GetUPlane()), |
96 const_cast<uint8_t*>(frame->GetVPlane()), timestamp, | 97 const_cast<uint8_t*>(frame->GetVPlane()), timestamp, |
97 base::Bind(&base::DeletePointer<cricket::VideoFrame>, frame->Copy())); | 98 base::Bind(&base::DeletePointer<cricket::VideoFrame>, |
| 99 base::Passed(&frame_copy))); |
98 } | 100 } |
99 | 101 |
100 io_message_loop_->PostTask( | 102 io_message_loop_->PostTask( |
101 FROM_HERE, | 103 FROM_HERE, |
102 base::Bind(&RemoteVideoSourceDelegate::DoRenderFrameOnIOThread, | 104 base::Bind(&RemoteVideoSourceDelegate::DoRenderFrameOnIOThread, |
103 this, video_frame)); | 105 this, video_frame)); |
104 } | 106 } |
105 | 107 |
106 void MediaStreamRemoteVideoSource:: | 108 void MediaStreamRemoteVideoSource:: |
107 RemoteVideoSourceDelegate::DoRenderFrameOnIOThread( | 109 RemoteVideoSourceDelegate::DoRenderFrameOnIOThread( |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 case webrtc::MediaStreamTrackInterface::kEnded: | 178 case webrtc::MediaStreamTrackInterface::kEnded: |
177 SetReadyState(blink::WebMediaStreamSource::ReadyStateEnded); | 179 SetReadyState(blink::WebMediaStreamSource::ReadyStateEnded); |
178 break; | 180 break; |
179 default: | 181 default: |
180 NOTREACHED(); | 182 NOTREACHED(); |
181 break; | 183 break; |
182 } | 184 } |
183 } | 185 } |
184 | 186 |
185 } // namespace content | 187 } // namespace content |
OLD | NEW |