Rebaseline global-interface-listing-expected.txt
[chromium-blink-merge.git] / media / base / renderer.h
blobd5b323bb25ef1cd32a3e156aaa01d003c174a790
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.
5 #ifndef MEDIA_BASE_RENDERER_H_
6 #define MEDIA_BASE_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/cdm_context.h"
13 #include "media/base/media_export.h"
14 #include "media/base/pipeline_status.h"
16 namespace media {
18 class DemuxerStreamProvider;
19 class VideoFrame;
21 class MEDIA_EXPORT Renderer {
22 public:
23 Renderer();
25 // Stops rendering and fires any pending callbacks.
26 virtual ~Renderer();
28 // Initializes the Renderer with |demuxer_stream_provider|, executing
29 // |init_cb| upon completion. If initialization fails, only |init_cb| (not
30 // |error_cb|) should be called. |demuxer_stream_provider| must be valid for
31 // the lifetime of the Renderer object. |init_cb| must only be run after this
32 // method has returned. Firing |init_cb| may result in the immediate
33 // destruction of the caller, so it must be run only prior to returning.
35 // Permanent callbacks:
36 // - |statistics_cb|: Executed periodically with rendering statistics.
37 // - |buffering_state_cb|: Executed when buffering state is changed.
38 // - |ended_cb|: Executed when rendering has reached the end of stream.
39 // - |error_cb|: Executed if any error was encountered after initialization.
40 // - |waiting_for_decryption_key_cb|: Executed whenever the key needed to
41 // decrypt the stream is not available.
42 virtual void Initialize(
43 DemuxerStreamProvider* demuxer_stream_provider,
44 const PipelineStatusCB& init_cb,
45 const StatisticsCB& statistics_cb,
46 const BufferingStateCB& buffering_state_cb,
47 const base::Closure& ended_cb,
48 const PipelineStatusCB& error_cb,
49 const base::Closure& waiting_for_decryption_key_cb) = 0;
51 // Associates the |cdm_context| with this Renderer for decryption (and
52 // decoding) of media data, then fires |cdm_attached_cb| with the result.
53 virtual void SetCdm(CdmContext* cdm_context,
54 const CdmAttachedCB& cdm_attached_cb) = 0;
56 // The following functions must be called after Initialize().
58 // Discards any buffered data, executing |flush_cb| when completed.
59 virtual void Flush(const base::Closure& flush_cb) = 0;
61 // Starts rendering from |time|.
62 virtual void StartPlayingFrom(base::TimeDelta time) = 0;
64 // Updates the current playback rate. The default playback rate should be 1.
65 virtual void SetPlaybackRate(double playback_rate) = 0;
67 // Sets the output volume. The default volume should be 1.
68 virtual void SetVolume(float volume) = 0;
70 // Returns the current media time.
71 virtual base::TimeDelta GetMediaTime() = 0;
73 // Returns whether |this| renders audio.
74 virtual bool HasAudio() = 0;
76 // Returns whether |this| renders video.
77 virtual bool HasVideo() = 0;
79 private:
80 DISALLOW_COPY_AND_ASSIGN(Renderer);
83 } // namespace media
85 #endif // MEDIA_BASE_RENDERER_H_