Adding codecs to the RtpParameters returned by an RtpSender.
Contains every field except for sdpFmtpLine.
Setting a reordered list of codecs is not yet supported.
R=glaznev@webrtc.org, pthatcher@webrtc.org, skvlad@webrtc.org, tkchin@webrtc.org
Review URL: https://codereview.webrtc.org/1885473004 .
Cr-Commit-Position: refs/heads/master@{#12453}
diff --git a/webrtc/api/objc/RTCRtpCodecParameters+Private.h b/webrtc/api/objc/RTCRtpCodecParameters+Private.h
new file mode 100644
index 0000000..aabbf7d
--- /dev/null
+++ b/webrtc/api/objc/RTCRtpCodecParameters+Private.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2016 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 <Foundation/Foundation.h>
+
+#import "webrtc/api/objc/RTCRtpCodecParameters.h"
+
+#include "webrtc/api/rtpparameters.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface RTCRtpCodecParameters ()
+
+/** Returns the equivalent native RtpCodecParameters structure. */
+@property(nonatomic, readonly) webrtc::RtpCodecParameters nativeParameters;
+
+/** Initialize the object with a native RtpCodecParameters structure. */
+- (instancetype)initWithNativeParameters:
+ (const webrtc::RtpCodecParameters &)nativeParameters;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/webrtc/api/objc/RTCRtpCodecParameters.h b/webrtc/api/objc/RTCRtpCodecParameters.h
new file mode 100644
index 0000000..ec0c647
--- /dev/null
+++ b/webrtc/api/objc/RTCRtpCodecParameters.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2016 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 <Foundation/Foundation.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+extern const NSString * const kRtxCodecMimeType;
+extern const NSString * const kRedCodecMimeType;
+extern const NSString * const kUlpfecCodecMimeType;
+extern const NSString * const kOpusCodecMimeType;
+extern const NSString * const kIsacCodecMimeType;
+extern const NSString * const kL16CodecMimeType;
+extern const NSString * const kG722CodecMimeType;
+extern const NSString * const kIlbcCodecMimeType;
+extern const NSString * const kPcmuCodecMimeType;
+extern const NSString * const kPcmaCodecMimeType;
+extern const NSString * const kDtmfCodecMimeType;
+extern const NSString * const kComfortNoiseCodecMimeType;
+extern const NSString * const kVp8CodecMimeType;
+extern const NSString * const kVp9CodecMimeType;
+extern const NSString * const kH264CodecMimeType;
+
+/** Defined in http://w3c.github.io/webrtc-pc/#idl-def-RTCRtpCodecParameters */
+@interface RTCRtpCodecParameters : NSObject
+
+/** The RTP payload type. */
+@property(nonatomic, assign) int payloadType;
+
+/**
+ * The codec MIME type. Valid types are listed in:
+ * http://www.iana.org/assignments/rtp-parameters/rtp-parameters.xhtml#rtp-parameters-2
+ *
+ * Several supported types are represented by the constants above.
+ */
+@property(nonatomic, nonnull) NSString *mimeType;
+
+/** The codec clock rate expressed in Hertz. */
+@property(nonatomic, assign) int clockRate;
+
+/** The number of channels (mono=1, stereo=2). */
+@property(nonatomic, assign) int channels;
+
+- (instancetype)init NS_DESIGNATED_INITIALIZER;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/webrtc/api/objc/RTCRtpCodecParameters.mm b/webrtc/api/objc/RTCRtpCodecParameters.mm
new file mode 100644
index 0000000..8bc2204
--- /dev/null
+++ b/webrtc/api/objc/RTCRtpCodecParameters.mm
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2016 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 "RTCRtpCodecParameters+Private.h"
+
+#import "webrtc/base/objc/NSString+StdString.h"
+#import "webrtc/media/base/mediaconstants.h"
+
+const NSString * const kRtxCodecMimeType = @(cricket::kRtxCodecName);
+const NSString * const kRedCodecMimeType = @(cricket::kRedCodecName);
+const NSString * const kUlpfecCodecMimeType = @(cricket::kUlpfecCodecName);
+const NSString * const kOpusCodecMimeType = @(cricket::kOpusCodecName);
+const NSString * const kIsacCodecMimeType = @(cricket::kIsacCodecName);
+const NSString * const kL16CodecMimeType = @(cricket::kL16CodecName);
+const NSString * const kG722CodecMimeType = @(cricket::kG722CodecName);
+const NSString * const kIlbcCodecMimeType = @(cricket::kIlbcCodecName);
+const NSString * const kPcmuCodecMimeType = @(cricket::kPcmuCodecName);
+const NSString * const kPcmaCodecMimeType = @(cricket::kPcmaCodecName);
+const NSString * const kDtmfCodecMimeType = @(cricket::kDtmfCodecName);
+const NSString * const kComfortNoiseCodecMimeType = @(cricket::kComfortNoiseCodecName);
+const NSString * const kVp8CodecMimeType = @(cricket::kVp8CodecName);
+const NSString * const kVp9CodecMimeType = @(cricket::kVp9CodecName);
+const NSString * const kH264CodecMimeType = @(cricket::kH264CodecName);
+
+@implementation RTCRtpCodecParameters
+
+@synthesize payloadType = _payloadType;
+@synthesize mimeType = _mimeType;
+@synthesize clockRate = _clockRate;
+@synthesize channels = _channels;
+
+- (instancetype)init {
+ return [super init];
+}
+
+- (instancetype)initWithNativeParameters:
+ (const webrtc::RtpCodecParameters &)nativeParameters {
+ if (self = [self init]) {
+ _payloadType = nativeParameters.payload_type;
+ _mimeType = [NSString stringForStdString:nativeParameters.mime_type];
+ _clockRate = nativeParameters.clock_rate;
+ _channels = nativeParameters.channels;
+ }
+ return self;
+}
+
+- (webrtc::RtpCodecParameters)nativeParameters {
+ webrtc::RtpCodecParameters parameters;
+ parameters.payload_type = _payloadType;
+ parameters.mime_type = [NSString stdStringForString:_mimeType];
+ parameters.clock_rate = _clockRate;
+ parameters.channels = _channels;
+ return parameters;
+}
+
+@end
diff --git a/webrtc/api/objc/RTCRtpParameters.h b/webrtc/api/objc/RTCRtpParameters.h
index 91d8108..7b66f37 100644
--- a/webrtc/api/objc/RTCRtpParameters.h
+++ b/webrtc/api/objc/RTCRtpParameters.h
@@ -10,6 +10,7 @@
#import <Foundation/Foundation.h>
+#import "webrtc/api/objc/RTCRtpCodecParameters.h"
#import "webrtc/api/objc/RTCRtpEncodingParameters.h"
#import "webrtc/base/objc/RTCMacros.h"
@@ -21,6 +22,9 @@
/** The currently active encodings in the order of preference. */
@property(nonatomic, copy) NSArray<RTCRtpEncodingParameters *> *encodings;
+/** The negotiated set of send codecs in order of preference. */
+@property(nonatomic, copy) NSArray<RTCRtpCodecParameters *> *codecs;
+
- (instancetype)init NS_DESIGNATED_INITIALIZER;
@end
diff --git a/webrtc/api/objc/RTCRtpParameters.mm b/webrtc/api/objc/RTCRtpParameters.mm
index e8c4a44..5e79106 100644
--- a/webrtc/api/objc/RTCRtpParameters.mm
+++ b/webrtc/api/objc/RTCRtpParameters.mm
@@ -9,11 +9,14 @@
*/
#import "RTCRtpParameters+Private.h"
+
+#import "RTCRtpCodecParameters+Private.h"
#import "RTCRtpEncodingParameters+Private.h"
@implementation RTCRtpParameters
@synthesize encodings = _encodings;
+@synthesize codecs = _codecs;
- (instancetype)init {
return [super init];
@@ -28,6 +31,13 @@
initWithNativeParameters:encoding]];
}
_encodings = encodings;
+
+ NSMutableArray *codecs = [[NSMutableArray alloc] init];
+ for (const auto &codec : nativeParameters.codecs) {
+ [codecs addObject:[[RTCRtpCodecParameters alloc]
+ initWithNativeParameters:codec]];
+ }
+ _codecs = codecs;
}
return self;
}
@@ -37,6 +47,9 @@
for (RTCRtpEncodingParameters *encoding in _encodings) {
parameters.encodings.push_back(encoding.nativeParameters);
}
+ for (RTCRtpCodecParameters *codec in _codecs) {
+ parameters.codecs.push_back(codec.nativeParameters);
+ }
return parameters;
}