| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_LOCAL_AUDIO_TRACK_ADAPTER_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_LOCAL_AUDIO_TRACK_ADAPTER_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_LOCAL_AUDIO_TRACK_ADAPTER_H_ | 6 #define CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_LOCAL_AUDIO_TRACK_ADAPTER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_vector.h" | 11 #include "base/memory/scoped_vector.h" |
| 12 #include "base/single_thread_task_runner.h" |
| 12 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
| 13 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
| 14 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
| 15 #include "third_party/libjingle/source/talk/app/webrtc/mediastreamtrack.h" | 16 #include "third_party/libjingle/source/talk/app/webrtc/mediastreamtrack.h" |
| 16 #include "third_party/libjingle/source/talk/media/base/audiorenderer.h" | 17 #include "third_party/libjingle/source/talk/media/base/audiorenderer.h" |
| 17 | 18 |
| 18 namespace cricket { | 19 namespace cricket { |
| 19 class AudioRenderer; | 20 class AudioRenderer; |
| 20 } | 21 } |
| 21 | 22 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 34 : NON_EXPORTED_BASE(public cricket::AudioRenderer), | 35 : NON_EXPORTED_BASE(public cricket::AudioRenderer), |
| 35 NON_EXPORTED_BASE( | 36 NON_EXPORTED_BASE( |
| 36 public webrtc::MediaStreamTrack<webrtc::AudioTrackInterface>) { | 37 public webrtc::MediaStreamTrack<webrtc::AudioTrackInterface>) { |
| 37 public: | 38 public: |
| 38 static scoped_refptr<WebRtcLocalAudioTrackAdapter> Create( | 39 static scoped_refptr<WebRtcLocalAudioTrackAdapter> Create( |
| 39 const std::string& label, | 40 const std::string& label, |
| 40 webrtc::AudioSourceInterface* track_source); | 41 webrtc::AudioSourceInterface* track_source); |
| 41 | 42 |
| 42 WebRtcLocalAudioTrackAdapter( | 43 WebRtcLocalAudioTrackAdapter( |
| 43 const std::string& label, | 44 const std::string& label, |
| 44 webrtc::AudioSourceInterface* track_source); | 45 webrtc::AudioSourceInterface* track_source, |
| 46 const scoped_refptr<base::SingleThreadTaskRunner>& signaling_thread); |
| 45 | 47 |
| 46 ~WebRtcLocalAudioTrackAdapter() override; | 48 ~WebRtcLocalAudioTrackAdapter() override; |
| 47 | 49 |
| 48 void Initialize(WebRtcLocalAudioTrack* owner); | 50 void Initialize(WebRtcLocalAudioTrack* owner); |
| 49 | 51 |
| 50 std::vector<int> VoeChannels() const; | 52 std::vector<int> VoeChannels() const; |
| 51 | 53 |
| 52 // Called on the audio thread by the WebRtcLocalAudioTrack to set the signal | 54 // Called on the audio thread by the WebRtcLocalAudioTrack to set the signal |
| 53 // level of the audio data. | 55 // level of the audio data. |
| 54 void SetSignalLevel(int signal_level); | 56 void SetSignalLevel(int signal_level); |
| 55 | 57 |
| 56 // Method called by the WebRtcLocalAudioTrack to set the processor that | 58 // Method called by the WebRtcLocalAudioTrack to set the processor that |
| 57 // applies signal processing on the data of the track. | 59 // applies signal processing on the data of the track. |
| 58 // This class will keep a reference of the |processor|. | 60 // This class will keep a reference of the |processor|. |
| 59 // Called on the main render thread. | 61 // Called on the main render thread. |
| 60 void SetAudioProcessor( | 62 void SetAudioProcessor( |
| 61 const scoped_refptr<MediaStreamAudioProcessor>& processor); | 63 const scoped_refptr<MediaStreamAudioProcessor>& processor); |
| 62 | 64 |
| 63 private: | 65 private: |
| 64 // webrtc::MediaStreamTrack implementation. | 66 // webrtc::MediaStreamTrack implementation. |
| 65 std::string kind() const override; | 67 std::string kind() const override; |
| 68 bool set_enabled(bool enable) override; |
| 66 | 69 |
| 67 // webrtc::AudioTrackInterface implementation. | 70 // webrtc::AudioTrackInterface implementation. |
| 68 void AddSink(webrtc::AudioTrackSinkInterface* sink) override; | 71 void AddSink(webrtc::AudioTrackSinkInterface* sink) override; |
| 69 void RemoveSink(webrtc::AudioTrackSinkInterface* sink) override; | 72 void RemoveSink(webrtc::AudioTrackSinkInterface* sink) override; |
| 70 bool GetSignalLevel(int* level) override; | 73 bool GetSignalLevel(int* level) override; |
| 71 rtc::scoped_refptr<webrtc::AudioProcessorInterface> GetAudioProcessor() | 74 rtc::scoped_refptr<webrtc::AudioProcessorInterface> GetAudioProcessor() |
| 72 override; | 75 override; |
| 73 | 76 |
| 74 // cricket::AudioCapturer implementation. | 77 // cricket::AudioCapturer implementation. |
| 75 void AddChannel(int channel_id) override; | 78 void AddChannel(int channel_id) override; |
| 76 void RemoveChannel(int channel_id) override; | 79 void RemoveChannel(int channel_id) override; |
| 77 | 80 |
| 78 // webrtc::AudioTrackInterface implementation. | 81 // webrtc::AudioTrackInterface implementation. |
| 79 webrtc::AudioSourceInterface* GetSource() const override; | 82 webrtc::AudioSourceInterface* GetSource() const override; |
| 80 cricket::AudioRenderer* GetRenderer() override; | 83 cricket::AudioRenderer* GetRenderer() override; |
| 81 | 84 |
| 82 // Weak reference. | 85 // Weak reference. |
| 83 WebRtcLocalAudioTrack* owner_; | 86 WebRtcLocalAudioTrack* owner_; |
| 84 | 87 |
| 85 // The source of the audio track which handles the audio constraints. | 88 // The source of the audio track which handles the audio constraints. |
| 86 // TODO(xians): merge |track_source_| to |capturer_| in WebRtcLocalAudioTrack. | 89 // TODO(xians): merge |track_source_| to |capturer_| in WebRtcLocalAudioTrack. |
| 87 rtc::scoped_refptr<webrtc::AudioSourceInterface> track_source_; | 90 rtc::scoped_refptr<webrtc::AudioSourceInterface> track_source_; |
| 88 | 91 |
| 92 // Libjingle's signaling thread. |
| 93 const scoped_refptr<base::SingleThreadTaskRunner> signaling_thread_; |
| 94 |
| 89 // The audio processsor that applies audio processing on the data of audio | 95 // The audio processsor that applies audio processing on the data of audio |
| 90 // track. | 96 // track. |
| 91 scoped_refptr<MediaStreamAudioProcessor> audio_processor_; | 97 scoped_refptr<MediaStreamAudioProcessor> audio_processor_; |
| 92 | 98 |
| 93 // A vector of WebRtc VoE channels that the capturer sends data to. | 99 // A vector of WebRtc VoE channels that the capturer sends data to. |
| 94 std::vector<int> voe_channels_; | 100 std::vector<int> voe_channels_; |
| 95 | 101 |
| 96 // A vector of the peer connection sink adapters which receive the audio data | 102 // A vector of the peer connection sink adapters which receive the audio data |
| 97 // from the audio track. | 103 // from the audio track. |
| 98 ScopedVector<WebRtcAudioSinkAdapter> sink_adapters_; | 104 ScopedVector<WebRtcAudioSinkAdapter> sink_adapters_; |
| 99 | 105 |
| 100 // The amplitude of the signal. | 106 // The amplitude of the signal. |
| 101 int signal_level_; | 107 int signal_level_; |
| 102 | 108 |
| 103 // Thread checker for libjingle's signaling thread. | 109 // Thread checker for libjingle's signaling thread. |
| 104 base::ThreadChecker signaling_thread_; | 110 base::ThreadChecker signaling_thread_checker_; |
| 105 base::ThreadChecker capture_thread_; | 111 base::ThreadChecker capture_thread_; |
| 106 | 112 |
| 107 // Protects |voe_channels_|, |audio_processor_| and |signal_level_|. | 113 // Protects |voe_channels_|, |audio_processor_| and |signal_level_|. |
| 108 mutable base::Lock lock_; | 114 mutable base::Lock lock_; |
| 109 }; | 115 }; |
| 110 | 116 |
| 111 } // namespace content | 117 } // namespace content |
| 112 | 118 |
| 113 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_LOCAL_AUDIO_TRACK_ADAPTER_H_ | 119 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_LOCAL_AUDIO_TRACK_ADAPTER_H_ |
| OLD | NEW |