blob: be47894a8fe18837bd3a67efaaa1966bbf1c9364 [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 "RTCRtpEncodingParameters+Private.h"
12
13@implementation RTCRtpEncodingParameters
14
15@synthesize isActive = _isActive;
16@synthesize maxBitrateBps = _maxBitrateBps;
deadbeef8014c752017-01-06 16:53:00 -080017@synthesize ssrc = _ssrc;
skvlad79b4b872016-04-08 17:28:55 -070018
19static const int kBitrateUnlimited = -1;
20
21- (instancetype)init {
22 return [super init];
23}
24
25- (instancetype)initWithNativeParameters:
26 (const webrtc::RtpEncodingParameters &)nativeParameters {
27 if (self = [self init]) {
28 _isActive = nativeParameters.active;
29 // TODO(skvlad): Replace with rtc::Optional once the C++ code is updated.
30 if (nativeParameters.max_bitrate_bps != kBitrateUnlimited) {
31 _maxBitrateBps =
32 [NSNumber numberWithInt:nativeParameters.max_bitrate_bps];
33 }
deadbeef8014c752017-01-06 16:53:00 -080034 if (nativeParameters.ssrc) {
35 _ssrc = [NSNumber numberWithUnsignedLong:*nativeParameters.ssrc];
36 }
skvlad79b4b872016-04-08 17:28:55 -070037 }
38 return self;
39}
40
41- (webrtc::RtpEncodingParameters)nativeParameters {
42 webrtc::RtpEncodingParameters parameters;
43 parameters.active = _isActive;
44 if (_maxBitrateBps != nil) {
45 parameters.max_bitrate_bps = _maxBitrateBps.intValue;
46 }
deadbeef8014c752017-01-06 16:53:00 -080047 if (_ssrc != nil) {
48 parameters.ssrc = rtc::Optional<uint32_t>(_ssrc.unsignedLongValue);
49 }
skvlad79b4b872016-04-08 17:28:55 -070050 return parameters;
51}
52
53@end