This is in preparation for deleting the include in rtc_base/refcount.h, but that change has to wait for some downstream applications to not rely in the indirect include. Partial reland of "Make rtc_base/refcount.h self contained, not including refcountedobject.h." This is a reland of b7239a9dc825ddb25dbc800aed3a065163b9a10e Original change's description: > Make rtc_base/refcount.h self contained, not including refcountedobject.h. > > The refcount.h file doesn't depend on anything from > refcountedobject.h. The motivation of this change to make it possible > to add additional declarations to refcount.h, and include it from > refcountedobject.h. > > Bug: webrtc:8270 > Change-Id: I24f6131f471e675570968d00065ff9b1f55e3373 > Reviewed-on: https://webrtc-review.googlesource.com/5760 > Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> > Commit-Queue: Niels Moller <nisse@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#20106} Bug: webrtc:8270 Change-Id: I63a42712f6c1ec83823c629d1a954fd1a04d4a6c Reviewed-on: https://webrtc-review.googlesource.com/7281 Commit-Queue: Karl Wiberg <kwiberg@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20185}
107 lines
2.9 KiB
Plaintext
107 lines
2.9 KiB
Plaintext
/*
|
|
* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
#if !defined(__has_feature) || !__has_feature(objc_arc)
|
|
#error "This file requires ARC support."
|
|
#endif
|
|
|
|
#include "modules/video_capture/objc/device_info_objc.h"
|
|
#include "modules/video_capture/objc/rtc_video_capture_objc.h"
|
|
#include "rtc_base/refcount.h"
|
|
#include "rtc_base/refcountedobject.h"
|
|
#include "rtc_base/scoped_ref_ptr.h"
|
|
|
|
using namespace webrtc;
|
|
using namespace videocapturemodule;
|
|
|
|
rtc::scoped_refptr<VideoCaptureModule> VideoCaptureImpl::Create(
|
|
const char* deviceUniqueIdUTF8) {
|
|
return VideoCaptureIos::Create(deviceUniqueIdUTF8);
|
|
}
|
|
|
|
VideoCaptureIos::VideoCaptureIos()
|
|
: is_capturing_(false) {
|
|
capability_.width = kDefaultWidth;
|
|
capability_.height = kDefaultHeight;
|
|
capability_.maxFPS = kDefaultFrameRate;
|
|
capture_device_ = nil;
|
|
}
|
|
|
|
VideoCaptureIos::~VideoCaptureIos() {
|
|
if (is_capturing_) {
|
|
[capture_device_ stopCapture];
|
|
capture_device_ = nil;
|
|
}
|
|
}
|
|
|
|
rtc::scoped_refptr<VideoCaptureModule> VideoCaptureIos::Create(
|
|
const char* deviceUniqueIdUTF8) {
|
|
if (!deviceUniqueIdUTF8[0]) {
|
|
return NULL;
|
|
}
|
|
|
|
rtc::scoped_refptr<VideoCaptureIos> capture_module(
|
|
new rtc::RefCountedObject<VideoCaptureIos>());
|
|
|
|
const int32_t name_length = strlen(deviceUniqueIdUTF8);
|
|
if (name_length > kVideoCaptureUniqueNameLength)
|
|
return nullptr;
|
|
|
|
capture_module->_deviceUniqueId = new char[name_length + 1];
|
|
strncpy(capture_module->_deviceUniqueId, deviceUniqueIdUTF8, name_length + 1);
|
|
capture_module->_deviceUniqueId[name_length] = '\0';
|
|
|
|
capture_module->capture_device_ =
|
|
[[RTCVideoCaptureIosObjC alloc] initWithOwner:capture_module];
|
|
if (!capture_module->capture_device_) {
|
|
return nullptr;
|
|
}
|
|
|
|
if (![capture_module->capture_device_
|
|
setCaptureDeviceByUniqueId:
|
|
[[NSString alloc] initWithCString:deviceUniqueIdUTF8
|
|
encoding:NSUTF8StringEncoding]]) {
|
|
return nullptr;
|
|
}
|
|
return capture_module;
|
|
}
|
|
|
|
int32_t VideoCaptureIos::StartCapture(
|
|
const VideoCaptureCapability& capability) {
|
|
capability_ = capability;
|
|
|
|
if (![capture_device_ startCaptureWithCapability:capability]) {
|
|
return -1;
|
|
}
|
|
|
|
is_capturing_ = true;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int32_t VideoCaptureIos::StopCapture() {
|
|
if (![capture_device_ stopCapture]) {
|
|
return -1;
|
|
}
|
|
|
|
is_capturing_ = false;
|
|
return 0;
|
|
}
|
|
|
|
bool VideoCaptureIos::CaptureStarted() {
|
|
return is_capturing_;
|
|
}
|
|
|
|
int32_t VideoCaptureIos::CaptureSettings(VideoCaptureCapability& settings) {
|
|
settings = capability_;
|
|
settings.videoType = VideoType::kNV12;
|
|
return 0;
|
|
}
|