| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2016 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #import "RTCRtpEncodingParameters+Private.h" | 11 #import "RTCRtpEncodingParameters+Private.h" |
| 12 | 12 |
| 13 @implementation RTCRtpEncodingParameters | 13 @implementation RTCRtpEncodingParameters |
| 14 | 14 |
| 15 @synthesize isActive = _isActive; | 15 @synthesize isActive = _isActive; |
| 16 @synthesize maxBitrateBps = _maxBitrateBps; | 16 @synthesize maxBitrateBps = _maxBitrateBps; |
| 17 @synthesize ssrc = _ssrc; | 17 @synthesize ssrc = _ssrc; |
| 18 | 18 |
| 19 static const int kBitrateUnlimited = -1; | |
| 20 | |
| 21 - (instancetype)init { | 19 - (instancetype)init { |
| 22 return [super init]; | 20 return [super init]; |
| 23 } | 21 } |
| 24 | 22 |
| 25 - (instancetype)initWithNativeParameters: | 23 - (instancetype)initWithNativeParameters: |
| 26 (const webrtc::RtpEncodingParameters &)nativeParameters { | 24 (const webrtc::RtpEncodingParameters &)nativeParameters { |
| 27 if (self = [self init]) { | 25 if (self = [self init]) { |
| 28 _isActive = nativeParameters.active; | 26 _isActive = nativeParameters.active; |
| 29 // TODO(skvlad): Replace with rtc::Optional once the C++ code is updated. | 27 if (nativeParameters.max_bitrate_bps) { |
| 30 if (nativeParameters.max_bitrate_bps != kBitrateUnlimited) { | |
| 31 _maxBitrateBps = | 28 _maxBitrateBps = |
| 32 [NSNumber numberWithInt:nativeParameters.max_bitrate_bps]; | 29 [NSNumber numberWithInt:*nativeParameters.max_bitrate_bps]; |
| 33 } | 30 } |
| 34 if (nativeParameters.ssrc) { | 31 if (nativeParameters.ssrc) { |
| 35 _ssrc = [NSNumber numberWithUnsignedLong:*nativeParameters.ssrc]; | 32 _ssrc = [NSNumber numberWithUnsignedLong:*nativeParameters.ssrc]; |
| 36 } | 33 } |
| 37 } | 34 } |
| 38 return self; | 35 return self; |
| 39 } | 36 } |
| 40 | 37 |
| 41 - (webrtc::RtpEncodingParameters)nativeParameters { | 38 - (webrtc::RtpEncodingParameters)nativeParameters { |
| 42 webrtc::RtpEncodingParameters parameters; | 39 webrtc::RtpEncodingParameters parameters; |
| 43 parameters.active = _isActive; | 40 parameters.active = _isActive; |
| 44 if (_maxBitrateBps != nil) { | 41 if (_maxBitrateBps != nil) { |
| 45 parameters.max_bitrate_bps = _maxBitrateBps.intValue; | 42 parameters.max_bitrate_bps = rtc::Optional<int>(_maxBitrateBps.intValue); |
| 46 } | 43 } |
| 47 if (_ssrc != nil) { | 44 if (_ssrc != nil) { |
| 48 parameters.ssrc = rtc::Optional<uint32_t>(_ssrc.unsignedLongValue); | 45 parameters.ssrc = rtc::Optional<uint32_t>(_ssrc.unsignedLongValue); |
| 49 } | 46 } |
| 50 return parameters; | 47 return parameters; |
| 51 } | 48 } |
| 52 | 49 |
| 53 @end | 50 @end |
| OLD | NEW |