OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #import "RTCMediaStream.h" | 11 #import "RTCMediaStream.h" |
12 | 12 |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #import "webrtc/api/objc/RTCAudioTrack+Private.h" | 15 #import "webrtc/api/objc/RTCAudioTrack+Private.h" |
16 #import "webrtc/api/objc/RTCMediaStream+Private.h" | 16 #import "webrtc/api/objc/RTCMediaStream+Private.h" |
17 #import "webrtc/api/objc/RTCMediaStreamTrack+Private.h" | 17 #import "webrtc/api/objc/RTCMediaStreamTrack+Private.h" |
18 #import "webrtc/api/objc/RTCPeerConnectionFactory+Private.h" | 18 #import "webrtc/api/objc/RTCPeerConnectionFactory+Private.h" |
19 #import "webrtc/api/objc/RTCVideoTrack+Private.h" | 19 #import "webrtc/api/objc/RTCVideoTrack+Private.h" |
20 #import "webrtc/base/objc/NSString+StdString.h" | 20 #import "webrtc/base/objc/NSString+StdString.h" |
21 | 21 |
22 // TODO(hjon): Update nullability types. See http://crbug/webrtc/5592 | |
23 | |
24 @implementation RTCMediaStream { | 22 @implementation RTCMediaStream { |
25 NSMutableArray *_audioTracks; | 23 NSMutableArray *_audioTracks; |
26 NSMutableArray *_videoTracks; | 24 NSMutableArray *_videoTracks; |
27 rtc::scoped_refptr<webrtc::MediaStreamInterface> _nativeMediaStream; | 25 rtc::scoped_refptr<webrtc::MediaStreamInterface> _nativeMediaStream; |
28 } | 26 } |
29 | 27 |
30 - (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory | 28 - (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory |
31 streamId:(NSString *)streamId { | 29 streamId:(NSString *)streamId { |
32 NSParameterAssert(factory); | 30 NSParameterAssert(factory); |
33 NSParameterAssert(streamId.length); | 31 NSParameterAssert(streamId.length); |
34 std::string nativeId = [NSString stdStringForString:streamId]; | 32 std::string nativeId = [NSString stdStringForString:streamId]; |
35 rtc::scoped_refptr<webrtc::MediaStreamInterface> stream = | 33 rtc::scoped_refptr<webrtc::MediaStreamInterface> stream = |
36 factory.nativeFactory->CreateLocalMediaStream(nativeId); | 34 factory.nativeFactory->CreateLocalMediaStream(nativeId); |
37 return [self initWithNativeMediaStream:stream]; | 35 return [self initWithNativeMediaStream:stream]; |
38 } | 36 } |
39 | 37 |
40 - (NSArray *)audioTracks { | 38 - (NSArray<RTCAudioTrack *> *)audioTracks { |
41 // - (NSArray<RTCAudioTrack *> *)audioTracks { | |
42 return [_audioTracks copy]; | 39 return [_audioTracks copy]; |
43 } | 40 } |
44 | 41 |
45 - (NSArray *)videoTracks { | 42 - (NSArray<RTCVideoTrack *> *)videoTracks { |
46 // - (NSArray<RTCVideoTrack *> *)videoTracks { | |
47 return [_videoTracks copy]; | 43 return [_videoTracks copy]; |
48 } | 44 } |
49 | 45 |
50 - (NSString *)streamId { | 46 - (NSString *)streamId { |
51 return [NSString stringForStdString:_nativeMediaStream->label()]; | 47 return [NSString stringForStdString:_nativeMediaStream->label()]; |
52 } | 48 } |
53 | 49 |
54 - (void)addAudioTrack:(RTCAudioTrack *)audioTrack { | 50 - (void)addAudioTrack:(RTCAudioTrack *)audioTrack { |
55 if (_nativeMediaStream->AddTrack(audioTrack.nativeAudioTrack)) { | 51 if (_nativeMediaStream->AddTrack(audioTrack.nativeAudioTrack)) { |
56 [_audioTracks addObject:audioTrack]; | 52 [_audioTracks addObject:audioTrack]; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 RTCMediaStreamTrackType type = RTCMediaStreamTrackTypeVideo; | 114 RTCMediaStreamTrackType type = RTCMediaStreamTrackTypeVideo; |
119 RTCVideoTrack *videoTrack = | 115 RTCVideoTrack *videoTrack = |
120 [[RTCVideoTrack alloc] initWithNativeTrack:track type:type]; | 116 [[RTCVideoTrack alloc] initWithNativeTrack:track type:type]; |
121 [_videoTracks addObject:videoTrack]; | 117 [_videoTracks addObject:videoTrack]; |
122 } | 118 } |
123 } | 119 } |
124 return self; | 120 return self; |
125 } | 121 } |
126 | 122 |
127 @end | 123 @end |
OLD | NEW |