#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
+#include "tizen_src/chromium_impl/media/filters/media_player_tizen_client.h"
#include "ui/gfx/geometry/size.h"
namespace base {
class CONTENT_EXPORT TizenRendererImpl
: public media::Renderer,
- public media::mojom::MediaPlayerRendererExtension {
+ public media::mojom::MediaPlayerRendererExtension,
+ public media::MediaPlayerTizenClient {
public:
using RendererExtension = media::mojom::MediaPlayerRendererExtension;
using ClientExtension = media::mojom::MediaPlayerRendererClientExtension;
void SetPlaybackRate(double playback_rate) override;
void SetVolume(float volume) override;
base::TimeDelta GetMediaTime() override;
+ media::RendererType GetRendererType() override;
void OnSelectedVideoTracksChanged(
const std::vector<media::DemuxerStream*>& enabled_tracks,
base::OnceClosure change_completed_cb) override;
void OnUpdateAudioMutingState(bool muted) {}
void OnWebContentsDestroyed();
- // Should be removed.
- void Seek(base::TimeDelta time);
-
- // Proxy functions for MediaPlayerRendererClientExtension
- void OnVideoSizeChange(const gfx::Size& size);
- void OnDurationChange(base::TimeDelta duration);
- void OnBufferUpdate(base::TimeDelta time);
-
-#if defined(TIZEN_VIDEO_HOLE)
- void SetVideoHole(bool is_video_hole) final;
- void SetMediaGeometry(const gfx::RectF& rect) final;
-
- gfx::Rect GetViewportRect() const;
+ void Seek(base::TimeDelta time, base::OnceClosure seek_cb);
+
+ void Suspend() override;
+
+ void ToggleFullscreenMode(bool is_fullscreen, ToggledFullscreenCB cb) final;
+
+ // MediaPlayerTizenClient implementation.
+ void OnError(media::PipelineStatus error) override;
+ void OnFallback(media::PipelineStatus fallback) override {}
+ void OnEnded() override;
+ void OnStatisticsUpdate(const media::PipelineStatistics& stats) override;
+ void OnSeekableTimeChange(base::TimeDelta min_time,
+ base::TimeDelta max_time,
+ bool is_live) override;
+ void OnBufferingStateChange(
+ media::BufferingState new_buffering_state,
+ media::BufferingStateChangeReason reason) override;
+ void OnWaiting(media::WaitingReason reason) override;
+ void OnAudioConfigChange(const media::AudioDecoderConfig& config) override;
+ void OnVideoConfigChange(const media::VideoDecoderConfig& config) override;
+ void OnVideoNaturalSizeChange(const gfx::Size& size) override;
+ void OnVideoOpacityChange(bool opaque) override;
+ void OnVideoFrameRateChange(absl::optional<int> fps) override;
+ void OnRequestSeek(base::TimeDelta time) override;
+ void OnRequestSuspend(bool resource_conflict) override;
+ void OnVideoSizeChange(const gfx::Size& size) override;
+ void OnDurationChange(base::TimeDelta duration) override;
+ void OnBufferUpdate(base::TimeDelta time) override;
+
+#if BUILDFLAG(IS_TIZEN_TV)
+ bool PlaybackNotificationEnabled();
+ void NotifyPlaybackState(int state,
+ int player_id = 0,
+ const std::string& url = "",
+ const std::string& mime_type = "",
+ bool* media_resource_acquired = NULL,
+ std::string* translated_url = NULL,
+ std::string* drm_info = NULL) override;
+ void OnLivePlaybackComplete() override;
#endif
+#if defined(TIZEN_TBM_SUPPORT)
+ void OnNewTbmFrameAvailable(uint32_t player_id,
+ gfx::TbmBufferHandle tbm_handle,
+ base::TimeDelta timestamp) override;
+ void OnTbmBufferExhausted(const gfx::TbmBufferHandle& tbm_handle) override;
+#else
void OnNewFrameAvailable(uint32_t playerId,
base::UnsafeSharedMemoryRegion frame,
uint32_t size,
base::TimeDelta timestamp,
uint32_t width,
- uint32_t height);
+ uint32_t height) override;
+#endif
-#if defined(TIZEN_TBM_SUPPORT)
- void OnNewTbmFrameAvailable(uint32_t player_id,
- gfx::TbmBufferHandle tbm_handle,
- base::TimeDelta timestamp);
- void OnTbmBufferExhausted(const gfx::TbmBufferHandle& tbm_handle) override;
+#if BUILDFLAG(IS_TIZEN_TV)
+ content::WebContentsDelegate* GetWebContentsDelegate() const override;
+#endif
+
+#if defined(TIZEN_VIDEO_HOLE)
+ void SetVideoHole(bool is_video_hole) final;
+ void SetMediaGeometry(const gfx::RectF& rect) final;
+ gfx::Rect GetViewportRect() const;
+#endif
+
+#if BUILDFLAG(IS_TIZEN_TV)
+ void SetContentMimeType(const std::string& mime_type) override;
+ void SetParentalRatingResult(bool is_pass) override;
#endif
private:
- class RendererClientInternal;
const float kDefaultVolume = 1.0;
enum State {
void SetStreamInfo();
void SetPlayerVolume();
+ void SetPlayerInitialize();
+ void SetPlayerPrepare();
#if defined(TIZEN_VIDEO_HOLE)
void SetPlayerVideoHole();
void SetPlayerMediaGeometry();
+ void OnWebViewMoved();
#endif
- void OnRendererEnded();
- void OnError(media::PipelineStatus error);
- void OnStatisticsUpdate(const media::PipelineStatistics& stats);
- void OnBufferingStateChange(media::BufferingState new_buffering_state,
- media::BufferingStateChangeReason reason);
- void OnWaiting(media::WaitingReason reason);
- void OnAudioConfigChange(const media::AudioDecoderConfig& config);
- void OnVideoConfigChange(const media::VideoDecoderConfig& config);
- void OnVideoNaturalSizeChange(const gfx::Size& size);
- void OnVideoOpacityChange(bool opaque);
- void OnVideoFrameRateChange(absl::optional<int> fps);
-
- media::RendererClient* client_;
-
- State state_;
+ content::WebContents* GetWebContents() const;
+
+ media::RendererClient* client_ = nullptr;
+
+ State state_ = STATE_UNINITIALIZED;
// Task runner used to execute pipeline tasks.
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
media::VideoRendererSink* const sink_ = nullptr;
mojo::Remote<ClientExtension> client_extension_;
+
+ int player_id_ = 0;
+
// Identifiers to find the RenderFrameHost that created |this|.
// NOTE: We store these IDs rather than a RenderFrameHost* because we do not
// know when the RenderFrameHost is destroyed.
- int render_process_id_;
- int routing_id_;
+ int render_process_id_ = 0;
+ int routing_id_ = 0;
- // Temporary callback used for Initialize() and Flush().
+ // Temporary callback used for Initialize().
media::PipelineStatusCallback init_cb_;
- base::OnceClosure flush_cb_;
- std::unique_ptr<RendererClientInternal> audio_renderer_client_;
- std::unique_ptr<RendererClientInternal> video_renderer_client_;
-
- media::MediaResource* media_resource_;
- media::DemuxerStream* audio_stream_;
- media::DemuxerStream* video_stream_;
+ media::MediaResource* media_resource_ = nullptr;
+ media::DemuxerStream* audio_stream_ = nullptr;
+ media::DemuxerStream* video_stream_ = nullptr;
std::unique_ptr<media::MediaPlayerTizen> media_player_;
double volume_ = kDefaultVolume;
// The time to start playback from after starting/seeking has completed.
base::TimeDelta start_time_;
- media::BufferingState audio_buffering_state_;
- media::BufferingState video_buffering_state_;
+ media::BufferingState audio_buffering_state_ = media::BUFFERING_HAVE_NOTHING;
+ media::BufferingState video_buffering_state_ = media::BUFFERING_HAVE_NOTHING;
// Whether we've received the audio/video ended events.
bool media_ended_ = false;
bool web_contents_muted_ = false;
mojo::Receiver<MediaPlayerRendererExtension> renderer_extension_receiver_;
raw_ptr<content::MediaPlayerRendererWebContentsObserver>
- web_contents_observer_;
+ web_contents_observer_ = nullptr;
// Indicates if a serious error has been encountered by the |media_player_|.
bool has_error_ = false;
+ bool resource_conflicted_ = true;
+ bool is_suspended_ = false;
#if defined(TIZEN_VIDEO_HOLE)
- WebContents* web_contents_;
bool is_video_hole_ = false;
gfx::RectF video_rect_;
#endif
+#if BUILDFLAG(IS_TIZEN_TV)
+ int notify_playback_state_;
+ // Stores the mime type. Required for URL streams which are DASH
+ // content, so that we can set it to the media_player_ before calling
+ // initialize / prepare.
+ std::string mime_type_;
+#endif
+
+ WebContents* web_contents_ = nullptr;
+
base::WeakPtrFactory<TizenRendererImpl> weak_factory_{this};
};