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
b4228f91
Commit
b4228f91
authored
Apr 24, 2020
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
适配ZLToolKit
parent
a9fcd9db
隐藏空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
32 行增加
和
35 行删除
+32
-35
3rdpart/ZLToolKit
+1
-1
server/Process.cpp
+1
-1
src/Common/MediaSource.h
+2
-2
src/Http/HttpDownloader.cpp
+1
-1
src/Http/HttpFileManager.cpp
+2
-3
src/Http/HttpSession.cpp
+1
-1
src/Http/HttpSession.h
+5
-5
src/Record/HlsMakerImp.cpp
+1
-1
src/Record/MP4.cpp
+1
-1
src/Rtmp/FlvMuxer.cpp
+1
-1
src/Rtp/RtpProcess.cpp
+13
-13
src/Rtp/RtpProcess.h
+3
-5
没有找到文件。
ZLToolKit
@
2dad545f
Subproject commit
ebd96d983d8dd3268e3e77ed08fb57d67666061c
Subproject commit
2dad545fb22083dc9bdcd7ad60e2f90498197320
server/Process.cpp
查看文件 @
b4228f91
...
@@ -75,7 +75,7 @@ void Process::run(const string &cmd, const string &log_file_tmp) {
...
@@ -75,7 +75,7 @@ void Process::run(const string &cmd, const string &log_file_tmp) {
int
log_fd
=
-
1
;
int
log_fd
=
-
1
;
int
flags
=
O_CREAT
|
O_WRONLY
|
O_APPEND
;
int
flags
=
O_CREAT
|
O_WRONLY
|
O_APPEND
;
mode_t
mode
=
S_IRWXO
|
S_IRWXG
|
S_IRWXU
;
// S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH;
mode_t
mode
=
S_IRWXO
|
S_IRWXG
|
S_IRWXU
;
// S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH;
File
::
create
file
_path
(
log_file
.
data
(),
mode
);
File
::
create_path
(
log_file
.
data
(),
mode
);
if
((
log_fd
=
::
open
(
log_file
.
c_str
(),
flags
,
mode
))
<
0
)
{
if
((
log_fd
=
::
open
(
log_file
.
c_str
(),
flags
,
mode
))
<
0
)
{
fprintf
(
stderr
,
"open log file %s failed:%d(%s)
\r\n
"
,
log_file
.
data
(),
errno
,
strerror
(
errno
));
fprintf
(
stderr
,
"open log file %s failed:%d(%s)
\r\n
"
,
log_file
.
data
(),
errno
,
strerror
(
errno
));
}
}
...
...
src/Common/MediaSource.h
查看文件 @
b4228f91
...
@@ -185,7 +185,7 @@ private:
...
@@ -185,7 +185,7 @@ private:
template
<
typename
packet
,
typename
policy
=
FlushPolicy
,
typename
packet_list
=
List
<
std
::
shared_ptr
<
packet
>
>
>
template
<
typename
packet
,
typename
policy
=
FlushPolicy
,
typename
packet_list
=
List
<
std
::
shared_ptr
<
packet
>
>
>
class
VideoPacketCache
{
class
VideoPacketCache
{
public
:
public
:
VideoPacketCache
()
:
_policy
(
tru
e
)
{
VideoPacketCache
()
:
_policy
(
fals
e
)
{
_cache
=
std
::
make_shared
<
packet_list
>
();
_cache
=
std
::
make_shared
<
packet_list
>
();
}
}
...
@@ -231,7 +231,7 @@ private:
...
@@ -231,7 +231,7 @@ private:
template
<
typename
packet
,
typename
policy
=
FlushPolicy
,
typename
packet_list
=
List
<
std
::
shared_ptr
<
packet
>
>
>
template
<
typename
packet
,
typename
policy
=
FlushPolicy
,
typename
packet_list
=
List
<
std
::
shared_ptr
<
packet
>
>
>
class
AudioPacketCache
{
class
AudioPacketCache
{
public
:
public
:
AudioPacketCache
()
:
_policy
(
fals
e
)
{
AudioPacketCache
()
:
_policy
(
tru
e
)
{
_cache
=
std
::
make_shared
<
packet_list
>
();
_cache
=
std
::
make_shared
<
packet_list
>
();
}
}
...
...
src/Http/HttpDownloader.cpp
查看文件 @
b4228f91
...
@@ -28,7 +28,7 @@ void HttpDownloader::startDownload(const string& url, const string& filePath,boo
...
@@ -28,7 +28,7 @@ void HttpDownloader::startDownload(const string& url, const string& filePath,boo
if
(
_filePath
.
empty
()){
if
(
_filePath
.
empty
()){
_filePath
=
exeDir
()
+
"HttpDownloader/"
+
MD5
(
url
).
hexdigest
();
_filePath
=
exeDir
()
+
"HttpDownloader/"
+
MD5
(
url
).
hexdigest
();
}
}
_saveFile
=
File
::
create
file_file
(
_filePath
.
data
(),
bAppend
?
"ab"
:
"wb"
);
_saveFile
=
File
::
create
_file
(
_filePath
.
data
(),
bAppend
?
"ab"
:
"wb"
);
if
(
!
_saveFile
){
if
(
!
_saveFile
){
auto
strErr
=
StrPrinter
<<
"打开文件失败:"
<<
filePath
<<
endl
;
auto
strErr
=
StrPrinter
<<
"打开文件失败:"
<<
filePath
<<
endl
;
throw
std
::
runtime_error
(
strErr
);
throw
std
::
runtime_error
(
strErr
);
...
...
src/Http/HttpFileManager.cpp
查看文件 @
b4228f91
...
@@ -315,7 +315,7 @@ public:
...
@@ -315,7 +315,7 @@ public:
SockInfoImp
()
=
default
;
SockInfoImp
()
=
default
;
~
SockInfoImp
()
override
=
default
;
~
SockInfoImp
()
override
=
default
;
const
string
&
get_local_ip
()
override
{
string
get_local_ip
()
override
{
return
_local_ip
;
return
_local_ip
;
}
}
...
@@ -323,9 +323,8 @@ public:
...
@@ -323,9 +323,8 @@ public:
return
_local_port
;
return
_local_port
;
}
}
const
string
&
get_peer_ip
()
override
{
string
get_peer_ip
()
override
{
return
_peer_ip
;
return
_peer_ip
;
}
}
uint16_t
get_peer_port
()
override
{
uint16_t
get_peer_port
()
override
{
...
...
src/Http/HttpSession.cpp
查看文件 @
b4228f91
...
@@ -59,7 +59,7 @@ int64_t HttpSession::onRecvHeader(const char *header,uint64_t len) {
...
@@ -59,7 +59,7 @@ int64_t HttpSession::onRecvHeader(const char *header,uint64_t len) {
string
cmd
=
_parser
.
Method
();
string
cmd
=
_parser
.
Method
();
auto
it
=
s_func_map
.
find
(
cmd
);
auto
it
=
s_func_map
.
find
(
cmd
);
if
(
it
==
s_func_map
.
end
())
{
if
(
it
==
s_func_map
.
end
())
{
Warn
L
<<
"不支持该命令:"
<<
cmd
;
Warn
P
(
this
)
<<
"不支持该命令:"
<<
cmd
;
sendResponse
(
"405 Not Allowed"
,
true
);
sendResponse
(
"405 Not Allowed"
,
true
);
return
0
;
return
0
;
}
}
...
...
src/Http/HttpSession.h
查看文件 @
b4228f91
...
@@ -41,11 +41,11 @@ public:
...
@@ -41,11 +41,11 @@ public:
typedef
std
::
function
<
void
(
const
string
&
errMsg
,
const
string
&
accessPath
,
int
cookieLifeSecond
)
>
HttpAccessPathInvoker
;
typedef
std
::
function
<
void
(
const
string
&
errMsg
,
const
string
&
accessPath
,
int
cookieLifeSecond
)
>
HttpAccessPathInvoker
;
HttpSession
(
const
Socket
::
Ptr
&
pSock
);
HttpSession
(
const
Socket
::
Ptr
&
pSock
);
virtual
~
HttpSession
()
;
~
HttpSession
()
override
;
v
irtual
v
oid
onRecv
(
const
Buffer
::
Ptr
&
)
override
;
void
onRecv
(
const
Buffer
::
Ptr
&
)
override
;
v
irtual
v
oid
onError
(
const
SockException
&
err
)
override
;
void
onError
(
const
SockException
&
err
)
override
;
v
irtual
v
oid
onManager
()
override
;
void
onManager
()
override
;
static
string
urlDecode
(
const
string
&
str
);
static
string
urlDecode
(
const
string
&
str
);
protected
:
protected
:
//FlvMuxer override
//FlvMuxer override
...
@@ -80,7 +80,7 @@ protected:
...
@@ -80,7 +80,7 @@ protected:
* @return true代表允许websocket连接,否则拒绝
* @return true代表允许websocket连接,否则拒绝
*/
*/
virtual
bool
onWebSocketConnect
(
const
Parser
&
header
){
virtual
bool
onWebSocketConnect
(
const
Parser
&
header
){
Warn
L
<<
"http server do not support websocket default"
;
Warn
P
(
this
)
<<
"http server do not support websocket default"
;
return
false
;
return
false
;
}
}
...
...
src/Record/HlsMakerImp.cpp
查看文件 @
b4228f91
...
@@ -92,7 +92,7 @@ void HlsMakerImp::onWriteHls(const char *data, int len) {
...
@@ -92,7 +92,7 @@ void HlsMakerImp::onWriteHls(const char *data, int len) {
std
::
shared_ptr
<
FILE
>
HlsMakerImp
::
makeFile
(
const
string
&
file
,
bool
setbuf
)
{
std
::
shared_ptr
<
FILE
>
HlsMakerImp
::
makeFile
(
const
string
&
file
,
bool
setbuf
)
{
auto
file_buf
=
_file_buf
;
auto
file_buf
=
_file_buf
;
auto
ret
=
shared_ptr
<
FILE
>
(
File
::
create
file
_file
(
file
.
data
(),
"wb"
),
[
file_buf
](
FILE
*
fp
)
{
auto
ret
=
shared_ptr
<
FILE
>
(
File
::
create_file
(
file
.
data
(),
"wb"
),
[
file_buf
](
FILE
*
fp
)
{
if
(
fp
)
{
if
(
fp
)
{
fclose
(
fp
);
fclose
(
fp
);
}
}
...
...
src/Record/MP4.cpp
查看文件 @
b4228f91
...
@@ -72,7 +72,7 @@ MP4File::Reader MP4File::createReader(){
...
@@ -72,7 +72,7 @@ MP4File::Reader MP4File::createReader(){
void
MP4File
::
openFile
(
const
char
*
file
,
const
char
*
mode
)
{
void
MP4File
::
openFile
(
const
char
*
file
,
const
char
*
mode
)
{
//创建文件
//创建文件
auto
fp
=
File
::
create
file_file
(
file
,
mode
);
auto
fp
=
File
::
create
_file
(
file
,
mode
);
if
(
!
fp
){
if
(
!
fp
){
throw
std
::
runtime_error
(
string
(
"打开文件失败:"
)
+
file
);
throw
std
::
runtime_error
(
string
(
"打开文件失败:"
)
+
file
);
}
}
...
...
src/Rtmp/FlvMuxer.cpp
查看文件 @
b4228f91
...
@@ -177,7 +177,7 @@ void FlvRecorder::startRecord(const EventPoller::Ptr &poller,const RtmpMediaSour
...
@@ -177,7 +177,7 @@ void FlvRecorder::startRecord(const EventPoller::Ptr &poller,const RtmpMediaSour
}
}
});
});
//新建文件
//新建文件
_file
.
reset
(
File
::
create
file_file
(
file_path
.
data
(),
"wb"
),
[
fileBuf
](
FILE
*
fp
){
_file
.
reset
(
File
::
create
_file
(
file_path
.
data
(),
"wb"
),
[
fileBuf
](
FILE
*
fp
){
if
(
fp
){
if
(
fp
){
fflush
(
fp
);
fflush
(
fp
);
fclose
(
fp
);
fclose
(
fp
);
...
...
src/Rtp/RtpProcess.cpp
查看文件 @
b4228f91
...
@@ -76,7 +76,7 @@ RtpProcess::RtpProcess(uint32_t ssrc) {
...
@@ -76,7 +76,7 @@ RtpProcess::RtpProcess(uint32_t ssrc) {
GET_CONFIG
(
string
,
dump_dir
,
RtpProxy
::
kDumpDir
);
GET_CONFIG
(
string
,
dump_dir
,
RtpProxy
::
kDumpDir
);
{
{
FILE
*
fp
=
!
dump_dir
.
empty
()
?
File
::
create
file_file
(
File
::
absolutePath
(
_media_info
.
_streamid
+
".rtp"
,
dump_dir
).
data
(),
"wb"
)
:
nullptr
;
FILE
*
fp
=
!
dump_dir
.
empty
()
?
File
::
create
_file
(
File
::
absolutePath
(
_media_info
.
_streamid
+
".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
);
...
@@ -85,7 +85,7 @@ RtpProcess::RtpProcess(uint32_t ssrc) {
...
@@ -85,7 +85,7 @@ RtpProcess::RtpProcess(uint32_t ssrc) {
}
}
{
{
FILE
*
fp
=
!
dump_dir
.
empty
()
?
File
::
create
file_file
(
File
::
absolutePath
(
_media_info
.
_streamid
+
".mp2"
,
dump_dir
).
data
(),
"wb"
)
:
nullptr
;
FILE
*
fp
=
!
dump_dir
.
empty
()
?
File
::
create
_file
(
File
::
absolutePath
(
_media_info
.
_streamid
+
".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
);
...
@@ -94,7 +94,7 @@ RtpProcess::RtpProcess(uint32_t ssrc) {
...
@@ -94,7 +94,7 @@ RtpProcess::RtpProcess(uint32_t ssrc) {
}
}
{
{
FILE
*
fp
=
!
dump_dir
.
empty
()
?
File
::
create
file_file
(
File
::
absolutePath
(
_media_info
.
_streamid
+
".video"
,
dump_dir
).
data
(),
"wb"
)
:
nullptr
;
FILE
*
fp
=
!
dump_dir
.
empty
()
?
File
::
create
_file
(
File
::
absolutePath
(
_media_info
.
_streamid
+
".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
);
...
@@ -119,8 +119,8 @@ RtpProcess::~RtpProcess() {
...
@@ -119,8 +119,8 @@ RtpProcess::~RtpProcess() {
//流量统计事件广播
//流量统计事件广播
GET_CONFIG
(
uint32_t
,
iFlowThreshold
,
General
::
kFlowThreshold
);
GET_CONFIG
(
uint32_t
,
iFlowThreshold
,
General
::
kFlowThreshold
);
if
(
_
ui64TotalB
ytes
>
iFlowThreshold
*
1024
)
{
if
(
_
total_b
ytes
>
iFlowThreshold
*
1024
)
{
NoticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastFlowReport
,
_media_info
,
_
ui64TotalB
ytes
,
duration
,
false
,
static_cast
<
SockInfo
&>
(
*
this
));
NoticeCenter
::
Instance
().
emitEvent
(
Broadcast
::
kBroadcastFlowReport
,
_media_info
,
_
total_b
ytes
,
duration
,
false
,
static_cast
<
SockInfo
&>
(
*
this
));
}
}
}
}
...
@@ -146,7 +146,7 @@ bool RtpProcess::inputRtp(const Socket::Ptr &sock, const char *data, int data_le
...
@@ -146,7 +146,7 @@ bool RtpProcess::inputRtp(const Socket::Ptr &sock, const char *data, int data_le
return
false
;
return
false
;
}
}
_
ui64TotalB
ytes
+=
data_len
;
_
total_b
ytes
+=
data_len
;
_last_rtp_time
.
resetTime
();
_last_rtp_time
.
resetTime
();
bool
ret
=
handleOneRtp
(
0
,
_track
,(
unsigned
char
*
)
data
,
data_len
);
bool
ret
=
handleOneRtp
(
0
,
_track
,(
unsigned
char
*
)
data
,
data_len
);
if
(
dts_out
){
if
(
dts_out
){
...
@@ -328,11 +328,11 @@ bool RtpProcess::alive() {
...
@@ -328,11 +328,11 @@ bool RtpProcess::alive() {
return
false
;
return
false
;
}
}
const
string
&
RtpProcess
::
get_peer_ip
()
{
string
RtpProcess
::
get_peer_ip
()
{
if
(
_
peer_ip
.
empty
()
&&
_
addr
){
if
(
_addr
){
_peer_ip
=
SockUtil
::
inet_ntoa
(((
struct
sockaddr_in
*
)
_addr
)
->
sin_addr
);
return
SockUtil
::
inet_ntoa
(((
struct
sockaddr_in
*
)
_addr
)
->
sin_addr
);
}
}
return
_peer_ip
;
return
"0.0.0.0"
;
}
}
uint16_t
RtpProcess
::
get_peer_port
()
{
uint16_t
RtpProcess
::
get_peer_port
()
{
...
@@ -342,11 +342,11 @@ uint16_t RtpProcess::get_peer_port() {
...
@@ -342,11 +342,11 @@ uint16_t RtpProcess::get_peer_port() {
return
ntohs
(((
struct
sockaddr_in
*
)
_addr
)
->
sin_port
);
return
ntohs
(((
struct
sockaddr_in
*
)
_addr
)
->
sin_port
);
}
}
const
string
&
RtpProcess
::
get_local_ip
()
{
string
RtpProcess
::
get_local_ip
()
{
if
(
_sock
){
if
(
_sock
){
_local_ip
=
_sock
->
get_local_ip
();
return
_sock
->
get_local_ip
();
}
}
return
_local_ip
;
return
"0.0.0.0"
;
}
}
uint16_t
RtpProcess
::
get_local_port
()
{
uint16_t
RtpProcess
::
get_local_port
()
{
...
...
src/Rtp/RtpProcess.h
查看文件 @
b4228f91
...
@@ -32,9 +32,9 @@ public:
...
@@ -32,9 +32,9 @@ public:
bool
inputRtp
(
const
Socket
::
Ptr
&
sock
,
const
char
*
data
,
int
data_len
,
const
struct
sockaddr
*
addr
,
uint32_t
*
dts_out
=
nullptr
);
bool
inputRtp
(
const
Socket
::
Ptr
&
sock
,
const
char
*
data
,
int
data_len
,
const
struct
sockaddr
*
addr
,
uint32_t
*
dts_out
=
nullptr
);
bool
alive
();
bool
alive
();
const
string
&
get_local_ip
()
override
;
string
get_local_ip
()
override
;
uint16_t
get_local_port
()
override
;
uint16_t
get_local_port
()
override
;
const
string
&
get_peer_ip
()
override
;
string
get_peer_ip
()
override
;
uint16_t
get_peer_port
()
override
;
uint16_t
get_peer_port
()
override
;
string
getIdentifier
()
const
override
;
string
getIdentifier
()
const
override
;
...
@@ -65,11 +65,9 @@ private:
...
@@ -65,11 +65,9 @@ private:
unordered_map
<
int
,
Stamp
>
_stamps
;
unordered_map
<
int
,
Stamp
>
_stamps
;
uint32_t
_dts
=
0
;
uint32_t
_dts
=
0
;
Decoder
::
Ptr
_decoder
;
Decoder
::
Ptr
_decoder
;
string
_peer_ip
;
string
_local_ip
;
std
::
weak_ptr
<
MediaSourceEvent
>
_listener
;
std
::
weak_ptr
<
MediaSourceEvent
>
_listener
;
MediaInfo
_media_info
;
MediaInfo
_media_info
;
uint64_t
_
ui64TotalB
ytes
=
0
;
uint64_t
_
total_b
ytes
=
0
;
Socket
::
Ptr
_sock
;
Socket
::
Ptr
_sock
;
};
};
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论