| Index: webrtc/examples/objc/AppRTCMobile/ARDAppClient.m
|
| diff --git a/webrtc/examples/objc/AppRTCMobile/ARDAppClient.m b/webrtc/examples/objc/AppRTCMobile/ARDAppClient.m
|
| index cfcb3565483c9f9e04a8c1f49232b0aaf74b4fd3..40a2be7cbf8cc3ec5d2c96f10d7693ba2504dcd7 100644
|
| --- a/webrtc/examples/objc/AppRTCMobile/ARDAppClient.m
|
| +++ b/webrtc/examples/objc/AppRTCMobile/ARDAppClient.m
|
| @@ -50,12 +50,14 @@ static NSInteger const kARDAppClientErrorInvalidRoom = -6;
|
| static NSString * const kARDMediaStreamId = @"ARDAMS";
|
| static NSString * const kARDAudioTrackId = @"ARDAMSa0";
|
| static NSString * const kARDVideoTrackId = @"ARDAMSv0";
|
| +static NSString * const kARDVideoTrackKind = @"video";
|
|
|
| // TODO(tkchin): Add these as UI options.
|
| static BOOL const kARDAppClientEnableTracing = NO;
|
| static BOOL const kARDAppClientEnableRtcEventLog = YES;
|
| static int64_t const kARDAppClientAecDumpMaxSizeInBytes = 5e6; // 5 MB.
|
| static int64_t const kARDAppClientRtcEventLogMaxSizeInBytes = 5e6; // 5 MB.
|
| +static int const kKbpsMultiplier = 1000;
|
|
|
| // We need a proxy to NSTimer because it causes a strong retain cycle. When
|
| // using the proxy, |invalidate| must be called before it properly deallocs.
|
| @@ -476,6 +478,7 @@ static int64_t const kARDAppClientRtcEventLogMaxSizeInBytes = 5e6; // 5 MB.
|
| [[ARDSessionDescriptionMessage alloc]
|
| initWithDescription:sdpPreferringH264];
|
| [self sendSignalingMessage:message];
|
| + [self setMaxBitrateForPeerConnectionVideoSender];
|
| });
|
| }
|
|
|
| @@ -680,21 +683,35 @@ 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;
|
| [_delegate appClient:self didReceiveLocalVideoTrack:track];
|
| }
|
| +
|
| return sender;
|
| }
|
|
|
| +- (void)setMaxBitrateForPeerConnectionVideoSender {
|
| + for (RTCRtpSender *sender in _peerConnection.senders) {
|
| + if (sender.track != nil) {
|
| + if ([sender.track.kind isEqualToString:kARDVideoTrackKind]) {
|
| + [self setMaxBitrate:_maxBitrate forVideoSender:sender];
|
| + }
|
| + }
|
| + }
|
| +}
|
| +
|
| - (void)setMaxBitrate:(NSNumber *)maxBitrate forVideoSender:(RTCRtpSender *)sender {
|
| - for (RTCRtpEncodingParameters *encoding in sender.parameters.encodings) {
|
| - encoding.maxBitrateBps = maxBitrate;
|
| + if (maxBitrate.intValue <= 0) {
|
| + return;
|
| + }
|
| +
|
| + RTCRtpParameters *parametersToModify = sender.parameters;
|
| + for (RTCRtpEncodingParameters *encoding in parametersToModify.encodings) {
|
| + encoding.maxBitrateBps = @(maxBitrate.intValue * kKbpsMultiplier);
|
| }
|
| + [sender setParameters:parametersToModify];
|
| }
|
|
|
| - (RTCRtpSender *)createAudioSender {
|
|
|