blob: 270f1b2e3bb825f46b9281725e658a72d48bbbf4 [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;
Rasmus Brandta3e69e62018-06-05 10:55:56 +020017@synthesize minBitrateBps = _minBitrateBps;
Rasmus Brandt3c769412018-09-27 09:53:11 +020018@synthesize maxFramerate = _maxFramerate;
Rasmus Brandt86f78cb2018-10-03 09:34:47 +020019@synthesize numTemporalLayers = _numTemporalLayers;
deadbeef8014c752017-01-06 16:53:00 -080020@synthesize ssrc = _ssrc;
skvlad79b4b872016-04-08 17:28:55 -070021
skvlad79b4b872016-04-08 17:28:55 -070022- (instancetype)init {
23 return [super init];
24}
25
26- (instancetype)initWithNativeParameters:
27 (const webrtc::RtpEncodingParameters &)nativeParameters {
28 if (self = [self init]) {
29 _isActive = nativeParameters.active;
deadbeefe702b302017-02-04 12:09:01 -080030 if (nativeParameters.max_bitrate_bps) {
skvlad79b4b872016-04-08 17:28:55 -070031 _maxBitrateBps =
deadbeefe702b302017-02-04 12:09:01 -080032 [NSNumber numberWithInt:*nativeParameters.max_bitrate_bps];
skvlad79b4b872016-04-08 17:28:55 -070033 }
Rasmus Brandta3e69e62018-06-05 10:55:56 +020034 if (nativeParameters.min_bitrate_bps) {
35 _minBitrateBps =
36 [NSNumber numberWithInt:*nativeParameters.min_bitrate_bps];
37 }
Rasmus Brandt3c769412018-09-27 09:53:11 +020038 if (nativeParameters.max_framerate) {
39 _maxFramerate = [NSNumber numberWithInt:*nativeParameters.max_framerate];
40 }
Rasmus Brandt86f78cb2018-10-03 09:34:47 +020041 if (nativeParameters.num_temporal_layers) {
42 _numTemporalLayers = [NSNumber numberWithInt:*nativeParameters.num_temporal_layers];
43 }
deadbeef8014c752017-01-06 16:53:00 -080044 if (nativeParameters.ssrc) {
45 _ssrc = [NSNumber numberWithUnsignedLong:*nativeParameters.ssrc];
46 }
skvlad79b4b872016-04-08 17:28:55 -070047 }
48 return self;
49}
50
51- (webrtc::RtpEncodingParameters)nativeParameters {
52 webrtc::RtpEncodingParameters parameters;
53 parameters.active = _isActive;
54 if (_maxBitrateBps != nil) {
Danil Chapovalov196100e2018-06-21 10:17:24 +020055 parameters.max_bitrate_bps = absl::optional<int>(_maxBitrateBps.intValue);
skvlad79b4b872016-04-08 17:28:55 -070056 }
Rasmus Brandta3e69e62018-06-05 10:55:56 +020057 if (_minBitrateBps != nil) {
Danil Chapovalov196100e2018-06-21 10:17:24 +020058 parameters.min_bitrate_bps = absl::optional<int>(_minBitrateBps.intValue);
Rasmus Brandta3e69e62018-06-05 10:55:56 +020059 }
Rasmus Brandt3c769412018-09-27 09:53:11 +020060 if (_maxFramerate != nil) {
61 parameters.max_framerate = absl::optional<int>(_maxFramerate.intValue);
62 }
Rasmus Brandt86f78cb2018-10-03 09:34:47 +020063 if (_numTemporalLayers != nil) {
64 parameters.num_temporal_layers = absl::optional<int>(_numTemporalLayers.intValue);
65 }
deadbeef8014c752017-01-06 16:53:00 -080066 if (_ssrc != nil) {
Danil Chapovalov196100e2018-06-21 10:17:24 +020067 parameters.ssrc = absl::optional<uint32_t>(_ssrc.unsignedLongValue);
deadbeef8014c752017-01-06 16:53:00 -080068 }
skvlad79b4b872016-04-08 17:28:55 -070069 return parameters;
70}
71
72@end