OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_OUTPUT_DELEGATE_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_OUTPUT_DELEGATE_IMPL_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_OUTPUT_DELEGATE_IMPL_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_OUTPUT_DELEGATE_IMPL_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 29 matching lines...) Expand all Loading... |
40 MediaObserver* media_observer, | 40 MediaObserver* media_observer, |
41 int stream_id, | 41 int stream_id, |
42 int render_frame_id, | 42 int render_frame_id, |
43 int render_process_id, | 43 int render_process_id, |
44 const media::AudioParameters& params, | 44 const media::AudioParameters& params, |
45 const std::string& output_device_id); | 45 const std::string& output_device_id); |
46 | 46 |
47 ~AudioOutputDelegateImpl() override; | 47 ~AudioOutputDelegateImpl() override; |
48 | 48 |
49 // AudioOutputDelegate implementation. | 49 // AudioOutputDelegate implementation. |
50 scoped_refptr<media::AudioOutputController> GetController() const override; | |
51 int GetStreamId() const override; | 50 int GetStreamId() const override; |
52 void OnPlayStream() override; | 51 void OnPlayStream() override; |
53 void OnPauseStream() override; | 52 void OnPauseStream() override; |
54 void OnSetVolume(double volume) override; | 53 void OnSetVolume(double volume) override; |
55 | 54 |
56 private: | 55 private: |
57 class ControllerEventHandler; | 56 class ControllerEventHandler; |
| 57 friend class AudioOutputDelegateTest; |
58 | 58 |
59 void SendCreatedNotification(); | 59 void SendCreatedNotification(); |
60 void OnError(); | 60 void OnError(); |
61 void UpdatePlayingState(bool playing); | 61 void UpdatePlayingState(bool playing); |
| 62 media::AudioOutputController* GetControllerForTesting() const; |
62 | 63 |
63 // This is the event handler which |this| send notifications to. | 64 // This is the event handler which |this| send notifications to. |
64 EventHandler* subscriber_; | 65 EventHandler* subscriber_; |
65 std::unique_ptr<media::AudioLog> const audio_log_; | 66 std::unique_ptr<media::AudioLog> const audio_log_; |
66 // |controller_event_handler_| proxies events from controller to |this|. | 67 // |controller_event_handler_| proxies events from controller to |this|. |
67 // |controller_event_handler_|, |reader_| and |mirroring_manager_| will | 68 // |controller_event_handler_|, |reader_| and |mirroring_manager_| will |
68 // outlive |this|, see the destructor for details. | 69 // outlive |this|, see the destructor for details. |
69 std::unique_ptr<ControllerEventHandler> controller_event_handler_; | 70 std::unique_ptr<ControllerEventHandler> controller_event_handler_; |
70 std::unique_ptr<AudioSyncReader> reader_; | 71 std::unique_ptr<AudioSyncReader> reader_; |
71 AudioMirroringManager* mirroring_manager_; | 72 AudioMirroringManager* mirroring_manager_; |
72 scoped_refptr<media::AudioOutputController> controller_; | 73 scoped_refptr<media::AudioOutputController> controller_; |
73 const int stream_id_; | 74 const int stream_id_; |
74 const int render_frame_id_; | 75 const int render_frame_id_; |
75 const int render_process_id_; | 76 const int render_process_id_; |
76 | 77 |
77 // This flag ensures that we only send OnStreamStateChanged notifications | 78 // This flag ensures that we only send OnStreamStateChanged notifications |
78 // and (de)register with the stream monitor when the state actually changes. | 79 // and (de)register with the stream monitor when the state actually changes. |
79 bool playing_ = false; | 80 bool playing_ = false; |
80 base::WeakPtrFactory<AudioOutputDelegateImpl> weak_factory_; | 81 base::WeakPtrFactory<AudioOutputDelegateImpl> weak_factory_; |
81 | 82 |
82 DISALLOW_COPY_AND_ASSIGN(AudioOutputDelegateImpl); | 83 DISALLOW_COPY_AND_ASSIGN(AudioOutputDelegateImpl); |
83 }; | 84 }; |
84 | 85 |
85 } // namespace content | 86 } // namespace content |
86 | 87 |
87 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_OUTPUT_DELEGATE_IMPL_H_ | 88 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_OUTPUT_DELEGATE_IMPL_H_ |
OLD | NEW |