1 // Copyright (c) 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.
5 #ifndef MEDIA_BASE_OUTPUT_DEVICE_H_
6 #define MEDIA_BASE_OUTPUT_DEVICE_H_
10 #include "base/callback.h"
11 #include "media/audio/audio_parameters.h"
12 #include "media/base/media_export.h"
13 #include "url/origin.h"
17 // Result of an audio output device switch operation
18 enum SwitchOutputDeviceResult
{
19 SWITCH_OUTPUT_DEVICE_RESULT_SUCCESS
= 0,
20 SWITCH_OUTPUT_DEVICE_RESULT_ERROR_NOT_FOUND
,
21 SWITCH_OUTPUT_DEVICE_RESULT_ERROR_NOT_AUTHORIZED
,
22 SWITCH_OUTPUT_DEVICE_RESULT_ERROR_INTERNAL
,
23 SWITCH_OUTPUT_DEVICE_RESULT_LAST
= SWITCH_OUTPUT_DEVICE_RESULT_ERROR_INTERNAL
,
26 typedef base::Callback
<void(SwitchOutputDeviceResult
)> SwitchOutputDeviceCB
;
28 // OutputDevice is an interface that allows performing operations related
29 // audio output devices.
33 // Attempts to switch the audio output device.
34 // Once the attempt is finished, |callback| is invoked with the
35 // result of the operation passed as a parameter. The result is a value from
36 // the media::SwitchOutputDeviceResult enum.
37 // There is no guarantee about the thread where |callback| will
38 // be invoked, so users are advised to use media::BindToCurrentLoop() to
39 // ensure that |callback| runs on the correct thread.
40 // Note also that copy constructors and destructors for arguments bound to
41 // |callback| may run on arbitrary threads as |callback| is moved across
42 // threads. It is advisable to bind arguments such that they are released by
43 // |callback| when it runs in order to avoid surprises.
44 virtual void SwitchOutputDevice(const std::string
& device_id
,
45 const url::Origin
& security_origin
,
46 const SwitchOutputDeviceCB
& callback
) = 0;
48 // Returns the device's audio output parameters.
49 // If the parameters are not available, this method blocks until they
50 // become available. Must never be called on the IO thread.
51 virtual AudioParameters
GetOutputParameters() = 0;
54 virtual ~OutputDevice() {}
59 #endif // MEDIA_BASE_OUTPUT_DEVICE_H_