[M120 Migration][MM] Handle live stream duration and currenttime
[platform/framework/web/chromium-efl.git] / media / base / renderer_client.h
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.
4
5 #ifndef MEDIA_BASE_RENDERER_CLIENT_H_
6 #define MEDIA_BASE_RENDERER_CLIENT_H_
7
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"
17
18 namespace media {
19
20 // Interface used by Renderer, AudioRenderer, VideoRenderer and
21 // MediaPlayerRenderer implementations to notify their clients.
22 class MEDIA_EXPORT RendererClient {
23  public:
24   // Executed if any error was encountered after Renderer initialization.
25   virtual void OnError(PipelineStatus status) = 0;
26
27   // Executed if there is a non-fatal fallback that should be reported
28   virtual void OnFallback(PipelineStatus status) = 0;
29
30   // Executed when rendering has reached the end of stream.
31   virtual void OnEnded() = 0;
32
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;
37
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;
42
43   // Executed whenever the Renderer is waiting because of |reason|.
44   virtual void OnWaiting(WaitingReason reason) = 0;
45
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;
50
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;
54
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;
58
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();
63
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;
68
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,
73                                     bool is_live) {}
74
75   virtual void OnRequestSuspend(bool resource_conflicted) {}
76
77   virtual void OnRequestSeek(base::TimeDelta time) {}
78
79   virtual void OnLivePlaybackComplete() {}
80 #endif
81 };
82
83 }  // namespace media
84
85 #endif  // MEDIA_BASE_RENDERER_CLIENT_H_