| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_BASE_FAKE_AUDIO_RENDERER_SINK_H_ | 5 #ifndef MEDIA_BASE_FAKE_AUDIO_RENDERER_SINK_H_ |
| 6 #define MEDIA_BASE_FAKE_AUDIO_RENDERER_SINK_H_ | 6 #define MEDIA_BASE_FAKE_AUDIO_RENDERER_SINK_H_ |
| 7 | 7 |
| 8 #include <string> |
| 9 |
| 8 #include "media/audio/audio_parameters.h" | 10 #include "media/audio/audio_parameters.h" |
| 9 #include "media/base/audio_renderer_sink.h" | 11 #include "media/base/audio_renderer_sink.h" |
| 12 #include "url/gurl.h" |
| 10 | 13 |
| 11 namespace media { | 14 namespace media { |
| 12 | 15 |
| 13 class FakeAudioRendererSink : public AudioRendererSink { | 16 class FakeAudioRendererSink : public AudioRendererSink { |
| 14 public: | 17 public: |
| 15 enum State { | 18 enum State { |
| 16 kUninitialized, | 19 kUninitialized, |
| 17 kInitialized, | 20 kInitialized, |
| 18 kStarted, | 21 kStarted, |
| 19 kPaused, | 22 kPaused, |
| 20 kPlaying, | 23 kPlaying, |
| 21 kStopped | 24 kStopped |
| 22 }; | 25 }; |
| 23 | 26 |
| 24 FakeAudioRendererSink(); | 27 FakeAudioRendererSink(); |
| 25 | 28 |
| 26 void Initialize(const AudioParameters& params, | 29 void Initialize(const AudioParameters& params, |
| 27 RenderCallback* callback) override; | 30 RenderCallback* callback) override; |
| 28 void Start() override; | 31 void Start() override; |
| 29 void Stop() override; | 32 void Stop() override; |
| 30 void Pause() override; | 33 void Pause() override; |
| 31 void Play() override; | 34 void Play() override; |
| 32 bool SetVolume(double volume) override; | 35 bool SetVolume(double volume) override; |
| 36 void SwitchOutputDevice(const std::string& device_id, |
| 37 const GURL& security_origin, |
| 38 const base::Callback<void(int)>& callback) override; |
| 39 |
| 33 | 40 |
| 34 // Attempts to call Render() on the callback provided to | 41 // Attempts to call Render() on the callback provided to |
| 35 // Initialize() with |dest| and |audio_delay_milliseconds|. | 42 // Initialize() with |dest| and |audio_delay_milliseconds|. |
| 36 // Returns true and sets |frames_written| to the return value of the | 43 // Returns true and sets |frames_written| to the return value of the |
| 37 // Render() call. | 44 // Render() call. |
| 38 // Returns false if this object is in a state where calling Render() | 45 // Returns false if this object is in a state where calling Render() |
| 39 // should not occur. (i.e., in the kPaused or kStopped state.) The | 46 // should not occur. (i.e., in the kPaused or kStopped state.) The |
| 40 // value of |frames_written| is undefined if false is returned. | 47 // value of |frames_written| is undefined if false is returned. |
| 41 bool Render(AudioBus* dest, int audio_delay_milliseconds, | 48 bool Render(AudioBus* dest, int audio_delay_milliseconds, |
| 42 int* frames_written); | 49 int* frames_written); |
| 43 void OnRenderError(); | 50 void OnRenderError(); |
| 44 | 51 |
| 45 State state() const { return state_; } | 52 State state() const { return state_; } |
| 46 | 53 |
| 47 protected: | 54 protected: |
| 48 ~FakeAudioRendererSink() override; | 55 ~FakeAudioRendererSink() override; |
| 49 | 56 |
| 50 private: | 57 private: |
| 51 void ChangeState(State new_state); | 58 void ChangeState(State new_state); |
| 52 | 59 |
| 53 State state_; | 60 State state_; |
| 54 RenderCallback* callback_; | 61 RenderCallback* callback_; |
| 55 | 62 |
| 56 DISALLOW_COPY_AND_ASSIGN(FakeAudioRendererSink); | 63 DISALLOW_COPY_AND_ASSIGN(FakeAudioRendererSink); |
| 57 }; | 64 }; |
| 58 | 65 |
| 59 } // namespace media | 66 } // namespace media |
| 60 | 67 |
| 61 #endif // MEDIA_BASE_FAKE_AUDIO_RENDERER_SINK_H_ | 68 #endif // MEDIA_BASE_FAKE_AUDIO_RENDERER_SINK_H_ |
| OLD | NEW |