Skip to content

Commit 9fd26c7

Browse files
committed
upload src
1 parent f2da97f commit 9fd26c7

16 files changed

+3146
-99
lines changed

CMakeLists.txt

Lines changed: 54 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,60 @@
11
cmake_minimum_required(VERSION 3.5)
2+
set(CMAKE_CXX_STANDARD 17)
23
project(obs-streamlink)
34

5+
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}")
6+
7+
find_package(FFmpeg REQUIRED
8+
COMPONENTS avcodec avfilter avdevice avutil swscale avformat swresample)
9+
find_package(Python3 COMPONENTS Interpreter Development)
10+
find_library(Python3Gen NAME "python38.lib" PATHS "${Python3_LIBRARY_DIRS}" NO_DEFAULT_PATH)
11+
find_library(Python3Gen_Debug NAME "python38_d.lib" PATHS "${Python3_LIBRARY_DIRS}" NO_DEFAULT_PATH)
12+
13+
set(CMAKE_PREFIX_PATH "${QTDIR}")
414
set(CMAKE_INCLUDE_CURRENT_DIR ON)
15+
set(CMAKE_AUTOMOC ON)
16+
set(CMAKE_AUTOUIC ON)
517

6-
include(FindLibObs.cmake)
7-
find_package(LibObs REQUIRED)
18+
find_package(Qt5Core REQUIRED)
19+
find_package(Qt5Widgets REQUIRED)
820

