Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(201)

Unified Diff: content/renderer/media/restartable_audio_output_device_factory.h

Issue 1666363005: Switching audio clients to using RestartableAudioRendererSink interface as a sink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removing RestartableAudioOutputDevice interface Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..bbddb82109dcb85646067d48cce56caba478aaf8
--- /dev/null
+++ b/content/renderer/media/restartable_audio_output_device_factory.h
@@ -0,0 +1,88 @@
+// 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"
+#include "media/base/audio_renderer_sink.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 {
DaleCurtis 2016/02/08 19:10:25 Should we just make these new methods on the exist
o1ka 2016/02/09 14:15:38 Done.
+ 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::RestartableAudioRendererSink> 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.
+ // 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::RestartableAudioRendererSink* 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_

Powered by Google App Engine
This is Rietveld 408576698