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/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
14 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
15 #include "content/renderer/media/media_stream_track.h" | 15 #include "content/renderer/media/media_stream_audio_track.h" |
16 #include "content/renderer/media/tagged_list.h" | 16 #include "content/renderer/media/tagged_list.h" |
17 #include "media/audio/audio_parameters.h" | 17 #include "media/audio/audio_parameters.h" |
18 | 18 |
19 namespace media { | 19 namespace media { |
20 class AudioBus; | 20 class AudioBus; |
21 } | 21 } |
22 | 22 |
23 namespace content { | 23 namespace content { |
24 | 24 |
25 class MediaStreamAudioLevelCalculator; | 25 class MediaStreamAudioLevelCalculator; |
26 class MediaStreamAudioProcessor; | 26 class MediaStreamAudioProcessor; |
27 class MediaStreamAudioSink; | 27 class MediaStreamAudioSink; |
28 class MediaStreamAudioSinkOwner; | 28 class MediaStreamAudioSinkOwner; |
29 class MediaStreamAudioTrackSink; | 29 class MediaStreamAudioTrackSink; |
30 class WebAudioCapturerSource; | 30 class WebAudioCapturerSource; |
31 class WebRtcAudioCapturer; | 31 class WebRtcAudioCapturer; |
32 class WebRtcLocalAudioTrackAdapter; | 32 class WebRtcLocalAudioTrackAdapter; |
33 | 33 |
34 // A WebRtcLocalAudioTrack instance contains the implementations of | 34 // A WebRtcLocalAudioTrack instance contains the implementations of |
35 // MediaStreamTrackExtraData. | 35 // MediaStreamTrackExtraData. |
36 // When an instance is created, it will register itself as a track to the | 36 // When an instance is created, it will register itself as a track to the |
37 // WebRtcAudioCapturer to get the captured data, and forward the data to | 37 // WebRtcAudioCapturer to get the captured data, and forward the data to |
38 // its |sinks_|. The data flow can be stopped by disabling the audio track. | 38 // its |sinks_|. The data flow can be stopped by disabling the audio track. |
| 39 // TODO(tommi): Rename to MediaStreamLocalAudioTrack. |
39 class CONTENT_EXPORT WebRtcLocalAudioTrack | 40 class CONTENT_EXPORT WebRtcLocalAudioTrack |
40 : NON_EXPORTED_BASE(public MediaStreamTrack) { | 41 : NON_EXPORTED_BASE(public MediaStreamAudioTrack) { |
41 public: | 42 public: |
42 WebRtcLocalAudioTrack(WebRtcLocalAudioTrackAdapter* adapter, | 43 WebRtcLocalAudioTrack(WebRtcLocalAudioTrackAdapter* adapter, |
43 const scoped_refptr<WebRtcAudioCapturer>& capturer, | 44 const scoped_refptr<WebRtcAudioCapturer>& capturer, |
44 WebAudioCapturerSource* webaudio_source); | 45 WebAudioCapturerSource* webaudio_source); |
45 | 46 |
46 ~WebRtcLocalAudioTrack() override; | 47 ~WebRtcLocalAudioTrack() override; |
47 | 48 |
48 // Add a sink to the track. This function will trigger a OnSetFormat() | 49 // Add a sink to the track. This function will trigger a OnSetFormat() |
49 // call on the |sink|. | 50 // call on the |sink|. |
50 // Called on the main render thread. | 51 // Called on the main render thread. |
51 void AddSink(MediaStreamAudioSink* sink); | 52 void AddSink(MediaStreamAudioSink* sink) override; |
52 | 53 |
53 // Remove a sink from the track. | 54 // Remove a sink from the track. |
54 // Called on the main render thread. | 55 // Called on the main render thread. |
55 void RemoveSink(MediaStreamAudioSink* sink); | 56 void RemoveSink(MediaStreamAudioSink* sink) override; |
56 | 57 |
57 // Starts the local audio track. Called on the main render thread and | 58 // Starts the local audio track. Called on the main render thread and |
58 // should be called only once when audio track is created. | 59 // should be called only once when audio track is created. |
59 void Start(); | 60 void Start(); |
60 | 61 |
61 // Overrides for MediaStreamTrack. | 62 // Overrides for MediaStreamTrack. |
62 | 63 |
63 void SetEnabled(bool enabled) override; | 64 void SetEnabled(bool enabled) override; |
64 | 65 |
65 // Stops the local audio track. Called on the main render thread and | 66 // Stops the local audio track. Called on the main render thread and |
66 // should be called only once when audio track going away. | 67 // should be called only once when audio track going away. |
67 void Stop() override; | 68 void Stop() override; |
68 | 69 |
69 webrtc::AudioTrackInterface* GetAudioAdapter() override; | 70 webrtc::AudioTrackInterface* GetAudioAdapter() override; |
70 | 71 |
71 // Returns the output format of the capture source. May return an invalid | 72 // Returns the output format of the capture source. May return an invalid |
72 // AudioParameters if the format is not yet available. | 73 // AudioParameters if the format is not yet available. |
73 // Called on the main render thread. | 74 // Called on the main render thread. |
74 media::AudioParameters GetOutputFormat() const; | 75 media::AudioParameters GetOutputFormat() const override; |
75 | 76 |
76 // Method called by the capturer to deliver the capture data. | 77 // Method called by the capturer to deliver the capture data. |
77 // Called on the capture audio thread. | 78 // Called on the capture audio thread. |
78 void Capture(const media::AudioBus& audio_bus, | 79 void Capture(const media::AudioBus& audio_bus, |
79 base::TimeTicks estimated_capture_time, | 80 base::TimeTicks estimated_capture_time, |
80 bool force_report_nonzero_energy); | 81 bool force_report_nonzero_energy); |
81 | 82 |
82 // Method called by the capturer to set the audio parameters used by source | 83 // Method called by the capturer to set the audio parameters used by source |
83 // of the capture data.. | 84 // of the capture data.. |
84 // Called on the capture audio thread. | 85 // Called on the capture audio thread. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 // Used to calculate the signal level that shows in the UI. | 126 // Used to calculate the signal level that shows in the UI. |
126 // Accessed on only the audio thread. | 127 // Accessed on only the audio thread. |
127 scoped_ptr<MediaStreamAudioLevelCalculator> level_calculator_; | 128 scoped_ptr<MediaStreamAudioLevelCalculator> level_calculator_; |
128 | 129 |
129 DISALLOW_COPY_AND_ASSIGN(WebRtcLocalAudioTrack); | 130 DISALLOW_COPY_AND_ASSIGN(WebRtcLocalAudioTrack); |
130 }; | 131 }; |
131 | 132 |
132 } // namespace content | 133 } // namespace content |
133 | 134 |
134 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_LOCAL_AUDIO_TRACK_H_ | 135 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_LOCAL_AUDIO_TRACK_H_ |
OLD | NEW |