Roll leveldb 3f7758:803d69 (v1.17 -> v1.18)
[chromium-blink-merge.git] / media / base / video_renderer.h
blob360f7ade5eea7d8a587518130d8929ba1e8a6ef5
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/buffering_state.h"
12 #include "media/base/media_export.h"
13 #include "media/base/pipeline_status.h"
15 namespace media {
17 class DemuxerStream;
18 class VideoDecoder;
19 class VideoFrame;
21 class MEDIA_EXPORT VideoRenderer {
22 public:
23 // Used to paint VideoFrame.
24 typedef base::Callback<void(const scoped_refptr<VideoFrame>&)> PaintCB;
26 // Used to query the current time or duration of the media.
27 typedef base::Callback<base::TimeDelta()> TimeDeltaCB;
29 VideoRenderer();
31 // Stops all operations and fires all pending callbacks.
32 virtual ~VideoRenderer();
34 // Initializes a VideoRenderer with |stream|, executing |init_cb| upon
35 // completion.
37 // |statistics_cb| is executed periodically with video rendering stats, such
38 // as dropped frames.
40 // |buffering_state_cb| is executed when video rendering has either run out of
41 // data or has enough data to continue playback.
43 // |paint_cb| is executed on the video frame timing thread whenever a new
44 // frame is available for painting. Can be called from any thread.
46 // |ended_cb| is executed when video rendering has reached the end of stream.
48 // |error_cb| is executed if an error was encountered.
50 // |get_time_cb| is used to query the current media playback time.
51 virtual void Initialize(DemuxerStream* stream,
52 const PipelineStatusCB& init_cb,
53 const StatisticsCB& statistics_cb,
54 const BufferingStateCB& buffering_state_cb,
55 const PaintCB& paint_cb,
56 const base::Closure& ended_cb,
57 const PipelineStatusCB& error_cb,
58 const TimeDeltaCB& get_time_cb) = 0;
60 // Discards any video data and stops reading from |stream|, executing
61 // |callback| when completed.
63 // Clients should expect |buffering_state_cb| to be called with
64 // BUFFERING_HAVE_NOTHING while flushing is in progress.
65 virtual void Flush(const base::Closure& callback) = 0;
67 // Starts playback at |timestamp| by reading from |stream| and decoding and
68 // rendering video.
70 // Only valid to call after a successful Initialize() or Flush().
71 virtual void StartPlayingFrom(base::TimeDelta timestamp) = 0;
73 private:
74 DISALLOW_COPY_AND_ASSIGN(VideoRenderer);
77 } // namespace media
79 #endif // MEDIA_BASE_VIDEO_RENDERER_H_