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 "RTCRtpEncodingParameters+Private.h" |
| 12 | |
| 13 | @implementation RTCRtpEncodingParameters |
| 14 | |
| 15 | @synthesize isActive = _isActive; |
| 16 | @synthesize maxBitrateBps = _maxBitrateBps; |
Rasmus Brandt | a3e69e6 | 2018-06-05 10:55:56 +0200 | [diff] [blame] | 17 | @synthesize minBitrateBps = _minBitrateBps; |
Rasmus Brandt | 3c76941 | 2018-09-27 09:53:11 +0200 | [diff] [blame] | 18 | @synthesize maxFramerate = _maxFramerate; |
deadbeef | 8014c75 | 2017-01-06 16:53:00 -0800 | [diff] [blame] | 19 | @synthesize ssrc = _ssrc; |
skvlad | 79b4b87 | 2016-04-08 17:28:55 -0700 | [diff] [blame] | 20 | |
skvlad | 79b4b87 | 2016-04-08 17:28:55 -0700 | [diff] [blame] | 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; |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 29 | if (nativeParameters.max_bitrate_bps) { |
skvlad | 79b4b87 | 2016-04-08 17:28:55 -0700 | [diff] [blame] | 30 | _maxBitrateBps = |
deadbeef | e702b30 | 2017-02-04 12:09:01 -0800 | [diff] [blame] | 31 | [NSNumber numberWithInt:*nativeParameters.max_bitrate_bps]; |
skvlad | 79b4b87 | 2016-04-08 17:28:55 -0700 | [diff] [blame] | 32 | } |
Rasmus Brandt | a3e69e6 | 2018-06-05 10:55:56 +0200 | [diff] [blame] | 33 | if (nativeParameters.min_bitrate_bps) { |
| 34 | _minBitrateBps = |
| 35 | [NSNumber numberWithInt:*nativeParameters.min_bitrate_bps]; |
| 36 | } |
Rasmus Brandt | 3c76941 | 2018-09-27 09:53:11 +0200 | [diff] [blame] | 37 | if (nativeParameters.max_framerate) { |
| 38 | _maxFramerate = [NSNumber numberWithInt:*nativeParameters.max_framerate]; |
| 39 | } |
deadbeef | 8014c75 | 2017-01-06 16:53:00 -0800 | [diff] [blame] | 40 | if (nativeParameters.ssrc) { |
| 41 | _ssrc = [NSNumber numberWithUnsignedLong:*nativeParameters.ssrc]; |
| 42 | } |
skvlad | 79b4b87 | 2016-04-08 17:28:55 -0700 | [diff] [blame] | 43 | } |
| 44 | return self; |
| 45 | } |
| 46 | |
| 47 | - (webrtc::RtpEncodingParameters)nativeParameters { |
| 48 | webrtc::RtpEncodingParameters parameters; |
| 49 | parameters.active = _isActive; |
| 50 | if (_maxBitrateBps != nil) { |
Danil Chapovalov | 196100e | 2018-06-21 10:17:24 +0200 | [diff] [blame] | 51 | parameters.max_bitrate_bps = absl::optional<int>(_maxBitrateBps.intValue); |
skvlad | 79b4b87 | 2016-04-08 17:28:55 -0700 | [diff] [blame] | 52 | } |
Rasmus Brandt | a3e69e6 | 2018-06-05 10:55:56 +0200 | [diff] [blame] | 53 | if (_minBitrateBps != nil) { |
Danil Chapovalov | 196100e | 2018-06-21 10:17:24 +0200 | [diff] [blame] | 54 | parameters.min_bitrate_bps = absl::optional<int>(_minBitrateBps.intValue); |
Rasmus Brandt | a3e69e6 | 2018-06-05 10:55:56 +0200 | [diff] [blame] | 55 | } |
Rasmus Brandt | 3c76941 | 2018-09-27 09:53:11 +0200 | [diff] [blame] | 56 | if (_maxFramerate != nil) { |
| 57 | parameters.max_framerate = absl::optional<int>(_maxFramerate.intValue); |
| 58 | } |
deadbeef | 8014c75 | 2017-01-06 16:53:00 -0800 | [diff] [blame] | 59 | if (_ssrc != nil) { |
Danil Chapovalov | 196100e | 2018-06-21 10:17:24 +0200 | [diff] [blame] | 60 | parameters.ssrc = absl::optional<uint32_t>(_ssrc.unsignedLongValue); |
deadbeef | 8014c75 | 2017-01-06 16:53:00 -0800 | [diff] [blame] | 61 | } |
skvlad | 79b4b87 | 2016-04-08 17:28:55 -0700 | [diff] [blame] | 62 | return parameters; |
| 63 | } |
| 64 | |
| 65 | @end |