OLD | NEW |
---|---|
(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_BROWSER_MEDIA_AUDIO_OUTPUT_IMPL_H_ | |
6 #define CONTENT_BROWSER_MEDIA_AUDIO_OUTPUT_IMPL_H_ | |
7 | |
8 #include "base/callback.h" | |
9 #include "base/sync_socket.h" | |
10 #include "content/browser/renderer_host/media/audio_renderer_host.h" | |
11 #include "media/mojo/interfaces/audio_output.mojom.h" | |
12 #include "mojo/public/cpp/bindings/interface_request.h" | |
13 #include "mojo/public/cpp/bindings/strong_binding.h" | |
14 | |
15 namespace content { | |
16 class AudioOutputStreamImpl; | |
17 | |
18 // This class implements AudioOutput Mojo interface. It will be used | |
19 // by the AudioOutputClient to perform operations on audio output streams. | |
20 // AudioOutputClient is going to perform operations remotely and Mojo will | |
21 // transfer them to AudioOutputImpl. | |
22 // This class must always be accessed from the creation thread. | |
23 class CONTENT_EXPORT AudioOutputImpl | |
24 : NON_EXPORTED_BASE(public media::mojom::AudioOutput) { | |
25 public: | |
26 explicit AudioOutputImpl(RenderProcessHost* process_, | |
27 int render_frame_id, | |
28 media::mojom::AudioOutputRequest request); | |
29 | |
30 ~AudioOutputImpl() override; | |
31 | |
32 // Creates a Mojo service. | |
33 static void CreateService(RenderProcessHost* process_, | |
34 int render_frame_id, | |
35 media::mojom::AudioOutputRequest request); | |
36 // Initialized Mojo service on the IO thread. The service is bound to the | |
37 // IO thread so future Mojo calls performed by the AudioOutputClient to the | |
38 // AudioOutput interface will be run on that thread. | |
39 // There are a lot of dependencies used in audio output that require to be | |
40 // called on the IO thread, this is why we initialize Mojo service on this | |
41 // thread. There is a plan to enable these dependencies to run on another | |
42 // thread and move the Mojo service to this thread as IO thread is very | |
43 // performance sensitive and we want to move stuff off it. | |
44 static void CreateServiceOnIOThread(RenderProcessHost* process_, | |
45 int render_frame_id, | |
46 media::mojom::AudioOutputRequest request); | |
47 | |
48 // Called by AudioRendererHost::DoCompleteCreation to create the streams. | |
DaleCurtis
2016/05/23 20:50:37
This should just be CreateStream() StreamFactory i
rchtara
2016/05/24 17:25:55
Unfortunately, here the socket and shared memory r
| |
49 virtual void StreamFactory( | |
50 int stream_id, | |
51 base::SharedMemory* shared_memory, | |
52 base::SyncSocket::TransitDescriptor socket_descriptor); | |
53 | |
54 virtual bool CloseStream(int stream_id); | |
55 // Send an error message to the renderer, then close the stream. | |
56 virtual void ReportErrorAndCloseStream(int stream_id); | |
57 | |
58 private: | |
59 friend class AudioOutputImplTest; | |
60 friend class MockAudioOutputImpl; | |
61 FRIEND_TEST_ALL_PREFIXES(AudioOutputImplTest, CreateStream); | |
62 FRIEND_TEST_ALL_PREFIXES(AudioOutputImplTest, StreamFactory); | |
63 FRIEND_TEST_ALL_PREFIXES(AudioOutputImplTest, RemoveStream); | |
64 | |
65 static void Disconnect(int process_id, int render_frame_id); | |
66 | |
67 // AudioOutput interface implementation. | |
68 void CreateStream(int stream_id, | |
69 const media::AudioParameters& params, | |
70 const CreateStreamCallback& callback) override; | |
71 | |
72 RenderProcessHost* process_; | |
73 int render_frame_id_; | |
74 mojo::Binding<AudioOutput> binding_; | |
75 std::map<int, std::unique_ptr<AudioOutputStreamImpl>> stream_impls_; | |
76 std::map<int, media::mojom::AudioOutput::CreateStreamCallback> | |
77 create_stream_callbacks_; | |
78 | |
79 DISALLOW_COPY_AND_ASSIGN(AudioOutputImpl); | |
80 }; | |
81 | |
82 } // namespace content | |
83 | |
84 #endif // CONTENT_BROWSER_MEDIA_AUDIO_OUTPUT_IMPL_H_ | |
OLD | NEW |