Remove old about scheme URL constants.
[chromium-blink-merge.git] / media / base / video_renderer.h
blobfe46966ca4da2032911f175b30e91aff57d6f89a
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"
14 namespace media {
16 class DemuxerStream;
17 class VideoDecoder;
19 class MEDIA_EXPORT VideoRenderer {
20 public:
21 // Used to update the pipeline's clock time. The parameter is the time that
22 // the clock should not exceed.
23 typedef base::Callback<void(base::TimeDelta)> TimeCB;
25 // Used to query the current time or duration of the media.
26 typedef base::Callback<base::TimeDelta()> TimeDeltaCB;
28 VideoRenderer();
29 virtual ~VideoRenderer();
31 // Initialize a VideoRenderer with |stream|, executing |init_cb| upon
32 // completion.
34 // |statistics_cb| is executed periodically with video rendering stats, such
35 // as dropped frames.
37 // |time_cb| is executed whenever time has advanced by way of video rendering.
39 // |ended_cb| is executed when video rendering has reached the end of stream.
41 // |error_cb| is executed if an error was encountered.
43 // |get_time_cb| is used to query the current media playback time.
45 // |get_duration_cb| is used to query the media duration.
46 virtual void Initialize(DemuxerStream* stream,
47 const PipelineStatusCB& init_cb,
48 const StatisticsCB& statistics_cb,
49 const TimeCB& time_cb,
50 const base::Closure& ended_cb,
51 const PipelineStatusCB& error_cb,
52 const TimeDeltaCB& get_time_cb,
53 const TimeDeltaCB& get_duration_cb) = 0;
55 // Start audio decoding and rendering at the current playback rate, executing
56 // |callback| when playback is underway.
57 virtual void Play(const base::Closure& callback) = 0;
59 // Temporarily suspend decoding and rendering video, executing |callback| when
60 // playback has been suspended.
61 virtual void Pause(const base::Closure& callback) = 0;
63 // Discard any video data, executing |callback| when completed.
64 virtual void Flush(const base::Closure& callback) = 0;
66 // Start prerolling video data. If |time| equals kNoTimestamp() then all
67 // samples delivered to the renderer are used to complete preroll. If |time|
68 // does not equal kNoTimestamp(), then any samples delivered to the renderer
69 // with timestamps less than |time| are silently dropped and not used to
70 // satisfy preroll. |callback| is executed when preroll has completed.
72 // Only valid to call after a successful Initialize(), Pause(), or Flush().
73 virtual void Preroll(base::TimeDelta time,
74 const PipelineStatusCB& callback) = 0;
76 // Stop all operations in preparation for being deleted, executing |callback|
77 // when complete.
78 virtual void Stop(const base::Closure& callback) = 0;
80 // Updates the current playback rate.
81 virtual void SetPlaybackRate(float playback_rate) = 0;
83 private:
84 DISALLOW_COPY_AND_ASSIGN(VideoRenderer);
87 } // namespace media
89 #endif // MEDIA_BASE_VIDEO_RENDERER_H_