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

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

Issue 1856673002: Mojofication of the Chrome Audio Rendering Prototype Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « media/audio/audio_output_device.cc ('k') | media/audio/audio_output_ipc.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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> 8 #include <string>
9 9
10 #include "base/memory/shared_memory.h" 10 #include "base/memory/shared_memory.h"
11 #include "base/sync_socket.h" 11 #include "base/sync_socket.h"
12 #include "content/common/media/audio_output.mojom.h"
12 #include "media/audio/audio_parameters.h" 13 #include "media/audio/audio_parameters.h"
13 #include "media/base/media_export.h" 14 #include "media/base/media_export.h"
14 #include "media/base/output_device_info.h" 15 #include "media/base/output_device_info.h"
15 #include "url/origin.h" 16 #include "url/origin.h"
16 17
18 namespace mojom {
19 class AudioOutputStreamPtr;
20 }
21
17 namespace media { 22 namespace media {
18 23
24 class AudioOutputIPC;
25
19 // Current status of the audio output stream in the browser process. Browser 26 // Current status of the audio output stream in the browser process. Browser
20 // sends information about the current playback state and error to the 27 // sends information about the current playback state and error to the
21 // renderer process using this type. 28 // renderer process using this type.
22 enum AudioOutputIPCDelegateState { 29 enum AudioOutputIPCDelegateState {
23 AUDIO_OUTPUT_IPC_DELEGATE_STATE_PLAYING, 30 AUDIO_OUTPUT_IPC_DELEGATE_STATE_PLAYING,
24 AUDIO_OUTPUT_IPC_DELEGATE_STATE_PAUSED, 31 AUDIO_OUTPUT_IPC_DELEGATE_STATE_PAUSED,
25 AUDIO_OUTPUT_IPC_DELEGATE_STATE_ERROR, 32 AUDIO_OUTPUT_IPC_DELEGATE_STATE_ERROR,
26 AUDIO_OUTPUT_IPC_DELEGATE_STATE_LAST = AUDIO_OUTPUT_IPC_DELEGATE_STATE_ERROR 33 AUDIO_OUTPUT_IPC_DELEGATE_STATE_LAST = AUDIO_OUTPUT_IPC_DELEGATE_STATE_ERROR
27 }; 34 };
28 35
29 // Contains IPC notifications for the state of the server side 36 // Contains IPC notifications for the state of the server side
30 // (AudioOutputController) audio state changes and when an AudioOutputController 37 // (AudioOutputController) audio state changes and when an AudioOutputController
31 // has been created. Implemented by AudioOutputDevice. 38 // has been created. Implemented by AudioOutputDevice.
32 class MEDIA_EXPORT AudioOutputIPCDelegate { 39 class MEDIA_EXPORT AudioOutputIPCDelegate {
33 public: 40 public:
41 virtual AudioOutputIPC* getIPC() = 0;
42
34 // Called when state of an audio stream has changed. 43 // Called when state of an audio stream has changed.
35 virtual void OnStateChanged(AudioOutputIPCDelegateState state) = 0; 44 virtual void OnStateChanged(AudioOutputIPCDelegateState state) = 0;
36 45
37 // Called when an authorization request for an output device has been 46 // Called when an authorization request for an output device has been
38 // completed 47 // completed
39 virtual void OnDeviceAuthorized( 48 virtual void OnDeviceAuthorized(
40 OutputDeviceStatus device_status, 49 OutputDeviceStatus device_status,
41 const media::AudioParameters& output_params) = 0; 50 const media::AudioParameters& output_params) = 0;
42 51
43 // Called when an audio stream has been created. 52 // Called when an audio stream has been created.
44 // The shared memory |handle| points to a memory section that's used to 53 // The shared memory |handle| points to a memory section that's used to
45 // transfer audio buffers from the AudioOutputIPCDelegate back to the 54 // transfer audio buffers from the AudioOutputIPCDelegate back to the
46 // AudioRendererHost. The implementation of OnStreamCreated takes ownership. 55 // AudioRendererHost. The implementation of OnStreamCreated takes ownership.
47 // The |socket_handle| is used by AudioRendererHost to signal requests for 56 // The |socket_handle| is used by AudioRendererHost to signal requests for
48 // audio data to be written into the shared memory. The AudioOutputIPCDelegate 57 // audio data to be written into the shared memory. The AudioOutputIPCDelegate
49 // must read from this socket and provide audio whenever data (search for 58 // must read from this socket and provide audio whenever data (search for
50 // "pending_bytes") is received. 59 // "pending_bytes") is received.
51 virtual void OnStreamCreated(base::SharedMemoryHandle handle, 60 virtual void OnStreamCreated(content::mojom::AudioOutputStreamPtr* stream,
61 base::SharedMemoryHandle handle,
52 base::SyncSocket::Handle socket_handle, 62 base::SyncSocket::Handle socket_handle,
53 int length) = 0; 63 int length) = 0;
54 64
55 // Called when the AudioOutputIPC object is going away and/or when the IPC 65 // Called when the AudioOutputIPC object is going away and/or when the IPC
56 // channel has been closed and no more ipc requests can be made. 66 // channel has been closed and no more ipc requests can be made.
57 // Implementations should delete their owned AudioOutputIPC instance 67 // Implementations should delete their owned AudioOutputIPC instance
58 // immediately. 68 // immediately.
59 virtual void OnIPCClosed() = 0; 69 virtual void OnIPCClosed() = 0;
60 70
61 protected: 71 protected:
62 virtual ~AudioOutputIPCDelegate(); 72 virtual ~AudioOutputIPCDelegate();
63 }; 73 };
64 74
65 // Provides the IPC functionality for an AudioOutputIPCDelegate (e.g., an 75 // Provides the IPC functionality for an AudioOutputIPCDelegate (e.g., an
66 // AudioOutputDevice). The implementation should asynchronously deliver the 76 // AudioOutputDevice). The implementation should asynchronously deliver the
67 // messages to an AudioOutputController object (or create one in the case of 77 // messages to an AudioOutputController object (or create one in the case of
68 // CreateStream()), that may live in a separate process. 78 // CreateStream()), that may live in a separate process.
69 class MEDIA_EXPORT AudioOutputIPC { 79 class MEDIA_EXPORT AudioOutputIPC {
70 public: 80 public:
71 virtual ~AudioOutputIPC(); 81 virtual ~AudioOutputIPC();
72 82
83 content::mojom::AudioOutputStreamPtr* GetAudioOutputStream();
84
85 void SetAudioOutputStream(content::mojom::AudioOutputStreamPtr* stream);
86
73 // Sends a request to authorize the use of a specific audio output device 87 // Sends a request to authorize the use of a specific audio output device
74 // in the peer process. 88 // in the peer process.
75 // If |device_id| is nonempty, the browser selects the device 89 // If |device_id| is nonempty, the browser selects the device
76 // indicated by |device_id|, regardless of the value of |session_id|. 90 // indicated by |device_id|, regardless of the value of |session_id|.
77 // If |device_id| is empty and |session_id| is nonzero, the browser selects 91 // If |device_id| is empty and |session_id| is nonzero, the browser selects
78 // the output device associated with an opened input device indicated by 92 // the output device associated with an opened input device indicated by
79 // |session_id|. If no such device is found, the default device will be 93 // |session_id|. If no such device is found, the default device will be
80 // selected. 94 // selected.
81 // If |device_id| is empty and |session_id| is zero, the browser selects 95 // If |device_id| is empty and |session_id| is zero, the browser selects
82 // the default device. 96 // the default device.
(...skipping 22 matching lines...) Expand all
105 // Pauses an audio stream. This should generate a call to 119 // Pauses an audio stream. This should generate a call to
106 // AudioOutputController::Pause(). 120 // AudioOutputController::Pause().
107 virtual void PauseStream() = 0; 121 virtual void PauseStream() = 0;
108 122
109 // Closes the audio stream which should shut down the corresponding 123 // Closes the audio stream which should shut down the corresponding
110 // AudioOutputController in the peer process. 124 // AudioOutputController in the peer process.
111 virtual void CloseStream() = 0; 125 virtual void CloseStream() = 0;
112 126
113 // Sets the volume of the audio stream. 127 // Sets the volume of the audio stream.
114 virtual void SetVolume(double volume) = 0; 128 virtual void SetVolume(double volume) = 0;
129
130 private:
131 content::mojom::AudioOutputStreamPtr* stream_;
115 }; 132 };
116 133
117 } // namespace media 134 } // namespace media
118 135
119 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_IPC_H_ 136 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_IPC_H_
OLDNEW
« no previous file with comments | « media/audio/audio_output_device.cc ('k') | media/audio/audio_output_ipc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698