Chromium Code Reviews| Index: webrtc/examples/objc/AppRTCDemo/ARDAppClient.m |
| diff --git a/webrtc/examples/objc/AppRTCDemo/ARDAppClient.m b/webrtc/examples/objc/AppRTCDemo/ARDAppClient.m |
| index 7d060c9e9f4509c6307d247c85e52f5ecbd363eb..cb7577d6d83c0335593e7e089460bba9be2d0abc 100644 |
| --- a/webrtc/examples/objc/AppRTCDemo/ARDAppClient.m |
| +++ b/webrtc/examples/objc/AppRTCDemo/ARDAppClient.m |
| @@ -22,6 +22,7 @@ |
| #import "WebRTC/RTCMediaConstraints.h" |
| #import "WebRTC/RTCMediaStream.h" |
| #import "WebRTC/RTCPeerConnectionFactory.h" |
| +#import "WebRTC/RTCRtpSender.h" |
| #import "ARDAppEngineClient.h" |
| #import "ARDCEODTURNClient.h" |
| @@ -48,6 +49,11 @@ static NSInteger const kARDAppClientErrorCreateSDP = -3; |
| static NSInteger const kARDAppClientErrorSetSDP = -4; |
| static NSInteger const kARDAppClientErrorInvalidClient = -5; |
| static NSInteger const kARDAppClientErrorInvalidRoom = -6; |
| +static NSString * const kARDMediaTypeAudio = @"audio"; |
| +static NSString * const kARDMediaTypeVideo = @"video"; |
| +static NSString * const kARDMediaStreamId = @"ARDAMS"; |
| +static NSString * const kARDAudioTrackId = @"ARDAMSa0"; |
| +static NSString * const kARDVideoTrackId = @"ARDAMSv0"; |
| // TODO(tkchin): Remove guard once rtc_sdk_common_objc compiles on Mac. |
| #if defined(WEBRTC_IOS) |
| @@ -505,9 +511,9 @@ static BOOL const kARDAppClientEnableTracing = NO; |
| _peerConnection = [_factory peerConnectionWithConfiguration:config |
| constraints:constraints |
| delegate:self]; |
| - // Create AV media stream and add it to the peer connection. |
| - RTCMediaStream *localStream = [self createLocalMediaStream]; |
| - [_peerConnection addStream:localStream]; |
| + // Create AV senders. |
| + RTCRtpSender *audioSender = [self createAudioSender]; |
|
tkchin_webrtc
2016/04/27 20:22:20
unused locals?
|
| + RTCRtpSender *videoSender = [self createVideoSender]; |
| if (_isInitiator) { |
| // Send offer. |
| __weak ARDAppClient *weakSelf = self; |
| @@ -606,17 +612,23 @@ static BOOL const kARDAppClientEnableTracing = NO; |
| } |
| } |
| -- (RTCMediaStream *)createLocalMediaStream { |
| - RTCMediaStream *localStream = [_factory mediaStreamWithStreamId:@"ARDAMS"]; |
| - RTCVideoTrack *localVideoTrack = [self createLocalVideoTrack]; |
| - if (localVideoTrack) { |
| - [localStream addVideoTrack:localVideoTrack]; |
| - [_delegate appClient:self didReceiveLocalVideoTrack:localVideoTrack]; |
| +- (RTCRtpSender *)createVideoSender { |
| + RTCRtpSender *sender = [_peerConnection senderWithKind:kARDMediaTypeVideo |
| + streamId:kARDMediaStreamId]; |
| + RTCVideoTrack *track = [self createLocalVideoTrack]; |
| + if (track) { |
| + sender.track = track; |
| + [_delegate appClient:self didReceiveLocalVideoTrack:track]; |
| } |
| - RTCAudioTrack *localAudioTrack = |
| - [_factory audioTrackWithTrackId:@"ARDAMSa0"]; |
| - [localStream addAudioTrack:localAudioTrack]; |
| - return localStream; |
| + return sender; |
| +} |
| + |
| +- (RTCRtpSender *)createAudioSender { |
| + RTCRtpSender *sender = [_peerConnection senderWithKind:kARDMediaTypeAudio |
| + streamId:kARDMediaStreamId]; |
| + RTCAudioTrack *track = [_factory audioTrackWithTrackId:kARDAudioTrackId]; |
| + sender.track = track; |
| + return sender; |
| } |
| - (RTCVideoTrack *)createLocalVideoTrack { |
| @@ -634,7 +646,7 @@ static BOOL const kARDAppClientEnableTracing = NO; |
| [_factory avFoundationVideoSourceWithConstraints:mediaConstraints]; |
| localVideoTrack = |
| [_factory videoTrackWithSource:source |
| - trackId:@"ARDAMSv0"]; |
| + trackId:kARDVideoTrackId]; |
| } |
| #endif |
| return localVideoTrack; |