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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 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_RESTARTABLE_AUDIO_OUTPUT_DEVICE_FACTORY_H_
6 #define CONTENT_RENDERER_MEDIA_RESTARTABLE_AUDIO_OUTPUT_DEVICE_FACTORY_H_
7
8 #include <string>
9
10 #include "base/callback.h"
11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h"
13 #include "content/common/content_export.h"
14 #include "media/audio/audio_parameters.h"
15
16 namespace media {
17 class RestartableAudioOutputDevice;
18 }
19
20 namespace url {
21 class Origin;
22 }
23
24 namespace content {
25
26 // A factory for creating RestartableAudioOutputDevice.
27 // There is a global factory function that can be installed for the purposes of
28 // testing to provide specialized implementations.
29 class CONTENT_EXPORT RestartableAudioOutputDeviceFactory {
30 public:
31 enum SourceType {
32 kSourceHighLatency = 0,
33 kSourceWebRTC,
34 kSourceLocalUserMedia,
35 kSourceWebAudio,
36 kSourceLast = kSourceWebAudio // Only used for validation of format.
37 };
38
39 // Creates an RestartableAudioOutputDevice.
40 // |render_frame_id| refers to the RenderFrame containing the entity
41 // producing the audio. If |session_id| is nonzero, it is used by the browser
42 // to select the correct input device ID and its associated output device, if
43 // it exists. If |session_id| is zero, |device_id| and |security_origin|
44 // identify the output device to use.
45 // If |session_id| is zero and |device_id| and |security_origin| are empty,
46 // the default output device will be selected.
47 static scoped_refptr<media::RestartableAudioOutputDevice> NewOutputDevice(
48 SourceType source_type,
49 int render_frame_id,
50 int session_id,
51 const std::string& device_id,
52 const url::Origin& security_origin);
53
54 // 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
55 // A helper to get output HW parameters in the absence of AudioOutputDevice.
56 static media::AudioParameters GetOutputHWParams(
57 int render_frame_id,
58 int session_id,
59 const std::string& device_id,
60 const url::Origin& security_origin);
61
62 protected:
63 RestartableAudioOutputDeviceFactory();
64 virtual ~RestartableAudioOutputDeviceFactory();
65
66 // You can derive from this class and specify an implementation for this
67 // function to provide alternate restartable audio output device
68 // implementations. If the return value of this function is NULL, we fall back
69 // on the default implementation.
70 virtual media::RestartableAudioOutputDevice* CreateOutputDevice(
71 SourceType source_type,
72 int render_frame_id,
73 int sesssion_id,
74 const std::string& device_id,
75 const url::Origin& security_origin) = 0;
76
77 private:
78 // The current globally registered factory. This is NULL when we should
79 // create the default AudioRendererSinks.
80 static RestartableAudioOutputDeviceFactory* factory_;
81
82 DISALLOW_COPY_AND_ASSIGN(RestartableAudioOutputDeviceFactory);
83 };
84
85 } // namespace content
86
87 #endif // CONTENT_RENDERER_MEDIA_RESTARTABLE_AUDIO_OUTPUT_DEVICE_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698