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
69098612
Commit
69098612
authored
Aug 01, 2019
by
xiongziliang
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/xiongziliang/ZLMediaKit
into zqsong
parents
776dd4c0
2e95c3b2
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
35 行增加
和
69 行删除
+35
-69
3rdpart/ZLToolKit
+1
-1
src/Extension/H264Rtmp.cpp
+3
-32
src/Extension/H264Rtmp.h
+0
-1
src/Player/PlayerBase.h
+3
-18
src/Rtmp/RtmpPlayer.cpp
+20
-1
src/Rtmp/RtmpPlayer.h
+2
-6
src/Rtmp/RtmpPlayerImp.h
+1
-5
tests/test_player.cpp
+5
-5
没有找到文件。
ZLToolKit
@
936d3c05
Subproject commit
fe572323b10d72819a4d69b326dd70e73c7bf1a6
Subproject commit
936d3c05b183cba279bb348f8eac9eca0cc810c2
src/Extension/H264Rtmp.cpp
查看文件 @
69098612
...
...
@@ -51,6 +51,8 @@ bool H264RtmpDecoder::decodeRtmp(const RtmpPacket::Ptr &pkt) {
//缓存sps pps,后续插入到I帧之前
_sps
=
pkt
->
getH264SPS
();
_pps
=
pkt
->
getH264PPS
();
onGetH264
(
_sps
.
data
(),
_sps
.
size
(),
pkt
->
timeStamp
,
pkt
->
timeStamp
);
onGetH264
(
_pps
.
data
(),
_pps
.
size
(),
pkt
->
timeStamp
,
pkt
->
timeStamp
);
return
false
;
}
...
...
@@ -69,44 +71,13 @@ bool H264RtmpDecoder::decodeRtmp(const RtmpPacket::Ptr &pkt) {
if
(
iFrameLen
+
iOffset
>
iTotalLen
){
break
;
}
onGetH264
_l
(
pkt
->
strBuf
.
data
()
+
iOffset
,
iFrameLen
,
pkt
->
timeStamp
,
pts
);
onGetH264
(
pkt
->
strBuf
.
data
()
+
iOffset
,
iFrameLen
,
pkt
->
timeStamp
,
pts
);
iOffset
+=
iFrameLen
;
}
}
return
pkt
->
isVideoKeyFrame
();
}
inline
void
H264RtmpDecoder
::
onGetH264_l
(
const
char
*
pcData
,
int
iLen
,
uint32_t
dts
,
uint32_t
pts
)
{
switch
(
H264_TYPE
(
pcData
[
0
]))
{
case
H264Frame
:
:
NAL_IDR
:
{
//I frame
if
(
_sps
.
length
()){
onGetH264
(
_sps
.
data
(),
_sps
.
length
(),
dts
,
pts
);
}
if
(
_pps
.
length
()){
onGetH264
(
_pps
.
data
(),
_pps
.
length
(),
dts
,
pts
);
}
onGetH264
(
pcData
,
iLen
,
dts
,
pts
);
}
break
;
case
H264Frame
:
:
NAL_B_P
:
{
//I or P or B frame
onGetH264
(
pcData
,
iLen
,
dts
,
pts
);
}
break
;
case
H264Frame
:
:
NAL_SPS
:
{
_sps
.
assign
(
pcData
,
iLen
);
}
break
;
case
H264Frame
:
:
NAL_PPS
:
{
_pps
.
assign
(
pcData
,
iLen
);
}
break
;
default
:
break
;
}
}
inline
void
H264RtmpDecoder
::
onGetH264
(
const
char
*
pcData
,
int
iLen
,
uint32_t
dts
,
uint32_t
pts
)
{
#if 1
_h264frame
->
type
=
H264_TYPE
(
pcData
[
0
]);
...
...
src/Extension/H264Rtmp.h
查看文件 @
69098612
...
...
@@ -60,7 +60,6 @@ public:
}
protected
:
bool
decodeRtmp
(
const
RtmpPacket
::
Ptr
&
Rtmp
);
void
onGetH264_l
(
const
char
*
pcData
,
int
iLen
,
uint32_t
dts
,
uint32_t
pts
);
void
onGetH264
(
const
char
*
pcData
,
int
iLen
,
uint32_t
dts
,
uint32_t
pts
);
H264Frame
::
Ptr
obtainFrame
();
protected
:
...
...
src/Player/PlayerBase.h
查看文件 @
69098612
...
...
@@ -245,14 +245,9 @@ protected:
_playResultCB
=
nullptr
;
return
;
}
//播放成功后,我们还必须等待各个Track初始化完毕才能回调告知已经初始化完毕
if
(
isInited
(
0xFFFF
)){
//初始化完毕则立即回调
_playResultCB
(
ex
);
_playResultCB
=
nullptr
;
return
;
}
//播放成功却未初始化完毕,这个时候不回调汇报播放成功
//播放成功
_playResultCB
(
ex
);
_playResultCB
=
nullptr
;
}
void
onResume
()
override
{
...
...
@@ -260,16 +255,6 @@ protected:
_resumeCB
();
}
}
void
checkInited
(
int
analysisMs
){
if
(
!
_playResultCB
){
return
;
}
if
(
isInited
(
analysisMs
)){
_playResultCB
(
SockException
(
Err_success
,
"play success"
));
_playResultCB
=
nullptr
;
}
}
protected
:
function
<
void
(
const
SockException
&
ex
)
>
_shutdownCB
;
function
<
void
(
const
SockException
&
ex
)
>
_playResultCB
;
...
...
src/Rtmp/RtmpPlayer.cpp
查看文件 @
69098612
...
...
@@ -321,7 +321,6 @@ void RtmpPlayer::onCmd_onMetaData(AMFDecoder &dec) {
if
(
!
onCheckMeta
(
val
)){
throw
std
::
runtime_error
(
"onCheckMeta faied"
);
}
onPlayResult_l
(
SockException
(
Err_success
,
"play rtmp success"
));
}
void
RtmpPlayer
::
onStreamDry
(
uint32_t
ui32StreamId
)
{
...
...
@@ -329,6 +328,25 @@ void RtmpPlayer::onStreamDry(uint32_t ui32StreamId) {
onPlayResult_l
(
SockException
(
Err_other
,
"rtmp stream dry"
));
}
void
RtmpPlayer
::
onMediaData_l
(
const
RtmpPacket
::
Ptr
&
packet
)
{
_mediaTicker
.
resetTime
();
if
(
!
_pPlayTimer
){
//已经触发了onPlayResult事件,直接触发onMediaData事件
onMediaData
(
packet
);
return
;
}
if
(
packet
->
isCfgFrame
()){
//输入配置帧以便初始化完成各个track
onMediaData
(
packet
);
}
else
{
//先触发onPlayResult事件,这个时候解码器才能初始化完毕
onPlayResult_l
(
SockException
(
Err_success
,
"play rtmp success"
));
//触发onPlayResult事件后,再把帧数据输入到解码器
onMediaData
(
packet
);
}
}
void
RtmpPlayer
::
onRtmpChunk
(
RtmpPacket
&
chunkData
)
{
switch
(
chunkData
.
typeId
)
{
...
...
@@ -351,6 +369,7 @@ void RtmpPlayer::onRtmpChunk(RtmpPacket &chunkData) {
case
MSG_VIDEO
:
{
auto
idx
=
chunkData
.
typeId
%
2
;
if
(
_aNowStampTicker
[
idx
].
elapsedTime
()
>
500
)
{
//计算播放进度时间轴用
_aiNowStamp
[
idx
]
=
chunkData
.
timeStamp
;
}
onMediaData_l
(
std
::
make_shared
<
RtmpPacket
>
(
std
::
move
(
chunkData
)));
...
...
src/Rtmp/RtmpPlayer.h
查看文件 @
69098612
...
...
@@ -60,11 +60,7 @@ protected:
uint32_t
getProgressMilliSecond
()
const
;
void
seekToMilliSecond
(
uint32_t
ms
);
protected
:
void
onMediaData_l
(
const
RtmpPacket
::
Ptr
&
chunkData
)
{
_mediaTicker
.
resetTime
();
onMediaData
(
chunkData
);
}
void
onMediaData_l
(
const
RtmpPacket
::
Ptr
&
chunkData
);
void
onPlayResult_l
(
const
SockException
&
ex
);
//for Tcpclient
...
...
@@ -97,7 +93,7 @@ protected:
inline
void
send_createStream
();
inline
void
send_play
();
inline
void
send_pause
(
bool
bPause
);
private
:
string
_strApp
;
string
_strStream
;
string
_strTcUrl
;
...
...
src/Rtmp/RtmpPlayerImp.h
查看文件 @
69098612
...
...
@@ -58,7 +58,6 @@ public:
seekToMilliSecond
(
fProgress
*
getDuration
()
*
1000
);
};
void
play
(
const
string
&
strUrl
)
override
{
_analysisMs
=
(
*
this
)[
kMaxAnalysisMS
].
as
<
int
>
();
PlayerImp
<
RtmpPlayer
,
RtmpDemuxer
>::
play
(
strUrl
);
}
private
:
...
...
@@ -76,16 +75,13 @@ private:
_pRtmpMediaSrc
->
onWrite
(
chunkData
);
}
if
(
!
_parser
){
//这个流没有metedata
,那么尝试在音视频包里面还原出相关信息
//这个流没有metedata
_parser
.
reset
(
new
RtmpDemuxer
());
onPlayResult_l
(
SockException
(
Err_success
,
"play rtmp success"
));
}
_parser
->
inputRtmp
(
chunkData
);
checkInited
(
_analysisMs
);
}
private
:
RtmpMediaSource
::
Ptr
_pRtmpMediaSrc
;
int
_analysisMs
;
};
...
...
tests/test_player.cpp
查看文件 @
69098612
...
...
@@ -39,9 +39,9 @@ using namespace std;
using
namespace
toolkit
;
using
namespace
mediakit
;
std
::
string
Utf8ToGbk
(
std
::
string
src_str
)
{
#ifdef WIN32
std
::
string
Utf8ToGbk
(
std
::
string
src_str
){
int
len
=
MultiByteToWideChar
(
CP_UTF8
,
0
,
src_str
.
c_str
(),
-
1
,
NULL
,
0
);
wchar_t
*
wszGBK
=
new
wchar_t
[
len
+
1
];
memset
(
wszGBK
,
0
,
len
*
2
+
2
);
...
...
@@ -54,9 +54,6 @@ std::string Utf8ToGbk(std::string src_str)
if
(
wszGBK
)
delete
[]
wszGBK
;
if
(
szGBK
)
delete
[]
szGBK
;
return
strTemp
;
#else
return
src_str
;
#endif
}
class
log4Channel
:
public
LogChannel
{
...
...
@@ -75,6 +72,9 @@ public:
printf
(
"%s %s
\n
"
,
logContext
->
_function
,
Utf8ToGbk
(
logContext
->
str
()).
c_str
());
}
};
#else
typedef
ConsoleChannel
log4Channel
;
#endif
#ifdef WIN32
#include <TCHAR.h>
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论