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 | dacec71 | 2018-05-24 16:24:21 +0200 | [diff] [blame] | 13 | #import "RTCRtcpParameters+Private.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" |
Florent Castelli | abe301f | 2018-06-12 18:33:49 +0200 | [diff] [blame] | 16 | #import "RTCRtpHeaderExtension+Private.h" |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 17 | #import "helpers/NSString+StdString.h" |
skvlad | 79b4b87 | 2016-04-08 17:28:55 -0700 | [diff] [blame] | 18 | |
| 19 | @implementation RTCRtpParameters |
| 20 | |
Florent Castelli | cebf50f | 2018-05-03 15:31:53 +0200 | [diff] [blame] | 21 | @synthesize transactionId = _transactionId; |
Florent Castelli | dacec71 | 2018-05-24 16:24:21 +0200 | [diff] [blame] | 22 | @synthesize rtcp = _rtcp; |
Florent Castelli | abe301f | 2018-06-12 18:33:49 +0200 | [diff] [blame] | 23 | @synthesize headerExtensions = _headerExtensions; |
skvlad | 79b4b87 | 2016-04-08 17:28:55 -0700 | [diff] [blame] | 24 | @synthesize encodings = _encodings; |
Taylor Brandstetter | 0cd086b | 2016-04-20 16:23:10 -0700 | [diff] [blame] | 25 | @synthesize codecs = _codecs; |
skvlad | 79b4b87 | 2016-04-08 17:28:55 -0700 | [diff] [blame] | 26 | |
| 27 | - (instancetype)init { |
| 28 | return [super init]; |
| 29 | } |
| 30 | |
| 31 | - (instancetype)initWithNativeParameters: |
| 32 | (const webrtc::RtpParameters &)nativeParameters { |
| 33 | if (self = [self init]) { |
Florent Castelli | cebf50f | 2018-05-03 15:31:53 +0200 | [diff] [blame] | 34 | _transactionId = [NSString stringForStdString:nativeParameters.transaction_id]; |
Florent Castelli | dacec71 | 2018-05-24 16:24:21 +0200 | [diff] [blame] | 35 | _rtcp = [[RTCRtcpParameters alloc] initWithNativeParameters:nativeParameters.rtcp]; |
Florent Castelli | abe301f | 2018-06-12 18:33:49 +0200 | [diff] [blame] | 36 | |
| 37 | NSMutableArray *headerExtensions = [[NSMutableArray alloc] init]; |
| 38 | for (const auto &headerExtension : nativeParameters.header_extensions) { |
| 39 | [headerExtensions |
| 40 | addObject:[[RTCRtpHeaderExtension alloc] initWithNativeParameters:headerExtension]]; |
| 41 | } |
| 42 | _headerExtensions = headerExtensions; |
| 43 | |
skvlad | 79b4b87 | 2016-04-08 17:28:55 -0700 | [diff] [blame] | 44 | NSMutableArray *encodings = [[NSMutableArray alloc] init]; |
| 45 | for (const auto &encoding : nativeParameters.encodings) { |
| 46 | [encodings addObject:[[RTCRtpEncodingParameters alloc] |
| 47 | initWithNativeParameters:encoding]]; |
| 48 | } |
| 49 | _encodings = encodings; |
Taylor Brandstetter | 0cd086b | 2016-04-20 16:23:10 -0700 | [diff] [blame] | 50 | |
| 51 | NSMutableArray *codecs = [[NSMutableArray alloc] init]; |
| 52 | for (const auto &codec : nativeParameters.codecs) { |
| 53 | [codecs addObject:[[RTCRtpCodecParameters alloc] |
| 54 | initWithNativeParameters:codec]]; |
| 55 | } |
| 56 | _codecs = codecs; |
skvlad | 79b4b87 | 2016-04-08 17:28:55 -0700 | [diff] [blame] | 57 | } |
| 58 | return self; |
| 59 | } |
| 60 | |
| 61 | - (webrtc::RtpParameters)nativeParameters { |
Florent Castelli | cebf50f | 2018-05-03 15:31:53 +0200 | [diff] [blame] | 62 | webrtc::RtpParameters parameters; |
| 63 | parameters.transaction_id = [NSString stdStringForString:_transactionId]; |
Florent Castelli | dacec71 | 2018-05-24 16:24:21 +0200 | [diff] [blame] | 64 | parameters.rtcp = [_rtcp nativeParameters]; |
Florent Castelli | abe301f | 2018-06-12 18:33:49 +0200 | [diff] [blame] | 65 | for (RTCRtpHeaderExtension *headerExtension in _headerExtensions) { |
| 66 | parameters.header_extensions.push_back(headerExtension.nativeParameters); |
| 67 | } |
skvlad | 79b4b87 | 2016-04-08 17:28:55 -0700 | [diff] [blame] | 68 | for (RTCRtpEncodingParameters *encoding in _encodings) { |
| 69 | parameters.encodings.push_back(encoding.nativeParameters); |
| 70 | } |
Taylor Brandstetter | 0cd086b | 2016-04-20 16:23:10 -0700 | [diff] [blame] | 71 | for (RTCRtpCodecParameters *codec in _codecs) { |
| 72 | parameters.codecs.push_back(codec.nativeParameters); |
| 73 | } |
skvlad | 79b4b87 | 2016-04-08 17:28:55 -0700 | [diff] [blame] | 74 | return parameters; |
| 75 | } |
| 76 | |
| 77 | @end |