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

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

Issue 2821203005: Add a mojo implementation of AudioOutputIPC. (Closed)
Patch Set: Death tests, Olga's comments 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/content_export.h"
14 #include "content/common/media/renderer_audio_output_stream_factory.mojom.h"
15 #include "media/audio/audio_output_ipc.h"
16
17 namespace content {
18
19 // MojoAudioOutputIPC is a renderer-side class for handling creation,
20 // initialization and control of an output stream. May only be used on a single
21 // thread.
22 class CONTENT_EXPORT MojoAudioOutputIPC : public media::AudioOutputIPC {
23 public:
24 using FactoryAccessor =
25 base::RepeatingCallback<mojom::RendererAudioOutputStreamFactory*()>;
26
27 // |factory_accessor| is required to provide a
28 // RendererAudioOutputStreamFactory* if IPC is possible.
29 explicit MojoAudioOutputIPC(FactoryAccessor factory_accessor);
DaleCurtis 2017/05/24 01:36:54 Typically we end callbacks types with CB for clari
Max Morin 2017/05/30 14:17:11 Done.
30
31 ~MojoAudioOutputIPC() override;
32
33 // AudioOutputIPC implementation.
34 void RequestDeviceAuthorization(media::AudioOutputIPCDelegate* delegate,
DaleCurtis 2017/05/24 01:36:54 Technically I/O parameters should be last. I reali
Max Morin 2017/05/30 14:17:11 Yes, maybe we can revisit the AudioOutputIPC inter
35 int session_id,
36 const std::string& device_id,
37 const url::Origin& security_origin) override;
38 void CreateStream(media::AudioOutputIPCDelegate* delegate,
39 const media::AudioParameters& params) override;
40 void PlayStream() override;
41 void PauseStream() override;
42 void CloseStream() override;
43 void SetVolume(double volume) override;
44
45 private:
46 using AuthorizationCallback = mojom::RendererAudioOutputStreamFactory::
DaleCurtis 2017/05/24 01:36:55 AuthorizationCB is sufficient if you want.
Max Morin 2017/05/30 14:17:11 Done.
47 RequestDeviceAuthorizationCallback;
48
49 bool AuthorizationRequested();
50 bool StreamCreationRequested();
51 media::mojom::AudioOutputStreamProviderRequest MakeProviderRequest();
52
53 // Tries to acquire a RendererAudioOutputStreamFactory, returns true on
54 // success. On failure, |this| has been deleted, so returning immediately
55 // is required.
56 bool DoRequestDeviceAuthorization(int session_id,
57 const std::string& device_id,
58 AuthorizationCallback callback);
59
60 void RecievedDeviceAuthorization(media::OutputDeviceStatus status,
61 const media::AudioParameters& params,
62 const std::string& device_id) const;
63
64 void StreamCreated(mojo::ScopedSharedBufferHandle shared_memory,
65 mojo::ScopedHandle socket);
66
67 const FactoryAccessor factory_accessor_;
68
69 THREAD_CHECKER(thread_checker_);
70 media::mojom::AudioOutputStreamProviderPtr stream_provider_;
71 media::mojom::AudioOutputStreamPtr stream_;
72 media::AudioOutputIPCDelegate* delegate_ = nullptr;
73
74 // To make sure we don't send an "authorization completed" callback for a
75 // stream after it's closed, we use this weak factory.
76 base::WeakPtrFactory<MojoAudioOutputIPC> weak_factory_;
77
78 DISALLOW_COPY_AND_ASSIGN(MojoAudioOutputIPC);
79 };
80
81 } // namespace content
82
83 #endif // CONTENT_RENDERER_MEDIA_MOJO_AUDIO_OUTPUT_IPC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698