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
0d9bdec1
Commit
0d9bdec1
authored
Dec 06, 2019
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
支持rtp代理服务器
parent
55814070
隐藏空白字符变更
内嵌
并排
正在显示
26 个修改的文件
包含
638 行增加
和
630 行删除
+638
-630
3rdpart/media-server
+1
-1
CMakeLists.txt
+29
-55
LICENSE
+2
-0
README.md
+3
-0
conf/config.ini
+12
-0
server/WebApi.cpp
+2
-0
server/main.cpp
+32
-14
src/Common/config.cpp
+22
-0
src/Common/config.h
+11
-5
src/Rtp/PSDecoder.cpp
+36
-27
src/Rtp/PSDecoder.h
+35
-37
src/Rtp/RtpDecoder.cpp
+33
-24
src/Rtp/RtpDecoder.h
+31
-36
src/Rtp/RtpFileLoader.cpp
+0
-79
src/Rtp/RtpFileLoader.h
+0
-39
src/Rtp/RtpProcess.cpp
+39
-56
src/Rtp/RtpProcess.h
+34
-29
src/Rtp/RtpSelector.cpp
+31
-24
src/Rtp/RtpSelector.h
+32
-29
src/Rtp/RtpSession.cpp
+31
-24
src/Rtp/RtpSession.h
+32
-29
src/Rtp/RtpSplitter.cpp
+31
-26
src/Rtp/RtpSplitter.h
+32
-29
src/Rtp/UdpRecver.cpp
+31
-24
src/Rtp/UdpRecver.h
+30
-26
tests/test_rtp.cpp
+66
-17
没有找到文件。
media-server
@
358b7bd3
Subproject commit
678678b2ee7118d21d33a90a303698e0da02790c
Subproject commit
358b7bd3bf89564371fed48797ad396882f9d130
CMakeLists.txt
查看文件 @
0d9bdec1
...
@@ -30,29 +30,15 @@ endif ()
...
@@ -30,29 +30,15 @@ endif ()
LINK_DIRECTORIES
(
${
LIBRARY_OUTPUT_PATH
}
)
LINK_DIRECTORIES
(
${
LIBRARY_OUTPUT_PATH
}
)
#设置工程源码根目录
#设置工程源码根目录
set
(
ToolKit_Root
${
CMAKE_CURRENT_SOURCE_DIR
}
/3rdpart/ZLToolKit/src
)
set
(
ToolKit_Root
${
CMAKE_CURRENT_SOURCE_DIR
}
/3rdpart/ZLToolKit/src
)
set
(
MediaKit_Root
${
CMAKE_CURRENT_SOURCE_DIR
}
/src
)
set
(
MediaKit_Root
${
CMAKE_CURRENT_SOURCE_DIR
}
/src
)
set
(
MediaServer_Root
${
CMAKE_CURRENT_SOURCE_DIR
}
/3rdpart/media-server
)
set
(
MediaServer_Root
${
CMAKE_CURRENT_SOURCE_DIR
}
/3rdpart/media-server
)
#设置头文件目录
#设置头文件目录
INCLUDE_DIRECTORIES
(
${
ToolKit_Root
}
)
INCLUDE_DIRECTORIES
(
${
ToolKit_Root
}
)
INCLUDE_DIRECTORIES
(
${
MediaKit_Root
}
)
INCLUDE_DIRECTORIES
(
${
MediaKit_Root
}
)
#收集源代码
file
(
GLOB ToolKit_src_list
${
ToolKit_Root
}
/*/*.cpp
${
ToolKit_Root
}
/*/*.h
${
ToolKit_Root
}
/*/*.c
)
file
(
GLOB MediaKit_src_list
${
MediaKit_Root
}
/*/*.cpp
${
MediaKit_Root
}
/*/*.h
${
MediaKit_Root
}
/*/*.c
)
#去除win32的适配代码
if
(
NOT WIN32
)
list
(
REMOVE_ITEM ToolKit_src_list
${
ToolKit_Root
}
/win32/getopt.c
)
else
()
#防止Windows.h包含Winsock.h
add_definitions
(
-DWIN32_LEAN_AND_MEAN -DMP4V2_NO_STDINT_DEFS
)
endif
()
set
(
ENABLE_HLS true
)
set
(
ENABLE_HLS true
)
set
(
ENABLE_OPENSSL true
)
set
(
ENABLE_OPENSSL true
)
set
(
ENABLE_MYSQL false
)
set
(
ENABLE_MYSQL false
)
...
@@ -60,6 +46,7 @@ set(ENABLE_MP4V2 true)
...
@@ -60,6 +46,7 @@ set(ENABLE_MP4V2 true)
set
(
ENABLE_FAAC false
)
set
(
ENABLE_FAAC false
)
set
(
ENABLE_X264 false
)
set
(
ENABLE_X264 false
)
set
(
ENABLE_MP4RECORD true
)
set
(
ENABLE_MP4RECORD true
)
set
(
ENABLE_RTPPROXY true
)
set
(
LINK_LIB_LIST zlmediakit zltoolkit
)
set
(
LINK_LIB_LIST zlmediakit zltoolkit
)
...
@@ -109,6 +96,15 @@ if (FAAC_FOUND AND ENABLE_FAAC)
...
@@ -109,6 +96,15 @@ if (FAAC_FOUND AND ENABLE_FAAC)
list
(
APPEND LINK_LIB_LIST
${
FAAC_LIBRARIES
}
)
list
(
APPEND LINK_LIB_LIST
${
FAAC_LIBRARIES
}
)
endif
()
endif
()
if
(
${
CMAKE_BUILD_TYPE
}
MATCHES
"Release"
)
#查找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
()
endif
()
set
(
VS_FALGS
"/wd4819 /wd4996 /wd4018 /wd4267 /wd4244 /wd4101 /wd4828 /wd4309 /wd4573"
)
set
(
VS_FALGS
"/wd4819 /wd4996 /wd4018 /wd4267 /wd4244 /wd4101 /wd4828 /wd4309 /wd4573"
)
...
@@ -151,24 +147,28 @@ if(ENABLE_MP4RECORD)
...
@@ -151,24 +147,28 @@ if(ENABLE_MP4RECORD)
endif
(
WIN32
)
endif
(
WIN32
)
endif
()
endif
()
if
(
${
CMAKE_BUILD_TYPE
}
MATCHES
"Release"
)
if
(
ENABLE_RTPPROXY
)
#查找jemalloc是否安装
#添加rtp库用于rtp转ps/ts
find_package
(
JEMALLOC QUIET
)
aux_source_directory
(
${
MediaServer_Root
}
/librtp/include src_rtp
)
if
(
JEMALLOC_FOUND
)
aux_source_directory
(
${
MediaServer_Root
}
/librtp/source src_rtp
)
message
(
STATUS
"found library:
\"
${
JEMALLOC_LIBRARIES
}
\"
"
)
aux_source_directory
(
${
MediaServer_Root
}
/librtp/payload src_rtp
)
include_directories
(
${
JEMALLOC_INCLUDE_DIR
}
)
include_directories
(
${
MediaServer_Root
}
/librtp/include
)
list
(
APPEND LINK_LIB_LIST
${
JEMALLOC_LIBRARIES
}
)
add_library
(
rtp STATIC
${
src_rtp
}
)
endif
()
add_definitions
(
-DENABLE_RTPPROXY
)
list
(
APPEND LINK_LIB_LIST rtp
)
endif
()
endif
()
#收集源代码
file
(
GLOB ToolKit_src_list
${
ToolKit_Root
}
/*/*.cpp
${
ToolKit_Root
}
/*/*.h
${
ToolKit_Root
}
/*/*.c
)
file
(
GLOB MediaKit_src_list
${
MediaKit_Root
}
/*/*.cpp
${
MediaKit_Root
}
/*/*.h
${
MediaKit_Root
}
/*/*.c
)
#
添加rtp库用于rtp转ps/ts
#
去除win32的适配代码
aux_source_directory
(
${
MediaServer_Root
}
/librtp/include src_rtp
)
if
(
NOT WIN32
)
aux_source_directory
(
${
MediaServer_Root
}
/librtp/source src_rtp
)
list
(
REMOVE_ITEM ToolKit_src_list
${
ToolKit_Root
}
/win32/getopt.c
)
aux_source_directory
(
${
MediaServer_Root
}
/librtp/payload src_rtp
)
else
(
)
include_directories
(
${
MediaServer_Root
}
/librtp/include
)
#防止Windows.h包含Winsock.h
add_library
(
rtp STATIC
${
src_rtp
}
)
add_definitions
(
-DWIN32_LEAN_AND_MEAN -DMP4V2_NO_STDINT_DEFS
)
list
(
APPEND LINK_LIB_LIST rtp
)
endif
(
)
#添加库
#添加库
add_library
(
zltoolkit STATIC
${
ToolKit_src_list
}
)
add_library
(
zltoolkit STATIC
${
ToolKit_src_list
}
)
...
@@ -182,34 +182,8 @@ elseif(NOT ANDROID OR IOS)
...
@@ -182,34 +182,8 @@ elseif(NOT ANDROID OR IOS)
list
(
APPEND LINK_LIB_LIST pthread
)
list
(
APPEND LINK_LIB_LIST pthread
)
endif
()
endif
()
#测试程序
#测试程序
add_subdirectory
(
tests
)
add_subdirectory
(
tests
)
#主服务器
#主服务器
add_subdirectory
(
server
)
add_subdirectory
(
server
)
LICENSE
查看文件 @
0d9bdec1
MIT License
MIT License
Copyright (c) 2016-2019 xiongziliang <771730766@qq.com>
Copyright (c) 2016-2019 xiongziliang <771730766@qq.com>
Copyright (c) 2019 Gemfield <gemfield@civilnet.cn>
Copyright (c) 2018 huohuo <913481084@qq.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
of this software and associated documentation files (the "Software"), to deal
...
...
README.md
查看文件 @
0d9bdec1
...
@@ -331,6 +331,8 @@ docker build -t zlmediakit .
...
@@ -331,6 +331,8 @@ docker build -t zlmediakit .
MIT License
MIT License
Copyright (c) 2016-2019 xiongziliang
<771730766@qq.com>
Copyright (c) 2016-2019 xiongziliang
<771730766@qq.com>
Copyright (c) 2019 Gemfield
<gemfield@civilnet.cn>
Copyright (c) 2018 huohuo
<913481084@qq.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
of this software and associated documentation files (the "Software"), to deal
...
@@ -349,6 +351,7 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
...
@@ -349,6 +351,7 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
```
```
...
...
conf/config.ini
查看文件 @
0d9bdec1
...
@@ -161,6 +161,18 @@ maxRtpCount=50
...
@@ -161,6 +161,18 @@ maxRtpCount=50
#视频mtu大小,该参数限制rtp最大字节数,推荐不要超过1400
#视频mtu大小,该参数限制rtp最大字节数,推荐不要超过1400
videoMtuSize
=
1400
videoMtuSize
=
1400
[rtp_proxy]
#udp类型的代理服务器是否检查rtp源地址,地址不配备将丢弃数据
checkSource
=
1
#导出调试数据(包括rtp/ps/h264)至该目录,置空则关闭数据导出
dumpDir
=
#udp和tcp代理服务器,支持rtp(必须是ts或ps类型)代理
port
=
10000
#rtp如果是ts/ps类型则选择MP2P,还可以设置为MP4V-ES
rtp_type
=
MP2P
#rtp超时时间,单位秒
timeoutSec
=
15
[rtsp]
[rtsp]
#rtsp专有鉴权方式是采用base64还是md5方式
#rtsp专有鉴权方式是采用base64还是md5方式
authBasic
=
0
authBasic
=
0
...
...
server/WebApi.cpp
查看文件 @
0d9bdec1
...
@@ -693,6 +693,7 @@ void installWebApi() {
...
@@ -693,6 +693,7 @@ void installWebApi() {
invoker
.
responseFile
(
headerIn
,
StrCaseMap
(),
exePath
());
invoker
.
responseFile
(
headerIn
,
StrCaseMap
(),
exePath
());
});
});
#if defined(ENABLE_RTPPROXY)
API_REGIST
(
api
,
getSsrcInfo
,{
API_REGIST
(
api
,
getSsrcInfo
,{
CHECK_SECRET
();
CHECK_SECRET
();
CHECK_ARGS
(
"ssrc"
);
CHECK_ARGS
(
"ssrc"
);
...
@@ -705,6 +706,7 @@ void installWebApi() {
...
@@ -705,6 +706,7 @@ void installWebApi() {
val
[
"peer_ip"
]
=
process
->
get_peer_ip
();
val
[
"peer_ip"
]
=
process
->
get_peer_ip
();
val
[
"peer_port"
]
=
process
->
get_peer_port
();
val
[
"peer_port"
]
=
process
->
get_peer_port
();
});
});
#endif//ENABLE_RTPPROXY
// 开始录制hls或MP4
// 开始录制hls或MP4
API_REGIST
(
api
,
startRecord
,{
API_REGIST
(
api
,
startRecord
,{
...
...
server/main.cpp
查看文件 @
0d9bdec1
...
@@ -38,11 +38,11 @@
...
@@ -38,11 +38,11 @@
#include "Common/config.h"
#include "Common/config.h"
#include "Rtsp/UDPServer.h"
#include "Rtsp/UDPServer.h"
#include "Rtsp/RtspSession.h"
#include "Rtsp/RtspSession.h"
#include "Rtp/RtpSession.h"
#include "Rtmp/RtmpSession.h"
#include "Rtmp/RtmpSession.h"
#include "Shell/ShellSession.h"
#include "Shell/ShellSession.h"
#include "Rtmp/FlvMuxer.h"
#include "Player/PlayerProxy.h"
#include "Http/WebSocketSession.h"
#include "Http/WebSocketSession.h"
#include "Rtp/UdpRecver.h"
#include "WebApi.h"
#include "WebApi.h"
#include "WebHook.h"
#include "WebHook.h"
...
@@ -58,36 +58,31 @@ namespace mediakit {
...
@@ -58,36 +58,31 @@ namespace mediakit {
////////////HTTP配置///////////
////////////HTTP配置///////////
namespace
Http
{
namespace
Http
{
#define HTTP_FIELD "http."
#define HTTP_FIELD "http."
#define HTTP_PORT 80
const
string
kPort
=
HTTP_FIELD
"port"
;
const
string
kPort
=
HTTP_FIELD
"port"
;
#define HTTPS_PORT 443
const
string
kSSLPort
=
HTTP_FIELD
"sslport"
;
const
string
kSSLPort
=
HTTP_FIELD
"sslport"
;
onceToken
token1
([](){
onceToken
token1
([](){
mINI
::
Instance
()[
kPort
]
=
HTTP_PORT
;
mINI
::
Instance
()[
kPort
]
=
80
;
mINI
::
Instance
()[
kSSLPort
]
=
HTTPS_PORT
;
mINI
::
Instance
()[
kSSLPort
]
=
443
;
},
nullptr
);
},
nullptr
);
}
//namespace Http
}
//namespace Http
////////////SHELL配置///////////
////////////SHELL配置///////////
namespace
Shell
{
namespace
Shell
{
#define SHELL_FIELD "shell."
#define SHELL_FIELD "shell."
#define SHELL_PORT 9000
const
string
kPort
=
SHELL_FIELD
"port"
;
const
string
kPort
=
SHELL_FIELD
"port"
;
onceToken
token1
([](){
onceToken
token1
([](){
mINI
::
Instance
()[
kPort
]
=
SHELL_PORT
;
mINI
::
Instance
()[
kPort
]
=
9000
;
},
nullptr
);
},
nullptr
);
}
//namespace Shell
}
//namespace Shell
////////////RTSP服务器配置///////////
////////////RTSP服务器配置///////////
namespace
Rtsp
{
namespace
Rtsp
{
#define RTSP_FIELD "rtsp."
#define RTSP_FIELD "rtsp."
#define RTSP_PORT 554
#define RTSPS_PORT 322
const
string
kPort
=
RTSP_FIELD
"port"
;
const
string
kPort
=
RTSP_FIELD
"port"
;
const
string
kSSLPort
=
RTSP_FIELD
"sslport"
;
const
string
kSSLPort
=
RTSP_FIELD
"sslport"
;
onceToken
token1
([](){
onceToken
token1
([](){
mINI
::
Instance
()[
kPort
]
=
RTSP_PORT
;
mINI
::
Instance
()[
kPort
]
=
554
;
mINI
::
Instance
()[
kSSLPort
]
=
RTSPS_PORT
;
mINI
::
Instance
()[
kSSLPort
]
=
332
;
},
nullptr
);
},
nullptr
);
}
//namespace Rtsp
}
//namespace Rtsp
...
@@ -95,12 +90,21 @@ onceToken token1([](){
...
@@ -95,12 +90,21 @@ onceToken token1([](){
////////////RTMP服务器配置///////////
////////////RTMP服务器配置///////////
namespace
Rtmp
{
namespace
Rtmp
{
#define RTMP_FIELD "rtmp."
#define RTMP_FIELD "rtmp."
#define RTMP_PORT 1935
const
string
kPort
=
RTMP_FIELD
"port"
;
const
string
kPort
=
RTMP_FIELD
"port"
;
onceToken
token1
([](){
onceToken
token1
([](){
mINI
::
Instance
()[
kPort
]
=
RTMP_PORT
;
mINI
::
Instance
()[
kPort
]
=
1935
;
},
nullptr
);
},
nullptr
);
}
//namespace RTMP
}
//namespace RTMP
////////////Rtp代理相关配置///////////
namespace
RtpProxy
{
#define RTP_PROXY_FIELD "rtp_proxy."
const
string
kPort
=
RTP_PROXY_FIELD
"port"
;
onceToken
token1
([](){
mINI
::
Instance
()[
kPort
]
=
10000
;
},
nullptr
);
}
//namespace RtpProxy
}
// namespace mediakit
}
// namespace mediakit
...
@@ -269,6 +273,7 @@ int start_main(int argc,char *argv[]) {
...
@@ -269,6 +273,7 @@ int start_main(int argc,char *argv[]) {
uint16_t
rtmpPort
=
mINI
::
Instance
()[
Rtmp
::
kPort
];
uint16_t
rtmpPort
=
mINI
::
Instance
()[
Rtmp
::
kPort
];
uint16_t
httpPort
=
mINI
::
Instance
()[
Http
::
kPort
];
uint16_t
httpPort
=
mINI
::
Instance
()[
Http
::
kPort
];
uint16_t
httpsPort
=
mINI
::
Instance
()[
Http
::
kSSLPort
];
uint16_t
httpsPort
=
mINI
::
Instance
()[
Http
::
kSSLPort
];
uint16_t
rtp_proxy
=
mINI
::
Instance
()[
RtpProxy
::
kPort
];
//设置poller线程数,该函数必须在使用ZLToolKit网络相关对象之前调用才能生效
//设置poller线程数,该函数必须在使用ZLToolKit网络相关对象之前调用才能生效
EventPollerPool
::
setPoolSize
(
threads
);
EventPollerPool
::
setPoolSize
(
threads
);
...
@@ -284,6 +289,11 @@ int start_main(int argc,char *argv[]) {
...
@@ -284,6 +289,11 @@ int start_main(int argc,char *argv[]) {
//支持ssl加密的rtsp服务器,可用于诸如亚马逊echo show这样的设备访问
//支持ssl加密的rtsp服务器,可用于诸如亚马逊echo show这样的设备访问
TcpServer
::
Ptr
rtspSSLSrv
(
new
TcpServer
());
TcpServer
::
Ptr
rtspSSLSrv
(
new
TcpServer
());
#if defined(ENABLE_RTPPROXY)
UdpRecver
recver
;
TcpServer
::
Ptr
tcpRtpServer
(
new
TcpServer
());
#endif//defined(ENABLE_RTPPROXY)
try
{
try
{
//rtsp服务器,端口默认554
//rtsp服务器,端口默认554
rtspSrv
->
start
<
RtspSession
>
(
rtspPort
);
//默认554
rtspSrv
->
start
<
RtspSession
>
(
rtspPort
);
//默认554
...
@@ -297,6 +307,14 @@ int start_main(int argc,char *argv[]) {
...
@@ -297,6 +307,14 @@ int start_main(int argc,char *argv[]) {
httpsSrv
->
start
<
HttpsSession
>
(
httpsPort
);
httpsSrv
->
start
<
HttpsSession
>
(
httpsPort
);
//telnet远程调试服务器
//telnet远程调试服务器
shellSrv
->
start
<
ShellSession
>
(
shellPort
);
shellSrv
->
start
<
ShellSession
>
(
shellPort
);
#if defined(ENABLE_RTPPROXY)
//创建rtp udp服务器
recver
.
initSock
(
rtp_proxy
);
//创建rtp tcp服务器
tcpRtpServer
->
start
<
RtpSession
>
(
rtp_proxy
);
#endif//defined(ENABLE_RTPPROXY)
}
catch
(
std
::
exception
&
ex
){
}
catch
(
std
::
exception
&
ex
){
WarnL
<<
"端口占用或无权限:"
<<
ex
.
what
()
<<
endl
;
WarnL
<<
"端口占用或无权限:"
<<
ex
.
what
()
<<
endl
;
ErrorL
<<
"程序启动失败,请修改配置文件中端口号后重试!"
<<
endl
;
ErrorL
<<
"程序启动失败,请修改配置文件中端口号后重试!"
<<
endl
;
...
...
src/Common/config.cpp
查看文件 @
0d9bdec1
...
@@ -275,6 +275,28 @@ onceToken token([](){
...
@@ -275,6 +275,28 @@ onceToken token([](){
},
nullptr
);
},
nullptr
);
}
//namespace Hls
}
//namespace Hls
////////////Rtp代理相关配置///////////
namespace
RtpProxy
{
#define RTP_PROXY_FIELD "rtp_proxy."
//rtp调试数据保存目录
const
string
kDumpDir
=
RTP_PROXY_FIELD
"dumpDir"
;
//是否限制udp数据来源ip和端口
const
string
kCheckSource
=
RTP_PROXY_FIELD
"checkSource"
;
//rtp类型,支持MP2P/MP4V-ES
const
string
kRtpType
=
RTP_PROXY_FIELD
"rtp_type"
;
//rtp接收超时时间
const
string
kTimeoutSec
=
RTP_PROXY_FIELD
"timeoutSec"
;
onceToken
token
([](){
mINI
::
Instance
()[
kDumpDir
]
=
""
;
mINI
::
Instance
()[
kCheckSource
]
=
1
;
mINI
::
Instance
()[
kRtpType
]
=
"MP2P"
;
mINI
::
Instance
()[
kTimeoutSec
]
=
15
;
},
nullptr
);
}
//namespace RtpProxy
namespace
Client
{
namespace
Client
{
const
string
kNetAdapter
=
"net_adapter"
;
const
string
kNetAdapter
=
"net_adapter"
;
const
string
kRtpType
=
"rtp_type"
;
const
string
kRtpType
=
"rtp_type"
;
...
...
src/Common/config.h
查看文件 @
0d9bdec1
...
@@ -159,11 +159,6 @@ extern const string kBroadcastReloadConfig;
...
@@ -159,11 +159,6 @@ extern const string kBroadcastReloadConfig;
static type arg = mINI::Instance()[key]; \
static type arg = mINI::Instance()[key]; \
LISTEN_RELOAD_KEY(arg,key);
LISTEN_RELOAD_KEY(arg,key);
//兼容老代码
#define GET_CONFIG_AND_REGISTER GET_CONFIG
#define BroadcastRtmpPublishArgs BroadcastMediaPublishArgs
#define kBroadcastRtmpPublish kBroadcastMediaPublish
}
//namespace Broadcast
}
//namespace Broadcast
////////////通用配置///////////
////////////通用配置///////////
...
@@ -301,6 +296,17 @@ extern const string kFileBufSize;
...
@@ -301,6 +296,17 @@ extern const string kFileBufSize;
extern
const
string
kFilePath
;
extern
const
string
kFilePath
;
}
//namespace Hls
}
//namespace Hls
////////////Rtp代理相关配置///////////
namespace
RtpProxy
{
//rtp调试数据保存目录,置空则不生成
extern
const
string
kDumpDir
;
//是否限制udp数据来源ip和端口
extern
const
string
kCheckSource
;
//rtp类型,支持MP2P/MP4V-ES
extern
const
string
kRtpType
;
//rtp接收超时时间
extern
const
string
kTimeoutSec
;
}
//namespace RtpProxy
/**
/**
* rtsp/rtmp播放器、推流器相关设置名,
* rtsp/rtmp播放器、推流器相关设置名,
...
...
src/Rtp/PSDecoder.cpp
查看文件 @
0d9bdec1
/*
/*
* MIT License
* MIT License
*
*
* Copyright (c) 2016-
2019 Gemfield <gemfield@civilnet.cn>
* Copyright (c)
2019 Gemfield <gemfield@civilnet.cn>
*
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in all
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
* SOFTWARE.
*/
*/
#if defined(ENABLE_RTPPROXY)
#include "PSDecoder.h"
#include "PSDecoder.h"
#include "mpeg-ps.h"
namespace
mediakit
{
PSDecoder
::
PSDecoder
()
{
PSDecoder
::
PSDecoder
()
{
_ps_demuxer
=
ps_demuxer_create
([](
void
*
param
,
_ps_demuxer
=
ps_demuxer_create
([](
void
*
param
,
...
@@ -41,9 +45,13 @@ PSDecoder::PSDecoder() {
...
@@ -41,9 +45,13 @@ PSDecoder::PSDecoder() {
}
}
PSDecoder
::~
PSDecoder
()
{
PSDecoder
::~
PSDecoder
()
{
ps_demuxer_destroy
(
_ps_demuxer
);
ps_demuxer_destroy
(
(
struct
ps_demuxer_t
*
)
_ps_demuxer
);
}
}
int
PSDecoder
::
decodePS
(
const
uint8_t
*
data
,
size_
t
bytes
)
{
int
PSDecoder
::
decodePS
(
const
uint8_t
*
data
,
in
t
bytes
)
{
return
ps_demuxer_input
(
_ps_demuxer
,
data
,
bytes
);
return
ps_demuxer_input
(
(
struct
ps_demuxer_t
*
)
_ps_demuxer
,
data
,
bytes
);
}
}
}
//namespace mediakit
#endif//#if defined(ENABLE_RTPPROXY)
\ No newline at end of file
src/Rtp/PSDecoder.h
查看文件 @
0d9bdec1
/*
/*
* MIT License
* MIT License
*
*
* Copyright (c) 2016-
2019 Gemfield <gemfield@civilnet.cn>
* Copyright (c)
2019 Gemfield <gemfield@civilnet.cn>
*
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in all
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
* SOFTWARE.
*/
*/
#ifndef
RTPPROXY
_PSDECODER_H
#ifndef
ZLMEDIAKIT
_PSDECODER_H
#define
RTPPROXY
_PSDECODER_H
#define
ZLMEDIAKIT
_PSDECODER_H
#ifdef __cplusplus
#if defined(ENABLE_RTPPROXY)
extern
"C"
{
#include <stdint.h>
#endif
#include "mpeg-ps.h"
namespace
mediakit
{
#ifdef __cplusplus
}
#endif
class
PSDecoder
{
class
PSDecoder
{
public
:
public
:
PSDecoder
();
PSDecoder
();
virtual
~
PSDecoder
();
virtual
~
PSDecoder
();
int
decodePS
(
const
uint8_t
*
data
,
size_
t
bytes
);
int
decodePS
(
const
uint8_t
*
data
,
in
t
bytes
);
protected
:
protected
:
virtual
void
onPSDecode
(
int
stream
,
virtual
void
onPSDecode
(
int
stream
,
int
codecid
,
int
codecid
,
...
@@ -48,10 +44,12 @@ protected:
...
@@ -48,10 +44,12 @@ protected:
int64_t
pts
,
int64_t
pts
,
int64_t
dts
,
int64_t
dts
,
const
void
*
data
,
const
void
*
data
,
size_
t
bytes
)
=
0
;
in
t
bytes
)
=
0
;
private
:
private
:
struct
ps_demuxer_t
*
_ps_demuxer
=
nullptr
;
void
*
_ps_demuxer
=
nullptr
;
};
};
}
//namespace mediakit
#endif //RTPPROXY_PSDECODER_H
#endif//defined(ENABLE_RTPPROXY)
#endif //ZLMEDIAKIT_PSDECODER_H
src/Rtp/RtpDecoder.cpp
查看文件 @
0d9bdec1
/*
/*
* MIT License
* MIT License
*
*
* Copyright (c) 2016-
2019 Gemfield <gemfield@civilnet.cn>
* Copyright (c)
2019 Gemfield <gemfield@civilnet.cn>
*
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in all
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
* SOFTWARE.
*/
*/
#if defined(ENABLE_RTPPROXY)
#include <assert.h>
#include <assert.h>
#include "Util/logger.h"
#include "Util/logger.h"
#include "RtpDecoder.h"
#include "RtpDecoder.h"
#include "rtp-payload.h"
using
namespace
toolkit
;
using
namespace
toolkit
;
namespace
mediakit
{
RtpDecoder
::
RtpDecoder
()
{
RtpDecoder
::
RtpDecoder
()
{
_buffer
=
std
::
make_shared
<
BufferRaw
>
();
_buffer
=
std
::
make_shared
<
BufferRaw
>
();
}
}
...
@@ -68,3 +73,6 @@ void RtpDecoder::decodeRtp(const void *data, int bytes,const char *type_name) {
...
@@ -68,3 +73,6 @@ void RtpDecoder::decodeRtp(const void *data, int bytes,const char *type_name) {
rtp_payload_decode_input
(
_rtp_decoder
,
data
,
bytes
);
rtp_payload_decode_input
(
_rtp_decoder
,
data
,
bytes
);
}
}
}
}
}
//namespace mediakit
#endif//defined(ENABLE_RTPPROXY)
\ No newline at end of file
src/Rtp/RtpDecoder.h
查看文件 @
0d9bdec1
/*
/*
* MIT License
* MIT License
*
*
* Copyright (c) 2016-
2019 Gemfield <gemfield@civilnet.cn>
* Copyright (c)
2019 Gemfield <gemfield@civilnet.cn>
*
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in all
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
* SOFTWARE.
*/
*/
#ifndef
IPTV_RTPTOTS
_H
#ifndef
ZLMEDIAKIT_RTPDECODER
_H
#define
IPTV_RTPTOTS
_H
#define
ZLMEDIAKIT_RTPDECODER
_H
#if defined(ENABLE_RTPPROXY)
#include "Network/Buffer.h"
#include "Network/Buffer.h"
using
namespace
toolkit
;
using
namespace
toolkit
;
#ifdef __cplusplus
extern
"C"
{
#endif
#include "rtp-payload.h"
namespace
mediakit
{
#include "mpeg-ts.h"
#ifdef __cplusplus
}
#endif
class
RtpDecoder
{
class
RtpDecoder
{
public
:
public
:
...
@@ -51,5 +45,6 @@ private:
...
@@ -51,5 +45,6 @@ private:
BufferRaw
::
Ptr
_buffer
;
BufferRaw
::
Ptr
_buffer
;
};
};
}
//namespace mediakit
#endif //IPTV_RTPTOTS_H
#endif//defined(ENABLE_RTPPROXY)
#endif //ZLMEDIAKIT_RTPDECODER_H
src/Rtp/RtpFileLoader.cpp
deleted
100644 → 0
查看文件 @
55814070
/*
* MIT License
*
* Copyright (c) 2016-2019 Gemfield <gemfield@civilnet.cn>
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include <cstdint>
#include <cstdio>
#include <sys/socket.h>
#include "RtpFileLoader.h"
#include "Util/logger.h"
#include "RtpSelector.h"
using
namespace
toolkit
;
bool
RtpFileLoader
::
loadFile
(
const
char
*
path
)
{
FILE
*
fp
=
fopen
(
path
,
"rb"
);
if
(
!
fp
)
{
WarnL
<<
"open file failed:"
<<
path
;
return
false
;
}
uint32_t
timeStamp_last
=
0
;
uint16_t
len
;
char
rtp
[
2
*
1024
];
while
(
true
)
{
if
(
2
!=
fread
(
&
len
,
1
,
2
,
fp
))
{
WarnL
;
break
;
}
len
=
ntohs
(
len
);
if
(
len
<
12
||
len
>
sizeof
(
rtp
))
{
WarnL
<<
len
;
break
;
}
if
(
len
!=
fread
(
rtp
,
1
,
len
,
fp
))
{
WarnL
;
break
;
}
uint32_t
timeStamp
;
memcpy
(
&
timeStamp
,
rtp
+
4
,
4
);
timeStamp
=
ntohl
(
timeStamp
);
timeStamp
/=
90
;
if
(
timeStamp_last
){
auto
diff
=
timeStamp
-
timeStamp_last
;
if
(
diff
>
0
){
usleep
(
diff
*
1000
);
}
}
timeStamp_last
=
timeStamp
;
RtpSelector
::
Instance
().
inputRtp
(
rtp
,
len
,
nullptr
);
}
fclose
(
fp
);
return
true
;
}
src/Rtp/RtpFileLoader.h
deleted
100644 → 0
查看文件 @
55814070
/*
* MIT License
*
* Copyright (c) 2016-2019 Gemfield <gemfield@civilnet.cn>
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef RTPPROXY_RTPFILELOADER_H
#define RTPPROXY_RTPFILELOADER_H
class
RtpFileLoader
{
public
:
RtpFileLoader
(){};
~
RtpFileLoader
(){};
static
bool
loadFile
(
const
char
*
path
);
};
#endif //RTPPROXY_RTPFILELOADER_H
src/Rtp/RtpProcess.cpp
查看文件 @
0d9bdec1
/*
/*
* MIT License
* MIT License
*
*
* Copyright (c) 2016-
2019 Gemfield <gemfield@civilnet.cn>
* Copyright (c)
2019 Gemfield <gemfield@civilnet.cn>
*
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in all
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
* SOFTWARE.
*/
*/
#if defined(ENABLE_RTPPROXY)
#include "mpeg-ps.h"
#include "RtpProcess.h"
#include "RtpProcess.h"
#include "Util/File.h"
#include "Util/File.h"
#include "Util/logger.h"
#include "Extension/H265.h"
#include "Extension/H265.h"
#include "Extension/H264.h"
#include "Extension/AAC.h"
#include "Extension/AAC.h"
using
namespace
toolkit
;
namespace
mediakit
{
namespace
dump
{
const
string
kEnable
=
"dump.enable"
;
const
string
kDir
=
"dump.dir"
;
const
string
kChcekSource
=
"dump.checkSource"
;
onceToken
token
([](){
mINI
::
Instance
()[
kEnable
]
=
0
;
mINI
::
Instance
()[
kDir
]
=
"./dump/"
;
mINI
::
Instance
()[
kChcekSource
]
=
1
;
});
}
//namespace dump
namespace
Rtp
{
const
string
kRtpType
=
"rtp.rtp_type"
;
const
string
kTimeoutSec
=
"rtp.timeoutSec"
;
onceToken
token
([](){
mINI
::
Instance
()[
kRtpType
]
=
"MP2P"
;
mINI
::
Instance
()[
kTimeoutSec
]
=
15
;
});
}
//namespace dump
/**
/**
* 合并一些时间戳相同的frame
* 合并一些时间戳相同的frame
...
@@ -106,10 +86,9 @@ RtpProcess::RtpProcess(uint32_t ssrc) {
...
@@ -106,10 +86,9 @@ RtpProcess::RtpProcess(uint32_t ssrc) {
DebugL
<<
printSSRC
(
_ssrc
);
DebugL
<<
printSSRC
(
_ssrc
);
_muxer
=
std
::
make_shared
<
MultiMediaSourceMuxer
>
(
DEFAULT_VHOST
,
"rtp"
,
printSSRC
(
_ssrc
));
_muxer
=
std
::
make_shared
<
MultiMediaSourceMuxer
>
(
DEFAULT_VHOST
,
"rtp"
,
printSSRC
(
_ssrc
));
GET_CONFIG
(
bool
,
dump_enable
,
dump
::
kEnable
);
GET_CONFIG
(
string
,
dump_dir
,
RtpProxy
::
kDumpDir
);
GET_CONFIG
(
string
,
dump_dir
,
dump
::
kDir
);
{
{
FILE
*
fp
=
dump_enable
?
File
::
createfile_file
(
File
::
absolutePath
(
printSSRC
(
_ssrc
)
+
".rtp"
,
dump_dir
).
data
(),
"wb"
)
:
nullptr
;
FILE
*
fp
=
!
dump_dir
.
empty
()
?
File
::
createfile_file
(
File
::
absolutePath
(
printSSRC
(
_ssrc
)
+
".rtp"
,
dump_dir
).
data
(),
"wb"
)
:
nullptr
;
if
(
fp
){
if
(
fp
){
_save_file_rtp
.
reset
(
fp
,[](
FILE
*
fp
){
_save_file_rtp
.
reset
(
fp
,[](
FILE
*
fp
){
fclose
(
fp
);
fclose
(
fp
);
...
@@ -118,7 +97,7 @@ RtpProcess::RtpProcess(uint32_t ssrc) {
...
@@ -118,7 +97,7 @@ RtpProcess::RtpProcess(uint32_t ssrc) {
}
}
{
{
FILE
*
fp
=
dump_enable
?
File
::
createfile_file
(
File
::
absolutePath
(
printSSRC
(
_ssrc
)
+
".mp2"
,
dump_dir
).
data
(),
"wb"
)
:
nullptr
;
FILE
*
fp
=
!
dump_dir
.
empty
()
?
File
::
createfile_file
(
File
::
absolutePath
(
printSSRC
(
_ssrc
)
+
".mp2"
,
dump_dir
).
data
(),
"wb"
)
:
nullptr
;
if
(
fp
){
if
(
fp
){
_save_file_ps
.
reset
(
fp
,[](
FILE
*
fp
){
_save_file_ps
.
reset
(
fp
,[](
FILE
*
fp
){
fclose
(
fp
);
fclose
(
fp
);
...
@@ -127,7 +106,7 @@ RtpProcess::RtpProcess(uint32_t ssrc) {
...
@@ -127,7 +106,7 @@ RtpProcess::RtpProcess(uint32_t ssrc) {
}
}
{
{
FILE
*
fp
=
dump_enable
?
File
::
createfile_file
(
File
::
absolutePath
(
printSSRC
(
_ssrc
)
+
".video"
,
dump_dir
).
data
(),
"wb"
)
:
nullptr
;
FILE
*
fp
=
!
dump_dir
.
empty
()
?
File
::
createfile_file
(
File
::
absolutePath
(
printSSRC
(
_ssrc
)
+
".video"
,
dump_dir
).
data
(),
"wb"
)
:
nullptr
;
if
(
fp
){
if
(
fp
){
_save_file_video
.
reset
(
fp
,[](
FILE
*
fp
){
_save_file_video
.
reset
(
fp
,[](
FILE
*
fp
){
fclose
(
fp
);
fclose
(
fp
);
...
@@ -147,7 +126,7 @@ RtpProcess::~RtpProcess() {
...
@@ -147,7 +126,7 @@ RtpProcess::~RtpProcess() {
}
}
bool
RtpProcess
::
inputRtp
(
const
char
*
data
,
int
data_len
,
const
struct
sockaddr
*
addr
)
{
bool
RtpProcess
::
inputRtp
(
const
char
*
data
,
int
data_len
,
const
struct
sockaddr
*
addr
)
{
GET_CONFIG
(
bool
,
check_source
,
dump
::
kChce
kSource
);
GET_CONFIG
(
bool
,
check_source
,
RtpProxy
::
kChec
kSource
);
//检查源是否合法
//检查源是否合法
if
(
!
_addr
){
if
(
!
_addr
){
_addr
=
new
struct
sockaddr
;
_addr
=
new
struct
sockaddr
;
...
@@ -177,7 +156,7 @@ void RtpProcess::onRtpSorted(const RtpPacket::Ptr &rtp, int) {
...
@@ -177,7 +156,7 @@ void RtpProcess::onRtpSorted(const RtpPacket::Ptr &rtp, int) {
fwrite
((
uint8_t
*
)
rtp
->
data
()
+
4
,
rtp
->
size
()
-
4
,
1
,
_save_file_rtp
.
get
());
fwrite
((
uint8_t
*
)
rtp
->
data
()
+
4
,
rtp
->
size
()
-
4
,
1
,
_save_file_rtp
.
get
());
}
}
GET_CONFIG
(
string
,
rtp_type
,
::
Rtp
::
kRtpType
);
GET_CONFIG
(
string
,
rtp_type
,
::
Rtp
Proxy
::
kRtpType
);
decodeRtp
(
rtp
->
data
()
+
4
,
rtp
->
size
()
-
4
,
rtp_type
.
data
());
decodeRtp
(
rtp
->
data
()
+
4
,
rtp
->
size
()
-
4
,
rtp_type
.
data
());
}
}
...
@@ -198,7 +177,7 @@ void RtpProcess::onPSDecode(int stream,
...
@@ -198,7 +177,7 @@ void RtpProcess::onPSDecode(int stream,
int64_t
pts
,
int64_t
pts
,
int64_t
dts
,
int64_t
dts
,
const
void
*
data
,
const
void
*
data
,
size_
t
bytes
)
{
in
t
bytes
)
{
switch
(
codecid
)
{
switch
(
codecid
)
{
case
STREAM_VIDEO_H264
:
{
case
STREAM_VIDEO_H264
:
{
...
@@ -270,7 +249,7 @@ void RtpProcess::onPSDecode(int stream,
...
@@ -270,7 +249,7 @@ void RtpProcess::onPSDecode(int stream,
}
}
bool
RtpProcess
::
alive
()
{
bool
RtpProcess
::
alive
()
{
GET_CONFIG
(
int
,
timeoutSec
,
::
Rtp
::
kTimeoutSec
)
GET_CONFIG
(
int
,
timeoutSec
,
RtpProxy
::
kTimeoutSec
)
if
(
_last_rtp_time
.
elapsedTime
()
/
1000
<
timeoutSec
){
if
(
_last_rtp_time
.
elapsedTime
()
/
1000
<
timeoutSec
){
return
true
;
return
true
;
}
}
...
@@ -284,3 +263,6 @@ string RtpProcess::get_peer_ip() {
...
@@ -284,3 +263,6 @@ string RtpProcess::get_peer_ip() {
uint16_t
RtpProcess
::
get_peer_port
()
{
uint16_t
RtpProcess
::
get_peer_port
()
{
return
ntohs
(((
struct
sockaddr_in
*
)
_addr
)
->
sin_port
);
return
ntohs
(((
struct
sockaddr_in
*
)
_addr
)
->
sin_port
);
}
}
}
//namespace mediakit
#endif//defined(ENABLE_RTPPROXY)
\ No newline at end of file
src/Rtp/RtpProcess.h
查看文件 @
0d9bdec1
/*
/*
* MIT License
* MIT License
*
*
* Copyright (c) 2016-
2019 Gemfield <gemfield@civilnet.cn>
* Copyright (c)
2019 Gemfield <gemfield@civilnet.cn>
*
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in all
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
* SOFTWARE.
*/
*/
#ifndef RTPPROXY_RTPDECODER_H
#ifndef ZLMEDIAKIT_RTPPROCESS_H
#define RTPPROXY_RTPDECODER_H
#define ZLMEDIAKIT_RTPPROCESS_H
#if defined(ENABLE_RTPPROXY)
#include "Rtsp/RtpReceiver.h"
#include "Rtsp/RtpReceiver.h"
#include "RtpDecoder.h"
#include "RtpDecoder.h"
...
@@ -33,6 +35,8 @@
...
@@ -33,6 +35,8 @@
#include "Common/Device.h"
#include "Common/Device.h"
using
namespace
mediakit
;
using
namespace
mediakit
;
namespace
mediakit
{
string
printSSRC
(
uint32_t
ui32Ssrc
);
string
printSSRC
(
uint32_t
ui32Ssrc
);
class
FrameMerger
;
class
FrameMerger
;
...
@@ -54,7 +58,7 @@ protected:
...
@@ -54,7 +58,7 @@ protected:
int64_t
pts
,
int64_t
pts
,
int64_t
dts
,
int64_t
dts
,
const
void
*
data
,
const
void
*
data
,
size_
t
bytes
)
override
;
in
t
bytes
)
override
;
private
:
private
:
std
::
shared_ptr
<
FILE
>
_save_file_rtp
;
std
::
shared_ptr
<
FILE
>
_save_file_rtp
;
std
::
shared_ptr
<
FILE
>
_save_file_ps
;
std
::
shared_ptr
<
FILE
>
_save_file_ps
;
...
@@ -70,5 +74,6 @@ private:
...
@@ -70,5 +74,6 @@ private:
Ticker
_last_rtp_time
;
Ticker
_last_rtp_time
;
};
};
}
//namespace mediakit
#endif //RTPPROXY_RTPDECODER_H
#endif//defined(ENABLE_RTPPROXY)
#endif //ZLMEDIAKIT_RTPPROCESS_H
src/Rtp/RtpSelector.cpp
查看文件 @
0d9bdec1
/*
/*
* MIT License
* MIT License
*
*
* Copyright (c) 2016-
2019 Gemfield <gemfield@civilnet.cn>
* Copyright (c)
2019 Gemfield <gemfield@civilnet.cn>
*
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in all
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
* SOFTWARE.
*/
*/
#if defined(ENABLE_RTPPROXY)
#include "RtpSelector.h"
#include "RtpSelector.h"
namespace
mediakit
{
INSTANCE_IMP
(
RtpSelector
);
INSTANCE_IMP
(
RtpSelector
);
bool
RtpSelector
::
inputRtp
(
const
char
*
data
,
int
data_len
,
const
struct
sockaddr
*
addr
)
{
bool
RtpSelector
::
inputRtp
(
const
char
*
data
,
int
data_len
,
const
struct
sockaddr
*
addr
)
{
...
@@ -97,3 +100,6 @@ RtpSelector::RtpSelector() {
...
@@ -97,3 +100,6 @@ RtpSelector::RtpSelector() {
RtpSelector
::~
RtpSelector
()
{
RtpSelector
::~
RtpSelector
()
{
}
}
}
//namespace mediakit
#endif//defined(ENABLE_RTPPROXY)
\ No newline at end of file
src/Rtp/RtpSelector.h
查看文件 @
0d9bdec1
/*
/*
* MIT License
* MIT License
*
*
* Copyright (c) 2016-
2019 Gemfield <gemfield@civilnet.cn>
* Copyright (c)
2019 Gemfield <gemfield@civilnet.cn>
*
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in all
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
* SOFTWARE.
*/
*/
#ifndef
RTPPROXY
_RTPSELECTOR_H
#ifndef
ZLMEDIAKIT
_RTPSELECTOR_H
#define
RTPPROXY
_RTPSELECTOR_H
#define
ZLMEDIAKIT
_RTPSELECTOR_H
#include <cstdint>
#if defined(ENABLE_RTPPROXY)
#include <stdint.h>
#include <mutex>
#include <mutex>
#include <unordered_map>
#include <unordered_map>
#include "RtpProcess.h"
#include "RtpProcess.h"
namespace
mediakit
{
class
RtpSelector
:
public
std
::
enable_shared_from_this
<
RtpSelector
>
{
class
RtpSelector
:
public
std
::
enable_shared_from_this
<
RtpSelector
>
{
public
:
public
:
...
@@ -51,5 +53,6 @@ private:
...
@@ -51,5 +53,6 @@ private:
Ticker
_last_rtp_time
;
Ticker
_last_rtp_time
;
};
};
}
//namespace mediakit
#endif //RTPPROXY_RTPSELECTOR_H
#endif//defined(ENABLE_RTPPROXY)
#endif //ZLMEDIAKIT_RTPSELECTOR_H
src/Rtp/RtpSession.cpp
查看文件 @
0d9bdec1
/*
/*
* MIT License
* MIT License
*
*
* Copyright (c) 2016-2019 Gemfield <gemfield@civilnet.cn>
* Copyright (c) 2019 Gemfield <gemfield@civilnet.cn>
*
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in all
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
* SOFTWARE.
*/
*/
#if defined(ENABLE_RTPPROXY)
#include "RtpSession.h"
#include "RtpSession.h"
#include "RtpSelector.h"
#include "RtpSelector.h"
namespace
mediakit
{
RtpSession
::
RtpSession
(
const
Socket
::
Ptr
&
sock
)
:
TcpSession
(
sock
)
{
RtpSession
::
RtpSession
(
const
Socket
::
Ptr
&
sock
)
:
TcpSession
(
sock
)
{
DebugP
(
this
);
DebugP
(
this
);
...
@@ -70,3 +73,6 @@ void RtpSession::onRtpPacket(const char *data, uint64_t len) {
...
@@ -70,3 +73,6 @@ void RtpSession::onRtpPacket(const char *data, uint64_t len) {
_process
->
inputRtp
(
data
+
2
,
len
-
2
,
&
addr
);
_process
->
inputRtp
(
data
+
2
,
len
-
2
,
&
addr
);
_ticker
.
resetTime
();
_ticker
.
resetTime
();
}
}
}
//namespace mediakit
#endif//defined(ENABLE_RTPPROXY)
\ No newline at end of file
src/Rtp/RtpSession.h
查看文件 @
0d9bdec1
/*
/*
* MIT License
* MIT License
*
*
* Copyright (c) 2016-
2019 Gemfield <gemfield@civilnet.cn>
* Copyright (c)
2019 Gemfield <gemfield@civilnet.cn>
*
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in all
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
* SOFTWARE.
*/
*/
#ifndef
RTPPROXY
_RTPSESSION_H
#ifndef
ZLMEDIAKIT
_RTPSESSION_H
#define
RTPPROXY
_RTPSESSION_H
#define
ZLMEDIAKIT
_RTPSESSION_H
#if defined(ENABLE_RTPPROXY)
#include "Network/TcpSession.h"
#include "Network/TcpSession.h"
#include "RtpSplitter.h"
#include "RtpSplitter.h"
#include "RtpProcess.h"
#include "RtpProcess.h"
#include "Util/TimeTicker.h"
#include "Util/TimeTicker.h"
using
namespace
toolkit
;
using
namespace
toolkit
;
namespace
mediakit
{
class
RtpSession
:
public
TcpSession
,
public
RtpSplitter
{
class
RtpSession
:
public
TcpSession
,
public
RtpSplitter
{
public
:
public
:
RtpSession
(
const
Socket
::
Ptr
&
sock
);
RtpSession
(
const
Socket
::
Ptr
&
sock
);
...
@@ -50,5 +52,6 @@ private:
...
@@ -50,5 +52,6 @@ private:
struct
sockaddr
addr
;
struct
sockaddr
addr
;
};
};
}
//namespace mediakit
#endif //RTPPROXY_RTPSESSION_H
#endif//defined(ENABLE_RTPPROXY)
#endif //ZLMEDIAKIT_RTPSESSION_H
src/Rtp/RtpSplitter.cpp
查看文件 @
0d9bdec1
/*
/*
* MIT License
* MIT License
*
*
* Copyright (c) 2016-
2019 Gemfield <gemfield@civilnet.cn>
* Copyright (c)
2019 Gemfield <gemfield@civilnet.cn>
*
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in all
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
* SOFTWARE.
*/
*/
#if defined(ENABLE_RTPPROXY)
#include "RtpSplitter.h"
#include "RtpSplitter.h"
namespace
mediakit
{
RtpSplitter
::
RtpSplitter
()
{
RtpSplitter
::
RtpSplitter
()
{
}
}
...
@@ -50,4 +52,7 @@ const char *RtpSplitter::onSearchPacketTail(const char *data, int len) {
...
@@ -50,4 +52,7 @@ const char *RtpSplitter::onSearchPacketTail(const char *data, int len) {
int64_t
RtpSplitter
::
onRecvHeader
(
const
char
*
data
,
uint64_t
len
)
{
int64_t
RtpSplitter
::
onRecvHeader
(
const
char
*
data
,
uint64_t
len
)
{
onRtpPacket
(
data
,
len
);
onRtpPacket
(
data
,
len
);
return
0
;
return
0
;
}
}
\ No newline at end of file
}
//namespace mediakit
#endif//defined(ENABLE_RTPPROXY)
\ No newline at end of file
src/Rtp/RtpSplitter.h
查看文件 @
0d9bdec1
/*
/*
* MIT License
* MIT License
*
*
* Copyright (c) 2016-
2019 Gemfield <gemfield@civilnet.cn>
* Copyright (c)
2019 Gemfield <gemfield@civilnet.cn>
*
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in all
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
* SOFTWARE.
*/
*/
#ifndef
RTPPROXY
_RTPSPLITTER_H
#ifndef
ZLMEDIAKIT
_RTPSPLITTER_H
#define
RTPPROXY
_RTPSPLITTER_H
#define
ZLMEDIAKIT
_RTPSPLITTER_H
#if defined(ENABLE_RTPPROXY)
#include "Http/HttpRequestSplitter.h"
#include "Http/HttpRequestSplitter.h"
using
namespace
mediakit
;
namespace
mediakit
{
class
RtpSplitter
:
public
HttpRequestSplitter
{
class
RtpSplitter
:
public
HttpRequestSplitter
{
public
:
public
:
...
@@ -46,5 +48,6 @@ protected:
...
@@ -46,5 +48,6 @@ protected:
int64_t
onRecvHeader
(
const
char
*
data
,
uint64_t
len
)
override
;
int64_t
onRecvHeader
(
const
char
*
data
,
uint64_t
len
)
override
;
};
};
}
//namespace mediakit
#endif //RTPPROXY_RTPSPLITTER_H
#endif//defined(ENABLE_RTPPROXY)
#endif //ZLMEDIAKIT_RTPSPLITTER_H
src/Rtp/UdpRecver.cpp
查看文件 @
0d9bdec1
/*
/*
* MIT License
* MIT License
*
*
* Copyright (c) 2016-
2019 Gemfield <gemfield@civilnet.cn>
* Copyright (c)
2019 Gemfield <gemfield@civilnet.cn>
*
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in all
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
* SOFTWARE.
*/
*/
#if defined(ENABLE_RTPPROXY)
#include "UdpRecver.h"
#include "UdpRecver.h"
#include "RtpSelector.h"
#include "RtpSelector.h"
namespace
mediakit
{
UdpRecver
::
UdpRecver
()
{
UdpRecver
::
UdpRecver
()
{
}
}
...
@@ -48,3 +51,6 @@ bool UdpRecver::initSock(uint16_t local_port,const char *local_ip) {
...
@@ -48,3 +51,6 @@ bool UdpRecver::initSock(uint16_t local_port,const char *local_ip) {
EventPoller
::
Ptr
UdpRecver
::
getPoller
()
{
EventPoller
::
Ptr
UdpRecver
::
getPoller
()
{
return
_sock
->
getPoller
();
return
_sock
->
getPoller
();
}
}
}
//namespace mediakit
#endif//defined(ENABLE_RTPPROXY)
\ No newline at end of file
src/Rtp/UdpRecver.h
查看文件 @
0d9bdec1
/*
/*
* MIT License
* MIT License
*
*
* Copyright (c) 2016-
2019 Gemfield <gemfield@civilnet.cn>
* Copyright (c)
2019 Gemfield <gemfield@civilnet.cn>
*
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in all
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
* SOFTWARE.
*/
*/
#ifndef ZLMEDIAKIT_UDPRECVER_H
#ifndef ZLMEDIAKIT_UDPRECVER_H
#define ZLMEDIAKIT_UDPRECVER_H
#define ZLMEDIAKIT_UDPRECVER_H
#if defined(ENABLE_RTPPROXY)
#include <memory>
#include <memory>
#include "Network/Socket.h"
#include "Network/Socket.h"
using
namespace
std
;
using
namespace
std
;
using
namespace
toolkit
;
using
namespace
toolkit
;
namespace
mediakit
{
/**
/**
* 组播接收器
* 组播接收器
*/
*/
...
@@ -48,5 +51,6 @@ protected:
...
@@ -48,5 +51,6 @@ protected:
Socket
::
Ptr
_sock
;
Socket
::
Ptr
_sock
;
};
};
}
//namespace mediakit
#endif//defined(ENABLE_RTPPROXY)
#endif //ZLMEDIAKIT_UDPRECVER_H
#endif //ZLMEDIAKIT_UDPRECVER_H
tests/test_rtp.cpp
查看文件 @
0d9bdec1
/*
/*
* MIT License
* MIT License
*
*
* Copyright (c) 201
6-201
9 Gemfield <gemfield@civilnet.cn>
* Copyright (c) 2019 Gemfield <gemfield@civilnet.cn>
*
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
*
*
...
@@ -36,29 +36,78 @@
...
@@ -36,29 +36,78 @@
#include "Rtsp/RtspSession.h"
#include "Rtsp/RtspSession.h"
#include "Rtmp/RtmpSession.h"
#include "Rtmp/RtmpSession.h"
#include "Http/HttpSession.h"
#include "Http/HttpSession.h"
#include "Rtp/Rtp
FileLoade
r.h"
#include "Rtp/Rtp
Selecto
r.h"
using
namespace
std
;
using
namespace
std
;
using
namespace
toolkit
;
using
namespace
toolkit
;
using
namespace
mediakit
;
using
namespace
mediakit
;
int
main
(
int
argc
,
char
*
argv
[])
{
#if defined(ENABLE_RTPPROXY)
{
static
bool
loadFile
(
const
char
*
path
){
//设置日志
FILE
*
fp
=
fopen
(
path
,
"rb"
);
Logger
::
Instance
().
add
(
std
::
make_shared
<
ConsoleChannel
>
(
"ConsoleChannel"
));
if
(
!
fp
)
{
//启动异步日志线程
WarnL
<<
"open file failed:"
<<
path
;
Logger
::
Instance
().
setWriter
(
std
::
make_shared
<
AsyncLogWriter
>
());
return
false
;
loadIniConfig
((
exeDir
()
+
"config.ini"
).
data
());
TcpServer
::
Ptr
rtspSrv
(
new
TcpServer
());
TcpServer
::
Ptr
rtmpSrv
(
new
TcpServer
());
TcpServer
::
Ptr
httpSrv
(
new
TcpServer
());
rtspSrv
->
start
<
RtspSession
>
(
554
);
//默认554
rtmpSrv
->
start
<
RtmpSession
>
(
1935
);
//默认1935
httpSrv
->
start
<
HttpSession
>
(
80
);
//默认80
RtpFileLoader
::
loadFile
(
argv
[
1
]);
}
}
return
0
;
uint32_t
timeStamp_last
=
0
;
uint16_t
len
;
char
rtp
[
2
*
1024
];
while
(
true
)
{
if
(
2
!=
fread
(
&
len
,
1
,
2
,
fp
))
{
WarnL
;
break
;
}
len
=
ntohs
(
len
);
if
(
len
<
12
||
len
>
sizeof
(
rtp
))
{
WarnL
<<
len
;
break
;
}
if
(
len
!=
fread
(
rtp
,
1
,
len
,
fp
))
{
WarnL
;
break
;
}
uint32_t
timeStamp
;
memcpy
(
&
timeStamp
,
rtp
+
4
,
4
);
timeStamp
=
ntohl
(
timeStamp
);
timeStamp
/=
90
;
if
(
timeStamp_last
){
auto
diff
=
timeStamp
-
timeStamp_last
;
if
(
diff
>
0
){
usleep
(
diff
*
1000
);
}
}
timeStamp_last
=
timeStamp
;
RtpSelector
::
Instance
().
inputRtp
(
rtp
,
len
,
nullptr
);
}
fclose
(
fp
);
return
true
;
}
}
#endif//#if defined(ENABLE_RTPPROXY)
int
main
(
int
argc
,
char
*
argv
[])
{
//设置日志
Logger
::
Instance
().
add
(
std
::
make_shared
<
ConsoleChannel
>
(
"ConsoleChannel"
));
#if defined(ENABLE_RTPPROXY)
//启动异步日志线程
Logger
::
Instance
().
setWriter
(
std
::
make_shared
<
AsyncLogWriter
>
());
loadIniConfig
((
exeDir
()
+
"config.ini"
).
data
());
TcpServer
::
Ptr
rtspSrv
(
new
TcpServer
());
TcpServer
::
Ptr
rtmpSrv
(
new
TcpServer
());
TcpServer
::
Ptr
httpSrv
(
new
TcpServer
());
rtspSrv
->
start
<
RtspSession
>
(
554
);
//默认554
rtmpSrv
->
start
<
RtmpSession
>
(
1935
);
//默认1935
httpSrv
->
start
<
HttpSession
>
(
80
);
//默认80
loadFile
(
argv
[
1
]);
#else
ErrorL
<<
"please ENABLE_RTPPROXY and then test"
;
#endif//#if defined(ENABLE_RTPPROXY)
return
0
;
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论