| 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 | 14 |
| 15 namespace media { | 15 namespace media { |
| 16 | 16 |
| 17 class CdmContext; | 17 class CdmContext; |
| 18 class DemuxerStream; | 18 class DemuxerStream; |
| 19 class RendererClient; |
| 19 class TimeSource; | 20 class TimeSource; |
| 20 | 21 |
| 21 class MEDIA_EXPORT AudioRenderer { | 22 class MEDIA_EXPORT AudioRenderer { |
| 22 public: | 23 public: |
| 23 AudioRenderer(); | 24 AudioRenderer(); |
| 24 | 25 |
| 25 // Stop all operations and fire all pending callbacks. | 26 // Stop all operations and fire all pending callbacks. |
| 26 virtual ~AudioRenderer(); | 27 virtual ~AudioRenderer(); |
| 27 | 28 |
| 28 // Initialize an AudioRenderer with |stream|, executing |init_cb| upon | 29 // Initialize an AudioRenderer with |stream|, executing |init_cb| upon |
| 29 // completion. If initialization fails, only |init_cb| (not |error_cb|) will | 30 // completion. If initialization fails, only |init_cb| |
| 30 // be called. | 31 // (not RendererClient::OnError) will be called. |
| 31 // | 32 // |
| 32 // |cdm_context| can be used to handle encrypted streams. May be null if the | 33 // |cdm_context| can be used to handle encrypted streams. May be null if the |
| 33 // stream is not encrypted. | 34 // stream is not encrypted. |
| 34 // | 35 virtual void Initialize(DemuxerStream* stream, |
| 35 // |statistics_cb| is executed periodically with audio rendering stats. | 36 CdmContext* cdm_context, |
| 36 // | 37 RendererClient* client, |
| 37 // |buffering_state_cb| is executed when audio rendering has either run out of | 38 const PipelineStatusCB& init_cb) = 0; |
| 38 // data or has enough data to continue playback. | |
| 39 // | |
| 40 // |ended_cb| is executed when audio rendering has reached the end of stream. | |
| 41 // | |
| 42 // |error_cb| is executed if an error was encountered after initialization. | |
| 43 // | |
| 44 // |waiting_for_decryption_key_cb| is called whenever the key needed to | |
| 45 // decrypt the stream is not available. | |
| 46 virtual void Initialize( | |
| 47 DemuxerStream* stream, | |
| 48 const PipelineStatusCB& init_cb, | |
| 49 CdmContext* cdm_context, | |
| 50 const StatisticsCB& statistics_cb, | |
| 51 const BufferingStateCB& buffering_state_cb, | |
| 52 const base::Closure& ended_cb, | |
| 53 const PipelineStatusCB& error_cb, | |
| 54 const base::Closure& waiting_for_decryption_key_cb) = 0; | |
| 55 | 39 |
| 56 // Returns the TimeSource associated with audio rendering. | 40 // Returns the TimeSource associated with audio rendering. |
| 57 virtual TimeSource* GetTimeSource() = 0; | 41 virtual TimeSource* GetTimeSource() = 0; |
| 58 | 42 |
| 59 // Discard any audio data, executing |callback| when completed. | 43 // Discard any audio data, executing |callback| when completed. |
| 60 // | 44 // |
| 61 // Clients should expect |buffering_state_cb| to be called with | 45 // Clients should expect |buffering_state_cb| to be called with |
| 62 // BUFFERING_HAVE_NOTHING while flushing is in progress. | 46 // BUFFERING_HAVE_NOTHING while flushing is in progress. |
| 63 virtual void Flush(const base::Closure& callback) = 0; | 47 virtual void Flush(const base::Closure& callback) = 0; |
| 64 | 48 |
| 65 // Starts playback by reading from |stream| and decoding and rendering audio. | 49 // Starts playback by reading from |stream| and decoding and rendering audio. |
| 66 // | 50 // |
| 67 // Only valid to call after a successful Initialize() or Flush(). | 51 // Only valid to call after a successful Initialize() or Flush(). |
| 68 virtual void StartPlaying() = 0; | 52 virtual void StartPlaying() = 0; |
| 69 | 53 |
| 70 // Sets the output volume. | 54 // Sets the output volume. |
| 71 virtual void SetVolume(float volume) = 0; | 55 virtual void SetVolume(float volume) = 0; |
| 72 | 56 |
| 73 private: | 57 private: |
| 74 DISALLOW_COPY_AND_ASSIGN(AudioRenderer); | 58 DISALLOW_COPY_AND_ASSIGN(AudioRenderer); |
| 75 }; | 59 }; |
| 76 | 60 |
| 77 } // namespace media | 61 } // namespace media |
| 78 | 62 |
| 79 #endif // MEDIA_BASE_AUDIO_RENDERER_H_ | 63 #endif // MEDIA_BASE_AUDIO_RENDERER_H_ |
| OLD | NEW |