OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "webkit/media/android/webmediaplayer_android.h" | 5 #include "webkit/media/android/webmediaplayer_android.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
11 #include "cc/layers/video_layer.h" | 11 #include "cc/layers/video_layer.h" |
12 #include "gpu/GLES2/gl2extchromium.h" | 12 #include "gpu/GLES2/gl2extchromium.h" |
13 #include "media/base/android/media_player_bridge.h" | 13 #include "media/base/android/media_player_bridge.h" |
14 #include "media/base/video_frame.h" | 14 #include "media/base/video_frame.h" |
15 #include "net/base/mime_util.h" | 15 #include "net/base/mime_util.h" |
16 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" | 16 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" |
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerClient. h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerClient. h" |
20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaSource.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaSource.h" |
21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
22 #include "webkit/compositor_bindings/web_layer_impl.h" | 22 #include "webkit/compositor_bindings/web_layer_impl.h" |
23 #include "webkit/media/android/webmediaplayer_manager_android.h" | 23 #include "webkit/media/android/webmediaplayer_manager_android.h" |
24 #include "webkit/media/android/webmediaplayer_proxy_android.h" | 24 #include "webkit/media/android/webmediaplayer_proxy_android.h" |
25 #include "webkit/media/media_switches.h" | 25 #include "webkit/media/media_switches.h" |
26 #include "webkit/media/webmediaplayer_util.h" | 26 #include "webkit/media/webmediaplayer_util.h" |
27 | 27 |
28 #if defined(GOOGLE_TV) | |
29 #include "webkit/media/android/media_source_delegate.h" | |
30 #endif | |
31 | |
32 static const uint32 kGLTextureExternalOES = 0x8D65; | 28 static const uint32 kGLTextureExternalOES = 0x8D65; |
33 | 29 |
34 using WebKit::WebMediaPlayer; | 30 using WebKit::WebMediaPlayer; |
35 using WebKit::WebMediaSource; | 31 using WebKit::WebMediaSource; |
36 using WebKit::WebSize; | 32 using WebKit::WebSize; |
37 using WebKit::WebString; | 33 using WebKit::WebString; |
38 using WebKit::WebTimeRanges; | 34 using WebKit::WebTimeRanges; |
39 using WebKit::WebURL; | 35 using WebKit::WebURL; |
40 using media::MediaPlayerBridge; | 36 using media::MediaPlayerBridge; |
41 using media::VideoFrame; | 37 using media::VideoFrame; |
42 | 38 |
43 namespace webkit_media { | 39 namespace webkit_media { |
44 | 40 |
45 WebMediaPlayerAndroid::WebMediaPlayerAndroid( | 41 WebMediaPlayerAndroid::WebMediaPlayerAndroid( |
46 WebKit::WebFrame* frame, | 42 WebKit::WebFrame* frame, |
47 WebKit::WebMediaPlayerClient* client, | 43 WebKit::WebMediaPlayerClient* client, |
48 WebMediaPlayerManagerAndroid* manager, | 44 WebMediaPlayerManagerAndroid* manager, |
49 WebMediaPlayerProxyAndroid* proxy, | 45 WebMediaPlayerProxyAndroid* proxy, |
50 StreamTextureFactory* factory, | 46 StreamTextureFactory* factory) |
51 media::MediaLog* media_log) | |
52 : frame_(frame), | 47 : frame_(frame), |
53 client_(client), | 48 client_(client), |
54 buffered_(1u), | 49 buffered_(1u), |
55 main_loop_(base::MessageLoop::current()), | 50 main_loop_(base::MessageLoop::current()), |
56 pending_seek_(0), | 51 pending_seek_(0), |
57 seeking_(false), | 52 seeking_(false), |
58 did_loading_progress_(false), | 53 did_loading_progress_(false), |
59 manager_(manager), | 54 manager_(manager), |
60 network_state_(WebMediaPlayer::NetworkStateEmpty), | 55 network_state_(WebMediaPlayer::NetworkStateEmpty), |
61 ready_state_(WebMediaPlayer::ReadyStateHaveNothing), | 56 ready_state_(WebMediaPlayer::ReadyStateHaveNothing), |
62 is_playing_(false), | 57 is_playing_(false), |
63 needs_establish_peer_(true), | 58 needs_establish_peer_(true), |
64 has_size_info_(false), | 59 has_size_info_(false), |
65 stream_texture_factory_(factory), | 60 stream_texture_factory_(factory), |
66 needs_external_surface_(false), | 61 needs_external_surface_(false), |
67 video_frame_provider_client_(NULL), | 62 video_frame_provider_client_(NULL), |
68 proxy_(proxy), | 63 proxy_(proxy), |
69 current_time_(0), | 64 current_time_(0) { |
70 media_log_(media_log) { | |
71 main_loop_->AddDestructionObserver(this); | 65 main_loop_->AddDestructionObserver(this); |
72 if (manager_) | 66 if (manager_) |
73 player_id_ = manager_->RegisterMediaPlayer(this); | 67 player_id_ = manager_->RegisterMediaPlayer(this); |
74 | 68 |
75 if (stream_texture_factory_.get()) { | 69 if (stream_texture_factory_.get()) { |
76 stream_texture_proxy_.reset(stream_texture_factory_->CreateProxy()); | 70 stream_texture_proxy_.reset(stream_texture_factory_->CreateProxy()); |
77 stream_id_ = stream_texture_factory_->CreateStreamTexture(&texture_id_); | 71 stream_id_ = stream_texture_factory_->CreateStreamTexture(&texture_id_); |
78 ReallocateVideoFrame(); | 72 ReallocateVideoFrame(); |
79 } | 73 } |
80 } | 74 } |
(...skipping 19 matching lines...) Expand all Loading... | |
100 load(url, NULL, cors_mode); | 94 load(url, NULL, cors_mode); |
101 } | 95 } |
102 | 96 |
103 void WebMediaPlayerAndroid::load(const WebURL& url, | 97 void WebMediaPlayerAndroid::load(const WebURL& url, |
104 WebMediaSource* media_source, | 98 WebMediaSource* media_source, |
105 CORSMode cors_mode) { | 99 CORSMode cors_mode) { |
106 if (cors_mode != CORSModeUnspecified) | 100 if (cors_mode != CORSModeUnspecified) |
107 NOTIMPLEMENTED() << "No CORS support"; | 101 NOTIMPLEMENTED() << "No CORS support"; |
108 | 102 |
109 scoped_ptr<WebKit::WebMediaSource> scoped_media_source(media_source); | 103 scoped_ptr<WebKit::WebMediaSource> scoped_media_source(media_source); |
110 #if defined(GOOGLE_TV) | |
111 if (media_source) { | |
112 media_source_delegate_.reset( | |
113 new MediaSourceDelegate( | |
114 frame_, client_, proxy_, player_id_, media_log_)); | |
115 // |media_source_delegate_| is owned, so Unretained() is safe here. | |
116 media_source_delegate_->Initialize( | |
117 scoped_media_source.Pass(), | |
118 base::Bind(&WebMediaPlayerAndroid::UpdateNetworkState, | |
119 base::Unretained(this))); | |
120 } | |
121 #endif | |
122 | 104 |
105 InitializeMediaPlayer( | |
106 url, media_source == NULL ? 0 : MediaPlayerBridge::FLAG_MEDIA_SOURCE); | |
107 } | |
108 | |
109 void WebMediaPlayerAndroid::InitializeMediaPlayer(const WebURL& url, | |
110 int flags) { | |
123 url_ = url; | 111 url_ = url; |
124 GURL first_party_url = frame_->document().firstPartyForCookies(); | 112 GURL first_party_url = frame_->document().firstPartyForCookies(); |
125 if (proxy_) { | 113 if (proxy_) { |
126 proxy_->Initialize(player_id_, url_, media_source != NULL, first_party_url); | 114 proxy_->Initialize(player_id_, url, flags, first_party_url); |
127 if (manager_->IsInFullscreen(frame_)) | 115 if (manager_->IsInFullscreen(frame_)) |
128 proxy_->EnterFullscreen(player_id_); | 116 proxy_->EnterFullscreen(player_id_); |
129 } | 117 } |
130 | 118 |
131 UpdateNetworkState(WebMediaPlayer::NetworkStateLoading); | 119 UpdateNetworkState(WebMediaPlayer::NetworkStateLoading); |
132 UpdateReadyState(WebMediaPlayer::ReadyStateHaveNothing); | 120 UpdateReadyState(WebMediaPlayer::ReadyStateHaveNothing); |
133 } | 121 } |
134 | 122 |
135 void WebMediaPlayerAndroid::cancelLoad() { | 123 void WebMediaPlayerAndroid::cancelLoad() { |
136 NOTIMPLEMENTED(); | 124 NOTIMPLEMENTED(); |
137 } | 125 } |
138 | 126 |
139 void WebMediaPlayerAndroid::play() { | 127 void WebMediaPlayerAndroid::play() { |
140 #if defined(GOOGLE_TV) | |
141 if (hasVideo() && needs_external_surface_) { | |
142 DCHECK(!needs_establish_peer_); | |
143 if (proxy_) | |
144 proxy_->RequestExternalSurface(player_id_); | |
145 } | |
146 #endif | |
147 if (hasVideo() && needs_establish_peer_) | 128 if (hasVideo() && needs_establish_peer_) |
148 EstablishSurfaceTexturePeer(); | 129 EstablishSurfaceTexturePeer(); |
149 | 130 |
150 if (paused() && proxy_) | 131 if (paused() && proxy_) |
151 proxy_->Start(player_id_); | 132 proxy_->Start(player_id_); |
152 is_playing_ = true; | 133 is_playing_ = true; |
153 } | 134 } |
154 | 135 |
155 void WebMediaPlayerAndroid::pause() { | 136 void WebMediaPlayerAndroid::pause() { |
156 if (proxy_) | 137 if (proxy_) |
157 proxy_->Pause(player_id_); | 138 proxy_->Pause(player_id_); |
158 is_playing_ = false; | 139 is_playing_ = false; |
159 } | 140 } |
160 | 141 |
161 void WebMediaPlayerAndroid::seek(double seconds) { | 142 void WebMediaPlayerAndroid::seek(double seconds) { |
162 pending_seek_ = seconds; | 143 pending_seek_ = seconds; |
163 seeking_ = true; | 144 seeking_ = true; |
164 | 145 |
165 base::TimeDelta seek_time = ConvertSecondsToTimestamp(seconds); | 146 base::TimeDelta seek_time = ConvertSecondsToTimestamp(seconds); |
166 #if defined(GOOGLE_TV) | |
167 if (media_source_delegate_) | |
168 media_source_delegate_->Seek(seek_time); | |
169 #endif | |
170 if (proxy_) | 147 if (proxy_) |
171 proxy_->Seek(player_id_, seek_time); | 148 proxy_->Seek(player_id_, seek_time); |
172 } | 149 } |
173 | 150 |
174 bool WebMediaPlayerAndroid::supportsFullscreen() const { | 151 bool WebMediaPlayerAndroid::supportsFullscreen() const { |
175 return true; | 152 return true; |
176 } | 153 } |
177 | 154 |
178 bool WebMediaPlayerAndroid::supportsSave() const { | 155 bool WebMediaPlayerAndroid::supportsSave() const { |
179 return false; | 156 return false; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
255 | 232 |
256 WebMediaPlayer::NetworkState WebMediaPlayerAndroid::networkState() const { | 233 WebMediaPlayer::NetworkState WebMediaPlayerAndroid::networkState() const { |
257 return network_state_; | 234 return network_state_; |
258 } | 235 } |
259 | 236 |
260 WebMediaPlayer::ReadyState WebMediaPlayerAndroid::readyState() const { | 237 WebMediaPlayer::ReadyState WebMediaPlayerAndroid::readyState() const { |
261 return ready_state_; | 238 return ready_state_; |
262 } | 239 } |
263 | 240 |
264 const WebTimeRanges& WebMediaPlayerAndroid::buffered() { | 241 const WebTimeRanges& WebMediaPlayerAndroid::buffered() { |
265 #if defined(GOOGLE_TV) | |
266 if (media_source_delegate_) | |
267 return media_source_delegate_->Buffered(); | |
268 #endif | |
269 return buffered_; | 242 return buffered_; |
270 } | 243 } |
271 | 244 |
272 double WebMediaPlayerAndroid::maxTimeSeekable() const { | 245 double WebMediaPlayerAndroid::maxTimeSeekable() const { |
273 // TODO(hclam): If this stream is not seekable this should return 0. | 246 // TODO(hclam): If this stream is not seekable this should return 0. |
274 return duration(); | 247 return duration(); |
275 } | 248 } |
276 | 249 |
277 bool WebMediaPlayerAndroid::didLoadingProgress() const { | 250 bool WebMediaPlayerAndroid::didLoadingProgress() const { |
278 bool ret = did_loading_progress_; | 251 bool ret = did_loading_progress_; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
339 // Deprecated. | 312 // Deprecated. |
340 // TODO(qinmin): Remove this from WebKit::WebMediaPlayer as it is never used. | 313 // TODO(qinmin): Remove this from WebKit::WebMediaPlayer as it is never used. |
341 return WebMediaPlayer::MovieLoadTypeUnknown; | 314 return WebMediaPlayer::MovieLoadTypeUnknown; |
342 } | 315 } |
343 | 316 |
344 double WebMediaPlayerAndroid::mediaTimeForTimeValue(double timeValue) const { | 317 double WebMediaPlayerAndroid::mediaTimeForTimeValue(double timeValue) const { |
345 return ConvertSecondsToTimestamp(timeValue).InSecondsF(); | 318 return ConvertSecondsToTimestamp(timeValue).InSecondsF(); |
346 } | 319 } |
347 | 320 |
348 unsigned WebMediaPlayerAndroid::decodedFrameCount() const { | 321 unsigned WebMediaPlayerAndroid::decodedFrameCount() const { |
349 #if defined(GOOGLE_TV) | |
350 if (media_source_delegate_) | |
351 return media_source_delegate_->DecodedFrameCount(); | |
352 #endif | |
353 NOTIMPLEMENTED(); | 322 NOTIMPLEMENTED(); |
354 return 0; | 323 return 0; |
355 } | 324 } |
356 | 325 |
357 unsigned WebMediaPlayerAndroid::droppedFrameCount() const { | 326 unsigned WebMediaPlayerAndroid::droppedFrameCount() const { |
358 #if defined(GOOGLE_TV) | |
359 if (media_source_delegate_) | |
360 return media_source_delegate_->DroppedFrameCount(); | |
361 #endif | |
362 NOTIMPLEMENTED(); | 327 NOTIMPLEMENTED(); |
363 return 0; | 328 return 0; |
364 } | 329 } |
365 | 330 |
366 unsigned WebMediaPlayerAndroid::audioDecodedByteCount() const { | 331 unsigned WebMediaPlayerAndroid::audioDecodedByteCount() const { |
367 #if defined(GOOGLE_TV) | |
368 if (media_source_delegate_) | |
369 return media_source_delegate_->AudioDecodedByteCount(); | |
370 #endif | |
371 NOTIMPLEMENTED(); | 332 NOTIMPLEMENTED(); |
372 return 0; | 333 return 0; |
373 } | 334 } |
374 | 335 |
375 unsigned WebMediaPlayerAndroid::videoDecodedByteCount() const { | 336 unsigned WebMediaPlayerAndroid::videoDecodedByteCount() const { |
376 #if defined(GOOGLE_TV) | |
377 if (media_source_delegate_) | |
378 return media_source_delegate_->VideoDecodedByteCount(); | |
379 #endif | |
380 NOTIMPLEMENTED(); | 337 NOTIMPLEMENTED(); |
381 return 0; | 338 return 0; |
382 } | 339 } |
383 | 340 |
384 void WebMediaPlayerAndroid::OnMediaMetadataChanged( | 341 void WebMediaPlayerAndroid::OnMediaMetadataChanged( |
385 base::TimeDelta duration, int width, int height, bool success) { | 342 base::TimeDelta duration, int width, int height, bool success) { |
386 if (url_.SchemeIs("file")) | 343 if (url_.SchemeIs("file")) |
387 UpdateNetworkState(WebMediaPlayer::NetworkStateLoaded); | 344 UpdateNetworkState(WebMediaPlayer::NetworkStateLoaded); |
388 | 345 |
389 if (ready_state_ != WebMediaPlayer::ReadyStateHaveEnoughData) { | 346 if (ready_state_ != WebMediaPlayer::ReadyStateHaveEnoughData) { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
447 break; | 404 break; |
448 } | 405 } |
449 client_->repaint(); | 406 client_->repaint(); |
450 } | 407 } |
451 | 408 |
452 void WebMediaPlayerAndroid::OnVideoSizeChanged(int width, int height) { | 409 void WebMediaPlayerAndroid::OnVideoSizeChanged(int width, int height) { |
453 has_size_info_ = true; | 410 has_size_info_ = true; |
454 if (natural_size_.width == width && natural_size_.height == height) | 411 if (natural_size_.width == width && natural_size_.height == height) |
455 return; | 412 return; |
456 | 413 |
457 #if defined(GOOGLE_TV) | |
458 static bool has_switch = CommandLine::ForCurrentProcess()->HasSwitch( | |
459 switches::kUseExternalVideoSurfaceThresholdInPixels); | |
460 static int threshold = 0; | |
461 static bool parsed_arg = | |
462 has_switch && | |
463 base::StringToInt( | |
464 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | |
465 switches::kUseExternalVideoSurfaceThresholdInPixels), | |
466 &threshold); | |
467 | |
468 if ((parsed_arg && threshold <= width * height) || | |
469 // Use H/W surface for MSE as the content is protected. | |
470 media_source_delegate_) { | |
471 needs_external_surface_ = true; | |
472 SetNeedsEstablishPeer(false); | |
473 if (!paused() && proxy_) | |
474 proxy_->RequestExternalSurface(player_id_); | |
475 } | |
476 #endif | |
477 | |
478 natural_size_.width = width; | 414 natural_size_.width = width; |
479 natural_size_.height = height; | 415 natural_size_.height = height; |
480 ReallocateVideoFrame(); | 416 ReallocateVideoFrame(); |
481 } | 417 } |
482 | 418 |
483 void WebMediaPlayerAndroid::OnTimeUpdate(base::TimeDelta current_time) { | 419 void WebMediaPlayerAndroid::OnTimeUpdate(base::TimeDelta current_time) { |
484 current_time_ = static_cast<float>(current_time.InSecondsF()); | 420 current_time_ = static_cast<float>(current_time.InSecondsF()); |
485 } | 421 } |
486 | 422 |
487 void WebMediaPlayerAndroid::OnDidEnterFullscreen() { | 423 void WebMediaPlayerAndroid::OnDidEnterFullscreen() { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
567 stream_texture_factory_->DestroyStreamTexture(texture_id_); | 503 stream_texture_factory_->DestroyStreamTexture(texture_id_); |
568 stream_id_ = 0; | 504 stream_id_ = 0; |
569 } | 505 } |
570 | 506 |
571 current_frame_ = NULL; | 507 current_frame_ = NULL; |
572 manager_ = NULL; | 508 manager_ = NULL; |
573 proxy_ = NULL; | 509 proxy_ = NULL; |
574 } | 510 } |
575 | 511 |
576 void WebMediaPlayerAndroid::ReallocateVideoFrame() { | 512 void WebMediaPlayerAndroid::ReallocateVideoFrame() { |
577 if (needs_external_surface_) { | 513 if (NeedsExternalSurface()) { |
578 // VideoFrame::CreateHoleFrame is only defined under GOOGLE_TV. | 514 // VideoFrame::CreateHoleFrame is only defined under GOOGLE_TV. |
579 #if defined(GOOGLE_TV) | 515 #if defined(GOOGLE_TV) |
580 if (!natural_size_.isEmpty()) | 516 if (!natural_size_.isEmpty()) |
581 current_frame_ = VideoFrame::CreateHoleFrame(natural_size_); | 517 current_frame_ = VideoFrame::CreateHoleFrame(natural_size_); |
582 #else | 518 #else |
583 NOTIMPLEMENTED() << "Hole punching not supported outside of Google TV"; | 519 NOTIMPLEMENTED() << "Hole punching not supported outside of Google TV"; |
584 #endif | 520 #endif |
585 } else if (texture_id_) { | 521 } else if (texture_id_) { |
586 current_frame_ = VideoFrame::WrapNativeTexture( | 522 current_frame_ = VideoFrame::WrapNativeTexture( |
587 texture_id_, kGLTextureExternalOES, natural_size_, | 523 texture_id_, kGLTextureExternalOES, natural_size_, |
(...skipping 11 matching lines...) Expand all Loading... | |
599 video_frame_provider_client_->StopUsingProvider(); | 535 video_frame_provider_client_->StopUsingProvider(); |
600 video_frame_provider_client_ = client; | 536 video_frame_provider_client_ = client; |
601 | 537 |
602 // Set the callback target when a frame is produced. | 538 // Set the callback target when a frame is produced. |
603 if (stream_texture_proxy_) | 539 if (stream_texture_proxy_) |
604 stream_texture_proxy_->SetClient(client); | 540 stream_texture_proxy_->SetClient(client); |
605 } | 541 } |
606 | 542 |
607 scoped_refptr<media::VideoFrame> WebMediaPlayerAndroid::GetCurrentFrame() { | 543 scoped_refptr<media::VideoFrame> WebMediaPlayerAndroid::GetCurrentFrame() { |
608 if (stream_texture_proxy_ && !stream_texture_proxy_->IsBoundToThread() && | 544 if (stream_texture_proxy_ && !stream_texture_proxy_->IsBoundToThread() && |
609 stream_id_ && !needs_external_surface_) { | 545 stream_id_ && !NeedsExternalSurface()) { |
610 gfx::Size natural_size = current_frame_->natural_size(); | 546 gfx::Size natural_size = current_frame_->natural_size(); |
611 stream_texture_proxy_->BindToCurrentThread( | 547 stream_texture_proxy_->BindToCurrentThread( |
612 stream_id_, natural_size.width(), natural_size.height()); | 548 stream_id_, natural_size.width(), natural_size.height()); |
613 } | 549 } |
614 return current_frame_; | 550 return current_frame_; |
615 } | 551 } |
616 | 552 |
617 void WebMediaPlayerAndroid::PutCurrentFrame( | 553 void WebMediaPlayerAndroid::PutCurrentFrame( |
618 const scoped_refptr<media::VideoFrame>& frame) { | 554 const scoped_refptr<media::VideoFrame>& frame) { |
619 } | 555 } |
(...skipping 26 matching lines...) Expand all Loading... | |
646 } | 582 } |
647 | 583 |
648 // Return false when the geometry hasn't been changed from the last time. | 584 // Return false when the geometry hasn't been changed from the last time. |
649 if (last_computed_rect_ == *rect) | 585 if (last_computed_rect_ == *rect) |
650 return false; | 586 return false; |
651 | 587 |
652 // Store the changed geometry information when it is actually changed. | 588 // Store the changed geometry information when it is actually changed. |
653 last_computed_rect_ = *rect; | 589 last_computed_rect_ = *rect; |
654 return true; | 590 return true; |
655 } | 591 } |
656 | |
657 WebMediaPlayer::MediaKeyException | |
658 WebMediaPlayerAndroid::generateKeyRequest(const WebString& key_system, | |
659 const unsigned char* init_data, | |
660 unsigned init_data_length) { | |
661 if (media_source_delegate_) { | |
662 return media_source_delegate_->GenerateKeyRequest( | |
663 key_system, init_data, init_data_length); | |
664 } | |
665 return MediaKeyExceptionKeySystemNotSupported; | |
666 } | |
667 | |
668 WebMediaPlayer::MediaKeyException WebMediaPlayerAndroid::addKey( | |
669 const WebString& key_system, | |
670 const unsigned char* key, | |
671 unsigned key_length, | |
672 const unsigned char* init_data, | |
673 unsigned init_data_length, | |
674 const WebString& session_id) { | |
675 if (media_source_delegate_) { | |
676 return media_source_delegate_->AddKey( | |
677 key_system, key, key_length, init_data, init_data_length, session_id); | |
678 } | |
679 return MediaKeyExceptionKeySystemNotSupported; | |
680 } | |
681 | |
682 WebMediaPlayer::MediaKeyException WebMediaPlayerAndroid::cancelKeyRequest( | |
683 const WebString& key_system, | |
684 const WebString& session_id) { | |
685 if (media_source_delegate_) | |
686 return media_source_delegate_->CancelKeyRequest(key_system, session_id); | |
687 return MediaKeyExceptionKeySystemNotSupported; | |
688 } | |
689 | |
690 void WebMediaPlayerAndroid::OnReadFromDemuxer( | |
691 media::DemuxerStream::Type type, bool seek_done) { | |
692 if (media_source_delegate_) | |
693 media_source_delegate_->OnReadFromDemuxer(type, seek_done); | |
694 else | |
695 NOTIMPLEMENTED(); | |
696 } | |
697 #endif | 592 #endif |
698 | 593 |
699 void WebMediaPlayerAndroid::enterFullscreen() { | 594 void WebMediaPlayerAndroid::enterFullscreen() { |
700 if (proxy_ && manager_->CanEnterFullscreen(frame_)) { | 595 if (proxy_ && manager_->CanEnterFullscreen(frame_)) { |
701 proxy_->EnterFullscreen(player_id_); | 596 proxy_->EnterFullscreen(player_id_); |
702 SetNeedsEstablishPeer(false); | 597 SetNeedsEstablishPeer(false); |
703 } | 598 } |
704 } | 599 } |
705 | 600 |
706 void WebMediaPlayerAndroid::exitFullscreen() { | 601 void WebMediaPlayerAndroid::exitFullscreen() { |
707 if (proxy_) | 602 if (proxy_) |
708 proxy_->ExitFullscreen(player_id_); | 603 proxy_->ExitFullscreen(player_id_); |
709 } | 604 } |
710 | 605 |
711 bool WebMediaPlayerAndroid::canEnterFullscreen() const { | 606 bool WebMediaPlayerAndroid::canEnterFullscreen() const { |
712 return manager_->CanEnterFullscreen(frame_); | 607 return manager_->CanEnterFullscreen(frame_); |
713 } | 608 } |
714 | 609 |
610 bool WebMediaPlayerAndroid::NeedsExternalSurface() { | |
611 return needs_external_surface_; | |
612 } | |
613 | |
614 void WebMediaPlayerAndroid::SetNeedsExternalSurface( | |
615 bool needs_external_surface) { | |
616 needs_external_surface_ = needs_external_surface; | |
617 } | |
618 | |
619 WebMediaPlayerProxyAndroid* WebMediaPlayerAndroid::proxy() { return proxy_; } | |
qinmin
2013/04/29 17:31:49
move these functions to the header
wonsik
2013/05/01 14:15:38
Done.
| |
620 WebKit::WebFrame* WebMediaPlayerAndroid::frame() { return frame_; } | |
621 WebKit::WebMediaPlayerClient* WebMediaPlayerAndroid::client() { | |
622 return client_; | |
623 } | |
624 int WebMediaPlayerAndroid::player_id() { return player_id_; } | |
625 | |
715 } // namespace webkit_media | 626 } // namespace webkit_media |
OLD | NEW |