Chromium Code Reviews| Index: webkit/media/android/webmediaplayer_android.cc |
| diff --git a/webkit/media/android/webmediaplayer_android.cc b/webkit/media/android/webmediaplayer_android.cc |
| index 33ee91726d12e7d652e8a94c774db1156321b72f..cb3cc6edf8cde10ae026afd9aa5e3accd188a1c8 100644 |
| --- a/webkit/media/android/webmediaplayer_android.cc |
| +++ b/webkit/media/android/webmediaplayer_android.cc |
| @@ -28,6 +28,8 @@ |
| #if defined(GOOGLE_TV) |
| #include "webkit/media/android/media_source_delegate.h" |
| +#include "webkit/media/media_stream_audio_renderer.h" |
| +#include "webkit/media/media_stream_client.h" |
| #endif |
| static const uint32 kGLTextureExternalOES = 0x8D65; |
| @@ -68,7 +70,8 @@ WebMediaPlayerAndroid::WebMediaPlayerAndroid( |
| video_frame_provider_client_(NULL), |
| proxy_(proxy), |
| current_time_(0), |
| - media_log_(media_log) { |
| + media_log_(media_log), |
| + media_stream_client_(NULL) { |
| main_loop_->AddDestructionObserver(this); |
| if (manager_) |
| player_id_ = manager_->RegisterMediaPlayer(this); |
| @@ -78,6 +81,9 @@ WebMediaPlayerAndroid::WebMediaPlayerAndroid( |
| stream_id_ = stream_texture_factory_->CreateStreamTexture(&texture_id_); |
| ReallocateVideoFrame(); |
| } |
| +#if defined(GOOGLE_TV) |
| + demuxer_ = NULL; |
| +#endif |
| } |
| WebMediaPlayerAndroid::~WebMediaPlayerAndroid() { |
| @@ -95,6 +101,11 @@ WebMediaPlayerAndroid::~WebMediaPlayerAndroid() { |
| if (main_loop_) |
| main_loop_->RemoveDestructionObserver(this); |
| +#if defined(GOOGLE_TV) |
| + if (demuxer_ && !destroy_demuxer_cb_.is_null()) { |
| + destroy_demuxer_cb_.Run(); |
|
acolwell GONE FROM CHROMIUM
2013/05/14 18:17:47
You should probably clear the media_source_delegat
wonsik
2013/05/20 14:02:24
Done.
|
| + } |
| +#endif |
| } |
| void WebMediaPlayerAndroid::load(const WebURL& url, CORSMode cors_mode) { |
| @@ -107,24 +118,44 @@ void WebMediaPlayerAndroid::load(const WebURL& url, |
| if (cors_mode != CORSModeUnspecified) |
| NOTIMPLEMENTED() << "No CORS support"; |
| - scoped_ptr<WebKit::WebMediaSource> scoped_media_source(media_source); |
| + MediaPlayerAndroid::MediaSourceType media_source_type = |
| + MediaPlayerAndroid::MEDIA_SOURCE_URL; |
| #if defined(GOOGLE_TV) |
| if (media_source) { |
| - media_source_delegate_.reset( |
| - new MediaSourceDelegate( |
| - frame_, client_, proxy_, player_id_, media_log_)); |
| + media_source_type = MediaPlayerAndroid::MEDIA_SOURCE_MSE; |
| + } else if (media_stream_client_) { |
| + media_source_type = MediaPlayerAndroid::MEDIA_SOURCE_STREAM; |
| + } |
| + |
| + if (media_source_type != MediaPlayerAndroid::MEDIA_SOURCE_URL) { |
| // |media_source_delegate_| is owned, so Unretained() is safe here. |
| - media_source_delegate_->Initialize( |
| - scoped_media_source.Pass(), |
| + media_source_delegate_.reset(new MediaSourceDelegate( |
| + proxy_, |
| + player_id_, |
| base::Bind(&WebMediaPlayerAndroid::UpdateNetworkState, |
| - base::Unretained(this))); |
| + base::Unretained(this)))); |
| + if (media_source_type == MediaPlayerAndroid::MEDIA_SOURCE_MSE) { |
| + media_source_delegate_->InitializeMediaSource( |
| + frame_, client_, media_source, media_log_); |
| + } else if (media_source_type == MediaPlayerAndroid::MEDIA_SOURCE_STREAM) { |
| + media_source_delegate_->InitializeMediaStream(demuxer_); |
| + } |
| } |
| +#else |
| + if (media_source) |
|
acolwell GONE FROM CHROMIUM
2013/05/14 18:17:47
nit: I think this isn't necessary if you move the
wonsik
2013/05/20 14:02:24
Done --- assuming I understood your intention here
|
| + media_source_type = MediaPlayerAndroid::MEDIA_SOURCE_MSE; |
| #endif |
| + InitializeMediaPlayer(url, media_source_type); |
| +} |
| + |
| +void WebMediaPlayerAndroid::InitializeMediaPlayer( |
| + const WebURL& url, |
| + MediaPlayerAndroid::MediaSourceType media_source_type) { |
| url_ = url; |
| GURL first_party_url = frame_->document().firstPartyForCookies(); |
| if (proxy_) { |
| - proxy_->Initialize(player_id_, url_, media_source != NULL, first_party_url); |
| + proxy_->Initialize(player_id_, url, media_source_type, first_party_url); |
| if (manager_->IsInFullscreen(frame_)) |
| proxy_->EnterFullscreen(player_id_); |
| } |
| @@ -140,7 +171,6 @@ void WebMediaPlayerAndroid::cancelLoad() { |
| void WebMediaPlayerAndroid::play() { |
| #if defined(GOOGLE_TV) |
| if (hasVideo() && needs_external_surface_) { |
| - DCHECK(!needs_establish_peer_); |
| if (proxy_) |
| proxy_->RequestExternalSurface(player_id_, last_computed_rect_); |
| } |
| @@ -465,7 +495,6 @@ void WebMediaPlayerAndroid::OnVideoSizeChanged(int width, int height) { |
| CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| switches::kUseExternalVideoSurfaceThresholdInPixels), |
| &threshold); |
| - |
| if ((parsed_arg && threshold <= width * height) || |
| // Use H/W surface for MSE as the content is protected. |
| media_source_delegate_) { |
| @@ -655,10 +684,10 @@ bool WebMediaPlayerAndroid::RetrieveGeometryChange(gfx::RectF* rect) { |
| return true; |
| } |
| -WebMediaPlayer::MediaKeyException |
| -WebMediaPlayerAndroid::generateKeyRequest(const WebString& key_system, |
| - const unsigned char* init_data, |
| - unsigned init_data_length) { |
| +WebMediaPlayer::MediaKeyException WebMediaPlayerAndroid::generateKeyRequest( |
| + const WebString& key_system, |
| + const unsigned char* init_data, |
| + unsigned init_data_length) { |
| if (media_source_delegate_) { |
| return media_source_delegate_->GenerateKeyRequest( |
| key_system, init_data, init_data_length); |
| @@ -695,6 +724,16 @@ void WebMediaPlayerAndroid::OnReadFromDemuxer( |
| else |
| NOTIMPLEMENTED(); |
| } |
| + |
| +bool WebMediaPlayerAndroid::InjectMediaStream( |
| + MediaStreamClient* media_stream_client, |
| + media::Demuxer* demuxer, |
| + const base::Closure& destroy_demuxer_cb) { |
| + media_stream_client_ = media_stream_client; |
|
acolwell GONE FROM CHROMIUM
2013/05/14 18:17:47
DCHECK(!demuxer_)?
wonsik
2013/05/20 14:02:24
Done.
|
| + demuxer_ = demuxer; |
| + destroy_demuxer_cb_ = destroy_demuxer_cb; |
| + return true; |
| +} |
| #endif |
| void WebMediaPlayerAndroid::enterFullscreen() { |