Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Unified Diff: webrtc/examples/objc/AppRTCMobile/ARDAppClient.m

Issue 2492693003: Propagate bitrate setting to RTCRtpSender. (Closed)
Patch Set: Address comments Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | webrtc/examples/objc/AppRTCMobile/ios/ARDSettingsModel.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 {
« no previous file with comments | « no previous file | webrtc/examples/objc/AppRTCMobile/ios/ARDSettingsModel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698