| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_AUDIO_RENDERER_H_ | 5 #ifndef MEDIA_BASE_AUDIO_RENDERER_H_ |
| 6 #define MEDIA_BASE_AUDIO_RENDERER_H_ | 6 #define MEDIA_BASE_AUDIO_RENDERER_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| 11 #include "media/base/buffering_state.h" | 11 #include "media/base/buffering_state.h" |
| 12 #include "media/base/media_export.h" | 12 #include "media/base/media_export.h" |
| 13 #include "media/base/pipeline_status.h" | 13 #include "media/base/pipeline_status.h" |
| 14 #include "media/base/stream_position.h" |
| 14 | 15 |
| 15 namespace media { | 16 namespace media { |
| 16 | 17 |
| 17 class CdmContext; | 18 class CdmContext; |
| 18 class DemuxerStream; | 19 class DemuxerStream; |
| 19 class RendererClient; | 20 class RendererClient; |
| 20 class TimeSource; | 21 class TimeSource; |
| 21 | 22 |
| 22 class MEDIA_EXPORT AudioRenderer { | 23 class MEDIA_EXPORT AudioRenderer { |
| 23 public: | 24 public: |
| 24 AudioRenderer(); | 25 AudioRenderer() = default; |
| 25 | 26 |
| 26 // Stop all operations and fire all pending callbacks. | 27 // Stop all operations and fire all pending callbacks. |
| 27 virtual ~AudioRenderer(); | 28 virtual ~AudioRenderer() = default; |
| 28 | 29 |
| 29 // Initialize an AudioRenderer with |stream|, executing |init_cb| upon | 30 // Initialize an AudioRenderer with |stream|, executing |init_cb| upon |
| 30 // completion. If initialization fails, only |init_cb| | 31 // completion. If initialization fails, only |init_cb| |
| 31 // (not RendererClient::OnError) will be called. | 32 // (not RendererClient::OnError) will be called. |
| 32 // | 33 // |
| 33 // |cdm_context| can be used to handle encrypted streams. May be null if the | 34 // |cdm_context| can be used to handle encrypted streams. May be null if the |
| 34 // stream is not encrypted. | 35 // stream is not encrypted. |
| 35 virtual void Initialize(DemuxerStream* stream, | 36 virtual void Initialize(DemuxerStream* stream, |
| 36 CdmContext* cdm_context, | 37 CdmContext* cdm_context, |
| 37 RendererClient* client, | 38 RendererClient* client, |
| 38 const PipelineStatusCB& init_cb) = 0; | 39 const PipelineStatusCB& init_cb) = 0; |
| 39 | 40 |
| 40 // Returns the TimeSource associated with audio rendering. | 41 // Returns the TimeSource associated with audio rendering. |
| 41 virtual TimeSource* GetTimeSource() = 0; | 42 virtual TimeSource* GetTimeSource() = 0; |
| 42 | 43 |
| 43 // Discard any audio data, executing |callback| when completed. | 44 // Discard any audio data, executing |callback| when completed. |
| 44 // | 45 // |
| 45 // Clients should expect |buffering_state_cb| to be called with | 46 // Clients should expect |buffering_state_cb| to be called with |
| 46 // BUFFERING_HAVE_NOTHING while flushing is in progress. | 47 // BUFFERING_HAVE_NOTHING while flushing is in progress. |
| 47 virtual void Flush(const base::Closure& callback) = 0; | 48 virtual void Flush(const base::Closure& callback) = 0; |
| 48 | 49 |
| 49 // Starts playback by reading from |stream| and decoding and rendering audio. | 50 // Starts playback by reading from |stream| and decoding and rendering audio. |
| 50 // | 51 // |
| 51 // Only valid to call after a successful Initialize() or Flush(). | 52 // Only valid to call after a successful Initialize() or Flush(). |
| 52 virtual void StartPlaying() = 0; | 53 virtual void StartPlayingFrom(StreamPosition position) = 0; |
| 53 | 54 |
| 54 // Sets the output volume. | 55 // Sets the output volume. |
| 55 virtual void SetVolume(float volume) = 0; | 56 virtual void SetVolume(float volume) = 0; |
| 56 | 57 |
| 57 private: | 58 private: |
| 58 DISALLOW_COPY_AND_ASSIGN(AudioRenderer); | 59 DISALLOW_COPY_AND_ASSIGN(AudioRenderer); |
| 59 }; | 60 }; |
| 60 | 61 |
| 61 } // namespace media | 62 } // namespace media |
| 62 | 63 |
| 63 #endif // MEDIA_BASE_AUDIO_RENDERER_H_ | 64 #endif // MEDIA_BASE_AUDIO_RENDERER_H_ |
| OLD | NEW |