| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_LOCAL_AUDIO_TRACK_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_LOCAL_AUDIO_TRACK_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_WEBRTC_LOCAL_AUDIO_TRACK_H_ | 6 #define CONTENT_RENDERER_MEDIA_WEBRTC_LOCAL_AUDIO_TRACK_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 // Add/remove PeerConnection sink to/from the track. | 53 // Add/remove PeerConnection sink to/from the track. |
| 54 // TODO(xians): Remove these two methods after PeerConnection can use the | 54 // TODO(xians): Remove these two methods after PeerConnection can use the |
| 55 // same sink interface as MediaStreamAudioSink. | 55 // same sink interface as MediaStreamAudioSink. |
| 56 void AddSink(PeerConnectionAudioSink* sink); | 56 void AddSink(PeerConnectionAudioSink* sink); |
| 57 void RemoveSink(PeerConnectionAudioSink* sink); | 57 void RemoveSink(PeerConnectionAudioSink* sink); |
| 58 | 58 |
| 59 // Starts the local audio track. Called on the main render thread and | 59 // Starts the local audio track. Called on the main render thread and |
| 60 // should be called only once when audio track is created. | 60 // should be called only once when audio track is created. |
| 61 void Start(); | 61 void Start(); |
| 62 | 62 |
| 63 // Overrides for MediaStreamTrack. |
| 64 |
| 65 void SetEnabled(bool enabled) override; |
| 66 |
| 63 // Stops the local audio track. Called on the main render thread and | 67 // Stops the local audio track. Called on the main render thread and |
| 64 // should be called only once when audio track going away. | 68 // should be called only once when audio track going away. |
| 65 void Stop() override; | 69 void Stop() override; |
| 66 | 70 |
| 71 webrtc::AudioTrackInterface* GetAudioAdapter() override; |
| 72 |
| 67 // Method called by the capturer to deliver the capture data. | 73 // Method called by the capturer to deliver the capture data. |
| 68 // Called on the capture audio thread. | 74 // Called on the capture audio thread. |
| 69 void Capture(const int16* audio_data, | 75 void Capture(const int16* audio_data, |
| 70 base::TimeDelta delay, | 76 base::TimeDelta delay, |
| 71 int volume, | 77 int volume, |
| 72 bool key_pressed, | 78 bool key_pressed, |
| 73 bool need_audio_processing, | 79 bool need_audio_processing, |
| 74 bool force_report_nonzero_energy); | 80 bool force_report_nonzero_energy); |
| 75 | 81 |
| 76 // Method called by the capturer to set the audio parameters used by source | 82 // Method called by the capturer to set the audio parameters used by source |
| 77 // of the capture data.. | 83 // of the capture data.. |
| 78 // Called on the capture audio thread. | 84 // Called on the capture audio thread. |
| 79 void OnSetFormat(const media::AudioParameters& params); | 85 void OnSetFormat(const media::AudioParameters& params); |
| 80 | 86 |
| 81 // Method called by the capturer to set the processor that applies signal | 87 // Method called by the capturer to set the processor that applies signal |
| 82 // processing on the data of the track. | 88 // processing on the data of the track. |
| 83 // Called on the capture audio thread. | 89 // Called on the capture audio thread. |
| 84 void SetAudioProcessor( | 90 void SetAudioProcessor( |
| 85 const scoped_refptr<MediaStreamAudioProcessor>& processor); | 91 const scoped_refptr<MediaStreamAudioProcessor>& processor); |
| 86 | 92 |
| 87 private: | 93 private: |
| 88 typedef TaggedList<MediaStreamAudioTrackSink> SinkList; | 94 typedef TaggedList<MediaStreamAudioTrackSink> SinkList; |
| 89 | 95 |
| 90 // All usage of libjingle is through this adapter. The adapter holds | 96 // All usage of libjingle is through this adapter. The adapter holds |
| 91 // a reference on this object, but not vice versa. | 97 // a pointer to this object, but no reference. |
| 92 WebRtcLocalAudioTrackAdapter* adapter_; | 98 const scoped_refptr<WebRtcLocalAudioTrackAdapter> adapter_; |
| 93 | 99 |
| 94 // The provider of captured data to render. | 100 // The provider of captured data to render. |
| 95 scoped_refptr<WebRtcAudioCapturer> capturer_; | 101 scoped_refptr<WebRtcAudioCapturer> capturer_; |
| 96 | 102 |
| 97 // The source of the audio track which is used by WebAudio, which provides | 103 // The source of the audio track which is used by WebAudio, which provides |
| 98 // data to the audio track when hooking up with WebAudio. | 104 // data to the audio track when hooking up with WebAudio. |
| 99 scoped_refptr<WebAudioCapturerSource> webaudio_source_; | 105 scoped_refptr<WebAudioCapturerSource> webaudio_source_; |
| 100 | 106 |
| 101 // A tagged list of sinks that the audio data is fed to. Tags | 107 // A tagged list of sinks that the audio data is fed to. Tags |
| 102 // indicate tracks that need to be notified that the audio format | 108 // indicate tracks that need to be notified that the audio format |
| 103 // has changed. | 109 // has changed. |
| 104 SinkList sinks_; | 110 SinkList sinks_; |
| 105 | 111 |
| 106 // Used to DCHECK that some methods are called on the main render thread. | 112 // Used to DCHECK that some methods are called on the main render thread. |
| 107 base::ThreadChecker main_render_thread_checker_; | 113 base::ThreadChecker main_render_thread_checker_; |
| 114 // Tests that methods are called on libjingle's signaling thread. |
| 115 base::ThreadChecker signal_thread_checker_; |
| 108 | 116 |
| 109 // Used to DCHECK that some methods are called on the capture audio thread. | 117 // Used to DCHECK that some methods are called on the capture audio thread. |
| 110 base::ThreadChecker capture_thread_checker_; | 118 base::ThreadChecker capture_thread_checker_; |
| 111 | 119 |
| 112 // Protects |params_| and |sinks_|. | 120 // Protects |params_| and |sinks_|. |
| 113 mutable base::Lock lock_; | 121 mutable base::Lock lock_; |
| 114 | 122 |
| 115 // Audio parameters of the audio capture stream. | 123 // Audio parameters of the audio capture stream. |
| 116 // Accessed on only the audio capture thread. | 124 // Accessed on only the audio capture thread. |
| 117 media::AudioParameters audio_parameters_; | 125 media::AudioParameters audio_parameters_; |
| 118 | 126 |
| 119 // Used to calculate the signal level that shows in the UI. | 127 // Used to calculate the signal level that shows in the UI. |
| 120 // Accessed on only the audio thread. | 128 // Accessed on only the audio thread. |
| 121 scoped_ptr<MediaStreamAudioLevelCalculator> level_calculator_; | 129 scoped_ptr<MediaStreamAudioLevelCalculator> level_calculator_; |
| 122 | 130 |
| 123 DISALLOW_COPY_AND_ASSIGN(WebRtcLocalAudioTrack); | 131 DISALLOW_COPY_AND_ASSIGN(WebRtcLocalAudioTrack); |
| 124 }; | 132 }; |
| 125 | 133 |
| 126 } // namespace content | 134 } // namespace content |
| 127 | 135 |
| 128 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_LOCAL_AUDIO_TRACK_H_ | 136 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_LOCAL_AUDIO_TRACK_H_ |
| OLD | NEW |