Replace FINAL and OVERRIDE with their C++11 counterparts in content/renderer
[chromium-blink-merge.git] / content / renderer / media / webrtc / webrtc_local_audio_track_adapter.h
blobfc4f52d654b3db413045b477c9dded1e3162ed39
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_LOCAL_AUDIO_TRACK_ADAPTER_H_
6 #define CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_LOCAL_AUDIO_TRACK_ADAPTER_H_
8 #include <vector>
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_vector.h"
12 #include "base/synchronization/lock.h"
13 #include "content/common/content_export.h"
14 #include "third_party/libjingle/source/talk/app/webrtc/mediastreamtrack.h"
15 #include "third_party/libjingle/source/talk/media/base/audiorenderer.h"
17 namespace cricket {
18 class AudioRenderer;
21 namespace webrtc {
22 class AudioSourceInterface;
23 class AudioProcessorInterface;
26 namespace content {
28 class MediaStreamAudioProcessor;
29 class WebRtcAudioSinkAdapter;
30 class WebRtcLocalAudioTrack;
32 class CONTENT_EXPORT WebRtcLocalAudioTrackAdapter
33 : NON_EXPORTED_BASE(public cricket::AudioRenderer),
34 NON_EXPORTED_BASE(
35 public webrtc::MediaStreamTrack<webrtc::AudioTrackInterface>) {
36 public:
37 static scoped_refptr<WebRtcLocalAudioTrackAdapter> Create(
38 const std::string& label,
39 webrtc::AudioSourceInterface* track_source);
41 WebRtcLocalAudioTrackAdapter(
42 const std::string& label,
43 webrtc::AudioSourceInterface* track_source);
45 virtual ~WebRtcLocalAudioTrackAdapter();
47 void Initialize(WebRtcLocalAudioTrack* owner);
49 std::vector<int> VoeChannels() const;
51 // Called on the audio thread by the WebRtcLocalAudioTrack to set the signal
52 // level of the audio data.
53 void SetSignalLevel(int signal_level);
55 // Method called by the WebRtcLocalAudioTrack to set the processor that
56 // applies signal processing on the data of the track.
57 // This class will keep a reference of the |processor|.
58 // Called on the main render thread.
59 void SetAudioProcessor(
60 const scoped_refptr<MediaStreamAudioProcessor>& processor);
62 private:
63 // webrtc::MediaStreamTrack implementation.
64 virtual std::string kind() const override;
66 // webrtc::AudioTrackInterface implementation.
67 virtual void AddSink(webrtc::AudioTrackSinkInterface* sink) override;
68 virtual void RemoveSink(webrtc::AudioTrackSinkInterface* sink) override;
69 virtual bool GetSignalLevel(int* level) override;
70 virtual rtc::scoped_refptr<webrtc::AudioProcessorInterface>
71 GetAudioProcessor() override;
73 // cricket::AudioCapturer implementation.
74 virtual void AddChannel(int channel_id) override;
75 virtual void RemoveChannel(int channel_id) override;
77 // webrtc::AudioTrackInterface implementation.
78 virtual webrtc::AudioSourceInterface* GetSource() const override;
79 virtual cricket::AudioRenderer* GetRenderer() override;
81 // Weak reference.
82 WebRtcLocalAudioTrack* owner_;
84 // The source of the audio track which handles the audio constraints.
85 // TODO(xians): merge |track_source_| to |capturer_| in WebRtcLocalAudioTrack.
86 rtc::scoped_refptr<webrtc::AudioSourceInterface> track_source_;
88 // The audio processsor that applies audio processing on the data of audio
89 // track.
90 scoped_refptr<MediaStreamAudioProcessor> audio_processor_;
92 // A vector of WebRtc VoE channels that the capturer sends data to.
93 std::vector<int> voe_channels_;
95 // A vector of the peer connection sink adapters which receive the audio data
96 // from the audio track.
97 ScopedVector<WebRtcAudioSinkAdapter> sink_adapters_;
99 // The amplitude of the signal.
100 int signal_level_;
102 // Protects |voe_channels_|, |audio_processor_| and |signal_level_|.
103 mutable base::Lock lock_;
106 } // namespace content
108 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_LOCAL_AUDIO_TRACK_ADAPTER_H_