Upload upstream chromium 67.0.3396
[platform/framework/web/chromium-efl.git] / media / base / renderer.h
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/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"
16
17 namespace media {
18
19 class MediaResource;
20 class RendererClient;
21
22 class MEDIA_EXPORT Renderer {
23  public:
24   Renderer();
25
26   // Stops rendering and fires any pending callbacks.
27   virtual ~Renderer();
28
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;
37
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;
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 0.
52   virtual void SetPlaybackRate(double 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  private:
61   DISALLOW_COPY_AND_ASSIGN(Renderer);
62 };
63
64 }  // namespace media
65
66 #endif  // MEDIA_BASE_RENDERER_H_