| Index: media/base/android/mt/player.cc
|
| diff --git a/media/base/android/mt/player.cc b/media/base/android/mt/player.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..c20493a4dfb01a302849c7b947b2d066405f1b08
|
| --- /dev/null
|
| +++ b/media/base/android/mt/player.cc
|
| @@ -0,0 +1,185 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "media/base/android/mt/player.h"
|
| +
|
| +#include "base/bind.h"
|
| +#include "base/lazy_instance.h"
|
| +#include "base/logging.h"
|
| +#include "base/threading/thread.h"
|
| +
|
| +#include "media/base/android/media_player_manager.h"
|
| +
|
| +namespace media {
|
| +namespace mt {
|
| +
|
| +class MediaThread : public base::Thread {
|
| + public:
|
| + MediaThread() : base::Thread("MediaSource_MediaThread") {
|
| + Start();
|
| + }
|
| +};
|
| +
|
| +// Create media thread
|
| +base::LazyInstance<MediaThread>::Leaky
|
| + g_media_thread = LAZY_INSTANCE_INITIALIZER;
|
| +
|
| +
|
| +scoped_refptr<base::SingleThreadTaskRunner> GetMediaTaskRunner() {
|
| + return g_media_thread.Pointer()->task_runner();
|
| +}
|
| +
|
| +Player::Player(
|
| + int player_id,
|
| + MediaPlayerManager* manager,
|
| + const RequestMediaResourcesCB& request_media_resources_cb,
|
| + scoped_ptr<DemuxerAndroid> demuxer,
|
| + const GURL& frame_url)
|
| + : MediaPlayerAndroid(player_id,
|
| + manager,
|
| + request_media_resources_cb,
|
| + frame_url),
|
| + demuxer_(demuxer.Pass()),
|
| + weak_factory_(this)
|
| +{
|
| + DVLOG(1) << "Player::Player: player_id:" << player_id;
|
| +
|
| + demuxer_->Initialize(this);
|
| + weak_this_ = weak_factory_.GetWeakPtr();
|
| +}
|
| +
|
| +Player::~Player()
|
| +{
|
| + // Called on UI thread, we need to release asynchronously
|
| +}
|
| +
|
| +void Player::SetVideoSurface(gfx::ScopedJavaSurface surface) {
|
| + DVLOG(1) << __FUNCTION__;
|
| +
|
| + // gfx::ScopedJavaSurface has move constructor instead of copy,
|
| + // the following Bind() does not work
|
| + //GetMediaTaskRunner()->PostTask(
|
| + // FROM_HERE, base::Bind(&Player::SetVideoSurfaceInternal,
|
| + // weak_this_, surface));
|
| +}
|
| +
|
| +void Player::Start() {
|
| + DVLOG(1) << __FUNCTION__;
|
| +
|
| + GetMediaTaskRunner()->PostTask(
|
| + FROM_HERE, base::Bind(&Player::StartInternal, weak_this_));
|
| +}
|
| +
|
| +void Player::Pause(bool /* is_media_related_action */) {
|
| + DVLOG(1) << __FUNCTION__;
|
| +
|
| + GetMediaTaskRunner()->PostTask(
|
| + FROM_HERE, base::Bind(&Player::PauseInternal, weak_this_));
|
| +}
|
| +
|
| +void Player::SeekTo(base::TimeDelta timestamp) {
|
| + DVLOG(1) << __FUNCTION__ << " " << timestamp;
|
| +
|
| + GetMediaTaskRunner()->PostTask(
|
| + FROM_HERE, base::Bind(&Player::SeekToInternal, weak_this_, timestamp));
|
| +}
|
| +
|
| +void Player::Release() {
|
| + DVLOG(1) << __FUNCTION__;
|
| +
|
| + GetMediaTaskRunner()->PostTask(
|
| + FROM_HERE, base::Bind(&Player::ReleaseInternal, weak_this_));
|
| +}
|
| +
|
| +void Player::SetVolume(double volume) {
|
| + DVLOG(1) << __FUNCTION__ << " " << volume;
|
| +}
|
| +
|
| +int Player::GetVideoWidth() {
|
| + return 320;
|
| +}
|
| +
|
| +int Player::GetVideoHeight() {
|
| + return 240;
|
| +}
|
| +
|
| +base::TimeDelta Player::GetCurrentTime() {
|
| + return base::TimeDelta();
|
| +}
|
| +
|
| +base::TimeDelta Player::GetDuration() {
|
| + return base::TimeDelta();
|
| +}
|
| +
|
| +bool Player::IsPlaying() {
|
| + return false;
|
| +}
|
| +
|
| +bool Player::CanPause() {
|
| + return false;
|
| +}
|
| +
|
| +bool Player::CanSeekForward() {
|
| + return false;
|
| +}
|
| +
|
| +bool Player::CanSeekBackward() {
|
| + return false;
|
| +}
|
| +
|
| +bool Player::IsPlayerReady() {
|
| + DVLOG(1) << __FUNCTION__;
|
| + return true;
|
| +}
|
| +
|
| +void Player::SetCdm(BrowserCdm* cdm) {
|
| + DVLOG(1) << __FUNCTION__;
|
| +}
|
| +
|
| +void Player::OnDemuxerConfigsAvailable(const DemuxerConfigs& params) {
|
| + DVLOG(1) << __FUNCTION__;
|
| +
|
| + // TODO: Post on UI thread
|
| + manager()->OnMediaMetadataChanged(
|
| + player_id(), base::TimeDelta::FromMilliseconds(100000),
|
| + GetVideoWidth(), GetVideoHeight(), true);
|
| +}
|
| +
|
| +void Player::OnDemuxerDataAvailable(const DemuxerData& params) {
|
| + DVLOG(1) << __FUNCTION__;
|
| +}
|
| +
|
| +void Player::OnDemuxerSeekDone(base::TimeDelta actual_browser_seek_time) {
|
| + DVLOG(1) << __FUNCTION__ << " actual_time:" << actual_browser_seek_time;
|
| +}
|
| +
|
| +void Player::OnDemuxerDurationChanged(base::TimeDelta duration) {
|
| + DVLOG(1) << __FUNCTION__ << " duration:" << duration;
|
| +}
|
| +
|
| +
|
| +// Events from UI, called on Media thread
|
| +
|
| +void Player::SetVideoSurfaceInternal(gfx::ScopedJavaSurface surface) {
|
| + DVLOG(1) << __FUNCTION__;
|
| +}
|
| +
|
| +void Player::StartInternal() {
|
| + DVLOG(1) << __FUNCTION__;
|
| +}
|
| +
|
| +void Player::PauseInternal() {
|
| + DVLOG(1) << __FUNCTION__;
|
| +}
|
| +
|
| +void Player::SeekToInternal(base::TimeDelta timestamp) {
|
| + DVLOG(1) << __FUNCTION__ << " " << timestamp;
|
| +}
|
| +
|
| +void Player::ReleaseInternal() {
|
| + DVLOG(1) << __FUNCTION__;
|
| +}
|
| +
|
| +} // namespace mt
|
| +} // namespace media
|
|
|