diff options
author | Rick Pasetto <rick@lindenlab.com> | 2009-10-13 10:01:25 -0700 |
---|---|---|
committer | Rick Pasetto <rick@lindenlab.com> | 2009-10-13 10:01:25 -0700 |
commit | 64514057a4daabf068d37db80cbf83fd30e30cf7 (patch) | |
tree | d7e52cb1abc09d42ad49c384e6cc8cf47192874d | |
parent | 780719c14c6c2921eaf0a6021a4082b5486efafb (diff) | |
parent | f154a3a23f9dad1e4222ad0f90a40f4f79b38508 (diff) |
Merge from remote repo
-rw-r--r-- | indra/llplugin/llpluginclassmedia.cpp | 23 | ||||
-rw-r--r-- | indra/llplugin/llpluginclassmedia.h | 2 | ||||
-rw-r--r-- | indra/media_plugins/quicktime/media_plugin_quicktime.cpp | 14 | ||||
-rw-r--r-- | indra/test_apps/llplugintest/CMakeLists.txt | 64 | ||||
-rw-r--r-- | indra/test_apps/llplugintest/llmediaplugintest.cpp | 20 |
5 files changed, 116 insertions, 7 deletions
diff --git a/indra/llplugin/llpluginclassmedia.cpp b/indra/llplugin/llpluginclassmedia.cpp index e019cdcf21..2a343fd0c9 100644 --- a/indra/llplugin/llpluginclassmedia.cpp +++ b/indra/llplugin/llpluginclassmedia.cpp @@ -133,6 +133,7 @@ void LLPluginClassMedia::reset() mCurrentTime = 0.0f; mDuration = 0.0f; mCurrentRate = 0.0f; + mLoadedDuration = 0.0f; } void LLPluginClassMedia::idle(void) @@ -705,6 +706,7 @@ void LLPluginClassMedia::receivePluginMessage(const LLPluginMessage &message) bool time_duration_updated = false; + int previous_percent = mProgressPercent; if(message.hasValue("current_time")) { @@ -722,11 +724,32 @@ void LLPluginClassMedia::receivePluginMessage(const LLPluginMessage &message) mCurrentRate = message.getValueReal("current_rate"); } + if(message.hasValue("loaded_duration")) + { + mLoadedDuration = message.getValueReal("loaded_duration"); + time_duration_updated = true; + } + else + { + // If the message doesn't contain a loaded_duration param, assume it's equal to duration + mLoadedDuration = mDuration; + } + + // Calculate a percentage based on the loaded duration and total duration. + if(mDuration != 0.0f) // Don't divide by zero. + { + mProgressPercent = (int)((mLoadedDuration * 100.0f)/mDuration); + } + if(time_duration_updated) { mediaEvent(LLPluginClassMediaOwner::MEDIA_EVENT_TIME_DURATION_UPDATED); } + if(previous_percent != mProgressPercent) + { + mediaEvent(LLPluginClassMediaOwner::MEDIA_EVENT_PROGRESS_UPDATED); + } } else if(message_name == "media_status") { diff --git a/indra/llplugin/llpluginclassmedia.h b/indra/llplugin/llpluginclassmedia.h index 97f2a11ef2..697deec353 100644 --- a/indra/llplugin/llpluginclassmedia.h +++ b/indra/llplugin/llpluginclassmedia.h @@ -231,6 +231,7 @@ public: F64 getCurrentTime(void) const { return mCurrentTime; }; F64 getDuration(void) const { return mDuration; }; F64 getCurrentPlayRate(void) { return mCurrentRate; }; + F64 getLoadedDuration(void) const { return mLoadedDuration; }; // Initialize the URL history of the plugin by sending // "init_history" message @@ -339,6 +340,7 @@ protected: F64 mCurrentTime; F64 mDuration; F64 mCurrentRate; + F64 mLoadedDuration; }; diff --git a/indra/media_plugins/quicktime/media_plugin_quicktime.cpp b/indra/media_plugins/quicktime/media_plugin_quicktime.cpp index fbda65120d..556865f771 100644 --- a/indra/media_plugins/quicktime/media_plugin_quicktime.cpp +++ b/indra/media_plugins/quicktime/media_plugin_quicktime.cpp @@ -103,6 +103,7 @@ private: message.setValueReal("current_time", getCurrentTime()); message.setValueReal("duration", getDuration()); message.setValueReal("current_rate", Fix2X(GetMovieRate(mMovieHandle))); + message.setValueReal("loaded_duration", getLoadedDuration()); } sendMessage(message); @@ -593,6 +594,19 @@ private: return (F64)duration / (F64)scale; }; + F64 getLoadedDuration() + { + TimeValue duration; + if(GetMaxLoadedTimeInMovie( mMovieHandle, &duration ) != noErr) + { + // If GetMaxLoadedTimeInMovie returns an error, return the full duration of the movie. + duration = GetMovieDuration( mMovieHandle ); + } + TimeValue scale = GetMovieTimeScale( mMovieHandle ); + + return (F64)duration / (F64)scale; + }; + F64 getCurrentTime() { TimeValue curr_time = GetMovieTime( mMovieHandle, 0 ); diff --git a/indra/test_apps/llplugintest/CMakeLists.txt b/indra/test_apps/llplugintest/CMakeLists.txt index 295882c49a..88c4ba8ad9 100644 --- a/indra/test_apps/llplugintest/CMakeLists.txt +++ b/indra/test_apps/llplugintest/CMakeLists.txt @@ -28,7 +28,7 @@ include_directories( if (DARWIN) include(CMakeFindFrameworks) - find_library(CARBON_LIBRARY Carbon) + find_library(COREFOUNDATION_LIBRARY CoreFoundation) endif (DARWIN) ### demo_plugin @@ -261,6 +261,7 @@ set(llmediaplugintest_SOURCE_FILES add_executable(llmediaplugintest WIN32 + MACOSX_BUNDLE ${llmediaplugintest_SOURCE_FILES} ) @@ -280,6 +281,13 @@ target_link_libraries(llmediaplugintest ${PLUGIN_API_WINDOWS_LIBRARIES} ) +if (DARWIN) + # The testbed needs to use a couple of CoreFoundation calls now, to deal with being a bundled app. + target_link_libraries(llmediaplugintest + ${COREFOUNDATION_LIBRARY} + ) +endif (DARWIN) + add_dependencies(llmediaplugintest stage_third_party_libs SLPlugin @@ -300,22 +308,64 @@ endif (DARWIN OR LINUX) # Gather build products of the various dependencies into the build directory for the testbed. +if (DARWIN) + # path inside the app bundle where we'll need to copy plugins and other related files + set(PLUGINS_DESTINATION_DIR + ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/llmediaplugintest.app/Contents/Resources + ) + + # create the Contents/Resources directory + add_custom_command( + TARGET llmediaplugintest POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS + -E + make_directory + ${PLUGINS_DESTINATION_DIR} + COMMENT "Creating Resources directory in app bundle." + ) + + # copy the llcommon dylib and its dependencies to Contents/Resources. + get_target_property(BUILT_LLCOMMON llcommon LOCATION) + add_custom_command(TARGET llmediaplugintest POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${BUILT_LLCOMMON} ${PLUGINS_DESTINATION_DIR} + DEPENDS ${BUILT_LLCOMMON} + ) + # FIXME: these paths should come from somewhere reliable. The canonical list seems to be in indra/newview/viewer_manifest.py + add_custom_command(TARGET llmediaplugintest POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${ARCH_PREBUILT_DIRS_RELEASE}/libapr-1.0.3.7.dylib ${PLUGINS_DESTINATION_DIR} + DEPENDS ${ARCH_PREBUILT_DIRS_RELEASE}/libapr-1.0.3.7.dylib + ) + add_custom_command(TARGET llmediaplugintest POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${ARCH_PREBUILT_DIRS_RELEASE}/libaprutil-1.0.3.8.dylib ${PLUGINS_DESTINATION_DIR} + DEPENDS ${ARCH_PREBUILT_DIRS_RELEASE}/libaprutil-1.0.3.8.dylib + ) + add_custom_command(TARGET llmediaplugintest POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${ARCH_PREBUILT_DIRS_RELEASE}/libexpat.0.5.0.dylib ${PLUGINS_DESTINATION_DIR} + DEPENDS ${ARCH_PREBUILT_DIRS_RELEASE}/libexpat.0.5.0.dylib + ) +else (DARWIN) + set(PLUGINS_DESTINATION_DIR + ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/ + ) +endif (DARWIN) + get_target_property(BUILT_SLPLUGIN SLPlugin LOCATION) add_custom_command(TARGET llmediaplugintest POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy ${BUILT_SLPLUGIN} ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/ + COMMAND ${CMAKE_COMMAND} -E copy ${BUILT_SLPLUGIN} ${PLUGINS_DESTINATION_DIR} DEPENDS ${BUILT_SLPLUGIN} ) if (DARWIN OR WINDOWS) get_target_property(BUILT_WEBKIT_PLUGIN media_plugin_webkit LOCATION) add_custom_command(TARGET llmediaplugintest POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy ${BUILT_WEBKIT_PLUGIN} ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/ + COMMAND ${CMAKE_COMMAND} -E copy ${BUILT_WEBKIT_PLUGIN} ${PLUGINS_DESTINATION_DIR} DEPENDS ${BUILT_WEBKIT_PLUGIN} ) get_target_property(BUILT_QUICKTIME_PLUGIN media_plugin_quicktime LOCATION) add_custom_command(TARGET llmediaplugintest POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy ${BUILT_QUICKTIME_PLUGIN} ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/ + COMMAND ${CMAKE_COMMAND} -E copy ${BUILT_QUICKTIME_PLUGIN} ${PLUGINS_DESTINATION_DIR} DEPENDS ${BUILT_QUICKTIME_PLUGIN} ) @@ -325,16 +375,16 @@ if (DARWIN OR WINDOWS) COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/bookmarks.txt ${CMAKE_CURRENT_BINARY_DIR}/ DEPENDS ${BUILT_LLMEDIAPLUGINTEST} ) - # also copy it to the build configuration directory, which is what the mac wants... + # also copy it to the same place as SLPlugin, which is what the mac wants... add_custom_command(TARGET llmediaplugintest POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/bookmarks.txt ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/bookmarks.txt ${PLUGINS_DESTINATION_DIR} DEPENDS ${BUILT_LLMEDIAPLUGINTEST} ) endif (DARWIN OR WINDOWS) if (DARWIN) add_custom_command(TARGET llmediaplugintest POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/../libraries/universal-darwin/lib_release/libllqtwebkit.dylib ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/../libraries/universal-darwin/lib_release/libllqtwebkit.dylib ${PLUGINS_DESTINATION_DIR} DEPENDS ${CMAKE_SOURCE_DIR}/../libraries/universal-darwin/lib_release/libllqtwebkit.dylib ) endif (DARWIN) diff --git a/indra/test_apps/llplugintest/llmediaplugintest.cpp b/indra/test_apps/llplugintest/llmediaplugintest.cpp index f9568a9b5d..ba66b449f3 100644 --- a/indra/test_apps/llplugintest/llmediaplugintest.cpp +++ b/indra/test_apps/llplugintest/llmediaplugintest.cpp @@ -44,6 +44,7 @@ #if __APPLE__ #include <GLUT/glut.h> + #include <CoreFoundation/CoreFoundation.h> #else #define FREEGLUT_STATIC #include "GL/freeglut.h" @@ -2111,6 +2112,25 @@ void glutMouseButton( int button, int state, int x, int y ) // int main( int argc, char* argv[] ) { +#if LL_DARWIN + // Set the current working directory to <application bundle>/Contents/Resources/ + CFURLRef resources_url = CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle()); + if(resources_url != NULL) + { + CFStringRef resources_string = CFURLCopyFileSystemPath(resources_url, kCFURLPOSIXPathStyle); + CFRelease(resources_url); + if(resources_string != NULL) + { + char buffer[PATH_MAX] = ""; + if(CFStringGetCString(resources_string, buffer, sizeof(buffer), kCFStringEncodingUTF8)) + { + chdir(buffer); + } + CFRelease(resources_string); + } + } +#endif + glutInit( &argc, argv ); glutInitDisplayMode( GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGB ); |