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.
5 #ifndef MEDIA_BASE_RENDERER_H_
6 #define MEDIA_BASE_RENDERER_H_
8 #include "base/callback.h"
9 #include "base/macros.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/time/time.h"
12 #include "media/base/buffering_state.h"
13 #include "media/base/cdm_context.h"
14 #include "media/base/media_export.h"
15 #include "media/base/pipeline_status.h"
22 class MEDIA_EXPORT Renderer {
26 // Stops rendering and fires any pending callbacks.
29 // Initializes the Renderer with |media_resource|, executing |init_cb| upon
30 // completion. |media_resource| must be valid for the lifetime of the Renderer
31 // object. |init_cb| must only be run after this method has returned. Firing
32 // |init_cb| may result in the immediate destruction of the caller, so it must
33 // be run only prior to returning.
34 virtual void Initialize(MediaResource* media_resource,
35 RendererClient* client,
36 const PipelineStatusCB& init_cb) = 0;
38 // Associates the |cdm_context| with this Renderer for decryption (and
39 // decoding) of media data, then fires |cdm_attached_cb| with the result.
40 virtual void SetCdm(CdmContext* cdm_context,
41 const CdmAttachedCB& cdm_attached_cb) = 0;
43 // The following functions must be called after Initialize().
45 // Discards any buffered data, executing |flush_cb| when completed.
46 virtual void Flush(const base::Closure& flush_cb) = 0;
48 // Starts rendering from |time|.
49 virtual void StartPlayingFrom(base::TimeDelta time) = 0;
51 // Updates the current playback rate. The default playback rate should be 0.
52 virtual void SetPlaybackRate(double playback_rate) = 0;
54 // Sets the output volume. The default volume should be 1.
55 virtual void SetVolume(float volume) = 0;
57 // Returns the current media time.
58 virtual base::TimeDelta GetMediaTime() = 0;
61 DISALLOW_COPY_AND_ASSIGN(Renderer);
66 #endif // MEDIA_BASE_RENDERER_H_