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"
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_OBSOLETE
,
23 SWITCH_OUTPUT_DEVICE_RESULT_ERROR_NOT_SUPPORTED
,
24 SWITCH_OUTPUT_DEVICE_RESULT_LAST
=
25 SWITCH_OUTPUT_DEVICE_RESULT_ERROR_NOT_SUPPORTED
,
28 typedef base::Callback
<void(SwitchOutputDeviceResult
)> SwitchOutputDeviceCB
;
30 // OutputDevice is an interface that allows performing operations related
31 // audio output devices.
35 // Attempts to switch the audio output device.
36 // Once the attempt is finished, |callback| is invoked with the
37 // result of the operation passed as a parameter. The result is a value from
38 // the media::SwitchOutputDeviceResult enum.
39 // There is no guarantee about the thread where |callback| will
40 // be invoked, so users are advised to use media::BindToCurrentLoop() to
41 // ensure that |callback| runs on the correct thread.
42 // Note also that copy constructors and destructors for arguments bound to
43 // |callback| may run on arbitrary threads as |callback| is moved across
44 // threads. It is advisable to bind arguments such that they are released by
45 // |callback| when it runs in order to avoid surprises.
46 virtual void SwitchOutputDevice(const std::string
& device_id
,
47 const GURL
& security_origin
,
48 const SwitchOutputDeviceCB
& callback
) = 0;
51 virtual ~OutputDevice() {}
56 #endif // MEDIA_BASE_OUTPUT_DEVICE_H_