OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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_LOCAL_MEDIA_STREAM_AUDIO_SOURCE_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_LOCAL_MEDIA_STREAM_AUDIO_SOURCE_H_ |
| 7 |
| 8 #include "content/common/media/media_stream_options.h" |
| 9 #include "content/renderer/media/media_stream_audio_source.h" |
| 10 #include "media/base/audio_capturer_source.h" |
| 11 #include "media/audio/audio_input_device.h" |
| 12 |
| 13 namespace content { |
| 14 |
| 15 // Represents a local source of audio data generated by an AudioInputDevice. |
| 16 // Uses content::AudioDeviceFactory to auto-create the AudioInputDevice, using |
| 17 // the parameters and session ID found in StreamDeviceInfo, just before the |
| 18 // first track is connected. Audio data is transported directly to the tracks |
| 19 // (i.e., there is no audio processing). |
| 20 class CONTENT_EXPORT LocalMediaStreamAudioSource |
| 21 : NON_EXPORTED_BASE(public MediaStreamAudioSource), |
| 22 NON_EXPORTED_BASE(public media::AudioCapturerSource::CaptureCallback) { |
| 23 public: |
| 24 // |consumer_render_frame_id| references the RenderFrame that will consume the |
| 25 // audio data. Audio parameters and (optionally) a pre-existing audio session |
| 26 // ID are read from |device_info|. |
| 27 LocalMediaStreamAudioSource(int consumer_render_frame_id, |
| 28 const StreamDeviceInfo& device_info); |
| 29 |
| 30 ~LocalMediaStreamAudioSource() final; |
| 31 |
| 32 private: |
| 33 // MediaStreamAudioSource implementation. |
| 34 void DoStopSource() final; |
| 35 bool EnsureSourceIsStarted() final; |
| 36 |
| 37 // media::AudioCapturerSource::CaptureCallback implementation. |
| 38 void Capture(const media::AudioBus* audio_bus, |
| 39 int audio_delay_milliseconds, |
| 40 double volume, |
| 41 bool key_pressed) final; |
| 42 void OnCaptureError(const std::string& message) final; |
| 43 |
| 44 // The RenderFrame that will consume the audio data. Used when creating |
| 45 // AudioInputDevices via the AudioDeviceFactory. |
| 46 const int consumer_render_frame_id_; |
| 47 |
| 48 // The StreamDeviceInfo session ID. Used when creating AudioInputDevices via |
| 49 // the AudioDeviceFactory. |
| 50 const int session_id_; |
| 51 |
| 52 // The device created by the AudioDeviceFactory in EnsureSourceIsStarted(). |
| 53 scoped_refptr<media::AudioInputDevice> input_device_; |
| 54 |
| 55 DISALLOW_COPY_AND_ASSIGN(LocalMediaStreamAudioSource); |
| 56 }; |
| 57 |
| 58 } // namespace content |
| 59 |
| 60 #endif // CONTENT_RENDERER_MEDIA_LOCAL_MEDIA_STREAM_AUDIO_SOURCE_H_ |
OLD | NEW |