From be72748d2a69ddda51c4b41c0c8f2beba077b265 Mon Sep 17 00:00:00 2001 From: callum Date: Fri, 13 Nov 2009 11:03:39 -0800 Subject: Fix for DEV-42152 (Streaming media broken on QuickTime) --- indra/media_plugins/quicktime/media_plugin_quicktime.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'indra/media_plugins') diff --git a/indra/media_plugins/quicktime/media_plugin_quicktime.cpp b/indra/media_plugins/quicktime/media_plugin_quicktime.cpp index de927de1cd..dac0509531 100644 --- a/indra/media_plugins/quicktime/media_plugin_quicktime.cpp +++ b/indra/media_plugins/quicktime/media_plugin_quicktime.cpp @@ -528,11 +528,17 @@ private: if ( ! mMovieController ) return; - // service QuickTime - // Calling it this way doesn't have good behavior on Windows... -// MoviesTask( mMovieHandle, milliseconds ); - // This was the original, but I think using both MoviesTask and MCIdle is redundant. Trying with only MCIdle. -// MoviesTask( mMovieHandle, 0 ); + // this wasn't required in 1.xx viewer but we have to manually + // work the Windows message pump now + #if defined( LL_WINDOWS ) + MSG msg; + while ( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) ) + { + GetMessage( &msg, NULL, 0, 0 ); + TranslateMessage( &msg ); + DispatchMessage( &msg ); + }; + #endif MCIdle( mMovieController ); -- cgit v1.2.3 From 5890c850f8db30e105717b7c5fbbec91c434ebff Mon Sep 17 00:00:00 2001 From: Monroe Linden Date: Fri, 13 Nov 2009 13:05:16 -0800 Subject: Prevent the about:blank url from the initial navigate from leaking out of the webkit plugin. This should fix DEV-42766. --- indra/media_plugins/webkit/media_plugin_webkit.cpp | 128 +++++++++++++++------ 1 file changed, 94 insertions(+), 34 deletions(-) (limited to 'indra/media_plugins') diff --git a/indra/media_plugins/webkit/media_plugin_webkit.cpp b/indra/media_plugins/webkit/media_plugin_webkit.cpp index 3ce8ff3deb..1e79720f43 100644 --- a/indra/media_plugins/webkit/media_plugin_webkit.cpp +++ b/indra/media_plugins/webkit/media_plugin_webkit.cpp @@ -74,8 +74,17 @@ public: private: + enum + { + INIT_STATE_UNINITIALIZED, // Browser instance hasn't been set up yet + INIT_STATE_NAVIGATING, // Browser instance has been set up and initial navigate to about:blank has been issued + INIT_STATE_NAVIGATE_COMPLETE, // initial navigate to about:blank has completed + INIT_STATE_WAIT_REDRAW, // First real navigate begin has been received, waiting for page changed event to start handling redraws + INIT_STATE_RUNNING // All initialization gymnastics are complete. + }; int mBrowserWindowId; - bool mBrowserInitialized; + int mInitState; + std::string mInitialNavigateURL; bool mNeedsUpdate; bool mCanCut; @@ -93,7 +102,17 @@ private: checkEditState(); - if ( mNeedsUpdate ) + if(mInitState == INIT_STATE_NAVIGATE_COMPLETE) + { + if(!mInitialNavigateURL.empty()) + { + // We already have the initial navigate URL -- kick off the navigate. + LLQtWebKit::getInstance()->navigateTo( mBrowserWindowId, mInitialNavigateURL ); + mInitialNavigateURL.clear(); + } + } + + if ( (mInitState == INIT_STATE_RUNNING) && mNeedsUpdate ) { const unsigned char* browser_pixels = LLQtWebKit::getInstance()->grabBrowserWindow( mBrowserWindowId ); @@ -123,7 +142,7 @@ private: bool initBrowser() { // already initialized - if ( mBrowserInitialized ) + if ( mInitState > INIT_STATE_UNINITIALIZED ) return true; // not enough information to initialize the browser yet. @@ -210,20 +229,21 @@ private: // set background color to be black - mostly for initial login page LLQtWebKit::getInstance()->setBackgroundColor( mBrowserWindowId, 0x00, 0x00, 0x00 ); + // Set state _before_ starting the navigate, since onNavigateBegin might get called before this call returns. + mInitState = INIT_STATE_NAVIGATING; + // Don't do this here -- it causes the dreaded "white flash" when loading a browser instance. // FIXME: Re-added this because navigating to a "page" initializes things correctly - especially // for the HTTP AUTH dialog issues (DEV-41731). Will fix at a later date. LLQtWebKit::getInstance()->navigateTo( mBrowserWindowId, "about:blank" ); - // set flag so we don't do this again - mBrowserInitialized = true; - return true; }; return false; }; + //////////////////////////////////////////////////////////////////////////////// // virtual void onCursorChanged(const EventType& event) @@ -263,6 +283,11 @@ private: // virtual void onPageChanged( const EventType& event ) { + if(mInitState == INIT_STATE_WAIT_REDRAW) + { + mInitState = INIT_STATE_RUNNING; + } + // flag that an update is required mNeedsUpdate = true; }; @@ -271,62 +296,90 @@ private: // virtual void onNavigateBegin(const EventType& event) { - LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "navigate_begin"); - message.setValue("uri", event.getEventUri()); - sendMessage(message); - - setStatus(STATUS_LOADING); + if(mInitState > INIT_STATE_NAVIGATE_COMPLETE) + { + LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "navigate_begin"); + message.setValue("uri", event.getEventUri()); + sendMessage(message); + + setStatus(STATUS_LOADING); + } + else if(mInitState == INIT_STATE_NAVIGATE_COMPLETE) + { + mInitState = INIT_STATE_WAIT_REDRAW; + } + } //////////////////////////////////////////////////////////////////////////////// // virtual void onNavigateComplete(const EventType& event) { - LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "navigate_complete"); - message.setValue("uri", event.getEventUri()); - message.setValueS32("result_code", event.getIntValue()); - message.setValue("result_string", event.getStringValue()); - message.setValueBoolean("history_back_available", LLQtWebKit::getInstance()->userActionIsEnabled( mBrowserWindowId, LLQtWebKit::UA_NAVIGATE_BACK)); - message.setValueBoolean("history_forward_available", LLQtWebKit::getInstance()->userActionIsEnabled( mBrowserWindowId, LLQtWebKit::UA_NAVIGATE_FORWARD)); - sendMessage(message); - - setStatus(STATUS_LOADED); + if(mInitState > INIT_STATE_NAVIGATE_COMPLETE) + { + LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "navigate_complete"); + message.setValue("uri", event.getEventUri()); + message.setValueS32("result_code", event.getIntValue()); + message.setValue("result_string", event.getStringValue()); + message.setValueBoolean("history_back_available", LLQtWebKit::getInstance()->userActionIsEnabled( mBrowserWindowId, LLQtWebKit::UA_NAVIGATE_BACK)); + message.setValueBoolean("history_forward_available", LLQtWebKit::getInstance()->userActionIsEnabled( mBrowserWindowId, LLQtWebKit::UA_NAVIGATE_FORWARD)); + sendMessage(message); + + setStatus(STATUS_LOADED); + } + else if(mInitState == INIT_STATE_NAVIGATING) + { + mInitState = INIT_STATE_NAVIGATE_COMPLETE; + } + } //////////////////////////////////////////////////////////////////////////////// // virtual void onUpdateProgress(const EventType& event) { - LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "progress"); - message.setValueS32("percent", event.getIntValue()); - sendMessage(message); + if(mInitState > INIT_STATE_NAVIGATE_COMPLETE) + { + LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "progress"); + message.setValueS32("percent", event.getIntValue()); + sendMessage(message); + } } //////////////////////////////////////////////////////////////////////////////// // virtual void onStatusTextChange(const EventType& event) { - LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "status_text"); - message.setValue("status", event.getStringValue()); - sendMessage(message); + if(mInitState > INIT_STATE_NAVIGATE_COMPLETE) + { + LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "status_text"); + message.setValue("status", event.getStringValue()); + sendMessage(message); + } } //////////////////////////////////////////////////////////////////////////////// // virtual void onTitleChange(const EventType& event) { - LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "name_text"); - message.setValue("name", event.getStringValue()); - sendMessage(message); + if(mInitState > INIT_STATE_NAVIGATE_COMPLETE) + { + LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "name_text"); + message.setValue("name", event.getStringValue()); + sendMessage(message); + } } //////////////////////////////////////////////////////////////////////////////// // virtual void onLocationChange(const EventType& event) { - LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "location_changed"); - message.setValue("uri", event.getEventUri()); - sendMessage(message); + if(mInitState > INIT_STATE_NAVIGATE_COMPLETE) + { + LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "location_changed"); + message.setValue("uri", event.getEventUri()); + sendMessage(message); + } } //////////////////////////////////////////////////////////////////////////////// @@ -488,7 +541,7 @@ MediaPluginWebKit::MediaPluginWebKit(LLPluginInstance::sendMessageFunction host_ // std::cerr << "MediaPluginWebKit constructor" << std::endl; mBrowserWindowId = 0; - mBrowserInitialized = false; + mInitState = INIT_STATE_UNINITIALIZED; mNeedsUpdate = true; mCanCut = false; mCanCopy = false; @@ -674,7 +727,14 @@ void MediaPluginWebKit::receiveMessage(const char *message_string) if(!uri.empty()) { - LLQtWebKit::getInstance()->navigateTo( mBrowserWindowId, uri ); + if(mInitState >= INIT_STATE_NAVIGATE_COMPLETE) + { + LLQtWebKit::getInstance()->navigateTo( mBrowserWindowId, uri ); + } + else + { + mInitialNavigateURL = uri; + } } } else if(message_name == "mouse_event") -- cgit v1.2.3 From d19d581b485bf314d7a97e1348a77bad8835db77 Mon Sep 17 00:00:00 2001 From: Monroe Linden Date: Mon, 16 Nov 2009 13:48:50 -0800 Subject: Fix a logic error in the code to hide the initial about:blank navigate that caused DEV-42093 to recur. --- indra/media_plugins/webkit/media_plugin_webkit.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'indra/media_plugins') diff --git a/indra/media_plugins/webkit/media_plugin_webkit.cpp b/indra/media_plugins/webkit/media_plugin_webkit.cpp index 1e79720f43..09348782a4 100644 --- a/indra/media_plugins/webkit/media_plugin_webkit.cpp +++ b/indra/media_plugins/webkit/media_plugin_webkit.cpp @@ -296,7 +296,7 @@ private: // virtual void onNavigateBegin(const EventType& event) { - if(mInitState > INIT_STATE_NAVIGATE_COMPLETE) + if(mInitState >= INIT_STATE_NAVIGATE_COMPLETE) { LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "navigate_begin"); message.setValue("uri", event.getEventUri()); @@ -304,7 +304,8 @@ private: setStatus(STATUS_LOADING); } - else if(mInitState == INIT_STATE_NAVIGATE_COMPLETE) + + if(mInitState == INIT_STATE_NAVIGATE_COMPLETE) { mInitState = INIT_STATE_WAIT_REDRAW; } @@ -315,7 +316,7 @@ private: // virtual void onNavigateComplete(const EventType& event) { - if(mInitState > INIT_STATE_NAVIGATE_COMPLETE) + if(mInitState >= INIT_STATE_NAVIGATE_COMPLETE) { LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "navigate_complete"); message.setValue("uri", event.getEventUri()); @@ -338,7 +339,7 @@ private: // virtual void onUpdateProgress(const EventType& event) { - if(mInitState > INIT_STATE_NAVIGATE_COMPLETE) + if(mInitState >= INIT_STATE_NAVIGATE_COMPLETE) { LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "progress"); message.setValueS32("percent", event.getIntValue()); @@ -350,7 +351,7 @@ private: // virtual void onStatusTextChange(const EventType& event) { - if(mInitState > INIT_STATE_NAVIGATE_COMPLETE) + if(mInitState >= INIT_STATE_NAVIGATE_COMPLETE) { LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "status_text"); message.setValue("status", event.getStringValue()); @@ -362,7 +363,7 @@ private: // virtual void onTitleChange(const EventType& event) { - if(mInitState > INIT_STATE_NAVIGATE_COMPLETE) + if(mInitState >= INIT_STATE_NAVIGATE_COMPLETE) { LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "name_text"); message.setValue("name", event.getStringValue()); @@ -374,7 +375,7 @@ private: // virtual void onLocationChange(const EventType& event) { - if(mInitState > INIT_STATE_NAVIGATE_COMPLETE) + if(mInitState >= INIT_STATE_NAVIGATE_COMPLETE) { LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "location_changed"); message.setValue("uri", event.getEventUri()); -- cgit v1.2.3 From 18eab4a02675195c6498ca7b0982e62f0ddf9e60 Mon Sep 17 00:00:00 2001 From: callum Date: Mon, 16 Nov 2009 18:42:35 -0800 Subject: Merge with tip --- indra/media_plugins/quicktime/media_plugin_quicktime.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'indra/media_plugins') diff --git a/indra/media_plugins/quicktime/media_plugin_quicktime.cpp b/indra/media_plugins/quicktime/media_plugin_quicktime.cpp index dac0509531..182fab69d0 100644 --- a/indra/media_plugins/quicktime/media_plugin_quicktime.cpp +++ b/indra/media_plugins/quicktime/media_plugin_quicktime.cpp @@ -552,7 +552,7 @@ private: processState(); // see if title arrived and if so, update member variable with contents - checkTitle(); + //checkTitle(); // QT call to see if we are at the end - can't do with controller if ( IsMovieDone( mMovieHandle ) ) @@ -718,18 +718,24 @@ private: // find the size of the title ByteCount size; result = QTMetaDataGetItemValue( media_data_ref, item, NULL, 0, &size ); - if ( noErr != result || size <= 0 ) + if ( noErr != result || size <= 0 /*|| size > 1024 /* FIXME: arbitrary limit */ ) return false; // allocate some space and grab it - UInt8* item_data = new UInt8( size ); - memset( item_data, 0, size * sizeof( UInt8* ) ); + UInt8* item_data = new UInt8( size + 1 ); + memset( item_data, 0, ( size + 1 ) * sizeof( UInt8* ) ); result = QTMetaDataGetItemValue( media_data_ref, item, item_data, size, NULL ); if ( noErr != result ) + { + delete [] item_data; return false; + }; // save it - mMovieTitle = std::string( (char* )item_data ); + if ( strlen( (char*)item_data ) ) + mMovieTitle = std::string( (char* )item_data ); + else + mMovieTitle = ""; // clean up delete [] item_data; -- cgit v1.2.3 From ac9963ade2d8a70408f021581e44691285241bd1 Mon Sep 17 00:00:00 2001 From: callum Date: Mon, 16 Nov 2009 19:22:45 -0800 Subject: Fix for - DEV-42713 (Playing MP3s crash the QuickTime plugin) Note: This was fixed earlier in checkTitle() bosy and checked in by mistake. This checkin re-enables the title grabbing code. --- indra/media_plugins/quicktime/media_plugin_quicktime.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/media_plugins') diff --git a/indra/media_plugins/quicktime/media_plugin_quicktime.cpp b/indra/media_plugins/quicktime/media_plugin_quicktime.cpp index 182fab69d0..7148edda5c 100644 --- a/indra/media_plugins/quicktime/media_plugin_quicktime.cpp +++ b/indra/media_plugins/quicktime/media_plugin_quicktime.cpp @@ -552,7 +552,7 @@ private: processState(); // see if title arrived and if so, update member variable with contents - //checkTitle(); + checkTitle(); // QT call to see if we are at the end - can't do with controller if ( IsMovieDone( mMovieHandle ) ) -- cgit v1.2.3 From 18980efe16e19ab0562267e10ec55bed55b581fb Mon Sep 17 00:00:00 2001 From: callum Date: Mon, 16 Nov 2009 19:49:45 -0800 Subject: Fix up line endings issues. --- indra/media_plugins/quicktime/media_plugin_quicktime.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'indra/media_plugins') diff --git a/indra/media_plugins/quicktime/media_plugin_quicktime.cpp b/indra/media_plugins/quicktime/media_plugin_quicktime.cpp index 7148edda5c..f4add536eb 100644 --- a/indra/media_plugins/quicktime/media_plugin_quicktime.cpp +++ b/indra/media_plugins/quicktime/media_plugin_quicktime.cpp @@ -531,13 +531,13 @@ private: // this wasn't required in 1.xx viewer but we have to manually // work the Windows message pump now #if defined( LL_WINDOWS ) - MSG msg; - while ( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) ) - { - GetMessage( &msg, NULL, 0, 0 ); - TranslateMessage( &msg ); - DispatchMessage( &msg ); - }; + MSG msg; + while ( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) ) + { + GetMessage( &msg, NULL, 0, 0 ); + TranslateMessage( &msg ); + DispatchMessage( &msg ); + }; #endif MCIdle( mMovieController ); -- cgit v1.2.3 From ccc72757ef23fa7ffba066e5bdaf05e3f8a95cca Mon Sep 17 00:00:00 2001 From: James Cook Date: Mon, 16 Nov 2009 22:25:40 -0800 Subject: Fix comment-in-comment that was breaking Mac build. --- indra/media_plugins/quicktime/media_plugin_quicktime.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/media_plugins') diff --git a/indra/media_plugins/quicktime/media_plugin_quicktime.cpp b/indra/media_plugins/quicktime/media_plugin_quicktime.cpp index f4add536eb..236f79978d 100644 --- a/indra/media_plugins/quicktime/media_plugin_quicktime.cpp +++ b/indra/media_plugins/quicktime/media_plugin_quicktime.cpp @@ -718,7 +718,7 @@ private: // find the size of the title ByteCount size; result = QTMetaDataGetItemValue( media_data_ref, item, NULL, 0, &size ); - if ( noErr != result || size <= 0 /*|| size > 1024 /* FIXME: arbitrary limit */ ) + if ( noErr != result || size <= 0 /*|| size > 1024 FIXME: arbitrary limit */ ) return false; // allocate some space and grab it -- cgit v1.2.3