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