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

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

Issue 2443573003: Factor out AudioOutputDelegate from AudioRendererHost. (Closed)
Patch Set: Simplify. Created 4 years, 1 month 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_RENDERER_HOST_MEDIA_AUDIO_OUTPUT_DELEGATE_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_OUTPUT_DELEGATE_H_
7
8 #include <string>
9
10 #include "base/macros.h"
11 #include "base/memory/shared_memory.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/sync_socket.h"
14 #include "content/browser/media/capture/audio_mirroring_manager.h"
15 #include "content/public/browser/media_observer.h"
16 #include "media/audio/audio_logging.h"
17 #include "media/audio/audio_output_controller.h"
18 #include "media/base/audio_parameters.h"
19
20 namespace content {
21
22 // This class is operated on the IO thread.
23 class AudioOutputDelegate : private media::AudioOutputController::EventHandler {
24 public:
25 class EventHandler {
26 public:
27 // Only called when playing-state changes.
28 virtual void OnStreamStateChanged(bool playing) = 0;
29 // Called when construction is finished and the stream is ready for
30 // playout.
31 virtual void OnStreamCreated(int stream_id,
32 base::SharedMemory* shared_memory,
33 base::CancelableSyncSocket* socket) = 0;
34 // Called if stream encounters an error and has become unusable.
35 virtual void OnStreamError(int stream_id) = 0;
36 };
37
38 AudioOutputDelegate(EventHandler* handler,
39 media::AudioLog* audio_log,
40 AudioMirroringManager* mirroring_manager,
41 MediaObserver* media_observer,
42 int stream_id,
43 int render_frame_id,
44 int render_process_id,
45 media::AudioParameters params,
46 const std::string& output_device_id);
47 ~AudioOutputDelegate() override;
48
49 const scoped_refptr<media::AudioOutputController>& controller() const {
50 return controller_;
51 }
52
53 int stream_id() const { return stream_id_; }
54
55 // Stream control:
56 void OnPlayStream();
57 void OnPauseStream();
58 // After calling this method, it is an error to call other methods on this
59 // object, and the object should be destructed.
60 void OnCloseStream();
61 void OnSetVolume(double volume);
62
63 private:
64 // AudioOutputController::EventHandler implementation.
65 void OnControllerCreated() override;
66 void OnControllerPlaying() override;
67 void OnControllerPaused() override;
68 void OnControllerError() override;
69
70 EventHandler* const handler_;
71 media::AudioLog* const audio_log_;
72 AudioMirroringManager* const mirroring_manager_;
73 scoped_refptr<media::AudioOutputController> controller_;
74 const int stream_id_;
75 const int render_frame_id_;
76 const int render_process_id_;
77 bool playing_ = false;
78 base::WeakPtrFactory<AudioOutputDelegate> weak_factory_;
79
80 DISALLOW_COPY_AND_ASSIGN(AudioOutputDelegate);
81 };
82 } // namespace content
83
84 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_OUTPUT_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698