| 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" |
| 11 #include "base/threading/thread_checker.h" | 11 #include "base/threading/thread_checker.h" |
| 12 #include "base/trace_event/trace_event.h" | 12 #include "base/trace_event/trace_event.h" |
| 13 #include "content/renderer/media/native_handle_impl.h" | |
| 14 #include "content/renderer/media/webrtc/track_observer.h" | 13 #include "content/renderer/media/webrtc/track_observer.h" |
| 15 #include "media/base/bind_to_current_loop.h" | 14 #include "media/base/bind_to_current_loop.h" |
| 16 #include "media/base/video_frame.h" | 15 #include "media/base/video_frame.h" |
| 17 #include "media/base/video_util.h" | 16 #include "media/base/video_util.h" |
| 18 #include "third_party/libjingle/source/talk/media/base/videoframe.h" | 17 #include "third_party/libjingle/source/talk/media/base/videoframe.h" |
| 19 | 18 |
| 20 namespace content { | 19 namespace content { |
| 21 | 20 |
| 22 // Internal class used for receiving frames from the webrtc track on a | 21 // Internal class used for receiving frames from the webrtc track on a |
| 23 // libjingle thread and forward it to the IO-thread. | 22 // libjingle thread and forward it to the IO-thread. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 } | 63 } |
| 65 | 64 |
| 66 void MediaStreamRemoteVideoSource::RemoteVideoSourceDelegate::RenderFrame( | 65 void MediaStreamRemoteVideoSource::RemoteVideoSourceDelegate::RenderFrame( |
| 67 const cricket::VideoFrame* incoming_frame) { | 66 const cricket::VideoFrame* incoming_frame) { |
| 68 TRACE_EVENT0("webrtc", "RemoteVideoSourceDelegate::RenderFrame"); | 67 TRACE_EVENT0("webrtc", "RemoteVideoSourceDelegate::RenderFrame"); |
| 69 base::TimeDelta timestamp = base::TimeDelta::FromMicroseconds( | 68 base::TimeDelta timestamp = base::TimeDelta::FromMicroseconds( |
| 70 incoming_frame->GetElapsedTime() / rtc::kNumNanosecsPerMicrosec); | 69 incoming_frame->GetElapsedTime() / rtc::kNumNanosecsPerMicrosec); |
| 71 | 70 |
| 72 scoped_refptr<media::VideoFrame> video_frame; | 71 scoped_refptr<media::VideoFrame> video_frame; |
| 73 if (incoming_frame->GetNativeHandle() != NULL) { | 72 if (incoming_frame->GetNativeHandle() != NULL) { |
| 74 NativeHandleImpl* handle = | 73 video_frame = |
| 75 static_cast<NativeHandleImpl*>(incoming_frame->GetNativeHandle()); | 74 static_cast<media::VideoFrame*>(incoming_frame->GetNativeHandle()); |
| 76 video_frame = static_cast<media::VideoFrame*>(handle->GetHandle()); | |
| 77 video_frame->set_timestamp(timestamp); | 75 video_frame->set_timestamp(timestamp); |
| 78 } else { | 76 } else { |
| 79 const cricket::VideoFrame* frame = | 77 const cricket::VideoFrame* frame = |
| 80 incoming_frame->GetCopyWithRotationApplied(); | 78 incoming_frame->GetCopyWithRotationApplied(); |
| 81 | 79 |
| 82 gfx::Size size(frame->GetWidth(), frame->GetHeight()); | 80 gfx::Size size(frame->GetWidth(), frame->GetHeight()); |
| 83 | 81 |
| 84 // Non-square pixels are unsupported. | 82 // Non-square pixels are unsupported. |
| 85 DCHECK_EQ(frame->GetPixelWidth(), 1u); | 83 DCHECK_EQ(frame->GetPixelWidth(), 1u); |
| 86 DCHECK_EQ(frame->GetPixelHeight(), 1u); | 84 DCHECK_EQ(frame->GetPixelHeight(), 1u); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 case webrtc::MediaStreamTrackInterface::kEnded: | 176 case webrtc::MediaStreamTrackInterface::kEnded: |
| 179 SetReadyState(blink::WebMediaStreamSource::ReadyStateEnded); | 177 SetReadyState(blink::WebMediaStreamSource::ReadyStateEnded); |
| 180 break; | 178 break; |
| 181 default: | 179 default: |
| 182 NOTREACHED(); | 180 NOTREACHED(); |
| 183 break; | 181 break; |
| 184 } | 182 } |
| 185 } | 183 } |
| 186 | 184 |
| 187 } // namespace content | 185 } // namespace content |
| OLD | NEW |