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_
10 #include "base/memory/ref_counted.h"
11 #include "base/synchronization/lock.h"
12 #include "content/common/content_export.h"
13 #include "third_party/libjingle/source/talk/app/webrtc/mediastreamtrack.h"
14 #include "third_party/libjingle/source/talk/media/base/audiorenderer.h"
21 class AudioSourceInterface;
26 class WebRtcLocalAudioTrack;
28 class CONTENT_EXPORT WebRtcLocalAudioTrackAdapter
29 : NON_EXPORTED_BASE(public cricket::AudioRenderer),
31 public webrtc::MediaStreamTrack<webrtc::AudioTrackInterface>) {
33 static scoped_refptr<WebRtcLocalAudioTrackAdapter> Create(
34 const std::string& label,
35 webrtc::AudioSourceInterface* track_source);
37 WebRtcLocalAudioTrackAdapter(
38 const std::string& label,
39 webrtc::AudioSourceInterface* track_source);
41 virtual ~WebRtcLocalAudioTrackAdapter();
43 void Initialize(WebRtcLocalAudioTrack* owner);
45 std::vector<int> VoeChannels() const;
48 // webrtc::MediaStreamTrack implementation.
49 virtual std::string kind() const OVERRIDE;
51 // cricket::AudioCapturer implementation.
52 virtual void AddChannel(int channel_id) OVERRIDE;
53 virtual void RemoveChannel(int channel_id) OVERRIDE;
55 // webrtc::AudioTrackInterface implementation.
56 virtual webrtc::AudioSourceInterface* GetSource() const OVERRIDE;
57 virtual cricket::AudioRenderer* GetRenderer() OVERRIDE;
60 WebRtcLocalAudioTrack* owner_;
62 // The source of the audio track which handles the audio constraints.
63 // TODO(xians): merge |track_source_| to |capturer_| in WebRtcLocalAudioTrack.
64 talk_base::scoped_refptr<webrtc::AudioSourceInterface> track_source_;
66 // A vector of WebRtc VoE channels that the capturer sends data to.
67 std::vector<int> voe_channels_;
69 // Protects |voe_channels_|.
70 mutable base::Lock lock_;
73 } // namespace content
75 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_LOCAL_AUDIO_TRACK_ADAPTER_H_