renderer_client.h 2.9 KB

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