blob: af07a0485d64e92f57ddd00842264f0cb91e1b63 [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;
17
18static const int kBitrateUnlimited = -1;
19
20- (instancetype)init {
21 return [super init];
22}
23
24- (instancetype)initWithNativeParameters:
25 (const webrtc::RtpEncodingParameters &)nativeParameters {
26 if (self = [self init]) {
27 _isActive = nativeParameters.active;
28 // TODO(skvlad): Replace with rtc::Optional once the C++ code is updated.
29 if (nativeParameters.max_bitrate_bps != kBitrateUnlimited) {
30 _maxBitrateBps =
31 [NSNumber numberWithInt:nativeParameters.max_bitrate_bps];
32 }
33 }
34 return self;
35}
36
37- (webrtc::RtpEncodingParameters)nativeParameters {
38 webrtc::RtpEncodingParameters parameters;
39 parameters.active = _isActive;
40 if (_maxBitrateBps != nil) {
41 parameters.max_bitrate_bps = _maxBitrateBps.intValue;
42 }
43 return parameters;
44}
45
46@end