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

Side by Side Diff: content/renderer/media/audio_output_client.h

Issue 1896883002: Mojo interfaces needed for switching audio rendering stream creation and closing from IPC to Mojo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 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_AUDIO_OUTPUT_CLIENT_H_
6 #define CONTENT_RENDERER_MEDIA_AUDIO_OUTPUT_CLIENT_H_
7
8 #include <map>
9
10 #include "base/files/file.h"
11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/shared_memory_handle.h"
15 #include "base/sync_socket.h"
16 #include "base/threading/thread_checker.h"
17 #include "content/common/content_export.h"
18 #include "media/mojo/interfaces/audio_output.mojom.h"
19 #include "mojo/public/cpp/bindings/binding.h"
20 #include "mojo/public/cpp/bindings/interface_request.h"
21 #include "mojo/edk/embedder/embedder.h"
22 #include "mojo/public/c/system/buffer.h"
23 #include "mojo/public/cpp/bindings/binding.h"
24 #include "mojo/public/cpp/system/handle.h"
25 namespace base {
26 class SingleThreadTaskRunner;
27 }
28
29 namespace media {
30 class AudioParameters;
31 }
32
33 namespace content {
34
35 class AudioMessageFilter;
36 class ServiceRegistry;
37
38 class CONTENT_EXPORT AudioOutputClient {
39 public:
40 typedef std::map<int, std::unique_ptr<media::interfaces::AudioOutputStreamPtr> >
41 ScopedAudioOutputStreamPtrMap;
42
43 // Create a Mojo Audio Output Client. It's going to be created by
44 // RenderThreadImpl::init and be bound to RenderThread. This means that all
45 // future Mojo service calls and all Mojo callbacks are going to be
46 // performed on the RenderThread.
47 explicit AudioOutputClient(
48 ServiceRegistry* service_registry,
49 scoped_refptr<AudioMessageFilter> audio_message_filter);
50
51 ~AudioOutputClient();
52
53 // Create stream by calling the AudioOutput.CreateStream Mojo interface
54 // function using the Mojo service. This function could be called on any
55 // thread and is going to call CreateStreamOnMainThread in the RenderThread.
56 void CreateStream(int stream_id,
57 int render_frame_id,
58 const media::AudioParameters& params);
59
60 // Create stream by calling the AudioOutput.CreateStream Mojo interface
61 // function using the Mojo service. This function could be called on just
62 // the RenderThread.
63 void CreateStreamOnMainThread(int stream_id,
64 int render_frame_id,
65 const media::AudioParameters& params);
66
67 // Callback for AudioOutput.CreateStream which contains information about
68 // the new created stream. Called on RenderThread. This function is going to
69 // notify the |audio_message_filter_| of the stream creation by calling
70 // StreamCreated. StreamCreated could only be ran on |io_task_runner_| and
71 // this is why CreateStreamOnIOThread is going to be used to do that.
72 void CreateStreamCallback(int stream_id,
73 media::interfaces::AudioOutputStreamPtr stream,
74 mojo::ScopedSharedBufferHandle shared_buffer,
75 mojo::ScopedHandle socket_descriptor);
76
77 // Notify the |audio_message_filter_| of the stream creation. Can only be
78 // called on |io_task_runner_|.
79 void CreateStreamOnIOThread(
80 media::interfaces::AudioOutputStreamPtr* const stream,
81 base::SharedMemoryHandle handle,
82 base::SyncSocket::TransitDescriptor socket_descriptor,
83 uint32_t length);
84
85 // Close stream by calling the AudioOutputStream.Close Mojo interface
86 // function using the Mojo service. This function could be called on any
87 // thread and is going to call CloseStreamOnMainThread in the RenderThread.
88 void CloseStream(int stream_id);
89
90 // Close stream by calling the AudioOutputStream.Close Mojo interface
91 // function using the Mojo service. This function could be called on just the
92 // RenderThread.
93 void CloseStreamOnMainThread(int stream_id);
94
95 // Called when there is an error with AudioOutputStream Mojo interface in
96 // the renderer. This function is going to call ReportErrorOnIOThread in the
97 // RenderThread.
98 void OnStreamError(int stream_id);
99
100 // Notify the |audio_message_filter_| of a stream error. Can only be called
101 // on |io_task_runner_|.
102 void ReportErrorOnIOThread(int stream_id);
103
104 private:
105 // Mojo connection error handler.
106 void OnConnectionError();
107
108 scoped_refptr<AudioMessageFilter> audio_message_filter_;
109 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
110 // The Mojo service.
111 media::interfaces::AudioOutputPtr service_;
112 ScopedAudioOutputStreamPtrMap streams_;
113 DISALLOW_COPY_AND_ASSIGN(AudioOutputClient);
114 };
115
116 } // namespace content
117
118 #endif // CONTENT_RENDERER_MEDIA_AUDIO_OUTPUT_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698