| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 #if !defined(__has_feature) || !__has_feature(objc_arc) | 11 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 12 #error "This file requires ARC support." | 12 #error "This file requires ARC support." |
| 13 #endif | 13 #endif |
| 14 | 14 |
| 15 #include "webrtc/base/refcount.h" | 15 #include "webrtc/base/refcount.h" |
| 16 #include "webrtc/base/scoped_ref_ptr.h" | 16 #include "webrtc/base/scoped_ref_ptr.h" |
| 17 #include "webrtc/modules/video_capture/ios/device_info_ios_objc.h" | 17 #include "webrtc/modules/video_capture/objc/device_info_objc.h" |
| 18 #include "webrtc/modules/video_capture/ios/rtc_video_capture_ios_objc.h" | 18 #include "webrtc/modules/video_capture/objc/rtc_video_capture_objc.h" |
| 19 #include "webrtc/system_wrappers/include/trace.h" | 19 #include "webrtc/system_wrappers/include/trace.h" |
| 20 | 20 |
| 21 using namespace webrtc; | 21 using namespace webrtc; |
| 22 using namespace videocapturemodule; | 22 using namespace videocapturemodule; |
| 23 | 23 |
| 24 rtc::scoped_refptr<VideoCaptureModule> VideoCaptureImpl::Create( | 24 rtc::scoped_refptr<VideoCaptureModule> VideoCaptureImpl::Create( |
| 25 const int32_t capture_id, | 25 const int32_t capture_id, |
| 26 const char* deviceUniqueIdUTF8) { | 26 const char* deviceUniqueIdUTF8) { |
| 27 return VideoCaptureIos::Create(capture_id, deviceUniqueIdUTF8); | 27 return VideoCaptureIos::Create(capture_id, deviceUniqueIdUTF8); |
| 28 } | 28 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 strncpy(capture_module->_deviceUniqueId, deviceUniqueIdUTF8, name_length + 1); | 60 strncpy(capture_module->_deviceUniqueId, deviceUniqueIdUTF8, name_length + 1); |
| 61 capture_module->_deviceUniqueId[name_length] = '\0'; | 61 capture_module->_deviceUniqueId[name_length] = '\0'; |
| 62 | 62 |
| 63 capture_module->capture_device_ = | 63 capture_module->capture_device_ = |
| 64 [[RTCVideoCaptureIosObjC alloc] initWithOwner:capture_module | 64 [[RTCVideoCaptureIosObjC alloc] initWithOwner:capture_module |
| 65 captureId:capture_module->id_]; | 65 captureId:capture_module->id_]; |
| 66 if (!capture_module->capture_device_) { | 66 if (!capture_module->capture_device_) { |
| 67 return nullptr; | 67 return nullptr; |
| 68 } | 68 } |
| 69 | 69 |
| 70 if (![capture_module->capture_device_ setCaptureDeviceByUniqueId:[ | 70 if (![capture_module->capture_device_ |
| 71 [NSString alloc] initWithCString:deviceUniqueIdUTF8 | 71 setCaptureDeviceByUniqueId: |
| 72 encoding:NSUTF8StringEncoding]]) { | 72 [[NSString alloc] initWithCString:deviceUniqueIdUTF8 |
| 73 encoding:NSUTF8StringEncoding]]) { |
| 73 return nullptr; | 74 return nullptr; |
| 74 } | 75 } |
| 75 return capture_module; | 76 return capture_module; |
| 76 } | 77 } |
| 77 | 78 |
| 78 int32_t VideoCaptureIos::StartCapture( | 79 int32_t VideoCaptureIos::StartCapture( |
| 79 const VideoCaptureCapability& capability) { | 80 const VideoCaptureCapability& capability) { |
| 80 capability_ = capability; | 81 capability_ = capability; |
| 81 | 82 |
| 82 if (![capture_device_ startCaptureWithCapability:capability]) { | 83 if (![capture_device_ startCaptureWithCapability:capability]) { |
| 83 return -1; | 84 return -1; |
| 84 } | 85 } |
| 85 | 86 |
| 86 is_capturing_ = true; | 87 is_capturing_ = true; |
| 87 | 88 |
| 88 return 0; | 89 return 0; |
| 89 } | 90 } |
| 90 | 91 |
| 91 int32_t VideoCaptureIos::StopCapture() { | 92 int32_t VideoCaptureIos::StopCapture() { |
| 92 if (![capture_device_ stopCapture]) { | 93 if (![capture_device_ stopCapture]) { |
| 93 return -1; | 94 return -1; |
| 94 } | 95 } |
| 95 | 96 |
| 96 is_capturing_ = false; | 97 is_capturing_ = false; |
| 97 return 0; | 98 return 0; |
| 98 } | 99 } |
| 99 | 100 |
| 100 bool VideoCaptureIos::CaptureStarted() { return is_capturing_; } | 101 bool VideoCaptureIos::CaptureStarted() { |
| 102 return is_capturing_; |
| 103 } |
| 101 | 104 |
| 102 int32_t VideoCaptureIos::CaptureSettings(VideoCaptureCapability& settings) { | 105 int32_t VideoCaptureIos::CaptureSettings(VideoCaptureCapability& settings) { |
| 103 settings = capability_; | 106 settings = capability_; |
| 104 settings.rawType = kVideoNV12; | 107 settings.rawType = kVideoNV12; |
| 105 return 0; | 108 return 0; |
| 106 } | 109 } |
| OLD | NEW |