mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-03-05 03:48:34 -06:00
Make CMake download the prebuilt version of libmpv from our server; Add example asset that downloads its video on include
This commit is contained in:
35
data/assets/examples/video_on_globe.asset
Normal file
35
data/assets/examples/video_on_globe.asset
Normal file
@@ -0,0 +1,35 @@
|
||||
local earth = asset.require("scene/solarsystem/planets/earth/earth")
|
||||
|
||||
local data = asset.syncedResource({
|
||||
Name = "Example Globe Video",
|
||||
Type = "UrlSynchronization",
|
||||
Identifier = "example_globe_video",
|
||||
Url = "http://liu-se.cdn.openspaceproject.com/files/examples/test-video.mp4"
|
||||
})
|
||||
|
||||
local layer = {
|
||||
Identifier = "ExampleVideo",
|
||||
Video = data .. "/test-video.mp4",
|
||||
Name = "Example Video",
|
||||
Enabled = true,
|
||||
Type = "VideoTileLayer"
|
||||
}
|
||||
|
||||
asset.onInitialize(function()
|
||||
openspace.globebrowsing.addLayer(earth.Earth.Identifier, "ColorLayers", layer)
|
||||
end)
|
||||
|
||||
asset.onDeinitialize(function()
|
||||
openspace.globebrowsing.deleteLayer(earth.Earth.Identifier, "ColorLayers", layer)
|
||||
end)
|
||||
|
||||
asset.export("layer", layer)
|
||||
|
||||
asset.meta = {
|
||||
Name = "Video Player Test",
|
||||
Version = "1.0",
|
||||
Description = "An example asset that shows how to include a video on Earth",
|
||||
Author = "OpenSpace Team",
|
||||
URL = "https://openspaceproject.com",
|
||||
License = "MIT"
|
||||
}
|
||||
@@ -46,22 +46,52 @@ set(SOURCE_FILES
|
||||
source_group("Source Files" FILES ${SOURCE_FILES})
|
||||
|
||||
# Libmpv
|
||||
if(WIN32)
|
||||
if (WIN32)
|
||||
set(LIBMPV_ROOT "${CMAKE_CURRENT_BINARY_DIR}/ext/libmpv" CACHE INTERNAL "LIBMPV_ROOT")
|
||||
if (NOT IS_DIRECTORY "${LIBMPV_ROOT}")
|
||||
message(STATUS "Downloading LibMPV...")
|
||||
|
||||
# First download the SHA1 hash of the file
|
||||
file(
|
||||
DOWNLOAD
|
||||
"http://data.openspaceproject.com/ext/libmpv/2.0/libmpv.zip.sha1"
|
||||
"${LIBMPV_ROOT}/libmpv.zip.sha1"
|
||||
)
|
||||
file(READ "${LIBMPV_ROOT}/libmpv.zip.sha1" LIBMPV_SHA1)
|
||||
|
||||
# For some reason the SHA1 file contains extra linebreaks
|
||||
string(STRIP ${LIBMPV_SHA1} LIBMPV_SHA1)
|
||||
|
||||
# Then download the file itself
|
||||
file(
|
||||
DOWNLOAD
|
||||
"http://data.openspaceproject.com/ext/libmpv/2.0/libmpv.zip"
|
||||
"${LIBMPV_ROOT}/libmpv.zip"
|
||||
EXPECTED_HASH SHA1=${LIBMPV_SHA1}
|
||||
SHOW_PROGRESS
|
||||
)
|
||||
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} -E tar xzf "${LIBMPV_ROOT}/libmpv.zip"
|
||||
WORKING_DIRECTORY ${LIBMPV_ROOT}
|
||||
)
|
||||
endif ()
|
||||
|
||||
add_library(libmpv SHARED IMPORTED)
|
||||
target_include_directories(libmpv SYSTEM INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/ext/libmpv/include)
|
||||
target_include_directories(libmpv SYSTEM INTERFACE ${LIBMPV_ROOT}/libmpv/include)
|
||||
set_target_properties(libmpv PROPERTIES
|
||||
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/ext/libmpv/bin/mpv-2.dll"
|
||||
IMPORTED_IMPLIB "${CMAKE_CURRENT_SOURCE_DIR}/ext/libmpv/lib/mpv.lib"
|
||||
IMPORTED_LOCATION "${LIBMPV_ROOT}/libmpv/bin/mpv-2.dll"
|
||||
IMPORTED_IMPLIB "${LIBMPV_ROOT}/libmpv/lib/mpv.lib"
|
||||
)
|
||||
|
||||
add_library(libopenh264 SHARED IMPORTED)
|
||||
set_target_properties(libopenh264 PROPERTIES
|
||||
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/ext/libmpv/bin/libopenh264.dll"
|
||||
IMPORTED_IMPLIB "${CMAKE_CURRENT_SOURCE_DIR}/ext/libmpv/lib/mpv.lib"
|
||||
IMPORTED_LOCATION "${LIBMPV_ROOT}/libmpv/bin/libopenh264.dll"
|
||||
IMPORTED_IMPLIB "${LIBMPV_ROOT}/libmpv/lib/mpv.lib"
|
||||
)
|
||||
|
||||
target_link_libraries(openspace-module-globebrowsing PUBLIC libmpv libopenh264)
|
||||
else(WIN32)
|
||||
else (WIN32)
|
||||
find_package(LIBMPV REQUIRED)
|
||||
|
||||
target_include_directories(openspace-module-globebrowsing SYSTEM PRIVATE ${LIBMPV_INCLUDE_DIR})
|
||||
@@ -74,4 +104,4 @@ create_new_module(
|
||||
video_module
|
||||
STATIC
|
||||
${HEADER_FILES} ${SOURCE_FILES}
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user