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

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: rebase + tests in progress 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_BROWSER_MEDIA_AUDIO_OUTPUT_IMPL_H_
6 #define CONTENT_BROWSER_MEDIA_AUDIO_OUTPUT_IMPL_H_
7
8 #include "base/callback.h"
9 #include "content/browser/renderer_host/media/audio_renderer_host.h"
10 #include "media/mojo/interfaces/audio_output.mojom.h"
11 #include "mojo/public/cpp/bindings/interface_request.h"
12 #include "mojo/public/cpp/bindings/strong_binding.h"
13
14 namespace content {
15 class AudioOutputStreamImpl;
16
17 // This class implements AudioOutput Mojo interface. It will be used
18 // by the AudioOutputClient to perform operations on audio output streams.
19 // AudioOutputClient is going to perform operations remotely and Mojo will
20 // transfer them to AudioOutputImpl.
21 // This class must always be accessed from the creation thread.
22 class CONTENT_EXPORT AudioOutputImpl
23 : NON_EXPORTED_BASE(public media::mojom::AudioOutput) {
24 public:
25 explicit AudioOutputImpl(scoped_refptr<AudioRendererHost> audio_renderer_host,
26 int render_frame_id,
27 media::mojom::AudioOutputRequest request);
28
29 ~AudioOutputImpl() override;
30
31 // Creates a Mojo service.
32 static void CreateService(
33 scoped_refptr<AudioRendererHost> audio_renderer_host,
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(
45 scoped_refptr<AudioRendererHost> audio_renderer_host,
46 int render_frame_id,
47 media::mojom::AudioOutputRequest request);
48
49 // Called by AudioRendererHost::DoCompleteCreation to create the streams.
50 virtual media::mojom::AudioOutputStreamPtr StreamFactory(
51 int stream_id,
52 int render_frame_id,
53 AudioRendererHost* audio_renderer_host);
54
55 virtual bool RemoveStream(int stream_id);
56
57 private:
58 friend class AudioOutputImplTest;
59 FRIEND_TEST_ALL_PREFIXES(AudioOutputImplTest, CreateStream);
60 FRIEND_TEST_ALL_PREFIXES(AudioOutputImplTest, StreamFactory);
61 FRIEND_TEST_ALL_PREFIXES(AudioOutputImplTest, RemoveStream);
62 // AudioOutput interface implementation.
63 void CreateStream(int stream_id,
64 const media::AudioParameters& params,
65 const CreateStreamCallback& callback) override;
66
67 scoped_refptr<AudioRendererHost> audio_renderer_host_;
68 int render_frame_id_;
69 mojo::Binding<AudioOutput> binding_;
70 std::map<int, std::unique_ptr<AudioOutputStreamImpl>> stream_impls_;
71
72 base::Callback<AudioOutputStreamImpl*(
73 media::mojom::AudioOutputStreamRequest request,
74 int stream_id,
75 int renderer_frame_id,
76 AudioRendererHost* audio_renderer_host)>
77 factory_;
78 DISALLOW_COPY_AND_ASSIGN(AudioOutputImpl);
79 };
80
81 } // namespace content
82
83 #endif // CONTENT_BROWSER_MEDIA_AUDIO_OUTPUT_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698