Jon Hjelle | ca91e38 | 2016-01-21 15:36:47 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
tkchin | 9eeb624 | 2016-04-27 01:54:20 -0700 | [diff] [blame] | 11 | #import "RTCAudioTrack+Private.h" |
Jon Hjelle | ca91e38 | 2016-01-21 15:36:47 -0800 | [diff] [blame] | 12 | |
tkchin | 9eeb624 | 2016-04-27 01:54:20 -0700 | [diff] [blame] | 13 | #import "NSString+StdString.h" |
| 14 | #import "RTCMediaStreamTrack+Private.h" |
| 15 | #import "RTCPeerConnectionFactory+Private.h" |
Jon Hjelle | ca91e38 | 2016-01-21 15:36:47 -0800 | [diff] [blame] | 16 | |
| 17 | @implementation RTCAudioTrack |
| 18 | |
| 19 | - (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory |
| 20 | trackId:(NSString *)trackId { |
| 21 | NSParameterAssert(factory); |
| 22 | NSParameterAssert(trackId.length); |
| 23 | std::string nativeId = [NSString stdStringForString:trackId]; |
| 24 | rtc::scoped_refptr<webrtc::AudioTrackInterface> track = |
| 25 | factory.nativeFactory->CreateAudioTrack(nativeId, nullptr); |
| 26 | return [self initWithNativeTrack:track type:RTCMediaStreamTrackTypeAudio]; |
| 27 | } |
| 28 | |
| 29 | - (instancetype)initWithNativeTrack: |
| 30 | (rtc::scoped_refptr<webrtc::MediaStreamTrackInterface>)nativeTrack |
| 31 | type:(RTCMediaStreamTrackType)type { |
| 32 | NSParameterAssert(nativeTrack); |
| 33 | NSParameterAssert(type == RTCMediaStreamTrackTypeAudio); |
| 34 | return [super initWithNativeTrack:nativeTrack type:type]; |
| 35 | } |
| 36 | |
| 37 | #pragma mark - Private |
| 38 | |
| 39 | - (rtc::scoped_refptr<webrtc::AudioTrackInterface>)nativeAudioTrack { |
| 40 | return static_cast<webrtc::AudioTrackInterface *>(self.nativeTrack.get()); |
| 41 | } |
| 42 | |
| 43 | @end |