OLD | NEW |
| (Empty) |
1 // Copyright 2015 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. | |
4 | |
5 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_MEDIA_STREAM_REMOTE_AUDIO_TRACK_H_ | |
6 #define CONTENT_RENDERER_MEDIA_WEBRTC_MEDIA_STREAM_REMOTE_AUDIO_TRACK_H_ | |
7 | |
8 #include "base/memory/ref_counted.h" | |
9 #include "base/threading/thread_checker.h" | |
10 #include "content/renderer/media/media_stream_audio_track.h" | |
11 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" | |
12 | |
13 namespace content { | |
14 | |
15 class MediaStreamRemoteAudioSource; | |
16 | |
17 // MediaStreamRemoteAudioTrack is a WebRTC specific implementation of an | |
18 // audio track received from a PeerConnection. | |
19 // TODO(tommi): Chrome shouldn't have to care about remote vs local so | |
20 // we should have a single track implementation that delegates to the | |
21 // sources that do different things depending on the type of source. | |
22 class MediaStreamRemoteAudioTrack : public MediaStreamAudioTrack { | |
23 public: | |
24 explicit MediaStreamRemoteAudioTrack( | |
25 const blink::WebMediaStreamSource& source, bool enabled); | |
26 ~MediaStreamRemoteAudioTrack() override; | |
27 | |
28 // MediaStreamTrack override. | |
29 void SetEnabled(bool enabled) override; | |
30 | |
31 // MediaStreamAudioTrack overrides. | |
32 void AddSink(MediaStreamAudioSink* sink) override; | |
33 void RemoveSink(MediaStreamAudioSink* sink) override; | |
34 media::AudioParameters GetOutputFormat() const override; | |
35 | |
36 webrtc::AudioTrackInterface* GetAudioAdapter() override; | |
37 | |
38 private: | |
39 // MediaStreamAudioTrack override. | |
40 void OnStop() final; | |
41 | |
42 MediaStreamRemoteAudioSource* source() const; | |
43 | |
44 blink::WebMediaStreamSource source_; | |
45 bool enabled_; | |
46 }; | |
47 | |
48 // Inheriting from ExtraData directly since MediaStreamAudioSource has | |
49 // too much unrelated bloat. | |
50 // TODO(tommi): MediaStreamAudioSource needs refactoring. | |
51 // TODO(miu): On it! ;-) | |
52 class MediaStreamRemoteAudioSource | |
53 : public blink::WebMediaStreamSource::ExtraData { | |
54 public: | |
55 explicit MediaStreamRemoteAudioSource( | |
56 const scoped_refptr<webrtc::AudioTrackInterface>& track); | |
57 ~MediaStreamRemoteAudioSource() override; | |
58 | |
59 // Controls whether or not the source is included in the main, mixed, audio | |
60 // output from WebRTC as rendered by WebRtcAudioRenderer (media players). | |
61 void SetEnabledForMixing(bool enabled); | |
62 | |
63 // Adds an audio sink for a track belonging to this source. | |
64 // |enabled| is the enabled state of the track and can be updated via | |
65 // a call to SetSinksEnabled. | |
66 void AddSink(MediaStreamAudioSink* sink, MediaStreamAudioTrack* track, | |
67 bool enabled); | |
68 | |
69 // Removes an audio sink for a track belonging to this source. | |
70 void RemoveSink(MediaStreamAudioSink* sink, MediaStreamAudioTrack* track); | |
71 | |
72 // Turns audio callbacks on/off for all sinks belonging to a track. | |
73 void SetSinksEnabled(MediaStreamAudioTrack* track, bool enabled); | |
74 | |
75 // Removes all sinks belonging to a track. | |
76 void RemoveAll(MediaStreamAudioTrack* track); | |
77 | |
78 webrtc::AudioTrackInterface* GetAudioAdapter(); | |
79 | |
80 private: | |
81 class AudioSink; | |
82 std::unique_ptr<AudioSink> sink_; | |
83 const scoped_refptr<webrtc::AudioTrackInterface> track_; | |
84 base::ThreadChecker thread_checker_; | |
85 }; | |
86 | |
87 } // namespace content | |
88 | |
89 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_MEDIA_STREAM_REMOTE_AUDIO_TRACK_H_ | |
OLD | NEW |