OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2016 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 #import "RTCVideoSource+Private.h" | 11 #import "RTCMediaSource+Private.h" |
12 | 12 |
13 @implementation RTCVideoSource { | 13 #include "webrtc/base/checks.h" |
14 rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> _nativeVideoSource; | 14 |
| 15 @implementation RTCMediaSource { |
| 16 RTCMediaSourceType _type; |
| 17 } |
| 18 |
| 19 @synthesize nativeMediaSource = _nativeMediaSource; |
| 20 |
| 21 - (instancetype)initWithNativeMediaSource: |
| 22 (rtc::scoped_refptr<webrtc::MediaSourceInterface>)nativeMediaSource |
| 23 type:(RTCMediaSourceType)type { |
| 24 RTC_DCHECK(nativeMediaSource); |
| 25 if (self = [super init]) { |
| 26 _nativeMediaSource = nativeMediaSource; |
| 27 _type = type; |
| 28 } |
| 29 return self; |
15 } | 30 } |
16 | 31 |
17 - (RTCSourceState)state { | 32 - (RTCSourceState)state { |
18 return [[self class] sourceStateForNativeState:_nativeVideoSource->state()]; | 33 return [[self class] sourceStateForNativeState:_nativeMediaSource->state()]; |
19 } | |
20 | |
21 - (NSString *)description { | |
22 return [NSString stringWithFormat:@"RTCVideoSource:\n%@", | |
23 [[self class] stringForState:self.state]]; | |
24 } | 34 } |
25 | 35 |
26 #pragma mark - Private | 36 #pragma mark - Private |
27 | 37 |
28 - (rtc::scoped_refptr<webrtc::VideoTrackSourceInterface>)nativeVideoSource { | |
29 return _nativeVideoSource; | |
30 } | |
31 | |
32 - (instancetype)initWithNativeVideoSource: | |
33 (rtc::scoped_refptr<webrtc::VideoTrackSourceInterface>)nativeVideoSource { | |
34 NSParameterAssert(nativeVideoSource); | |
35 if (self = [super init]) { | |
36 _nativeVideoSource = nativeVideoSource; | |
37 } | |
38 return self; | |
39 } | |
40 | |
41 + (webrtc::MediaSourceInterface::SourceState)nativeSourceStateForState: | 38 + (webrtc::MediaSourceInterface::SourceState)nativeSourceStateForState: |
42 (RTCSourceState)state { | 39 (RTCSourceState)state { |
43 switch (state) { | 40 switch (state) { |
44 case RTCSourceStateInitializing: | 41 case RTCSourceStateInitializing: |
45 return webrtc::MediaSourceInterface::kInitializing; | 42 return webrtc::MediaSourceInterface::kInitializing; |
46 case RTCSourceStateLive: | 43 case RTCSourceStateLive: |
47 return webrtc::MediaSourceInterface::kLive; | 44 return webrtc::MediaSourceInterface::kLive; |
48 case RTCSourceStateEnded: | 45 case RTCSourceStateEnded: |
49 return webrtc::MediaSourceInterface::kEnded; | 46 return webrtc::MediaSourceInterface::kEnded; |
50 case RTCSourceStateMuted: | 47 case RTCSourceStateMuted: |
(...skipping 22 matching lines...) Expand all Loading... |
73 case RTCSourceStateLive: | 70 case RTCSourceStateLive: |
74 return @"Live"; | 71 return @"Live"; |
75 case RTCSourceStateEnded: | 72 case RTCSourceStateEnded: |
76 return @"Ended"; | 73 return @"Ended"; |
77 case RTCSourceStateMuted: | 74 case RTCSourceStateMuted: |
78 return @"Muted"; | 75 return @"Muted"; |
79 } | 76 } |
80 } | 77 } |
81 | 78 |
82 @end | 79 @end |
OLD | NEW |