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

Side by Side Diff: webrtc/sdk/objc/Framework/Classes/RTCAudioTrack.mm

Issue 2290583003: iOS: Add ability to specify audio constraints. (Closed)
Patch Set: Update ctor order. Created 4 years, 3 months 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 unified diff | Download patch
OLDNEW
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 "RTCAudioTrack+Private.h" 11 #import "RTCAudioTrack+Private.h"
12 12
13 #import "NSString+StdString.h" 13 #import "NSString+StdString.h"
14 #import "RTCAudioSource+Private.h"
14 #import "RTCMediaStreamTrack+Private.h" 15 #import "RTCMediaStreamTrack+Private.h"
15 #import "RTCPeerConnectionFactory+Private.h" 16 #import "RTCPeerConnectionFactory+Private.h"
16 17
18 #include "webrtc/base/checks.h"
19
17 @implementation RTCAudioTrack 20 @implementation RTCAudioTrack
18 21
22 @synthesize source = _source;
23
19 - (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory 24 - (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory
25 source:(RTCAudioSource *)source
20 trackId:(NSString *)trackId { 26 trackId:(NSString *)trackId {
21 NSParameterAssert(factory); 27 RTC_DCHECK(factory);
22 NSParameterAssert(trackId.length); 28 RTC_DCHECK(source);
29 RTC_DCHECK(trackId.length);
30
23 std::string nativeId = [NSString stdStringForString:trackId]; 31 std::string nativeId = [NSString stdStringForString:trackId];
24 rtc::scoped_refptr<webrtc::AudioTrackInterface> track = 32 rtc::scoped_refptr<webrtc::AudioTrackInterface> track =
25 factory.nativeFactory->CreateAudioTrack(nativeId, nullptr); 33 factory.nativeFactory->CreateAudioTrack(nativeId, source.nativeAudioSource );
26 return [self initWithNativeTrack:track type:RTCMediaStreamTrackTypeAudio]; 34 if ([self initWithNativeTrack:track type:RTCMediaStreamTrackTypeAudio]) {
35 _source = source;
36 }
37 return self;
27 } 38 }
28 39
29 - (instancetype)initWithNativeTrack: 40 - (instancetype)initWithNativeTrack:
30 (rtc::scoped_refptr<webrtc::MediaStreamTrackInterface>)nativeTrack 41 (rtc::scoped_refptr<webrtc::MediaStreamTrackInterface>)nativeTrack
31 type:(RTCMediaStreamTrackType)type { 42 type:(RTCMediaStreamTrackType)type {
32 NSParameterAssert(nativeTrack); 43 NSParameterAssert(nativeTrack);
33 NSParameterAssert(type == RTCMediaStreamTrackTypeAudio); 44 NSParameterAssert(type == RTCMediaStreamTrackTypeAudio);
34 return [super initWithNativeTrack:nativeTrack type:type]; 45 return [super initWithNativeTrack:nativeTrack type:type];
35 } 46 }
36 47
48
49 - (RTCAudioSource *)source {
50 if (!_source) {
51 rtc::scoped_refptr<webrtc::AudioSourceInterface> source =
52 self.nativeAudioTrack->GetSource();
53 if (source) {
54 _source = [[RTCAudioSource alloc] initWithNativeAudioSource:source.get()];
55 }
56 }
57 return _source;
58 }
59
37 #pragma mark - Private 60 #pragma mark - Private
38 61
39 - (rtc::scoped_refptr<webrtc::AudioTrackInterface>)nativeAudioTrack { 62 - (rtc::scoped_refptr<webrtc::AudioTrackInterface>)nativeAudioTrack {
40 return static_cast<webrtc::AudioTrackInterface *>(self.nativeTrack.get()); 63 return static_cast<webrtc::AudioTrackInterface *>(self.nativeTrack.get());
41 } 64 }
42 65
43 @end 66 @end
OLDNEW
« no previous file with comments | « webrtc/sdk/objc/Framework/Classes/RTCAudioSource+Private.h ('k') | webrtc/sdk/objc/Framework/Classes/RTCAudioTrack+Private.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698