blob: 5e791066df1426392099b3dd0a5f093f29b19d72 [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
13#import "RTCRtpCodecParameters+Private.h"
skvlad79b4b872016-04-08 17:28:55 -070014#import "RTCRtpEncodingParameters+Private.h"
15
16@implementation RTCRtpParameters
17
18@synthesize encodings = _encodings;
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -070019@synthesize codecs = _codecs;
skvlad79b4b872016-04-08 17:28:55 -070020
21- (instancetype)init {
22 return [super init];
23}
24
25- (instancetype)initWithNativeParameters:
26 (const webrtc::RtpParameters &)nativeParameters {
27 if (self = [self init]) {
28 NSMutableArray *encodings = [[NSMutableArray alloc] init];
29 for (const auto &encoding : nativeParameters.encodings) {
30 [encodings addObject:[[RTCRtpEncodingParameters alloc]
31 initWithNativeParameters:encoding]];
32 }
33 _encodings = encodings;
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -070034
35 NSMutableArray *codecs = [[NSMutableArray alloc] init];
36 for (const auto &codec : nativeParameters.codecs) {
37 [codecs addObject:[[RTCRtpCodecParameters alloc]
38 initWithNativeParameters:codec]];
39 }
40 _codecs = codecs;
skvlad79b4b872016-04-08 17:28:55 -070041 }
42 return self;
43}
44
45- (webrtc::RtpParameters)nativeParameters {
46 webrtc::RtpParameters parameters;
47 for (RTCRtpEncodingParameters *encoding in _encodings) {
48 parameters.encodings.push_back(encoding.nativeParameters);
49 }
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -070050 for (RTCRtpCodecParameters *codec in _codecs) {
51 parameters.codecs.push_back(codec.nativeParameters);
52 }
skvlad79b4b872016-04-08 17:28:55 -070053 return parameters;
54}
55
56@end