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" |
(...skipping 24 matching lines...) Expand all Loading... |
35 public webrtc::MediaStreamTrack<webrtc::AudioTrackInterface>) { | 35 public webrtc::MediaStreamTrack<webrtc::AudioTrackInterface>) { |
36 public: | 36 public: |
37 static scoped_refptr<WebRtcLocalAudioTrackAdapter> Create( | 37 static scoped_refptr<WebRtcLocalAudioTrackAdapter> Create( |
38 const std::string& label, | 38 const std::string& label, |
39 webrtc::AudioSourceInterface* track_source); | 39 webrtc::AudioSourceInterface* track_source); |
40 | 40 |
41 WebRtcLocalAudioTrackAdapter( | 41 WebRtcLocalAudioTrackAdapter( |
42 const std::string& label, | 42 const std::string& label, |
43 webrtc::AudioSourceInterface* track_source); | 43 webrtc::AudioSourceInterface* track_source); |
44 | 44 |
45 virtual ~WebRtcLocalAudioTrackAdapter(); | 45 ~WebRtcLocalAudioTrackAdapter() override; |
46 | 46 |
47 void Initialize(WebRtcLocalAudioTrack* owner); | 47 void Initialize(WebRtcLocalAudioTrack* owner); |
48 | 48 |
49 std::vector<int> VoeChannels() const; | 49 std::vector<int> VoeChannels() const; |
50 | 50 |
51 // Called on the audio thread by the WebRtcLocalAudioTrack to set the signal | 51 // Called on the audio thread by the WebRtcLocalAudioTrack to set the signal |
52 // level of the audio data. | 52 // level of the audio data. |
53 void SetSignalLevel(int signal_level); | 53 void SetSignalLevel(int signal_level); |
54 | 54 |
55 // Method called by the WebRtcLocalAudioTrack to set the processor that | 55 // Method called by the WebRtcLocalAudioTrack to set the processor that |
56 // applies signal processing on the data of the track. | 56 // applies signal processing on the data of the track. |
57 // This class will keep a reference of the |processor|. | 57 // This class will keep a reference of the |processor|. |
58 // Called on the main render thread. | 58 // Called on the main render thread. |
59 void SetAudioProcessor( | 59 void SetAudioProcessor( |
60 const scoped_refptr<MediaStreamAudioProcessor>& processor); | 60 const scoped_refptr<MediaStreamAudioProcessor>& processor); |
61 | 61 |
62 private: | 62 private: |
63 // webrtc::MediaStreamTrack implementation. | 63 // webrtc::MediaStreamTrack implementation. |
64 virtual std::string kind() const override; | 64 std::string kind() const override; |
65 | 65 |
66 // webrtc::AudioTrackInterface implementation. | 66 // webrtc::AudioTrackInterface implementation. |
67 virtual void AddSink(webrtc::AudioTrackSinkInterface* sink) override; | 67 void AddSink(webrtc::AudioTrackSinkInterface* sink) override; |
68 virtual void RemoveSink(webrtc::AudioTrackSinkInterface* sink) override; | 68 void RemoveSink(webrtc::AudioTrackSinkInterface* sink) override; |
69 virtual bool GetSignalLevel(int* level) override; | 69 bool GetSignalLevel(int* level) override; |
70 virtual rtc::scoped_refptr<webrtc::AudioProcessorInterface> | 70 rtc::scoped_refptr<webrtc::AudioProcessorInterface> GetAudioProcessor() |
71 GetAudioProcessor() override; | 71 override; |
72 | 72 |
73 // cricket::AudioCapturer implementation. | 73 // cricket::AudioCapturer implementation. |
74 virtual void AddChannel(int channel_id) override; | 74 void AddChannel(int channel_id) override; |
75 virtual void RemoveChannel(int channel_id) override; | 75 void RemoveChannel(int channel_id) override; |
76 | 76 |
77 // webrtc::AudioTrackInterface implementation. | 77 // webrtc::AudioTrackInterface implementation. |
78 virtual webrtc::AudioSourceInterface* GetSource() const override; | 78 webrtc::AudioSourceInterface* GetSource() const override; |
79 virtual cricket::AudioRenderer* GetRenderer() override; | 79 cricket::AudioRenderer* GetRenderer() override; |
80 | 80 |
81 // Weak reference. | 81 // Weak reference. |
82 WebRtcLocalAudioTrack* owner_; | 82 WebRtcLocalAudioTrack* owner_; |
83 | 83 |
84 // The source of the audio track which handles the audio constraints. | 84 // The source of the audio track which handles the audio constraints. |
85 // TODO(xians): merge |track_source_| to |capturer_| in WebRtcLocalAudioTrack. | 85 // TODO(xians): merge |track_source_| to |capturer_| in WebRtcLocalAudioTrack. |
86 rtc::scoped_refptr<webrtc::AudioSourceInterface> track_source_; | 86 rtc::scoped_refptr<webrtc::AudioSourceInterface> track_source_; |
87 | 87 |
88 // The audio processsor that applies audio processing on the data of audio | 88 // The audio processsor that applies audio processing on the data of audio |
89 // track. | 89 // track. |
90 scoped_refptr<MediaStreamAudioProcessor> audio_processor_; | 90 scoped_refptr<MediaStreamAudioProcessor> audio_processor_; |
91 | 91 |
92 // A vector of WebRtc VoE channels that the capturer sends data to. | 92 // A vector of WebRtc VoE channels that the capturer sends data to. |
93 std::vector<int> voe_channels_; | 93 std::vector<int> voe_channels_; |
94 | 94 |
95 // A vector of the peer connection sink adapters which receive the audio data | 95 // A vector of the peer connection sink adapters which receive the audio data |
96 // from the audio track. | 96 // from the audio track. |
97 ScopedVector<WebRtcAudioSinkAdapter> sink_adapters_; | 97 ScopedVector<WebRtcAudioSinkAdapter> sink_adapters_; |
98 | 98 |
99 // The amplitude of the signal. | 99 // The amplitude of the signal. |
100 int signal_level_; | 100 int signal_level_; |
101 | 101 |
102 // Protects |voe_channels_|, |audio_processor_| and |signal_level_|. | 102 // Protects |voe_channels_|, |audio_processor_| and |signal_level_|. |
103 mutable base::Lock lock_; | 103 mutable base::Lock lock_; |
104 }; | 104 }; |
105 | 105 |
106 } // namespace content | 106 } // namespace content |
107 | 107 |
108 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_LOCAL_AUDIO_TRACK_ADAPTER_H_ | 108 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_LOCAL_AUDIO_TRACK_ADAPTER_H_ |
OLD | NEW |