Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Z
ZLMediaKit
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
张翔宇
ZLMediaKit
Commits
0739b1dd
Commit
0739b1dd
authored
May 25, 2022
by
ziyue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完成FFmpeg相关代码迁移改造
parent
fa70af7c
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
113 行增加
和
83 行删除
+113
-83
CMakeLists.txt
+103
-7
player/AudioSRC.h
+0
-1
player/CMakeLists.txt
+7
-72
player/SDLAudioDevice.h
+1
-1
player/test_player.cpp
+2
-2
没有找到文件。
CMakeLists.txt
查看文件 @
0739b1dd
...
@@ -102,6 +102,7 @@ option(ENABLE_MEM_DEBUG "Enable Memory Debug" false)
...
@@ -102,6 +102,7 @@ option(ENABLE_MEM_DEBUG "Enable Memory Debug" false)
option
(
ENABLE_ASAN
"Enable Address Sanitize"
false
)
option
(
ENABLE_ASAN
"Enable Address Sanitize"
false
)
option
(
ENABLE_WEBRTC
"Enable WebRTC"
true
)
option
(
ENABLE_WEBRTC
"Enable WebRTC"
true
)
option
(
ENABLE_PLAYER
"Enable Player"
true
)
option
(
ENABLE_PLAYER
"Enable Player"
true
)
option
(
ENABLE_FFMPEG
"Enable FFmpeg"
true
)
option
(
ENABLE_MSVC_MT
"Enable MSVC Mt/Mtd lib"
true
)
option
(
ENABLE_MSVC_MT
"Enable MSVC Mt/Mtd lib"
true
)
option
(
ENABLE_API_STATIC_LIB
"Enable mk_api static lib"
false
)
option
(
ENABLE_API_STATIC_LIB
"Enable mk_api static lib"
false
)
option
(
USE_SOLUTION_FOLDERS
"Enable solution dir supported"
ON
)
option
(
USE_SOLUTION_FOLDERS
"Enable solution dir supported"
ON
)
...
@@ -200,13 +201,108 @@ endif ()
...
@@ -200,13 +201,108 @@ endif ()
set
(
LINK_LIB_LIST zlmediakit zltoolkit
)
set
(
LINK_LIB_LIST zlmediakit zltoolkit
)
##默认链接jemalloc库避免内存碎片
if
(
ENABLE_FFMPEG
)
#find_package(JEMALLOC QUIET)
find_package
(
PkgConfig QUIET
)
#if (JEMALLOC_FOUND)
#查找ffmpeg/libutil是否安装
# message(STATUS "found library:\"${JEMALLOC_LIBRARIES}\"")
if
(
PKG_CONFIG_FOUND
)
# include_directories(${JEMALLOC_INCLUDE_DIR})
pkg_check_modules
(
AVUTIL QUIET IMPORTED_TARGET libavutil
)
# list(APPEND LINK_LIB_LIST ${JEMALLOC_LIBRARIES})
if
(
AVUTIL_FOUND
)
#endif ()
include_directories
(
${
AVUTIL_INCLUDE_DIRS
}
)
link_directories
(
${
AVUTIL_LIBRARY_DIRS
}
)
list
(
APPEND LINK_LIB_LIST
${
AVUTIL_LIBRARIES
}
)
message
(
STATUS
"found library:
${
AVUTIL_LIBRARIES
}
"
)
endif
()
endif
()
#查找ffmpeg/libavcodec是否安装
if
(
PKG_CONFIG_FOUND
)
pkg_check_modules
(
AVCODEC QUIET IMPORTED_TARGET libavcodec
)
if
(
AVCODEC_FOUND
)
include_directories
(
${
AVCODEC_INCLUDE_DIRS
}
)
link_directories
(
${
AVCODEC_LIBRARY_DIRS
}
)
list
(
APPEND LINK_LIB_LIST
${
AVCODEC_LIBRARIES
}
)
message
(
STATUS
"found library:
${
AVCODEC_LIBRARIES
}
"
)
endif
()
endif
()
#查找ffmpeg/libswscale是否安装
if
(
PKG_CONFIG_FOUND
)
pkg_check_modules
(
SWSCALE QUIET IMPORTED_TARGET libswscale
)
if
(
SWSCALE_FOUND
)
include_directories
(
${
SWSCALE_INCLUDE_DIRS
}
)
link_directories
(
${
SWSCALE_LIBRARY_DIRS
}
)
list
(
APPEND LINK_LIB_LIST
${
SWSCALE_LIBRARIES
}
)
message
(
STATUS
"found library:
${
SWSCALE_LIBRARIES
}
"
)
endif
()
endif
()
#查找ffmpeg/libswresample是否安装
if
(
PKG_CONFIG_FOUND
)
pkg_check_modules
(
SWRESAMPLE QUIET IMPORTED_TARGET libswresample
)
if
(
SWRESAMPLE_FOUND
)
include_directories
(
${
SWRESAMPLE_INCLUDE_DIRS
}
)
link_directories
(
${
SWRESAMPLE_LIBRARY_DIRS
}
)
list
(
APPEND LINK_LIB_LIST
${
SWRESAMPLE_LIBRARIES
}
)
message
(
STATUS
"found library:
${
SWRESAMPLE_LIBRARIES
}
"
)
endif
()
endif
()
#查找ffmpeg/libutil是否安装
if
(
NOT AVUTIL_FOUND
)
find_package
(
AVUTIL QUIET
)
if
(
AVUTIL_FOUND
)
include_directories
(
${
AVUTIL_INCLUDE_DIR
}
)
list
(
APPEND LINK_LIB_LIST
${
AVUTIL_LIBRARIES
}
)
message
(
STATUS
"found library:
${
AVUTIL_LIBRARIES
}
"
)
endif
()
endif
()
#查找ffmpeg/libavcodec是否安装
if
(
NOT AVCODEC_FOUND
)
find_package
(
AVCODEC QUIET
)
if
(
AVCODEC_FOUND
)
include_directories
(
${
AVCODEC_INCLUDE_DIR
}
)
list
(
APPEND LINK_LIB_LIST
${
AVCODEC_LIBRARIES
}
)
message
(
STATUS
"found library:
${
AVCODEC_LIBRARIES
}
"
)
endif
()
endif
()
#查找ffmpeg/libswscale是否安装
if
(
NOT SWSCALE_FOUND
)
find_package
(
SWSCALE QUIET
)
if
(
SWSCALE_FOUND
)
include_directories
(
${
SWSCALE_INCLUDE_DIR
}
)
list
(
APPEND LINK_LIB_LIST
${
SWSCALE_LIBRARIES
}
)
message
(
STATUS
"found library:
${
SWSCALE_LIBRARIES
}
"
)
endif
()
endif
()
#查找ffmpeg/libswresample是否安装
if
(
NOT SWRESAMPLE_FOUND
)
find_package
(
SWRESAMPLE QUIET
)
if
(
SWRESAMPLE_FOUND
)
include_directories
(
${
SWRESAMPLE_INCLUDE_DIRS
}
)
list
(
APPEND LINK_LIB_LIST
${
SWRESAMPLE_LIBRARIES
}
)
message
(
STATUS
"found library:
${
SWRESAMPLE_LIBRARIES
}
"
)
endif
()
endif
()
if
(
AVUTIL_FOUND AND AVCODEC_FOUND AND SWSCALE_FOUND AND SWRESAMPLE_FOUND
)
add_definitions
(
-DENABLE_FFMPEG
)
else
()
set
(
ENABLE_FFMPEG off
)
message
(
WARNING
"ffmpeg相关功能未找到"
)
endif
()
endif
()
#默认链接jemalloc库避免内存碎片
find_package
(
JEMALLOC QUIET
)
if
(
JEMALLOC_FOUND
)
message
(
STATUS
"found library:
\"
${
JEMALLOC_LIBRARIES
}
\"
"
)
include_directories
(
${
JEMALLOC_INCLUDE_DIR
}
)
list
(
APPEND LINK_LIB_LIST
${
JEMALLOC_LIBRARIES
}
)
endif
()
#查找openssl是否安装
#查找openssl是否安装
find_package
(
OpenSSL QUIET
)
find_package
(
OpenSSL QUIET
)
...
...
player/AudioSRC.h
查看文件 @
0739b1dd
...
@@ -28,7 +28,6 @@ extern "C" {
...
@@ -28,7 +28,6 @@ extern "C" {
#include "Network/Buffer.h"
#include "Network/Buffer.h"
#include "SDLAudioDevice.h"
#include "SDLAudioDevice.h"
#include "FFMpegDecoder.h"
class
AudioSRCDelegate
{
class
AudioSRCDelegate
{
public
:
public
:
...
...
player/CMakeLists.txt
查看文件 @
0739b1dd
find_package
(
PkgConfig QUIET
)
if
(
NOT ENABLE_FFMPEG
)
return
()
endif
()
find_package
(
PkgConfig QUIET
)
#查找SDL2是否安装
#查找SDL2是否安装
if
(
PKG_CONFIG_FOUND
)
if
(
PKG_CONFIG_FOUND
)
pkg_check_modules
(
SDL2 QUIET IMPORTED_TARGET sdl2
)
pkg_check_modules
(
SDL2 QUIET IMPORTED_TARGET sdl2
)
...
@@ -18,70 +21,16 @@ else ()
...
@@ -18,70 +21,16 @@ else ()
endif
(
SDL2_FOUND
)
endif
(
SDL2_FOUND
)
endif
()
endif
()
#查找ffmpeg/libutil是否安装
if
(
PKG_CONFIG_FOUND
)
pkg_check_modules
(
AVUTIL QUIET IMPORTED_TARGET libavutil
)
if
(
AVUTIL_FOUND
)
include_directories
(
${
AVUTIL_INCLUDE_DIRS
}
)
link_directories
(
${
AVUTIL_LIBRARY_DIRS
}
)
list
(
APPEND LINK_LIB_LIST
${
AVUTIL_LIBRARIES
}
)
message
(
STATUS
"found library:
${
AVUTIL_LIBRARIES
}
"
)
endif
()
else
()
find_package
(
AVUTIL QUIET
)
if
(
AVUTIL_FOUND
)
include_directories
(
${
AVUTIL_INCLUDE_DIR
}
)
list
(
APPEND LINK_LIB_LIST
${
AVUTIL_LIBRARIES
}
)
message
(
STATUS
"found library:
${
AVUTIL_LIBRARIES
}
"
)
endif
()
endif
()
#查找ffmpeg/libswresample是否安装
if
(
PKG_CONFIG_FOUND
)
pkg_check_modules
(
SWRESAMPLE QUIET IMPORTED_TARGET libswresample
)
if
(
SWRESAMPLE_FOUND
)
include_directories
(
${
SWRESAMPLE_INCLUDE_DIRS
}
)
link_directories
(
${
SWRESAMPLE_LIBRARY_DIRS
}
)
list
(
APPEND LINK_LIB_LIST
${
SWRESAMPLE_LIBRARIES
}
)
message
(
STATUS
"found library:
${
SWRESAMPLE_LIBRARIES
}
"
)
endif
()
else
()
find_package
(
SWRESAMPLE QUIET
)
if
(
SWRESAMPLE_FOUND
)
include_directories
(
${
SWRESAMPLE_INCLUDE_DIR
}
)
list
(
APPEND LINK_LIB_LIST
${
SWRESAMPLE_LIBRARIES
}
)
message
(
STATUS
"found library:
${
SWRESAMPLE_LIBRARIES
}
"
)
endif
()
endif
()
#查找ffmpeg/libavcodec是否安装
if
(
PKG_CONFIG_FOUND
)
pkg_check_modules
(
AVCODEC QUIET IMPORTED_TARGET libavcodec
)
if
(
AVCODEC_FOUND
)
include_directories
(
${
AVCODEC_INCLUDE_DIRS
}
)
link_directories
(
${
AVCODEC_LIBRARY_DIRS
}
)
list
(
APPEND LINK_LIB_LIST
${
AVCODEC_LIBRARIES
}
)
message
(
STATUS
"found library:
${
AVCODEC_LIBRARIES
}
"
)
endif
()
else
()
find_package
(
AVCODEC QUIET
)
if
(
AVCODEC_FOUND
)
include_directories
(
${
AVCODEC_INCLUDE_DIR
}
)
list
(
APPEND LINK_LIB_LIST
${
AVCODEC_LIBRARIES
}
)
message
(
STATUS
"found library:
${
AVCODEC_LIBRARIES
}
"
)
endif
()
endif
()
set
(
PLAYER_NAME
"test_player"
)
set
(
PLAYER_NAME
"test_player"
)
#如果ffmpeg/libavcodec ffmpeg/libavcodec SDL 都安装了则编译播放器
#如果ffmpeg/libavcodec ffmpeg/libavcodec SDL 都安装了则编译播放器
if
(
SDL2_FOUND AND AVCODEC_FOUND AND AVUTIL_FOUND AND SWRESAMPLE_FOUND
)
if
(
NOT SDL2_FOUND
)
message
(
STATUS
"
${
PLAYER_NAME
}
enabled"
)
else
()
message
(
STATUS
"
${
PLAYER_NAME
}
disabled, please install sdl2 ffmpeg/libavcodec ffmpeg/libavutil ffmpeg/libswresample"
)
message
(
STATUS
"
${
PLAYER_NAME
}
disabled, please install sdl2 ffmpeg/libavcodec ffmpeg/libavutil ffmpeg/libswresample"
)
return
()
return
()
endif
()
endif
()
message
(
STATUS
"
${
PLAYER_NAME
}
enabled"
)
aux_source_directory
(
. SRC_LIST
)
aux_source_directory
(
. SRC_LIST
)
add_executable
(
${
PLAYER_NAME
}
${
SRC_LIST
}
)
add_executable
(
${
PLAYER_NAME
}
${
SRC_LIST
}
)
...
@@ -95,17 +44,3 @@ if (CMAKE_SYSTEM_NAME MATCHES "Linux")
...
@@ -95,17 +44,3 @@ if (CMAKE_SYSTEM_NAME MATCHES "Linux")
else
()
else
()
target_link_libraries
(
${
PLAYER_NAME
}
${
LINK_LIB_LIST
}
)
target_link_libraries
(
${
PLAYER_NAME
}
${
LINK_LIB_LIST
}
)
endif
()
endif
()
player/SDLAudioDevice.h
查看文件 @
0739b1dd
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
#define DEFAULT_SAMPLERATE 48000
#define DEFAULT_SAMPLERATE 48000
#define DEFAULT_FORMAT AUDIO_S16
#define DEFAULT_FORMAT AUDIO_S16
#define DEFAULT_CHANNEL 2
#define DEFAULT_CHANNEL 2
#define DEFAULT_SAMPLES
1024
#define DEFAULT_SAMPLES
2048
class
AudioSRC
;
class
AudioSRC
;
...
...
player/test_player.cpp
查看文件 @
0739b1dd
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
#include "Rtsp/UDPServer.h"
#include "Rtsp/UDPServer.h"
#include "Player/MediaPlayer.h"
#include "Player/MediaPlayer.h"
#include "Util/onceToken.h"
#include "Util/onceToken.h"
#include "
FFMpegDecoder
.h"
#include "
Codec/Transcode
.h"
#include "YuvDisplayer.h"
#include "YuvDisplayer.h"
#include "AudioSRC.h"
#include "AudioSRC.h"
using
namespace
std
;
using
namespace
std
;
...
@@ -103,7 +103,7 @@ int main(int argc, char *argv[]) {
...
@@ -103,7 +103,7 @@ int main(int argc, char *argv[]) {
}
}
auto
pcm
=
swr
->
inputFrame
(
frame
);
auto
pcm
=
swr
->
inputFrame
(
frame
);
auto
len
=
pcm
->
get
()
->
nb_samples
*
pcm
->
get
()
->
channels
*
av_get_bytes_per_sample
((
enum
AVSampleFormat
)
pcm
->
get
()
->
format
);
auto
len
=
pcm
->
get
()
->
nb_samples
*
pcm
->
get
()
->
channels
*
av_get_bytes_per_sample
((
enum
AVSampleFormat
)
pcm
->
get
()
->
format
);
audio_player
->
playPCM
((
const
char
*
)
(
pcm
->
get
()
->
data
[
0
]),
len
);
audio_player
->
playPCM
((
const
char
*
)
(
pcm
->
get
()
->
data
[
0
]),
MIN
(
len
,
frame
->
get
()
->
linesize
[
0
])
);
});
});
auto
audio_delegate
=
std
::
make_shared
<
FrameWriterInterfaceHelper
>
(
[
decoder
](
const
Frame
::
Ptr
&
frame
)
{
auto
audio_delegate
=
std
::
make_shared
<
FrameWriterInterfaceHelper
>
(
[
decoder
](
const
Frame
::
Ptr
&
frame
)
{
return
decoder
->
inputFrame
(
frame
,
false
);
return
decoder
->
inputFrame
(
frame
,
false
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论