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

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

Issue 2319493002: Add mojo interface for audio rendering. (Closed)
Patch Set: ++docs Created 3 years, 10 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
« no previous file with comments | « content/browser/bad_message.h ('k') | content/browser/renderer_host/media/audio_output_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_RENDERER_HOST_MEDIA_AUDIO_OUTPUT_IMPL_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_OUTPUT_IMPL_H_
7
8 #include <memory>
9 #include <string>
10
11 // This class handles IPC for single stream by delegating method calls to its
12 // AudioOutputDelegate.
13
14 #include "base/threading/thread_checker.h"
15 #include "content/browser/renderer_host/media/audio_output_delegate.h"
16 #include "content/common/content_export.h"
17 #include "content/common/media/audio_output.mojom.h"
18 #include "mojo/public/cpp/bindings/binding.h"
19
20 namespace content {
21
22 class CONTENT_EXPORT AudioOutputImpl
23 : public mojom::AudioOutput,
24 public AudioOutputDelegate::EventHandler {
25 public:
26 using CreateDelegateCallback =
27 base::OnceCallback<std::unique_ptr<AudioOutputDelegate>(
28 AudioOutputDelegate::EventHandler*,
29 const media::AudioParameters&)>;
30 using FinishedCallback = base::OnceCallback<void(mojom::AudioOutput*)>;
31
32 // |create_delegate_callback| is used to obtain an AudioOutputDelegate for the
33 // stream when it's started and |finished_callback| is called when this class
34 // should be removed (stream ended/error).
35 AudioOutputImpl(mojom::AudioOutputRequest request,
36 CreateDelegateCallback create_delegate_callback,
37 FinishedCallback finished_callback);
38
39 ~AudioOutputImpl() override;
40
41 private:
42 // mojom::AudioOutput implementation.
43 void Start(const media::AudioParameters& params,
44 const StartCallback& callback) override;
45 void Play() override;
46 void Pause() override;
47 void SetVolume(double volume) override;
48
49 // AudioOutputDelegate::EventHandler implementation.
50 void OnStreamCreated(int stream_id,
51 base::SharedMemory* shared_memory,
52 base::CancelableSyncSocket* foreign_socket) override;
53 void OnStreamError(int stream_id) override;
54
55 // Closes connection to client and notifies owner.
56 void OnError();
57
58 // The callback for the Start() must be stored until the response is ready.
59 StartCallback start_callback_;
60
61 mojo::Binding<AudioOutput> binding_;
62 CreateDelegateCallback create_delegate_callback_;
63 FinishedCallback finished_callback_;
64 std::unique_ptr<AudioOutputDelegate> delegate_;
65 base::ThreadChecker thread_checker_;
66
67 DISALLOW_COPY_AND_ASSIGN(AudioOutputImpl);
68 };
69
70 } // namespace content
71
72 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_OUTPUT_IMPL_H_
OLDNEW
« no previous file with comments | « content/browser/bad_message.h ('k') | content/browser/renderer_host/media/audio_output_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698