blob: 6748580d6dae8b54cd722afadc0fd0f8a4bd1524 [file] [log] [blame]
Jon Hjellef6c318e2016-01-11 14:39:01 -08001/*
2 * Copyright 2015 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
tkchin9eeb6242016-04-27 01:54:20 -070011#import "RTCVideoSource+Private.h"
Jon Hjellef6c318e2016-01-11 14:39:01 -080012
tkchind4bfbfc2016-08-30 11:56:05 -070013#include "webrtc/base/checks.h"
magjedabb84b82017-03-28 01:56:41 -070014#include "webrtc/sdk/objc/Framework/Classes/objcvideotracksource.h"
tkchind4bfbfc2016-08-30 11:56:05 -070015
magjedabb84b82017-03-28 01:56:41 -070016// TODO(magjed): Refactor this class and target ObjcVideoTrackSource only once
17// RTCAVFoundationVideoSource is gone. See http://crbug/webrtc/7177 for more
18// info.
Jon Hjelle065aacc2016-01-20 13:25:44 -080019@implementation RTCVideoSource {
perkja3ede6c2016-03-08 01:27:48 +010020 rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> _nativeVideoSource;
Jon Hjellef6c318e2016-01-11 14:39:01 -080021}
22
tkchind4bfbfc2016-08-30 11:56:05 -070023- (instancetype)initWithNativeVideoSource:
24 (rtc::scoped_refptr<webrtc::VideoTrackSourceInterface>)nativeVideoSource {
25 RTC_DCHECK(nativeVideoSource);
26 if (self = [super initWithNativeMediaSource:nativeVideoSource
27 type:RTCMediaSourceTypeVideo]) {
28 _nativeVideoSource = nativeVideoSource;
29 }
30 return self;
31}
32
33- (instancetype)initWithNativeMediaSource:
34 (rtc::scoped_refptr<webrtc::MediaSourceInterface>)nativeMediaSource
35 type:(RTCMediaSourceType)type {
36 RTC_NOTREACHED();
37 return nil;
Jon Hjellef6c318e2016-01-11 14:39:01 -080038}
39
40- (NSString *)description {
tkchind4bfbfc2016-08-30 11:56:05 -070041 NSString *stateString = [[self class] stringForState:self.state];
42 return [NSString stringWithFormat:@"RTCVideoSource( %p ): %@", self, stateString];
Jon Hjellef6c318e2016-01-11 14:39:01 -080043}
44
magjedabb84b82017-03-28 01:56:41 -070045- (void)capturer:(RTCVideoCapturer *)capturer didCaptureVideoFrame:(RTCVideoFrame *)frame {
46 static_cast<webrtc::ObjcVideoTrackSource *>(_nativeVideoSource.get())->OnCapturedFrame(frame);
47}
48
49- (void)adaptOutputFormatToWidth:(int)width height:(int)height fps:(int)fps {
50 static_cast<webrtc::ObjcVideoTrackSource *>(_nativeVideoSource.get())
51 ->OnOutputFormatRequest(width, height, fps);
52}
53
Jon Hjellef6c318e2016-01-11 14:39:01 -080054#pragma mark - Private
55
perkja3ede6c2016-03-08 01:27:48 +010056- (rtc::scoped_refptr<webrtc::VideoTrackSourceInterface>)nativeVideoSource {
Jon Hjelle065aacc2016-01-20 13:25:44 -080057 return _nativeVideoSource;
Jon Hjellef6c318e2016-01-11 14:39:01 -080058}
59
Jon Hjellef6c318e2016-01-11 14:39:01 -080060@end