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

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

Issue 2821203005: Add a mojo implementation of AudioOutputIPC. (Closed)
Patch Set: Fix test issues Created 3 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 2017 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_MOJO_AUDIO_OUTPUT_IPC_H_
6 #define CONTENT_RENDERER_MEDIA_MOJO_AUDIO_OUTPUT_IPC_H_
7
8 #include <string>
9
10 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/threading/thread_checker.h"
13 #include "content/common/media/renderer_audio_output_stream_factory.mojom.h"
14 #include "media/audio/audio_output_ipc.h"
15
16 namespace content {
17
18 // MojoAudioOutputIPC is a renderer-side class for handling creation,
19 // initialization and control of an output stream. May only be used on a single
20 // thread.
21 class MojoAudioOutputIPC : public media::AudioOutputIPC {
22 public:
23 using FactoryAccessor =
24 base::Callback<mojom::RendererAudioOutputStreamFactory*()>;
25
26 // |factory_accessor| is required to provide a
Max Morin 2017/05/05 14:06:14 Ignore stale comment, will change it to a better o
Max Morin 2017/05/11 15:31:18 Done.
27 // RendererAudioOutputStreamFactoryWrapper if IPC is possible.
28 explicit MojoAudioOutputIPC(FactoryAccessor factory_accessor);
29
30 ~MojoAudioOutputIPC() override;
31
32 // AudioOutputIPC implementation.
33 void RequestDeviceAuthorization(media::AudioOutputIPCDelegate* delegate,
34 int session_id,
35 const std::string& device_id,
36 const url::Origin& security_origin) override;
37 void CreateStream(media::AudioOutputIPCDelegate* delegate,
38 const media::AudioParameters& params) override;
39 void PlayStream() override;
40 void PauseStream() override;
41 void CloseStream() override;
42 void SetVolume(double volume) override;
43
44 private:
45 bool AuthorizationRequested();
46 bool StreamCreationRequested();
47 media::mojom::AudioOutputStreamProviderRequest MakeProviderRequest(
48 media::AudioOutputIPCDelegate* delegate);
49
50 void RecievedDeviceAuthorization(media::AudioOutputIPCDelegate* delegate,
51 media::OutputDeviceStatus status,
52 const media::AudioParameters& params,
53 const std::string& device_id) const;
54
55 void StreamCreated(media::AudioOutputIPCDelegate* delegate,
56 mojo::ScopedSharedBufferHandle shared_memory,
57 mojo::ScopedHandle socket);
58
59 const FactoryAccessor factory_accessor_;
60
61 base::ThreadChecker thread_checker_;
62 media::mojom::AudioOutputStreamProviderPtr stream_provider_;
63 media::mojom::AudioOutputStreamPtr stream_;
64
65 // To make sure we don't send an "authorization completed" callback for a
66 // stream after it's closed, we use this weak factory.
67 base::WeakPtrFactory<MojoAudioOutputIPC> weak_factory_;
68
69 DISALLOW_COPY_AND_ASSIGN(MojoAudioOutputIPC);
70 };
71
72 } // namespace content
73
74 #endif // CONTENT_RENDERER_MEDIA_MOJO_AUDIO_OUTPUT_IPC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698