9-
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
10-
set(ARCH 64)
21+
add_library(obs-streamlink MODULE
22+
obs-streamlink.cpp
23+
streamlink-source.cpp
24+
media-playback/decode.cpp
25+
media-playback/media.cpp
26+
python-streamlink.cpp
27+
)
28+
target_link_libraries(obs-streamlink PRIVATE
29+
"${LIBOBS_LIB}"
30+
"${W32_PTHREADS_LIB}"
31+
"${OBS_FRONTEND_LIB}"
32+
Qt5::Core
33+
Qt5::Widgets
34+
${FFMPEG_LIBRARIES}
35+
delayimp)
36+
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
37+
target_link_libraries(obs-streamlink PRIVATE "${Python3Gen}")
1138
else()
12-
set(ARCH 32)
39+
target_link_libraries(obs-streamlink PRIVATE "${Python3Gen}")
1340
endif()
14-
15-
add_library(obs-streamlink MODULE
16-
obs-streamlink.cpp)
17-
18-
target_include_directories(obs-streamlink PUBLIC "${LIBOBS_INCLUDE_DIR}/../UI/obs-frontend-api")
19-
target_link_libraries(obs-streamlink libobs)
20-
21-
# Windows
22-
if(WIN32)
23-
set(OBS_FRONTEND_LIB "OBS_FRONTEND_LIB-NOTFOUND" CACHE FILEPATH "OBS frontend library")
24-
if(OBS_FRONTEND_LIB EQUAL "OBS_FRONTEND_LIB-NOTFOUND")
25-
message(FATAL_ERROR "Could not find OBS Frontend API\'s library !")
26-
endif()
27-
28-
string(REGEX REPLACE "/RTC(su|[1su])" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
29-
message("${CMAKE_CXX_FLAGS_RELEASE}")
30-
31-
set(OBS_BUILDDIR_ARCH "build")
32-
if(ARCH EQUAL 64)
33-
set(OBS_ARCH_NAME "64bit")
34-
else()
35-
set(OBS_ARCH_NAME "32bit")
36-
add_definitions(/arch:SSE2)
37-
endif()
38-
39-
find_package(w32-pthreads REQUIRED)
40-
41-
target_link_libraries(obs-streamlink
42-
"${OBS_FRONTEND_LIB}"
43-
w32-pthreads)
44-
45-
set(RELEASE_DIR "${PROJECT_SOURCE_DIR}/release")
46-
add_custom_command(TARGET obs-streamlink POST_BUILD
41+
target_include_directories(obs-streamlink PRIVATE
42+
${Qt5Core_INCLUDES}
43+
${Qt5Widgets_INCLUDES}
44+
${FFMPEG_INCLUDE_DIRS}
45+
"${LIBOBS_INCLUDE_DIR}"
46+
"${OBS_FRONTEND_INCLUDE_DIR}"
47+
"${Python3_INCLUDE_DIRS}"
48+
)
49+
set(RELEASE_DIR "${PROJECT_SOURCE_DIR}/release")
50+
target_link_options(obs-streamlink PUBLIC
51+
"/NODEFAULTLIB:python38_d.lib"
52+
"/NODEFAULTLIB:python3_d.lib"
53+
"/NODEFAULTLIB:python38.lib"
54+
"/NODEFAULTLIB:python3.lib"
55+
"/delayload:python38.dll")
56+
57+
add_custom_command(TARGET obs-streamlink POST_BUILD
4758
COMMAND if $<CONFIG:Release>==1 (
4859
"${CMAKE_COMMAND}" -E make_directory
4960
"${RELEASE_DIR}/data/obs-plugins/obs-streamlink"
@@ -59,56 +70,19 @@ if(WIN32)
5970
"$<TARGET_FILE:obs-streamlink>"
6071
"${RELEASE_DIR}/obs-plugins/${OBS_ARCH_NAME}") else (call)
6172
)
62-
63-
add_custom_command(TARGET obs-streamlink POST_BUILD
73+
add_custom_command(TARGET obs-streamlink POST_BUILD
6474
# Copy to obs-studio dev environment for immediate testing
6575
COMMAND if $<CONFIG:Debug>==1 (
6676
"${CMAKE_COMMAND}" -E copy
6777
"$<TARGET_FILE:obs-streamlink>"
68-
"${LIBOBS_INCLUDE_DIR}/../${OBS_BUILDDIR_ARCH}/rundir/$<CONFIG>/obs-plugins/${OBS_ARCH_NAME}") else (call)
78+
"D:/product/obs-studio-master/build/rundir/Debug/obs-plugins/64bit/${OBS_ARCH_NAME}") else (call)
6979

7080
COMMAND if $<CONFIG:Debug>==1 (
7181
"${CMAKE_COMMAND}" -E make_directory
72-
"${LIBOBS_INCLUDE_DIR}/../${OBS_BUILDDIR_ARCH}/rundir/$<CONFIG>/data/obs-plugins/obs-streamlink") else (call)
82+
"D:/product/obs-studio-master/build/rundir/Debug/data/obs-plugins/obs-streamlink") else (call)
7383

7484
COMMAND if $<CONFIG:Debug>==1 (
7585
"${CMAKE_COMMAND}" -E copy_directory
7686
"${PROJECT_SOURCE_DIR}/data"
77-
"${LIBOBS_INCLUDE_DIR}/../${OBS_BUILDDIR_ARCH}/rundir/$<CONFIG>/data/obs-plugins/obs-streamlink") else (call)
78-
)
79-
endif()
80-
81-
# OSX
82-
if(APPLE)
83-
set_target_properties(obs-streamlink PROPERTIES PREFIX "")
84-
target_link_libraries(obs-streamlink
85-
"${OBS_FRONTEND_LIB}")
86-
endif()
87-
88-
# Linux
89-
if(UNIX AND NOT APPLE)
90-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -mtune=core2 -Ofast")
91-
92-
if(ARCH EQUAL 64)
93-
set(ARCH_NAME "x86_64")
94-
else()
95-
set(ARCH_NAME "i686")
96-
endif()
97-
98-
set_target_properties(obs-streamlink PROPERTIES PREFIX "")
99-
100-
target_link_libraries(obs-streamlink
101-
obs-frontend-api)
102-
103-
file(GLOB locale_files data/locale/*.ini)
104-
execute_process(COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE UNAME_MACHINE)
105-
106-
install(TARGETS obs-streamlink
107-
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/obs-plugins)
108-
# Dirty fix for Ubuntu
109-
install(TARGETS obs-streamlink
110-
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/${UNAME_MACHINE}-linux-gnu/obs-plugins)
111-
112-
install(FILES ${locale_files}
113-
DESTINATION "${CMAKE_INSTALL_PREFIX}/share/obs/obs-plugins/obs-streamlink/locale")
114-
endif()
87+
"D:/product/obs-studio-master/build/rundir/Debug/data/obs-plugins/obs-streamlink") else (call)
88+
)

FindFFmpeg.cmake

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
#
2+
# This module defines the following variables:
3+
#
4+
# FFMPEG_FOUND - All required components and the core library were found
5+
# FFMPEG_INCLUDE_DIRS - Combined list of all components include dirs
6+
# FFMPEG_LIBRARIES - Combined list of all components libraries
7+
# FFMPEG_VERSION_STRING - Version of the first component requested
8+
#
9+
# For each requested component the following variables are defined:
10+
#
11+
# FFMPEG_<component>_FOUND - The component was found
12+
# FFMPEG_<component>_INCLUDE_DIRS - The components include dirs
13+
# FFMPEG_<component>_LIBRARIES - The components libraries
14+
# FFMPEG_<component>_VERSION_STRING - The components version string
15+
# FFMPEG_<component>_VERSION_MAJOR - The components major version
16+
# FFMPEG_<component>_VERSION_MINOR - The components minor version
17+
# FFMPEG_<component>_VERSION_MICRO - The components micro version
18+
#
19+
# <component> is the uppercase name of the component
20+
21+
22+
find_package(PkgConfig QUIET)
23+
24+
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
25+
set(_lib_suffix 64)
26+
else()
27+
set(_lib_suffix 32)
28+
endif()
29+
30+
function(find_ffmpeg_library component header)
31+
string(TOUPPER "${component}" component_u)
32+
set(FFMPEG_${component_u}_FOUND FALSE PARENT_SCOPE)
33+
set(FFmpeg_${component}_FOUND FALSE PARENT_SCOPE)
34+
35+
if(PKG_CONFIG_FOUND)
36+
pkg_check_modules(PC_FFMPEG_${component} QUIET lib${component})
37+
endif()
38+
39+
find_path(FFMPEG_${component}_INCLUDE_DIR
40+
NAMES
41+
"lib${component}/${header}" "lib${component}/version.h"
42+
HINTS
43+
ENV FFmpegPath${_lib_suffix}
44+
ENV FFmpegPath
45+
ENV DepsPath${_lib_suffix}
46+
ENV DepsPath
47+
${FFmpegPath${_lib_suffix}}
48+
${FFmpegPath}
49+
${DepsPath${_lib_suffix}}
50+
${DepsPath}
51+
${PC_FFMPEG_${component}_INCLUDE_DIRS}
52+
PATHS
53+
/usr/include /usr/local/include /opt/local/include /sw/include
54+
PATH_SUFFIXES ffmpeg libav include)
55+
56+
find_library(FFMPEG_${component}_LIBRARY
57+
NAMES
58+
"${component}" "lib${component}"
59+
HINTS
60+
ENV FFmpegPath${_lib_suffix}
61+
ENV FFmpegPath
62+
ENV DepsPath${_lib_suffix}
63+
ENV DepsPath
64+
${FFmpegPath${_lib_suffix}}
65+
${FFmpegPath}
66+
${DepsPath${_lib_suffix}}
67+
${DepsPath}
68+
${PC_FFMPEG_${component}_LIBRARY_DIRS}
69+
PATHS
70+
/usr/lib /usr/local/lib /opt/local/lib /sw/lib
71+
PATH_SUFFIXES
72+
lib${_lib_suffix} lib
73+
libs${_lib_suffix} libs
74+
bin${_lib_suffix} bin
75+
../lib${_lib_suffix} ../lib
76+
../libs${_lib_suffix} ../libs
77+
../bin${_lib_suffix} ../bin)
78+
79+
set(FFMPEG_${component_u}_INCLUDE_DIRS ${FFMPEG_${component}_INCLUDE_DIR} PARENT_SCOPE)
80+
set(FFMPEG_${component_u}_LIBRARIES ${FFMPEG_${component}_LIBRARY} PARENT_SCOPE)
81+
82+
mark_as_advanced(FFMPEG_${component}_INCLUDE_DIR FFMPEG_${component}_LIBRARY)
83+
84+
if(FFMPEG_${component}_INCLUDE_DIR AND FFMPEG_${component}_LIBRARY)
85+
set(FFMPEG_${component_u}_FOUND TRUE PARENT_SCOPE)
86+
set(FFmpeg_${component}_FOUND TRUE PARENT_SCOPE)
87+
88+
list(APPEND FFMPEG_INCLUDE_DIRS ${FFMPEG_${component}_INCLUDE_DIR})
89+
list(REMOVE_DUPLICATES FFMPEG_INCLUDE_DIRS)
90+
set(FFMPEG_INCLUDE_DIRS "${FFMPEG_INCLUDE_DIRS}" PARENT_SCOPE)
91+
92+
list(APPEND FFMPEG_LIBRARIES ${FFMPEG_${component}_LIBRARY})
93+
list(REMOVE_DUPLICATES FFMPEG_LIBRARIES)
94+
set(FFMPEG_LIBRARIES "${FFMPEG_LIBRARIES}" PARENT_SCOPE)
95+
96+
set(FFMPEG_${component_u}_VERSION_STRING "unknown" PARENT_SCOPE)
97+
set(_vfile "${FFMPEG_${component}_INCLUDE_DIR}/lib${component}/version.h")
98+
99+
if(EXISTS "${_vfile}")
100+
file(STRINGS "${_vfile}" _version_parse REGEX "^.*VERSION_(MAJOR|MINOR|MICRO)[ \t]+[0-9]+[ \t]*$")
101+
string(REGEX REPLACE ".*VERSION_MAJOR[ \t]+([0-9]+).*" "\\1" _major "${_version_parse}")
102+
string(REGEX REPLACE ".*VERSION_MINOR[ \t]+([0-9]+).*" "\\1" _minor "${_version_parse}")
103+
string(REGEX REPLACE ".*VERSION_MICRO[ \t]+([0-9]+).*" "\\1" _micro "${_version_parse}")
104+
105+
set(FFMPEG_${component_u}_VERSION_MAJOR "${_major}" PARENT_SCOPE)
106+
set(FFMPEG_${component_u}_VERSION_MINOR "${_minor}" PARENT_SCOPE)
107+
set(FFMPEG_${component_u}_VERSION_MICRO "${_micro}" PARENT_SCOPE)
108+
109+
set(FFMPEG_${component_u}_VERSION_STRING "${_major}.${_minor}.${_micro}" PARENT_SCOPE)
110+
else()
111+
message(STATUS "Failed parsing FFmpeg ${component} version")
112+
endif()
113+
endif()
114+
endfunction()
115+
116+
set(FFMPEG_INCLUDE_DIRS)
117+
set(FFMPEG_LIBRARIES)
118+
119+
if(NOT FFmpeg_FIND_COMPONENTS)
120+
message(FATAL_ERROR "No FFmpeg components requested")
121+
endif()
122+
123+
list(GET FFmpeg_FIND_COMPONENTS 0 _first_comp)
124+
string(TOUPPER "${_first_comp}" _first_comp)
125+
126+
foreach(component ${FFmpeg_FIND_COMPONENTS})
127+
if(component STREQUAL "avcodec")
128+
find_ffmpeg_library("${component}" "avcodec.h")
129+
elseif(component STREQUAL "avdevice")
130+
find_ffmpeg_library("${component}" "avdevice.h")
131+
elseif(component STREQUAL "avfilter")
132+
find_ffmpeg_library("${component}" "avfilter.h")
133+
elseif(component STREQUAL "avformat")
134+
find_ffmpeg_library("${component}" "avformat.h")
135+
elseif(component STREQUAL "avresample")
136+
find_ffmpeg_library("${component}" "avresample.h")
137+
elseif(component STREQUAL "avutil")
138+
find_ffmpeg_library("${component}" "avutil.h")
139+
elseif(component STREQUAL "postproc")
140+
find_ffmpeg_library("${component}" "postprocess.h")
141+
elseif(component STREQUAL "swresample")
142+
find_ffmpeg_library("${component}" "swresample.h")
143+
elseif(component STREQUAL "swscale")
144+
find_ffmpeg_library("${component}" "swscale.h")
145+
else()
146+
message(FATAL_ERROR "Unknown FFmpeg component requested: ${component}")
147+
endif()
148+
endforeach()
149+
150+
include(FindPackageHandleStandardArgs)
151+
find_package_handle_standard_args(FFmpeg
152+
FOUND_VAR FFMPEG_FOUND
153+
REQUIRED_VARS FFMPEG_${_first_comp}_LIBRARIES FFMPEG_${_first_comp}_INCLUDE_DIRS
154+
VERSION_VAR FFMPEG_${_first_comp}_VERSION_STRING
155+
HANDLE_COMPONENTS)

data/locale/en-US.ini

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
1-
Test="Test streamlink."
1+
url="url"
2+
definitions="definitions"
3+
refresh_definitions="refresh definitions"
4+
hw_decode="HardwareDecode"
5+
setting="setting"
6+
is_advanced_settings_show="show advanced settings"
7+
advanced_settings="advanced settings"
8+
advanced_settings="options"
9+
http_proxy="http proxy"
10+
https_proxy="https proxy"

data/locale/zh-CN.ini

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
url="ֱ直播间地址"
2+
definitions="分辨率"
3+
refresh_definitions="刷新分辨率列表"
4+
hw_decode="启用硬件解码"
5+
setting="设置"
6+
is_advanced_settings_show="显示高级设置"
7+
advanced_settings="高级设置"
8+
streamlink_options="配置"
9+
http_proxy="http代理"
10+
https_proxy="https代理"

0 commit comments

Comments
 (0)