OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef MEDIA_BASE_RENDERER_H_ |
| 6 #define MEDIA_BASE_RENDERER_H_ |
| 7 |
| 8 #include "base/callback.h" |
| 9 #include "base/time/time.h" |
| 10 #include "media/base/buffering_state.h" |
| 11 #include "media/base/media_export.h" |
| 12 #include "media/base/pipeline_status.h" |
| 13 |
| 14 namespace media { |
| 15 |
| 16 class MediaKeys; |
| 17 |
| 18 class MEDIA_EXPORT Renderer { |
| 19 public: |
| 20 typedef base::Callback<base::TimeDelta()> TimeDeltaCB; |
| 21 |
| 22 Renderer(); |
| 23 |
| 24 // Stops rendering and fires any pending callbacks. |
| 25 virtual ~Renderer(); |
| 26 |
| 27 // Initializes the Renderer, executing |init_cb| upon completion. |
| 28 // TODO(xhwang): Provide a set of DemuxerStreams in Initialize(). |
| 29 // TODO(xhwang): Replace |init_cb| with a Closure. |
| 30 // |
| 31 // Permanent callbacks: |
| 32 // - |statistics_cb|: Executed periodically with rendering statistics. |
| 33 // - |time_cb|: Executed whenever time has advanced through rendering. |
| 34 // - |ended_cb|: Executed when rendering has reached the end of stream. |
| 35 // - |error_cb|: Executed if any error was encountered during rendering. |
| 36 virtual void Initialize(const PipelineStatusCB& init_cb, |
| 37 const StatisticsCB& statistics_cb, |
| 38 const base::Closure& ended_cb, |
| 39 const PipelineStatusCB& error_cb, |
| 40 const BufferingStateCB& buffering_state_cb, |
| 41 const TimeDeltaCB& get_duration_cb) = 0; |
| 42 |
| 43 // The following functions must be called after Initialize(). |
| 44 |
| 45 // Discards any buffered data, executing |flush_cb| when completed. |
| 46 virtual void Flush(const base::Closure& flush_cb) = 0; |
| 47 |
| 48 // Starts rendering from |time|. |
| 49 virtual void StartPlayingFrom(base::TimeDelta time) = 0; |
| 50 |
| 51 // Updates the current playback rate. The default playback rate should be 1. |
| 52 virtual void SetPlaybackRate(float playback_rate) = 0; |
| 53 |
| 54 // Sets the output volume. The default volume should be 1. |
| 55 virtual void SetVolume(float volume) = 0; |
| 56 |
| 57 // Returns the current media time. |
| 58 virtual base::TimeDelta GetMediaTime() = 0; |
| 59 |
| 60 // Returns whether |this| renders audio. |
| 61 virtual bool HasAudio() = 0; |
| 62 |
| 63 // Returns whether |this| renders video. |
| 64 virtual bool HasVideo() = 0; |
| 65 |
| 66 // Associates the |cdm| with this Renderer. |
| 67 virtual void SetCdm(MediaKeys* cdm) = 0; |
| 68 |
| 69 private: |
| 70 DISALLOW_COPY_AND_ASSIGN(Renderer); |
| 71 }; |
| 72 |
| 73 } // namespace media |
| 74 |
| 75 #endif // MEDIA_BASE_RENDERER_H_ |
OLD | NEW |