diff --git a/webrtc/examples/objc/AppRTCMobile/ARDAppClient.h b/webrtc/examples/objc/AppRTCMobile/ARDAppClient.h index d906ec726f..60ef70071c 100644 --- a/webrtc/examples/objc/AppRTCMobile/ARDAppClient.h +++ b/webrtc/examples/objc/AppRTCMobile/ARDAppClient.h @@ -65,6 +65,9 @@ typedef NS_ENUM(NSInteger, ARDAppClientState) { // Sets camera constraints. - (void)setCameraConstraints:(RTCMediaConstraints *)mediaConstraints; +// Sets maximum bitrate the rtp sender should use. +- (void)setMaxBitrate:(NSNumber *)maxBitrate; + // Establishes a connection with the AppRTC servers for the given room id. // If |isLoopback| is true, the call will connect to itself. // If |isAudioOnly| is true, video will be disabled for the call. diff --git a/webrtc/examples/objc/AppRTCMobile/ARDAppClient.m b/webrtc/examples/objc/AppRTCMobile/ARDAppClient.m index 4a073f3f1c..cfcb356548 100644 --- a/webrtc/examples/objc/AppRTCMobile/ARDAppClient.m +++ b/webrtc/examples/objc/AppRTCMobile/ARDAppClient.m @@ -102,6 +102,7 @@ static int64_t const kARDAppClientRtcEventLogMaxSizeInBytes = 5e6; // 5 MB. RTCFileLogger *_fileLogger; ARDTimerProxy *_statsTimer; RTCMediaConstraints *_cameraConstraints; + NSNumber *_maxBitrate; } @synthesize shouldGetStats = _shouldGetStats; @@ -328,6 +329,10 @@ static int64_t const kARDAppClientRtcEventLogMaxSizeInBytes = 5e6; // 5 MB. _cameraConstraints = mediaConstraints; } +- (void)setMaxBitrate:(NSNumber *)maxBitrate { + _maxBitrate = maxBitrate; +} + #pragma mark - ARDSignalingChannelDelegate - (void)channel:(id)channel @@ -675,6 +680,9 @@ static int64_t const kARDAppClientRtcEventLogMaxSizeInBytes = 5e6; // 5 MB. RTCRtpSender *sender = [_peerConnection senderWithKind:kRTCMediaStreamTrackKindVideo streamId:kARDMediaStreamId]; + + [self setMaxBitrate:_maxBitrate forVideoSender:sender]; + RTCVideoTrack *track = [self createLocalVideoTrack]; if (track) { sender.track = track; @@ -683,6 +691,12 @@ static int64_t const kARDAppClientRtcEventLogMaxSizeInBytes = 5e6; // 5 MB. return sender; } +- (void)setMaxBitrate:(NSNumber *)maxBitrate forVideoSender:(RTCRtpSender *)sender { + for (RTCRtpEncodingParameters *encoding in sender.parameters.encodings) { + encoding.maxBitrateBps = maxBitrate; + } +} + - (RTCRtpSender *)createAudioSender { RTCMediaConstraints *constraints = [self defaultMediaAudioConstraints]; RTCAudioSource *source = [_factory audioSourceWithConstraints:constraints];