blob: cae7a5031857b22d46e1db3672345496f8371d41 [file] [log] [blame]
Anders Carlsson73119182018-03-15 09:41:03 +01001/*
2 * Copyright 2018 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
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020011#include "sdk/objc/native/api/video_capturer.h"
Anders Carlsson73119182018-03-15 09:41:03 +010012
Karl Wiberg918f50c2018-07-05 11:40:33 +020013#include "absl/memory/memory.h"
Markus Handella1b82012021-05-26 18:56:30 +020014#include "api/video_track_source_proxy_factory.h"
15#include "rtc_base/ref_counted_object.h"
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020016#include "sdk/objc/native/src/objc_video_track_source.h"
Anders Carlsson73119182018-03-15 09:41:03 +010017
18namespace webrtc {
19
20rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> ObjCToNativeVideoCapturer(
Mirko Bonadeia81e9c82020-05-04 16:14:32 +020021 RTC_OBJC_TYPE(RTCVideoCapturer) * objc_video_capturer,
Anders Carlsson73119182018-03-15 09:41:03 +010022 rtc::Thread *signaling_thread,
23 rtc::Thread *worker_thread) {
24 RTCObjCVideoSourceAdapter *adapter = [[RTCObjCVideoSourceAdapter alloc] init];
25 rtc::scoped_refptr<webrtc::ObjCVideoTrackSource> objc_video_track_source(
26 new rtc::RefCountedObject<webrtc::ObjCVideoTrackSource>(adapter));
27 rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> video_source =
Markus Handella1b82012021-05-26 18:56:30 +020028 webrtc::CreateVideoTrackSourceProxy(signaling_thread, worker_thread, objc_video_track_source);
Anders Carlsson73119182018-03-15 09:41:03 +010029
30 objc_video_capturer.delegate = adapter;
31
32 return video_source;
33}
34
35} // namespace webrtc