Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Unified Diff: webrtc/api/objc/RTCMediaSource.mm

Issue 1538263002: Update API for Objective-C RTCMediaSource. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698