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
3 // found in the LICENSE file.
5 #ifndef MEDIA_BASE_VIDEO_RENDERER_H_
6 #define MEDIA_BASE_VIDEO_RENDERER_H_
8 #include "base/callback.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/time/time.h"
11 #include "media/base/media_export.h"
12 #include "media/base/pipeline_status.h"
23 class MEDIA_EXPORT VideoRenderer
{
25 // Used to update the pipeline's clock time. The parameter is the time that
26 // the clock should not exceed.
27 typedef base::Callback
<void(base::TimeDelta
)> TimeCB
;
29 // Executed when the natural size of the video has changed.
30 typedef base::Callback
<void(const gfx::Size
& size
)> NaturalSizeChangedCB
;
32 // Used to query the current time or duration of the media.
33 typedef base::Callback
<base::TimeDelta()> TimeDeltaCB
;
36 virtual ~VideoRenderer();
38 // Initialize a VideoRenderer with |stream|, executing |init_cb| upon
41 // |statistics_cb| is executed periodically with video rendering stats, such
44 // |time_cb| is executed whenever time has advanced by way of video rendering.
46 // |size_changed_cb| is executed whenever the dimensions of the video has
49 // |ended_cb| is executed when video rendering has reached the end of stream.
51 // |error_cb| is executed if an error was encountered.
53 // |get_time_cb| is used to query the current media playback time.
55 // |get_duration_cb| is used to query the media duration.
56 virtual void Initialize(DemuxerStream
* stream
,
57 const PipelineStatusCB
& init_cb
,
58 const StatisticsCB
& statistics_cb
,
59 const TimeCB
& time_cb
,
60 const NaturalSizeChangedCB
& size_changed_cb
,
61 const base::Closure
& ended_cb
,
62 const PipelineStatusCB
& error_cb
,
63 const TimeDeltaCB
& get_time_cb
,
64 const TimeDeltaCB
& get_duration_cb
) = 0;
66 // Start audio decoding and rendering at the current playback rate, executing
67 // |callback| when playback is underway.
68 virtual void Play(const base::Closure
& callback
) = 0;
70 // Temporarily suspend decoding and rendering video, executing |callback| when
71 // playback has been suspended.
72 virtual void Pause(const base::Closure
& callback
) = 0;
74 // Discard any video data, executing |callback| when completed.
75 virtual void Flush(const base::Closure
& callback
) = 0;
77 // Start prerolling video data for samples starting at |time|, executing
78 // |callback| when completed.
80 // Only valid to call after a successful Initialize() or Flush().
81 virtual void Preroll(base::TimeDelta time
,
82 const PipelineStatusCB
& callback
) = 0;
84 // Stop all operations in preparation for being deleted, executing |callback|
86 virtual void Stop(const base::Closure
& callback
) = 0;
88 // Updates the current playback rate.
89 virtual void SetPlaybackRate(float playback_rate
) = 0;
92 DISALLOW_COPY_AND_ASSIGN(VideoRenderer
);
97 #endif // MEDIA_BASE_VIDEO_RENDERER_H_