skvlad | 79b4b87 | 2016-04-08 17:28:55 -0700 | [diff] [blame] | 1 | /* |
| 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 Brandstetter | 0cd086b | 2016-04-20 16:23:10 -0700 | [diff] [blame] | 12 | |
Florent Castelli | cebf50f | 2018-05-03 15:31:53 +0200 | [diff] [blame^] | 13 | #import "NSString+StdString.h" |
Taylor Brandstetter | 0cd086b | 2016-04-20 16:23:10 -0700 | [diff] [blame] | 14 | #import "RTCRtpCodecParameters+Private.h" |
skvlad | 79b4b87 | 2016-04-08 17:28:55 -0700 | [diff] [blame] | 15 | #import "RTCRtpEncodingParameters+Private.h" |
| 16 | |
| 17 | @implementation RTCRtpParameters |
| 18 | |
Florent Castelli | cebf50f | 2018-05-03 15:31:53 +0200 | [diff] [blame^] | 19 | @synthesize transactionId = _transactionId; |
skvlad | 79b4b87 | 2016-04-08 17:28:55 -0700 | [diff] [blame] | 20 | @synthesize encodings = _encodings; |
Taylor Brandstetter | 0cd086b | 2016-04-20 16:23:10 -0700 | [diff] [blame] | 21 | @synthesize codecs = _codecs; |
skvlad | 79b4b87 | 2016-04-08 17:28:55 -0700 | [diff] [blame] | 22 | |
| 23 | - (instancetype)init { |
| 24 | return [super init]; |
| 25 | } |
| 26 | |
| 27 | - (instancetype)initWithNativeParameters: |
| 28 | (const webrtc::RtpParameters &)nativeParameters { |
| 29 | if (self = [self init]) { |
Florent Castelli | cebf50f | 2018-05-03 15:31:53 +0200 | [diff] [blame^] | 30 | _transactionId = [NSString stringForStdString:nativeParameters.transaction_id]; |
skvlad | 79b4b87 | 2016-04-08 17:28:55 -0700 | [diff] [blame] | 31 | NSMutableArray *encodings = [[NSMutableArray alloc] init]; |
| 32 | for (const auto &encoding : nativeParameters.encodings) { |
| 33 | [encodings addObject:[[RTCRtpEncodingParameters alloc] |
| 34 | initWithNativeParameters:encoding]]; |
| 35 | } |
| 36 | _encodings = encodings; |
Taylor Brandstetter | 0cd086b | 2016-04-20 16:23:10 -0700 | [diff] [blame] | 37 | |
| 38 | NSMutableArray *codecs = [[NSMutableArray alloc] init]; |
| 39 | for (const auto &codec : nativeParameters.codecs) { |
| 40 | [codecs addObject:[[RTCRtpCodecParameters alloc] |
| 41 | initWithNativeParameters:codec]]; |
| 42 | } |
| 43 | _codecs = codecs; |
skvlad | 79b4b87 | 2016-04-08 17:28:55 -0700 | [diff] [blame] | 44 | } |
| 45 | return self; |
| 46 | } |
| 47 | |
| 48 | - (webrtc::RtpParameters)nativeParameters { |
Florent Castelli | cebf50f | 2018-05-03 15:31:53 +0200 | [diff] [blame^] | 49 | webrtc::RtpParameters parameters; |
| 50 | parameters.transaction_id = [NSString stdStringForString:_transactionId]; |
skvlad | 79b4b87 | 2016-04-08 17:28:55 -0700 | [diff] [blame] | 51 | for (RTCRtpEncodingParameters *encoding in _encodings) { |
| 52 | parameters.encodings.push_back(encoding.nativeParameters); |
| 53 | } |
Taylor Brandstetter | 0cd086b | 2016-04-20 16:23:10 -0700 | [diff] [blame] | 54 | for (RTCRtpCodecParameters *codec in _codecs) { |
| 55 | parameters.codecs.push_back(codec.nativeParameters); |
| 56 | } |
skvlad | 79b4b87 | 2016-04-08 17:28:55 -0700 | [diff] [blame] | 57 | return parameters; |
| 58 | } |
| 59 | |
| 60 | @end |