tkchin | d4bfbfc | 2016-08-30 11:56:05 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 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 | |
| 11 | #import "RTCAudioSource+Private.h" |
| 12 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 13 | #include "rtc_base/checks.h" |
tkchin | d4bfbfc | 2016-08-30 11:56:05 -0700 | [diff] [blame] | 14 | |
| 15 | @implementation RTCAudioSource { |
tkchin | d4bfbfc | 2016-08-30 11:56:05 -0700 | [diff] [blame] | 16 | } |
| 17 | |
frederik.riedel | 0d1305e | 2017-02-23 13:57:00 -0800 | [diff] [blame] | 18 | @synthesize volume = _volume; |
kthelgason | 5a4c68e | 2017-03-28 04:35:58 -0700 | [diff] [blame] | 19 | @synthesize nativeAudioSource = _nativeAudioSource; |
frederik.riedel | 0d1305e | 2017-02-23 13:57:00 -0800 | [diff] [blame] | 20 | |
Yura Yaroshevich | 01cee07 | 2018-07-11 15:35:40 +0300 | [diff] [blame^] | 21 | - (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory |
| 22 | nativeAudioSource: |
| 23 | (rtc::scoped_refptr<webrtc::AudioSourceInterface>)nativeAudioSource { |
| 24 | RTC_DCHECK(factory); |
tkchin | d4bfbfc | 2016-08-30 11:56:05 -0700 | [diff] [blame] | 25 | RTC_DCHECK(nativeAudioSource); |
Yura Yaroshevich | 01cee07 | 2018-07-11 15:35:40 +0300 | [diff] [blame^] | 26 | |
| 27 | if (self = [super initWithFactory:factory |
| 28 | nativeMediaSource:nativeAudioSource |
| 29 | type:RTCMediaSourceTypeAudio]) { |
tkchin | d4bfbfc | 2016-08-30 11:56:05 -0700 | [diff] [blame] | 30 | _nativeAudioSource = nativeAudioSource; |
| 31 | } |
| 32 | return self; |
| 33 | } |
| 34 | |
Yura Yaroshevich | 01cee07 | 2018-07-11 15:35:40 +0300 | [diff] [blame^] | 35 | - (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory |
| 36 | nativeMediaSource:(rtc::scoped_refptr<webrtc::MediaSourceInterface>)nativeMediaSource |
| 37 | type:(RTCMediaSourceType)type { |
tkchin | d4bfbfc | 2016-08-30 11:56:05 -0700 | [diff] [blame] | 38 | RTC_NOTREACHED(); |
| 39 | return nil; |
| 40 | } |
| 41 | |
| 42 | - (NSString *)description { |
| 43 | NSString *stateString = [[self class] stringForState:self.state]; |
| 44 | return [NSString stringWithFormat:@"RTCAudioSource( %p ): %@", self, stateString]; |
| 45 | } |
| 46 | |
frederik.riedel | 0d1305e | 2017-02-23 13:57:00 -0800 | [diff] [blame] | 47 | - (void)setVolume:(double)volume { |
| 48 | _volume = volume; |
| 49 | _nativeAudioSource->SetVolume(volume); |
| 50 | } |
| 51 | |
tkchin | d4bfbfc | 2016-08-30 11:56:05 -0700 | [diff] [blame] | 52 | @end |