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

Side by Side Diff: media/audio/audio_output_ipc.h

Issue 1122393004: Add support for switching the audio output device for HTMLMediaElements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes to MediaPlayers so that they invoke callbacks in the correct threads. First complete implem… Created 5 years, 6 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MEDIA_AUDIO_AUDIO_OUTPUT_IPC_H_ 5 #ifndef MEDIA_AUDIO_AUDIO_OUTPUT_IPC_H_
6 #define MEDIA_AUDIO_AUDIO_OUTPUT_IPC_H_ 6 #define MEDIA_AUDIO_AUDIO_OUTPUT_IPC_H_
7 7
8 #include <string>
9
10 #include "base/callback.h"
8 #include "base/memory/shared_memory.h" 11 #include "base/memory/shared_memory.h"
9 #include "base/sync_socket.h" 12 #include "base/sync_socket.h"
10 #include "media/audio/audio_parameters.h" 13 #include "media/audio/audio_parameters.h"
11 #include "media/base/media_export.h" 14 #include "media/base/media_export.h"
15 #include "url/gurl.h"
12 16
13 namespace media { 17 namespace media {
14 18
15 // Contains IPC notifications for the state of the server side 19 // Contains IPC notifications for the state of the server side
16 // (AudioOutputController) audio state changes and when an AudioOutputController 20 // (AudioOutputController) audio state changes and when an AudioOutputController
17 // has been created. Implemented by AudioOutputDevice. 21 // has been created. Implemented by AudioOutputDevice.
18 class MEDIA_EXPORT AudioOutputIPCDelegate { 22 class MEDIA_EXPORT AudioOutputIPCDelegate {
19 public: 23 public:
20 // Current status of the audio output stream in the browser process. Browser 24 // Current status of the audio output stream in the browser process. Browser
21 // sends information about the current playback state and error to the 25 // sends information about the current playback state and error to the
22 // renderer process using this type. 26 // renderer process using this type.
23 enum State { 27 enum State {
24 kPlaying, 28 kPlaying,
25 kPaused, 29 kPaused,
26 kError, 30 kError,
27 kStateLast = kError 31 kStateLast = kError
28 }; 32 };
29 33
34 // Result of an audio output device switch operation
35 enum DeviceSwitchResult {
36 kSuccess = 0,
37 kNotFound,
38 kSecurityError,
39 kOtherError,
40 kDeviceSwitchResultLast = kOtherError
41 };
42
43
30 // Called when state of an audio stream has changed. 44 // Called when state of an audio stream has changed.
31 virtual void OnStateChanged(State state) = 0; 45 virtual void OnStateChanged(State state) = 0;
32 46
33 // Called when an audio stream has been created. 47 // Called when an audio stream has been created.
34 // The shared memory |handle| points to a memory section that's used to 48 // The shared memory |handle| points to a memory section that's used to
35 // transfer audio buffers from the AudioOutputIPCDelegate back to the 49 // transfer audio buffers from the AudioOutputIPCDelegate back to the
36 // AudioRendererHost. The implementation of OnStreamCreated takes ownership. 50 // AudioRendererHost. The implementation of OnStreamCreated takes ownership.
37 // The |socket_handle| is used by AudioRendererHost to signal requests for 51 // The |socket_handle| is used by AudioRendererHost to signal requests for
38 // audio data to be written into the shared memory. The AudioOutputIPCDelegate 52 // audio data to be written into the shared memory. The AudioOutputIPCDelegate
39 // must read from this socket and provide audio whenever data (search for 53 // must read from this socket and provide audio whenever data (search for
40 // "pending_bytes") is received. 54 // "pending_bytes") is received.
41 virtual void OnStreamCreated(base::SharedMemoryHandle handle, 55 virtual void OnStreamCreated(base::SharedMemoryHandle handle,
42 base::SyncSocket::Handle socket_handle, 56 base::SyncSocket::Handle socket_handle,
43 int length) = 0; 57 int length) = 0;
44 58
59 // Called when an attempt to switch the output device has been completed
60 virtual void OnDeviceSwitched(int request_id, DeviceSwitchResult result) = 0;
61
45 // Called when the AudioOutputIPC object is going away and/or when the IPC 62 // Called when the AudioOutputIPC object is going away and/or when the IPC
46 // channel has been closed and no more ipc requests can be made. 63 // channel has been closed and no more ipc requests can be made.
47 // Implementations should delete their owned AudioOutputIPC instance 64 // Implementations should delete their owned AudioOutputIPC instance
48 // immediately. 65 // immediately.
49 virtual void OnIPCClosed() = 0; 66 virtual void OnIPCClosed() = 0;
50 67
51 protected: 68 protected:
52 virtual ~AudioOutputIPCDelegate(); 69 virtual ~AudioOutputIPCDelegate();
53 }; 70 };
54 71
(...skipping 22 matching lines...) Expand all
77 // Pauses an audio stream. This should generate a call to 94 // Pauses an audio stream. This should generate a call to
78 // AudioOutputController::Pause(). 95 // AudioOutputController::Pause().
79 virtual void PauseStream() = 0; 96 virtual void PauseStream() = 0;
80 97
81 // Closes the audio stream which should shut down the corresponding 98 // Closes the audio stream which should shut down the corresponding
82 // AudioOutputController in the peer process. 99 // AudioOutputController in the peer process.
83 virtual void CloseStream() = 0; 100 virtual void CloseStream() = 0;
84 101
85 // Sets the volume of the audio stream. 102 // Sets the volume of the audio stream.
86 virtual void SetVolume(double volume) = 0; 103 virtual void SetVolume(double volume) = 0;
104
105 // Switches the output device of the audio stream. This should generate a
106 // call to AudioOutputController::SwitchOutputDevice().
107 virtual void SwitchDevice(const std::string& device_id,
108 const GURL& security_origin,
109 int request_id,
110 const base::Callback<void(int)>& callback) = 0;
87 }; 111 };
88 112
89 } // namespace media 113 } // namespace media
90 114
91 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_IPC_H_ 115 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_IPC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698