Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1798)

Side by Side Diff: webrtc/api/androidvideocapturer.cc

Issue 1655793003: Make cricket::VideoCapturer implement VideoSourceInterface (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Added dummy capturerenderadapter.cc Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « talk/session/media/channelmanager.cc ('k') | webrtc/api/remotevideocapturer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/api/androidvideocapturer.h" 11 #include "webrtc/api/androidvideocapturer.h"
12 12
13 #include "webrtc/api/java/jni/native_handle_impl.h" 13 #include "webrtc/api/java/jni/native_handle_impl.h"
14 #include "webrtc/base/common.h" 14 #include "webrtc/base/common.h"
15 #include "webrtc/base/json.h" 15 #include "webrtc/base/json.h"
16 #include "webrtc/base/timeutils.h" 16 #include "webrtc/base/timeutils.h"
17 #include "webrtc/media/webrtc/webrtcvideoframe.h" 17 #include "webrtc/media/webrtc/webrtcvideoframe.h"
18 18
19 namespace webrtc { 19 namespace webrtc {
20 20
21 // A hack for avoiding deep frame copies in 21 // A hack for avoiding deep frame copies in
22 // cricket::VideoCapturer.SignalFrameCaptured() using a custom FrameFactory. 22 // cricket::VideoCapturer.SignalFrameCaptured() using a custom FrameFactory.
23 // A frame is injected using UpdateCapturedFrame(), and converted into a 23 // A frame is injected using UpdateCapturedFrame(), and converted into a
24 // cricket::VideoFrame with CreateAliasedFrame(). UpdateCapturedFrame() should 24 // cricket::VideoFrame with CreateAliasedFrame(). UpdateCapturedFrame() should
25 // be called before CreateAliasedFrame() for every frame. 25 // be called before CreateAliasedFrame() for every frame.
26 // TODO(magjed): Add an interface cricket::VideoCapturer::OnFrameCaptured() 26 // TODO(magjed): Add an interface cricket::VideoCapturer::OnFrameCaptured()
27 // for ref counted I420 frames instead of this hack. 27 // for ref counted I420 frames instead of this hack.
28 class AndroidVideoCapturer::FrameFactory : public cricket::VideoFrameFactory { 28 class AndroidVideoCapturer::FrameFactory : public cricket::VideoFrameFactory {
29 public: 29 public:
30 FrameFactory(const rtc::scoped_refptr<AndroidVideoCapturerDelegate>& delegate) 30 explicit FrameFactory(
31 const rtc::scoped_refptr<AndroidVideoCapturerDelegate>& delegate)
31 : delegate_(delegate) { 32 : delegate_(delegate) {
32 // Create a CapturedFrame that only contains header information, not the 33 // Create a CapturedFrame that only contains header information, not the
33 // actual pixel data. 34 // actual pixel data.
34 captured_frame_.pixel_height = 1; 35 captured_frame_.pixel_height = 1;
35 captured_frame_.pixel_width = 1; 36 captured_frame_.pixel_width = 1;
36 captured_frame_.data = nullptr; 37 captured_frame_.data = nullptr;
37 captured_frame_.data_size = cricket::CapturedFrame::kUnknownDataSize; 38 captured_frame_.data_size = cricket::CapturedFrame::kUnknownDataSize;
38 captured_frame_.fourcc = static_cast<uint32_t>(cricket::FOURCC_ANY); 39 captured_frame_.fourcc = static_cast<uint32_t>(cricket::FOURCC_ANY);
39 } 40 }
40 41
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 !json_value["height"].isNull() && 135 !json_value["height"].isNull() &&
135 !json_value["framerate"].isNull()); 136 !json_value["framerate"].isNull());
136 cricket::VideoFormat format( 137 cricket::VideoFormat format(
137 json_value["width"].asInt(), 138 json_value["width"].asInt(),
138 json_value["height"].asInt(), 139 json_value["height"].asInt(),
139 cricket::VideoFormat::FpsToInterval(json_value["framerate"].asInt()), 140 cricket::VideoFormat::FpsToInterval(json_value["framerate"].asInt()),
140 cricket::FOURCC_YV12); 141 cricket::FOURCC_YV12);
141 formats.push_back(format); 142 formats.push_back(format);
142 } 143 }
143 SetSupportedFormats(formats); 144 SetSupportedFormats(formats);
144 // Do not apply frame rotation by default.
145 SetApplyRotation(false);
146 } 145 }
147 146
148 AndroidVideoCapturer::~AndroidVideoCapturer() { 147 AndroidVideoCapturer::~AndroidVideoCapturer() {
149 RTC_CHECK(!running_); 148 RTC_CHECK(!running_);
150 } 149 }
151 150
152 cricket::CaptureState AndroidVideoCapturer::Start( 151 cricket::CaptureState AndroidVideoCapturer::Start(
153 const cricket::VideoFormat& capture_format) { 152 const cricket::VideoFormat& capture_format) {
154 RTC_CHECK(thread_checker_.CalledOnValidThread()); 153 RTC_CHECK(thread_checker_.CalledOnValidThread());
155 RTC_CHECK(!running_); 154 RTC_CHECK(!running_);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 224
226 bool AndroidVideoCapturer::GetBestCaptureFormat( 225 bool AndroidVideoCapturer::GetBestCaptureFormat(
227 const cricket::VideoFormat& desired, 226 const cricket::VideoFormat& desired,
228 cricket::VideoFormat* best_format) { 227 cricket::VideoFormat* best_format) {
229 // Delegate this choice to VideoCapturerAndroid.startCapture(). 228 // Delegate this choice to VideoCapturerAndroid.startCapture().
230 *best_format = desired; 229 *best_format = desired;
231 return true; 230 return true;
232 } 231 }
233 232
234 } // namespace webrtc 233 } // namespace webrtc
OLDNEW
« no previous file with comments | « talk/session/media/channelmanager.cc ('k') | webrtc/api/remotevideocapturer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698