Changeset 126008 in webkit
- Timestamp:
- Aug 20, 2012 1:47:04 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r126005 r126008 1 2012-08-20 Robin Cao <robin.cao@torchmobile.com.cn> 2 3 [BlackBerry] Adapt to changes in the platform media player API 4 https://bugs.webkit.org/show_bug.cgi?id=94329 5 PR #194237 6 7 Reviewed by Antonio Gomes. 8 9 The interface to platform's media player has changed from MMRPlayer 10 to PlatformPlayer. This patch adapts to this change. 11 12 And we also decided to postpone the creation of PlatformPlayer until 13 the loading started. This is needed because we may create different 14 types of player for different media sources. 15 16 This is a refactor, no new tests. 17 18 * platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp: 19 (WebCore::MediaPlayerPrivate::getSupportedTypes): 20 (WebCore::MediaPlayerPrivate::supportsType): 21 (WebCore::MediaPlayerPrivate::notifyAppActivatedEvent): 22 (WebCore::MediaPlayerPrivate::setCertificatePath): 23 (WebCore::MediaPlayerPrivate::MediaPlayerPrivate): 24 (WebCore::MediaPlayerPrivate::load): 25 (WebCore::MediaPlayerPrivate::cancelLoad): 26 (WebCore::MediaPlayerPrivate::prepareToPlay): 27 (WebCore::MediaPlayerPrivate::play): 28 (WebCore::MediaPlayerPrivate::pause): 29 (WebCore::MediaPlayerPrivate::naturalSize): 30 (WebCore::MediaPlayerPrivate::hasVideo): 31 (WebCore::MediaPlayerPrivate::hasAudio): 32 (WebCore::MediaPlayerPrivate::duration): 33 (WebCore::MediaPlayerPrivate::currentTime): 34 (WebCore::MediaPlayerPrivate::seek): 35 (WebCore::MediaPlayerPrivate::setRate): 36 (WebCore::MediaPlayerPrivate::paused): 37 (WebCore::MediaPlayerPrivate::setVolume): 38 (WebCore::MediaPlayerPrivate::maxTimeSeekable): 39 (WebCore::MediaPlayerPrivate::buffered): 40 (WebCore::MediaPlayerPrivate::paint): 41 (WebCore::MediaPlayerPrivate::hasAvailableVideoFrame): 42 (WebCore::MediaPlayerPrivate::movieLoadType): 43 (WebCore::MediaPlayerPrivate::setAllowPPSVolumeUpdates): 44 (WebCore::MediaPlayerPrivate::updateStates): 45 (WebCore): 46 (WebCore::MediaPlayerPrivate::onStateChanged): 47 (WebCore::MediaPlayerPrivate::onMediaStatusChanged): 48 (WebCore::MediaPlayerPrivate::onError): 49 (WebCore::MediaPlayerPrivate::waitMetadataTimerFired): 50 (WebCore::MediaPlayerPrivate::showErrorDialog): 51 * platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.h: 52 (MediaPlayerPrivate): 53 1 54 2012-08-19 Kentaro Hara <haraken@chromium.org> 2 55 -
trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp
r125388 r126008 67 67 void MediaPlayerPrivate::getSupportedTypes(HashSet<String>& types) 68 68 { 69 set<string> supported = MMRPlayer::allSupportedMimeTypes();69 set<string> supported = PlatformPlayer::allSupportedMimeTypes(); 70 70 set<string>::iterator i = supported.begin(); 71 71 for (; i != supported.end(); i++) … … 81 81 82 82 // spec says we should not return "probably" if the codecs string is empty 83 if ( MMRPlayer::mimeTypeSupported(type.ascii().data())) {83 if (PlatformPlayer::mimeTypeSupported(type.ascii().data())) { 84 84 LOG(Media, "MediaPlayer supports type; cache contains type '%s'.", type.ascii().data()); 85 85 return codecs.isEmpty() ? MediaPlayer::MayBeSupported : MediaPlayer::IsSupported; … … 91 91 void MediaPlayerPrivate::notifyAppActivatedEvent(bool activated) 92 92 { 93 MMRPlayer::notifyAppActivatedEvent(activated);93 PlatformPlayer::notifyAppActivatedEvent(activated); 94 94 } 95 95 96 96 void MediaPlayerPrivate::setCertificatePath(const String& caPath) 97 97 { 98 MMRPlayer::setCertificatePath(string(caPath.utf8().data()));98 PlatformPlayer::setCertificatePath(string(caPath.utf8().data())); 99 99 } 100 100 101 101 MediaPlayerPrivate::MediaPlayerPrivate(MediaPlayer* player) 102 102 : m_webCorePlayer(player) 103 , m_platformPlayer(0) 103 104 , m_networkState(MediaPlayer::Empty) 104 105 , m_readyState(MediaPlayer::HaveNothing) … … 115 116 , m_waitMetadataPopDialogCounter(0) 116 117 { 117 void* tabId = 0;118 if (frameView() && frameView()->hostWindow())119 tabId = frameView()->hostWindow()->platformPageClient();120 #if USE(ACCELERATED_COMPOSITING)121 m_platformPlayer = new MMRPlayer(this, tabId, true);122 #else123 m_platformPlayer = new MMRPlayer(this, tabId, false);124 #endif125 118 } 126 119 … … 157 150 } 158 151 152 void* tabId = 0; 153 if (frameView() && frameView()->hostWindow()) 154 tabId = frameView()->hostWindow()->platformPageClient(); 155 156 deleteGuardedObject(m_platformPlayer); 157 #if USE(ACCELERATED_COMPOSITING) 158 m_platformPlayer = PlatformPlayer::create(this, tabId, true, modifiedUrl.utf8().data()); 159 #else 160 m_platformPlayer = PlatformPlayer::create(this, tabId, false, modifiedUrl.utf8().data()); 161 #endif 162 159 163 String cookiePairs; 160 164 if (!url.isEmpty()) … … 168 172 void MediaPlayerPrivate::cancelLoad() 169 173 { 170 m_platformPlayer->cancelLoad(); 174 if (m_platformPlayer) 175 m_platformPlayer->cancelLoad(); 171 176 } 172 177 173 178 void MediaPlayerPrivate::prepareToPlay() 174 179 { 175 m_platformPlayer->prepareToPlay(); 180 if (m_platformPlayer) 181 m_platformPlayer->prepareToPlay(); 176 182 } 177 183 178 184 void MediaPlayerPrivate::play() 179 185 { 180 m_platformPlayer->play(); 186 if (m_platformPlayer) 187 m_platformPlayer->play(); 181 188 } 182 189 183 190 void MediaPlayerPrivate::pause() 184 191 { 185 m_platformPlayer->pause(); 192 if (m_platformPlayer) 193 m_platformPlayer->pause(); 186 194 } 187 195 … … 193 201 IntSize MediaPlayerPrivate::naturalSize() const 194 202 { 203 if (!m_platformPlayer) 204 return IntSize(); 205 195 206 // Cannot return empty size, otherwise paint() will never get called. 196 207 // Also, the values here will affect the aspect ratio of the output rectangle that will … … 210 221 bool MediaPlayerPrivate::hasVideo() const 211 222 { 212 return m_platformPlayer->hasVideo(); 223 if (m_platformPlayer) 224 return m_platformPlayer->hasVideo(); 225 return false; 213 226 } 214 227 215 228 bool MediaPlayerPrivate::hasAudio() const 216 229 { 217 return m_platformPlayer->hasAudio(); 230 if (m_platformPlayer) 231 return m_platformPlayer->hasAudio(); 232 return false; 218 233 } 219 234 … … 225 240 float MediaPlayerPrivate::duration() const 226 241 { 227 return m_platformPlayer->duration(); 242 if (m_platformPlayer) 243 return m_platformPlayer->duration(); 244 return 0.0f; 228 245 } 229 246 … … 233 250 float MediaPlayerPrivate::currentTime() const 234 251 { 252 if (!m_platformPlayer) 253 return 0.0f; 254 235 255 // For very short media on the order of SeekSubmissionDelay we get 236 256 // unwanted repeats if we don't return the most up-to-date currentTime(). … … 241 261 void MediaPlayerPrivate::seek(float time) 242 262 { 263 if (!m_platformPlayer) 264 return; 265 243 266 m_lastSeekTime = time; 244 267 m_lastSeekTimePending = true; … … 263 286 void MediaPlayerPrivate::setRate(float rate) 264 287 { 265 m_platformPlayer->setRate(rate); 288 if (m_platformPlayer) 289 m_platformPlayer->setRate(rate); 266 290 } 267 291 268 292 bool MediaPlayerPrivate::paused() const 269 293 { 270 return m_platformPlayer->paused(); 294 if (m_platformPlayer) 295 return m_platformPlayer->paused(); 296 return false; 271 297 } 272 298 273 299 void MediaPlayerPrivate::setVolume(float volume) 274 300 { 275 m_platformPlayer->setVolume(volume); 301 if (m_platformPlayer) 302 m_platformPlayer->setVolume(volume); 276 303 } 277 304 … … 288 315 float MediaPlayerPrivate::maxTimeSeekable() const 289 316 { 290 return m_platformPlayer->maxTimeSeekable(); 317 if (m_platformPlayer) 318 return m_platformPlayer->maxTimeSeekable(); 319 return 0.0f; 291 320 } 292 321 293 322 PassRefPtr<TimeRanges> MediaPlayerPrivate::buffered() const 294 323 { 324 if (!m_platformPlayer) 325 return TimeRanges::create(); 326 295 327 RefPtr<TimeRanges> timeRanges = TimeRanges::create(); 296 328 if (float bufferLoaded = m_platformPlayer->bufferLoaded()) … … 312 344 void MediaPlayerPrivate::paint(GraphicsContext* context, const IntRect& rect) 313 345 { 346 if (!m_platformPlayer) 347 return; 348 314 349 #if USE(ACCELERATED_COMPOSITING) 315 350 // Only process paint calls coming via the accelerated compositing code … … 336 371 bool MediaPlayerPrivate::hasAvailableVideoFrame() const 337 372 { 338 return m_platformPlayer->hasAvailableVideoFrame(); 373 if (m_platformPlayer) 374 return m_platformPlayer->hasAvailableVideoFrame(); 375 return false; 339 376 } 340 377 … … 346 383 MediaPlayer::MovieLoadType MediaPlayerPrivate::movieLoadType() const 347 384 { 348 return static_cast<MediaPlayer::MovieLoadType>(m_platformPlayer->movieLoadType()); 385 if (m_platformPlayer) 386 return static_cast<MediaPlayer::MovieLoadType>(m_platformPlayer->movieLoadType()); 387 return MediaPlayer::Unknown; 349 388 } 350 389 … … 455 494 void MediaPlayerPrivate::setAllowPPSVolumeUpdates(bool allow) 456 495 { 457 return m_platformPlayer->setAllowPPSVolumeUpdates(allow); 496 if (m_platformPlayer) 497 return m_platformPlayer->setAllowPPSVolumeUpdates(allow); 458 498 } 459 499 … … 463 503 MediaPlayer::ReadyState oldReadyState = m_readyState; 464 504 465 MMRPlayer::Error currentError = m_platformPlayer->error();505 PlatformPlayer::Error currentError = m_platformPlayer->error(); 466 506 467 507 HTMLMediaElement* element = static_cast<HTMLMediaElement*>(m_webCorePlayer->mediaPlayerClient()); 468 508 469 if (currentError != MMRPlayer::MediaOK) {509 if (currentError != PlatformPlayer::MediaOK) { 470 510 m_readyState = MediaPlayer::HaveNothing; 471 if (currentError == MMRPlayer::MediaDecodeError)511 if (currentError == PlatformPlayer::MediaDecodeError) 472 512 m_networkState = MediaPlayer::DecodeError; 473 else if (currentError == MMRPlayer::MediaMetaDataError474 || currentError == MMRPlayer::MediaAudioReceiveError475 || currentError == MMRPlayer::MediaVideoReceiveError)513 else if (currentError == PlatformPlayer::MediaMetaDataError 514 || currentError == PlatformPlayer::MediaAudioReceiveError 515 || currentError == PlatformPlayer::MediaVideoReceiveError) 476 516 m_networkState = MediaPlayer::NetworkError; 477 517 } else { 478 518 switch (m_platformPlayer->mediaState()) { 479 case MMRPlayer::MMRPlayStateIdle:519 case PlatformPlayer::MMRPlayStateIdle: 480 520 m_networkState = MediaPlayer::Idle; 481 521 break; 482 case MMRPlayer::MMRPlayStatePlaying:522 case PlatformPlayer::MMRPlayStatePlaying: 483 523 m_networkState = MediaPlayer::Loading; 484 524 break; 485 case MMRPlayer::MMRPlayStateStopped:525 case PlatformPlayer::MMRPlayStateStopped: 486 526 m_networkState = MediaPlayer::Idle; 487 527 break; 488 case MMRPlayer::MMRPlayStateUnknown:528 case PlatformPlayer::MMRPlayStateUnknown: 489 529 default: 490 530 break; … … 492 532 493 533 switch (m_platformPlayer->state()) { 494 case MMRPlayer::MP_STATE_IDLE:534 case PlatformPlayer::MP_STATE_IDLE: 495 535 #if USE(ACCELERATED_COMPOSITING) 496 536 setBuffering(false); … … 505 545 element->exitFullscreen(); 506 546 break; 507 case MMRPlayer::MP_STATE_ACTIVE:547 case PlatformPlayer::MP_STATE_ACTIVE: 508 548 #if USE(ACCELERATED_COMPOSITING) 509 549 m_showBufferingImage = false; … … 514 554 #endif 515 555 break; 516 case MMRPlayer::MP_STATE_UNSUPPORTED:556 case PlatformPlayer::MP_STATE_UNSUPPORTED: 517 557 break; 518 558 default: … … 530 570 } 531 571 532 // I MMRPlayerListener callbacks implementation533 void MediaPlayerPrivate::onStateChanged( MMRPlayer::MpState)572 // IPlatformPlayerListener callbacks implementation 573 void MediaPlayerPrivate::onStateChanged(PlatformPlayer::MpState) 534 574 { 535 575 updateStates(); 536 576 } 537 577 538 void MediaPlayerPrivate::onMediaStatusChanged( MMRPlayer::MMRPlayState)578 void MediaPlayerPrivate::onMediaStatusChanged(PlatformPlayer::MMRPlayState) 539 579 { 540 580 updateStates(); 541 581 } 542 582 543 void MediaPlayerPrivate::onError( MMRPlayer::Error type)583 void MediaPlayerPrivate::onError(PlatformPlayer::Error type) 544 584 { 545 585 updateStates(); … … 641 681 m_waitMetadataPopDialogCounter = 0; 642 682 643 int wait = showErrorDialog( MMRPlayer::MediaMetaDataTimeoutError);683 int wait = showErrorDialog(PlatformPlayer::MediaMetaDataTimeoutError); 644 684 if (!wait) 645 685 onPauseNotified(); … … 703 743 } 704 744 705 int MediaPlayerPrivate::showErrorDialog( MMRPlayer::Error type)745 int MediaPlayerPrivate::showErrorDialog(PlatformPlayer::Error type) 706 746 { 707 747 using namespace BlackBerry::WebKit; … … 709 749 WebPageClient::AlertType atype; 710 750 switch (type) { 711 case MMRPlayer::MediaOK:751 case PlatformPlayer::MediaOK: 712 752 atype = WebPageClient::MediaOK; 713 753 break; 714 case MMRPlayer::MediaDecodeError:754 case PlatformPlayer::MediaDecodeError: 715 755 atype = WebPageClient::MediaDecodeError; 716 756 break; 717 case MMRPlayer::MediaMetaDataError:757 case PlatformPlayer::MediaMetaDataError: 718 758 atype = WebPageClient::MediaMetaDataError; 719 759 break; 720 case MMRPlayer::MediaMetaDataTimeoutError:760 case PlatformPlayer::MediaMetaDataTimeoutError: 721 761 atype = WebPageClient::MediaMetaDataTimeoutError; 722 762 break; 723 case MMRPlayer::MediaNoMetaDataError:763 case PlatformPlayer::MediaNoMetaDataError: 724 764 atype = WebPageClient::MediaNoMetaDataError; 725 765 break; 726 case MMRPlayer::MediaVideoReceiveError:766 case PlatformPlayer::MediaVideoReceiveError: 727 767 atype = WebPageClient::MediaVideoReceiveError; 728 768 break; 729 case MMRPlayer::MediaAudioReceiveError:769 case PlatformPlayer::MediaAudioReceiveError: 730 770 atype = WebPageClient::MediaAudioReceiveError; 731 771 break; 732 case MMRPlayer::MediaInvalidError:772 case PlatformPlayer::MediaInvalidError: 733 773 atype = WebPageClient::MediaInvalidError; 734 774 break; -
trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.h
r123747 r126008 23 23 #include "MediaPlayerPrivate.h" 24 24 25 #include <BlackBerryPlatform MMRPlayer.h>25 #include <BlackBerryPlatformPlayer.h> 26 26 27 27 namespace BlackBerry { … … 33 33 namespace WebCore { 34 34 35 class MediaPlayerPrivate : public MediaPlayerPrivateInterface, public BlackBerry::Platform::I MMRPlayerListener {35 class MediaPlayerPrivate : public MediaPlayerPrivateInterface, public BlackBerry::Platform::IPlatformPlayerListener { 36 36 public: 37 37 virtual ~MediaPlayerPrivate(); … … 114 114 void setAllowPPSVolumeUpdates(bool); 115 115 116 // I MMRPlayerListener implementation.117 virtual void onStateChanged(BlackBerry::Platform:: MMRPlayer::MpState);118 virtual void onMediaStatusChanged(BlackBerry::Platform:: MMRPlayer::MMRPlayState);119 virtual void onError(BlackBerry::Platform:: MMRPlayer::Error);116 // IPlatformPlayerListener implementation. 117 virtual void onStateChanged(BlackBerry::Platform::PlatformPlayer::MpState); 118 virtual void onMediaStatusChanged(BlackBerry::Platform::PlatformPlayer::MMRPlayState); 119 virtual void onError(BlackBerry::Platform::PlatformPlayer::Error); 120 120 virtual void onDurationChanged(float); 121 121 virtual void onTimeChanged(float); … … 137 137 virtual bool isElementPaused() const; 138 138 virtual bool isTabVisible() const; 139 virtual int showErrorDialog(BlackBerry::Platform:: MMRPlayer::Error);139 virtual int showErrorDialog(BlackBerry::Platform::PlatformPlayer::Error); 140 140 virtual BlackBerry::Platform::Graphics::Window* platformWindow(); 141 141 … … 150 150 151 151 MediaPlayer* m_webCorePlayer; 152 BlackBerry::Platform:: MMRPlayer* m_platformPlayer;152 BlackBerry::Platform::PlatformPlayer* m_platformPlayer; 153 153 154 154 mutable MediaPlayer::NetworkState m_networkState;
Note: See TracChangeset
for help on using the changeset viewer.