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

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

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

Powered by Google App Engine
This is Rietveld 408576698