blob: 42542b8b8f0033acefa116db5b17ebc1827b105f [file] [log] [blame]
Jon Hjelleca91e382016-01-21 15:36:47 -08001/*
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
tkchin9eeb6242016-04-27 01:54:20 -070011#import "RTCAudioTrack+Private.h"
Jon Hjelleca91e382016-01-21 15:36:47 -080012
tkchin9eeb6242016-04-27 01:54:20 -070013#import "NSString+StdString.h"
14#import "RTCMediaStreamTrack+Private.h"
15#import "RTCPeerConnectionFactory+Private.h"
Jon Hjelleca91e382016-01-21 15:36:47 -080016
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