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

Side by Side Diff: content/browser/media/audio_output_impl.h

Issue 1930393002: Switch stream creation and closing in Chrome audio rendering from IPC to Mojo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixwindows Created 4 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
(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 base {
16 class SharedMemory;
17 }
18
19 namespace content {
20 class AudioOutputStreamImpl;
21 class RenderFrameHostImpl;
22
23 // This class implements AudioOutput Mojo interface. It is connected to
24 // the AudioOutputClient to perform operations on audio output streams.
25 // AudioOutputClient is going to perform operations remotely and Mojo is
26 // transfer them to AudioOutputImpl.
27 // This class must always be accessed from the creation thread.
28 class CONTENT_EXPORT AudioOutputImpl
29 : NON_EXPORTED_BASE(public media::mojom::AudioOutput) {
30 public:
31 explicit AudioOutputImpl(RenderFrameHostImpl* frame,
32 media::mojom::AudioOutputRequest request);
33
34 ~AudioOutputImpl() override;
35
36 // Creates a Mojo service.
37 static void CreateService(RenderFrameHostImpl* frame,
38 media::mojom::AudioOutputRequest request);
39
40 // Initializes Mojo service on the IO thread. The service is bound to the
41 // IO thread so future Mojo calls performed by the AudioOutputClient to the
42 // AudioOutput interface will be run on that thread.
43 // There are a lot of dependencies used in audio output that require to be
44 // called on the IO thread, this is why we initialize Mojo service on this
45 // thread.
46 static void CreateServiceOnIOThread(RenderFrameHostImpl* frame,
47 media::mojom::AudioOutputRequest request);
48
49 // Called by AudioRendererHost::DoCompleteCreation to create the streams.
50 virtual void CreateStreamFactory(
51 int stream_id,
52 base::SharedMemory* shared_memory,
53 base::SyncSocket::TransitDescriptor socket_descriptor);
54
55 virtual bool CloseStream(int stream_id);
56
57 // Sends an error message to the renderer, then close the stream.
58 virtual void ReportErrorAndCloseStream(int stream_id);
59
60 private:
61 friend class AudioOutputImplTest;
62 friend class MockAudioOutputImpl;
63 FRIEND_TEST_ALL_PREFIXES(AudioOutputImplTest, CreateStream);
64 FRIEND_TEST_ALL_PREFIXES(AudioOutputImplTest, StreamFactory);
65 FRIEND_TEST_ALL_PREFIXES(AudioOutputImplTest, RemoveStream);
66
67 // AudioOutput interface implementation.
68 void CreateStream(int stream_id,
69 const media::AudioParameters& params,
70 const CreateStreamCallback& callback) override;
71
72 void InitAudioRendererHost();
73
74 RenderFrameHostImpl* frame_;
75 mojo::Binding<AudioOutput> binding_;
76 scoped_refptr<AudioRendererHost> audio_renderer_host_;
77 // Maps from |stream_id| to AudioOutputStreamImpl.
78 std::map<int, std::unique_ptr<AudioOutputStreamImpl>> stream_impls_;
79 // Maps from |stream_id| to CreateStreamCallback.
80 std::map<int, media::mojom::AudioOutput::CreateStreamCallback>
81 create_stream_callbacks_;
82
83 DISALLOW_COPY_AND_ASSIGN(AudioOutputImpl);
84 };
85
86 } // namespace content
87
88 #endif // CONTENT_BROWSER_MEDIA_AUDIO_OUTPUT_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698