1 // Copyright 2016 The Chromium Authors
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_CLIENT_H_
6 #define MEDIA_BASE_RENDERER_CLIENT_H_
8 #include "media/base/audio_decoder_config.h"
9 #include "media/base/buffering_state.h"
10 #include "media/base/media_export.h"
11 #include "media/base/media_status.h"
12 #include "media/base/pipeline_status.h"
13 #include "media/base/video_decoder_config.h"
14 #include "media/base/waiting.h"
15 #include "third_party/abseil-cpp/absl/types/optional.h"
16 #include "ui/gfx/geometry/size.h"
20 // Interface used by Renderer, AudioRenderer, VideoRenderer and
21 // MediaPlayerRenderer implementations to notify their clients.
22 class MEDIA_EXPORT RendererClient {
24 // Executed if any error was encountered after Renderer initialization.
25 virtual void OnError(PipelineStatus status) = 0;
27 // Executed if there is a non-fatal fallback that should be reported
28 virtual void OnFallback(PipelineStatus status) = 0;
30 // Executed when rendering has reached the end of stream.
31 virtual void OnEnded() = 0;
33 // Executed periodically with rendering statistics. Fields *_decoded*,
34 // *_dropped and *memory_usage should be the delta since the last
35 // OnStatisticsUpdate() call.
36 virtual void OnStatisticsUpdate(const PipelineStatistics& stats) = 0;
38 // Executed when buffering state is changed. |reason| indicates the cause of
39 // the state change, when known.
40 virtual void OnBufferingStateChange(BufferingState state,
41 BufferingStateChangeReason reason) = 0;
43 // Executed whenever the Renderer is waiting because of |reason|.
44 virtual void OnWaiting(WaitingReason reason) = 0;
46 // Executed whenever DemuxerStream status returns kConfigChange. Initial
47 // configs provided by OnMetadata.
48 virtual void OnAudioConfigChange(const AudioDecoderConfig& config) = 0;
49 virtual void OnVideoConfigChange(const VideoDecoderConfig& config) = 0;
51 // Executed for the first video frame and whenever natural size changes.
52 // Only used if media stream contains a video track.
53 virtual void OnVideoNaturalSizeChange(const gfx::Size& size) = 0;
55 // Executed for the first video frame and whenever opacity changes.
56 // Only used if media stream contains a video track.
57 virtual void OnVideoOpacityChange(bool opaque) = 0;
59 // Returns true if video stream is available in the media resource.
60 // TODO(crbug.com/988535): Used by AudioRendererImpl. This can be removed
61 // when the bug is resolved.
62 virtual bool IsVideoStreamAvailable();
64 // Called when the bucketed frames per second has changed. |fps| will be
65 // unset if the frame rate is unstable. The duration used for the frame rate
66 // is based on the wall clock time, not the media time.
67 virtual void OnVideoFrameRateChange(absl::optional<int> fps) = 0;
69 #if defined(TIZEN_MULTIMEDIA)
70 // Called when seekable time range is found in a live stream.
71 virtual void OnSeekableTimeChange(base::TimeDelta min_time,
72 base::TimeDelta max_time,
75 virtual void OnRequestSuspend(bool resource_conflicted) {}
77 virtual void OnRequestSeek(base::TimeDelta time) {}
79 virtual void OnLivePlaybackComplete() {}
85 #endif // MEDIA_BASE_RENDERER_CLIENT_H_