Index: content/renderer/media/restartable_audio_output_device_factory.h |
diff --git a/content/renderer/media/restartable_audio_output_device_factory.h b/content/renderer/media/restartable_audio_output_device_factory.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..2831b45235fabdea441a1d2103db8b1abded5545 |
--- /dev/null |
+++ b/content/renderer/media/restartable_audio_output_device_factory.h |
@@ -0,0 +1,87 @@ |
+// Copyright (c) 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CONTENT_RENDERER_MEDIA_RESTARTABLE_AUDIO_OUTPUT_DEVICE_FACTORY_H_ |
+#define CONTENT_RENDERER_MEDIA_RESTARTABLE_AUDIO_OUTPUT_DEVICE_FACTORY_H_ |
+ |
+#include <string> |
+ |
+#include "base/callback.h" |
+#include "base/macros.h" |
+#include "base/memory/ref_counted.h" |
+#include "content/common/content_export.h" |
+#include "media/audio/audio_parameters.h" |
+ |
+namespace media { |
+class RestartableAudioOutputDevice; |
+} |
+ |
+namespace url { |
+class Origin; |
+} |
+ |
+namespace content { |
+ |
+// A factory for creating RestartableAudioOutputDevice. |
+// There is a global factory function that can be installed for the purposes of |
+// testing to provide specialized implementations. |
+class CONTENT_EXPORT RestartableAudioOutputDeviceFactory { |
+ public: |
+ enum SourceType { |
+ kSourceHighLatency = 0, |
+ kSourceWebRTC, |
+ kSourceLocalUserMedia, |
+ kSourceWebAudio, |
+ kSourceLast = kSourceWebAudio // Only used for validation of format. |
+ }; |
+ |
+ // Creates an RestartableAudioOutputDevice. |
+ // |render_frame_id| refers to the RenderFrame containing the entity |
+ // producing the audio. If |session_id| is nonzero, it is used by the browser |
+ // to select the correct input device ID and its associated output device, if |
+ // it exists. If |session_id| is zero, |device_id| and |security_origin| |
+ // identify the output device to use. |
+ // If |session_id| is zero and |device_id| and |security_origin| are empty, |
+ // the default output device will be selected. |
+ static scoped_refptr<media::RestartableAudioOutputDevice> NewOutputDevice( |
+ SourceType source_type, |
+ int render_frame_id, |
+ int session_id, |
+ const std::string& device_id, |
+ const url::Origin& security_origin); |
+ |
+ // TODO(olka): find a better home for this function. |
o1ka
2016/02/05 16:04:23
Could you suggest a better place for it? A dedicat
|
+ // A helper to get output HW parameters in the absence of AudioOutputDevice. |
+ static media::AudioParameters GetOutputHWParams( |
+ int render_frame_id, |
+ int session_id, |
+ const std::string& device_id, |
+ const url::Origin& security_origin); |
+ |
+ protected: |
+ RestartableAudioOutputDeviceFactory(); |
+ virtual ~RestartableAudioOutputDeviceFactory(); |
+ |
+ // You can derive from this class and specify an implementation for this |
+ // function to provide alternate restartable audio output device |
+ // implementations. If the return value of this function is NULL, we fall back |
+ // on the default implementation. |
+ virtual media::RestartableAudioOutputDevice* CreateOutputDevice( |
+ SourceType source_type, |
+ int render_frame_id, |
+ int sesssion_id, |
+ const std::string& device_id, |
+ const url::Origin& security_origin) = 0; |
+ |
+ private: |
+ // The current globally registered factory. This is NULL when we should |
+ // create the default AudioRendererSinks. |
+ static RestartableAudioOutputDeviceFactory* factory_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(RestartableAudioOutputDeviceFactory); |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_RENDERER_MEDIA_RESTARTABLE_AUDIO_OUTPUT_DEVICE_FACTORY_H_ |