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 MEDIA_AUDIO_AUDIO_OUTPUT_DELEGATE_H_ | 5 #ifndef MEDIA_AUDIO_AUDIO_OUTPUT_DELEGATE_H_ |
6 #define MEDIA_AUDIO_AUDIO_OUTPUT_DELEGATE_H_ | 6 #define MEDIA_AUDIO_AUDIO_OUTPUT_DELEGATE_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "media/base/media_export.h" | 13 #include "media/base/media_export.h" |
14 | 14 |
15 namespace base { | 15 namespace base { |
16 class SharedMemory; | 16 class SharedMemory; |
17 class CancelableSyncSocket; | 17 class CancelableSyncSocket; |
18 } | 18 } |
19 | 19 |
20 namespace media { | 20 namespace media { |
21 | 21 |
22 class AudioOutputController; | |
23 | |
24 class MEDIA_EXPORT AudioOutputDelegate { | 22 class MEDIA_EXPORT AudioOutputDelegate { |
25 public: | 23 public: |
26 // An AudioOutputDelegate must not call back to its EventHandler in its | 24 // An AudioOutputDelegate must not call back to its EventHandler in its |
27 // constructor. | 25 // constructor. |
28 class MEDIA_EXPORT EventHandler { | 26 class MEDIA_EXPORT EventHandler { |
29 public: | 27 public: |
30 EventHandler(); | 28 EventHandler(); |
31 virtual ~EventHandler(); | 29 virtual ~EventHandler(); |
32 | 30 |
33 // Called when construction is finished and the stream is ready for | 31 // Called when construction is finished and the stream is ready for |
34 // playout. | 32 // playout. |
35 virtual void OnStreamCreated( | 33 virtual void OnStreamCreated( |
36 int stream_id, | 34 int stream_id, |
37 base::SharedMemory* shared_memory, | 35 base::SharedMemory* shared_memory, |
38 std::unique_ptr<base::CancelableSyncSocket> socket) = 0; | 36 std::unique_ptr<base::CancelableSyncSocket> socket) = 0; |
39 | 37 |
40 // Called if stream encounters an error and has become unusable. | 38 // Called if stream encounters an error and has become unusable. |
41 virtual void OnStreamError(int stream_id) = 0; | 39 virtual void OnStreamError(int stream_id) = 0; |
42 }; | 40 }; |
43 | 41 |
44 AudioOutputDelegate(); | 42 AudioOutputDelegate(); |
45 virtual ~AudioOutputDelegate(); | 43 virtual ~AudioOutputDelegate(); |
46 | 44 |
47 // TODO(maxmorin): Remove GetController() when crbug.com/647185 is closed. | |
48 // This function is used to provide control of the audio stream to | |
49 // WebrtcAudioPrivateGetActiveSinkFunction and others in the webrtc extension | |
50 // API. Since the controller is shared, this means that it might outlive the | |
51 // AudioOutputDelegate. In this case, it is still safe to call functions on | |
52 // the controller, but it will not do anything. The controller is also shared | |
53 // with AudioStreamMonitor. | |
54 virtual scoped_refptr<AudioOutputController> GetController() const = 0; | |
55 virtual int GetStreamId() const = 0; | 45 virtual int GetStreamId() const = 0; |
56 | 46 |
57 // Stream control: | 47 // Stream control: |
58 virtual void OnPlayStream() = 0; | 48 virtual void OnPlayStream() = 0; |
59 virtual void OnPauseStream() = 0; | 49 virtual void OnPauseStream() = 0; |
60 virtual void OnSetVolume(double volume) = 0; | 50 virtual void OnSetVolume(double volume) = 0; |
61 }; | 51 }; |
62 | 52 |
63 } // namespace media | 53 } // namespace media |
64 | 54 |
65 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_DELEGATE_H_ | 55 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_DELEGATE_H_ |
OLD | NEW |