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

Side by Side Diff: webrtc/modules/video_capture/objc/video_capture.mm

Issue 2381853002: Revert of Unify the macOS and iOS capturer implementations (Closed)
Patch Set: Created 4 years, 2 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
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #if !defined(__has_feature) || !__has_feature(objc_arc)
12 #error "This file requires ARC support."
13 #endif
14
15 #include "webrtc/base/refcount.h"
16 #include "webrtc/base/scoped_ref_ptr.h"
17 #include "webrtc/modules/video_capture/objc/device_info_objc.h"
18 #include "webrtc/modules/video_capture/objc/rtc_video_capture_objc.h"
19 #include "webrtc/system_wrappers/include/trace.h"
20
21 using namespace webrtc;
22 using namespace videocapturemodule;
23
24 rtc::scoped_refptr<VideoCaptureModule> VideoCaptureImpl::Create(
25 const int32_t capture_id,
26 const char* deviceUniqueIdUTF8) {
27 return VideoCaptureIos::Create(capture_id, deviceUniqueIdUTF8);
28 }
29
30 VideoCaptureIos::VideoCaptureIos(const int32_t capture_id)
31 : VideoCaptureImpl(capture_id), is_capturing_(false), id_(capture_id) {
32 capability_.width = kDefaultWidth;
33 capability_.height = kDefaultHeight;
34 capability_.maxFPS = kDefaultFrameRate;
35 capture_device_ = nil;
36 }
37
38 VideoCaptureIos::~VideoCaptureIos() {
39 if (is_capturing_) {
40 [capture_device_ stopCapture];
41 capture_device_ = nil;
42 }
43 }
44
45 rtc::scoped_refptr<VideoCaptureModule> VideoCaptureIos::Create(
46 const int32_t capture_id,
47 const char* deviceUniqueIdUTF8) {
48 if (!deviceUniqueIdUTF8[0]) {
49 return NULL;
50 }
51
52 rtc::scoped_refptr<VideoCaptureIos> capture_module(
53 new rtc::RefCountedObject<VideoCaptureIos>(capture_id));
54
55 const int32_t name_length = strlen(deviceUniqueIdUTF8);
56 if (name_length > kVideoCaptureUniqueNameLength)
57 return nullptr;
58
59 capture_module->_deviceUniqueId = new char[name_length + 1];
60 strncpy(capture_module->_deviceUniqueId, deviceUniqueIdUTF8, name_length + 1);
61 capture_module->_deviceUniqueId[name_length] = '\0';
62
63 capture_module->capture_device_ =
64 [[RTCVideoCaptureIosObjC alloc] initWithOwner:capture_module
65 captureId:capture_module->id_];
66 if (!capture_module->capture_device_) {
67 return nullptr;
68 }
69
70 if (![capture_module->capture_device_
71 setCaptureDeviceByUniqueId:
72 [[NSString alloc] initWithCString:deviceUniqueIdUTF8
73 encoding:NSUTF8StringEncoding]]) {
74 return nullptr;
75 }
76 return capture_module;
77 }
78
79 int32_t VideoCaptureIos::StartCapture(
80 const VideoCaptureCapability& capability) {
81 capability_ = capability;
82
83 if (![capture_device_ startCaptureWithCapability:capability]) {
84 return -1;
85 }
86
87 is_capturing_ = true;
88
89 return 0;
90 }
91
92 int32_t VideoCaptureIos::StopCapture() {
93 if (![capture_device_ stopCapture]) {
94 return -1;
95 }
96
97 is_capturing_ = false;
98 return 0;
99 }
100
101 bool VideoCaptureIos::CaptureStarted() {
102 return is_capturing_;
103 }
104
105 int32_t VideoCaptureIos::CaptureSettings(VideoCaptureCapability& settings) {
106 settings = capability_;
107 settings.rawType = kVideoNV12;
108 return 0;
109 }
OLDNEW
« no previous file with comments | « webrtc/modules/video_capture/objc/video_capture.h ('k') | webrtc/modules/video_capture/video_capture.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698