blob: 7c00b08bc53c54415e439e832ff1e34610d682a8 [file] [log] [blame]
skvlad79b4b872016-04-08 17:28:55 -07001/*
2 * Copyright 2016 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
11#import "RTCRtpParameters+Private.h"
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -070012
Florent Castellicebf50f2018-05-03 15:31:53 +020013#import "NSString+StdString.h"
Florent Castellidacec712018-05-24 16:24:21 +020014#import "RTCRtcpParameters+Private.h"
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -070015#import "RTCRtpCodecParameters+Private.h"
skvlad79b4b872016-04-08 17:28:55 -070016#import "RTCRtpEncodingParameters+Private.h"
17
18@implementation RTCRtpParameters
19
Florent Castellicebf50f2018-05-03 15:31:53 +020020@synthesize transactionId = _transactionId;
Florent Castellidacec712018-05-24 16:24:21 +020021@synthesize rtcp = _rtcp;
skvlad79b4b872016-04-08 17:28:55 -070022@synthesize encodings = _encodings;
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -070023@synthesize codecs = _codecs;
skvlad79b4b872016-04-08 17:28:55 -070024
25- (instancetype)init {
26 return [super init];
27}
28
29- (instancetype)initWithNativeParameters:
30 (const webrtc::RtpParameters &)nativeParameters {
31 if (self = [self init]) {
Florent Castellicebf50f2018-05-03 15:31:53 +020032 _transactionId = [NSString stringForStdString:nativeParameters.transaction_id];
Florent Castellidacec712018-05-24 16:24:21 +020033 _rtcp = [[RTCRtcpParameters alloc] initWithNativeParameters:nativeParameters.rtcp];
skvlad79b4b872016-04-08 17:28:55 -070034 NSMutableArray *encodings = [[NSMutableArray alloc] init];
35 for (const auto &encoding : nativeParameters.encodings) {
36 [encodings addObject:[[RTCRtpEncodingParameters alloc]
37 initWithNativeParameters:encoding]];
38 }
39 _encodings = encodings;
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -070040
41 NSMutableArray *codecs = [[NSMutableArray alloc] init];
42 for (const auto &codec : nativeParameters.codecs) {
43 [codecs addObject:[[RTCRtpCodecParameters alloc]
44 initWithNativeParameters:codec]];
45 }
46 _codecs = codecs;
skvlad79b4b872016-04-08 17:28:55 -070047 }
48 return self;
49}
50
51- (webrtc::RtpParameters)nativeParameters {
Florent Castellicebf50f2018-05-03 15:31:53 +020052 webrtc::RtpParameters parameters;
53 parameters.transaction_id = [NSString stdStringForString:_transactionId];
Florent Castellidacec712018-05-24 16:24:21 +020054 parameters.rtcp = [_rtcp nativeParameters];
skvlad79b4b872016-04-08 17:28:55 -070055 for (RTCRtpEncodingParameters *encoding in _encodings) {
56 parameters.encodings.push_back(encoding.nativeParameters);
57 }
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -070058 for (RTCRtpCodecParameters *codec in _codecs) {
59 parameters.codecs.push_back(codec.nativeParameters);
60 }
skvlad79b4b872016-04-08 17:28:55 -070061 return parameters;
62}
63
64@end