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/webrtc_video_capturer_adapter.h" | 5 #include "content/renderer/media/webrtc/webrtc_video_capturer_adapter.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/aligned_memory.h" | 8 #include "base/memory/aligned_memory.h" |
9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
10 #include "media/base/video_frame.h" | 10 #include "media/base/video_frame.h" |
11 #include "media/base/video_frame_pool.h" | 11 #include "media/base/video_frame_pool.h" |
12 #include "third_party/libjingle/source/talk/media/base/videoframefactory.h" | 12 #include "third_party/libjingle/source/talk/media/base/videoframefactory.h" |
13 #include "third_party/libjingle/source/talk/media/webrtc/webrtcvideoframe.h" | 13 #include "third_party/libjingle/source/talk/media/webrtc/webrtcvideoframe.h" |
14 #include "third_party/libyuv/include/libyuv/convert_from.h" | 14 #include "third_party/libyuv/include/libyuv/convert_from.h" |
15 #include "third_party/libyuv/include/libyuv/scale.h" | 15 #include "third_party/libyuv/include/libyuv/scale.h" |
16 #include "third_party/webrtc/common_video/interface/video_frame_buffer.h" | 16 #include "third_party/webrtc/common_video/interface/video_frame_buffer.h" |
| 17 #include "third_party/webrtc/common_video/rotation.h" |
17 | 18 |
18 namespace content { | 19 namespace content { |
19 namespace { | 20 namespace { |
20 | 21 |
21 // Empty method used for keeping a reference to the original media::VideoFrame. | 22 // Empty method used for keeping a reference to the original media::VideoFrame. |
22 // The reference to |frame| is kept in the closure that calls this method. | 23 // The reference to |frame| is kept in the closure that calls this method. |
23 void ReleaseOriginalFrame(const scoped_refptr<media::VideoFrame>& frame) { | 24 void ReleaseOriginalFrame(const scoped_refptr<media::VideoFrame>& frame) { |
24 } | 25 } |
25 | 26 |
26 int WebRtcToMediaPlaneType(webrtc::PlaneType type) { | 27 int WebRtcToMediaPlaneType(webrtc::PlaneType type) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 DCHECK(frame.get()); | 90 DCHECK(frame.get()); |
90 // Create a CapturedFrame that only contains header information, not the | 91 // Create a CapturedFrame that only contains header information, not the |
91 // actual pixel data. | 92 // actual pixel data. |
92 captured_frame_.width = frame->natural_size().width(); | 93 captured_frame_.width = frame->natural_size().width(); |
93 captured_frame_.height = frame->natural_size().height(); | 94 captured_frame_.height = frame->natural_size().height(); |
94 captured_frame_.elapsed_time = elapsed_time; | 95 captured_frame_.elapsed_time = elapsed_time; |
95 captured_frame_.time_stamp = frame->timestamp().InMicroseconds() * | 96 captured_frame_.time_stamp = frame->timestamp().InMicroseconds() * |
96 base::Time::kNanosecondsPerMicrosecond; | 97 base::Time::kNanosecondsPerMicrosecond; |
97 captured_frame_.pixel_height = 1; | 98 captured_frame_.pixel_height = 1; |
98 captured_frame_.pixel_width = 1; | 99 captured_frame_.pixel_width = 1; |
99 captured_frame_.rotation = 0; | 100 captured_frame_.rotation = webrtc::kVideoRotation_0; |
100 captured_frame_.data = NULL; | 101 captured_frame_.data = NULL; |
101 captured_frame_.data_size = cricket::CapturedFrame::kUnknownDataSize; | 102 captured_frame_.data_size = cricket::CapturedFrame::kUnknownDataSize; |
102 captured_frame_.fourcc = static_cast<uint32>(cricket::FOURCC_ANY); | 103 captured_frame_.fourcc = static_cast<uint32>(cricket::FOURCC_ANY); |
103 | 104 |
104 frame_ = frame; | 105 frame_ = frame; |
105 } | 106 } |
106 | 107 |
107 void ReleaseFrame() { frame_ = NULL; } | 108 void ReleaseFrame() { frame_ = NULL; } |
108 | 109 |
109 const cricket::CapturedFrame* GetCapturedFrame() const { | 110 const cricket::CapturedFrame* GetCapturedFrame() const { |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 DCHECK(frame_factory_ == frame_factory()); | 278 DCHECK(frame_factory_ == frame_factory()); |
278 frame_factory_->SetFrame(frame, elapsed_time); | 279 frame_factory_->SetFrame(frame, elapsed_time); |
279 | 280 |
280 // This signals to libJingle that a new VideoFrame is available. | 281 // This signals to libJingle that a new VideoFrame is available. |
281 SignalFrameCaptured(this, frame_factory_->GetCapturedFrame()); | 282 SignalFrameCaptured(this, frame_factory_->GetCapturedFrame()); |
282 | 283 |
283 frame_factory_->ReleaseFrame(); // Release the frame ASAP. | 284 frame_factory_->ReleaseFrame(); // Release the frame ASAP. |
284 } | 285 } |
285 | 286 |
286 } // namespace content | 287 } // namespace content |
OLD | NEW |