Index: webrtc/api/objc/RTCMediaSource.mm |
diff --git a/webrtc/api/objc/RTCMediaSource.mm b/webrtc/api/objc/RTCMediaSource.mm |
new file mode 100644 |
index 0000000000000000000000000000000000000000..45406c2ccaad38d9d2722e5cf48c996e8f124010 |
--- /dev/null |
+++ b/webrtc/api/objc/RTCMediaSource.mm |
@@ -0,0 +1,89 @@ |
+/* |
+ * Copyright 2015 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. |
+ */ |
+ |
+#import "RTCMediaSource.h" |
+ |
+#import "webrtc/api/objc/RTCMediaSource+Private.h" |
+ |
+@interface RTCMediaSource () { |
tkchin_webrtc
2016/01/05 18:44:34
? Don't think you need this to be public
hjon
2016/01/06 00:17:15
Quite right. :-)
|
+ rtc::scoped_refptr<webrtc::MediaSourceInterface> _mediaSource; |
+} |
+@end |
+ |
+@implementation RTCMediaSource |
+ |
+- (RTCSourceState)state { |
+ return [[self class] objCSourceStateForNativeSourceState: |
+ _mediaSource->state()]; |
+} |
+ |
+- (NSString *)description { |
+ return [NSString stringWithFormat:@"RTCMediaSource:\n%@", |
+ [[self class] descriptionForObjCSourceState: |
+ self.state]]; |
+} |
+ |
+#pragma mark - Private |
+ |
+- (rtc::scoped_refptr<webrtc::MediaSourceInterface>)nativeMediaSource { |
+ return _mediaSource; |
+} |
+ |
+- (instancetype)initWithMediaSource: |
+ (rtc::scoped_refptr<webrtc::MediaSourceInterface>)mediaSource { |
+ NSParameterAssert(mediaSource); |
+ if (self = [super init]) { |
+ _mediaSource = mediaSource; |
+ } |
+ return self; |
+} |
+ |
++ (webrtc::MediaSourceInterface::SourceState)nativeSourceStateForObjCSourceState: |
tkchin_webrtc
2016/01/05 18:44:34
just remove "ObjCSource" from all of these and it
hjon
2016/01/06 00:17:15
Done.
|
+ (RTCSourceState)state { |
+ switch (state) { |
+ case RTCSourceStateInitializing: |
+ return webrtc::MediaSourceInterface::kInitializing; |
+ case RTCSourceStateLive: |
+ return webrtc::MediaSourceInterface::kLive; |
+ case RTCSourceStateEnded: |
+ return webrtc::MediaSourceInterface::kEnded; |
+ case RTCSourceStateMuted: |
+ return webrtc::MediaSourceInterface::kMuted; |
+ } |
+} |
+ |
++ (RTCSourceState)objCSourceStateForNativeSourceState: |
+ (webrtc::MediaSourceInterface::SourceState)nativeState { |
+ switch (nativeState) { |
+ case webrtc::MediaSourceInterface::kInitializing: |
+ return RTCSourceStateInitializing; |
+ case webrtc::MediaSourceInterface::kLive: |
+ return RTCSourceStateLive; |
+ case webrtc::MediaSourceInterface::kEnded: |
+ return RTCSourceStateEnded; |
+ case webrtc::MediaSourceInterface::kMuted: |
+ return RTCSourceStateMuted; |
+ } |
+} |
+ |
++ (NSString *)descriptionForObjCSourceState:(RTCSourceState)state { |
+ switch (state) { |
+ case RTCSourceStateInitializing: |
+ return @"Initializing"; |
+ case RTCSourceStateLive: |
+ return @"Live"; |
+ case RTCSourceStateEnded: |
+ return @"Ended"; |
+ case RTCSourceStateMuted: |
+ return @"Muted"; |
+ } |
+} |
+ |
+@end |