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 |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/synchronization/lock.h" | 12 #include "base/synchronization/lock.h" |
13 #include "base/threading/thread_checker.h" | 13 #include "base/threading/thread_checker.h" |
14 #include "content/renderer/media/media_stream_track.h" | 14 #include "content/renderer/media/media_stream_track.h" |
15 #include "content/renderer/media/tagged_list.h" | 15 #include "content/renderer/media/tagged_list.h" |
16 #include "content/renderer/media/webrtc_audio_device_impl.h" | 16 #include "media/audio/audio_parameters.h" |
17 | 17 |
18 namespace content { | 18 namespace content { |
19 | 19 |
20 class MediaStreamAudioLevelCalculator; | 20 class MediaStreamAudioLevelCalculator; |
21 class MediaStreamAudioProcessor; | 21 class MediaStreamAudioProcessor; |
22 class MediaStreamAudioSink; | 22 class MediaStreamAudioSink; |
23 class MediaStreamAudioSinkOwner; | 23 class MediaStreamAudioSinkOwner; |
24 class MediaStreamAudioTrackSink; | 24 class MediaStreamAudioTrackSink; |
25 class PeerConnectionAudioSink; | |
26 class WebAudioCapturerSource; | 25 class WebAudioCapturerSource; |
27 class WebRtcAudioCapturer; | 26 class WebRtcAudioCapturer; |
28 class WebRtcLocalAudioTrackAdapter; | 27 class WebRtcLocalAudioTrackAdapter; |
29 | 28 |
30 // A WebRtcLocalAudioTrack instance contains the implementations of | 29 // A WebRtcLocalAudioTrack instance contains the implementations of |
31 // MediaStreamTrackExtraData. | 30 // MediaStreamTrackExtraData. |
32 // When an instance is created, it will register itself as a track to the | 31 // When an instance is created, it will register itself as a track to the |
33 // WebRtcAudioCapturer to get the captured data, and forward the data to | 32 // WebRtcAudioCapturer to get the captured data, and forward the data to |
34 // its |sinks_|. The data flow can be stopped by disabling the audio track. | 33 // its |sinks_|. The data flow can be stopped by disabling the audio track. |
35 class CONTENT_EXPORT WebRtcLocalAudioTrack | 34 class CONTENT_EXPORT WebRtcLocalAudioTrack |
36 : NON_EXPORTED_BASE(public MediaStreamTrack) { | 35 : NON_EXPORTED_BASE(public MediaStreamTrack) { |
37 public: | 36 public: |
38 WebRtcLocalAudioTrack(WebRtcLocalAudioTrackAdapter* adapter, | 37 WebRtcLocalAudioTrack(WebRtcLocalAudioTrackAdapter* adapter, |
39 const scoped_refptr<WebRtcAudioCapturer>& capturer, | 38 const scoped_refptr<WebRtcAudioCapturer>& capturer, |
40 WebAudioCapturerSource* webaudio_source); | 39 WebAudioCapturerSource* webaudio_source); |
41 | 40 |
42 virtual ~WebRtcLocalAudioTrack(); | 41 virtual ~WebRtcLocalAudioTrack(); |
43 | 42 |
44 // Add a sink to the track. This function will trigger a OnSetFormat() | 43 // Add a sink to the track. This function will trigger a OnSetFormat() |
45 // call on the |sink|. | 44 // call on the |sink|. |
46 // Called on the main render thread. | 45 // Called on the main render thread. |
47 void AddSink(MediaStreamAudioSink* sink); | 46 void AddSink(MediaStreamAudioSink* sink); |
48 | 47 |
49 // Remove a sink from the track. | 48 // Remove a sink from the track. |
50 // Called on the main render thread. | 49 // Called on the main render thread. |
51 void RemoveSink(MediaStreamAudioSink* sink); | 50 void RemoveSink(MediaStreamAudioSink* sink); |
52 | 51 |
53 // Add/remove PeerConnection sink to/from the track. | |
54 // TODO(xians): Remove these two methods after PeerConnection can use the | |
55 // same sink interface as MediaStreamAudioSink. | |
56 void AddSink(PeerConnectionAudioSink* sink); | |
57 void RemoveSink(PeerConnectionAudioSink* sink); | |
58 | |
59 // Starts the local audio track. Called on the main render thread and | 52 // Starts the local audio track. Called on the main render thread and |
60 // should be called only once when audio track is created. | 53 // should be called only once when audio track is created. |
61 void Start(); | 54 void Start(); |
62 | 55 |
63 // Overrides for MediaStreamTrack. | 56 // Overrides for MediaStreamTrack. |
64 | 57 |
65 void SetEnabled(bool enabled) override; | 58 void SetEnabled(bool enabled) override; |
66 | 59 |
67 // Stops the local audio track. Called on the main render thread and | 60 // Stops the local audio track. Called on the main render thread and |
68 // should be called only once when audio track going away. | 61 // should be called only once when audio track going away. |
69 void Stop() override; | 62 void Stop() override; |
70 | 63 |
71 webrtc::AudioTrackInterface* GetAudioAdapter() override; | 64 webrtc::AudioTrackInterface* GetAudioAdapter() override; |
72 | 65 |
73 // Method called by the capturer to deliver the capture data. | 66 // Method called by the capturer to deliver the capture data. |
74 // Called on the capture audio thread. | 67 // Called on the capture audio thread. |
75 void Capture(const int16* audio_data, | 68 void Capture(const int16* audio_data, bool force_report_nonzero_energy); |
76 base::TimeDelta delay, | |
77 int volume, | |
78 bool key_pressed, | |
79 bool need_audio_processing, | |
80 bool force_report_nonzero_energy); | |
81 | 69 |
82 // Method called by the capturer to set the audio parameters used by source | 70 // Method called by the capturer to set the audio parameters used by source |
83 // of the capture data.. | 71 // of the capture data.. |
84 // Called on the capture audio thread. | 72 // Called on the capture audio thread. |
85 void OnSetFormat(const media::AudioParameters& params); | 73 void OnSetFormat(const media::AudioParameters& params); |
86 | 74 |
87 // Method called by the capturer to set the processor that applies signal | 75 // Method called by the capturer to set the processor that applies signal |
88 // processing on the data of the track. | 76 // processing on the data of the track. |
89 // Called on the capture audio thread. | 77 // Called on the capture audio thread. |
90 void SetAudioProcessor( | 78 void SetAudioProcessor( |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 // Used to calculate the signal level that shows in the UI. | 115 // Used to calculate the signal level that shows in the UI. |
128 // Accessed on only the audio thread. | 116 // Accessed on only the audio thread. |
129 scoped_ptr<MediaStreamAudioLevelCalculator> level_calculator_; | 117 scoped_ptr<MediaStreamAudioLevelCalculator> level_calculator_; |
130 | 118 |
131 DISALLOW_COPY_AND_ASSIGN(WebRtcLocalAudioTrack); | 119 DISALLOW_COPY_AND_ASSIGN(WebRtcLocalAudioTrack); |
132 }; | 120 }; |
133 | 121 |
134 } // namespace content | 122 } // namespace content |
135 | 123 |
136 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_LOCAL_AUDIO_TRACK_H_ | 124 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_LOCAL_AUDIO_TRACK_H_ |
OLD | NEW |