Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / 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/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 class DemuxerStreamProvider;
18
19 class MEDIA_EXPORT Renderer {
20  public:
21   typedef base::Callback<base::TimeDelta()> TimeDeltaCB;
22
23   Renderer();
24
25   // Stops rendering and fires any pending callbacks.
26   virtual ~Renderer();
27
28   // Initializes the Renderer with |demuxer_stream_provider|, executing
29   // |init_cb| upon completion.  If initialization failed, fires |error_cb|
30   // before |init_cb|. |demuxer_stream_provider| must be valid throughout the
31   // lifetime of the Renderer object.
32   //
33   // Permanent callbacks:
34   // - |statistics_cb|: Executed periodically with rendering statistics.
35   // - |time_cb|: Executed whenever time has advanced through rendering.
36   // - |ended_cb|: Executed when rendering has reached the end of stream.
37   // - |error_cb|: Executed if any error was encountered during rendering.
38   virtual void Initialize(DemuxerStreamProvider* demuxer_stream_provider,
39                           const base::Closure& init_cb,
40                           const StatisticsCB& statistics_cb,
41                           const base::Closure& ended_cb,
42                           const PipelineStatusCB& error_cb,
43                           const BufferingStateCB& buffering_state_cb) = 0;
44
45   // The following functions must be called after Initialize().
46
47   // Discards any buffered data, executing |flush_cb| when completed.
48   virtual void Flush(const base::Closure& flush_cb) = 0;
49
50   // Starts rendering from |time|.
51   virtual void StartPlayingFrom(base::TimeDelta time) = 0;
52
53   // Updates the current playback rate. The default playback rate should be 1.
54   virtual void SetPlaybackRate(float playback_rate) = 0;
55
56   // Sets the output volume. The default volume should be 1.
57   virtual void SetVolume(float volume) = 0;
58
59   // Returns the current media time.
60   virtual base::TimeDelta GetMediaTime() = 0;
61
62   // Returns whether |this| renders audio.
63   virtual bool HasAudio() = 0;
64
65   // Returns whether |this| renders video.
66   virtual bool HasVideo() = 0;
67
68   // Associates the |cdm| with this Renderer.
69   virtual void SetCdm(MediaKeys* cdm) = 0;
70
71  private:
72   DISALLOW_COPY_AND_ASSIGN(Renderer);
73 };
74
75 }  // namespace media
76
77 #endif  // MEDIA_BASE_RENDERER_H_