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
453660ab
Commit
453660ab
authored
Dec 26, 2019
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
整理MediaSource派生类
修复转协议或录制时忽然Track的问题
parent
9e8fe8c8
显示空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
46 行增加
和
17 行删除
+46
-17
src/Rtmp/RtmpDemuxer.cpp
+15
-0
src/Rtmp/RtmpDemuxer.h
+4
-5
src/Rtmp/RtmpMediaSourceImp.h
+10
-2
src/Rtsp/RtspDemuxer.cpp
+1
-1
src/Rtsp/RtspDemuxer.h
+7
-2
src/Rtsp/RtspMediaSourceImp.h
+7
-6
src/Rtsp/RtspPlayerImp.h
+2
-1
没有找到文件。
src/Rtmp/RtmpDemuxer.cpp
查看文件 @
453660ab
...
...
@@ -29,6 +29,21 @@
namespace
mediakit
{
void
RtmpDemuxer
::
loadMetaData
(
const
AMFValue
&
val
){
try
{
makeVideoTrack
(
val
[
"videocodecid"
]);
makeAudioTrack
(
val
[
"audiocodecid"
]);
val
.
object_for_each
([
&
](
const
string
&
key
,
const
AMFValue
&
val
)
{
if
(
key
==
"duration"
)
{
_fDuration
=
val
.
as_number
();
return
;
}
});
}
catch
(
std
::
exception
&
ex
){
WarnL
<<
ex
.
what
();
}
}
bool
RtmpDemuxer
::
inputRtmp
(
const
RtmpPacket
::
Ptr
&
pkt
)
{
switch
(
pkt
->
typeId
)
{
case
MSG_VIDEO
:
{
...
...
src/Rtmp/RtmpDemuxer.h
查看文件 @
453660ab
...
...
@@ -43,11 +43,10 @@ class RtmpDemuxer : public Demuxer{
public
:
typedef
std
::
shared_ptr
<
RtmpDemuxer
>
Ptr
;
/**
* 等效于RtmpDemuxer(AMFValue(AMF_NULL))
*/
RtmpDemuxer
(){}
virtual
~
RtmpDemuxer
(){};
RtmpDemuxer
()
=
default
;
virtual
~
RtmpDemuxer
()
=
default
;
void
loadMetaData
(
const
AMFValue
&
metadata
);
/**
* 开始解复用
...
...
src/Rtmp/RtmpMediaSourceImp.h
查看文件 @
453660ab
...
...
@@ -62,10 +62,18 @@ public:
~
RtmpMediaSourceImp
()
=
default
;
/**
* 设置metadata
*/
void
setMetaData
(
const
AMFValue
&
metadata
)
override
{
_demuxer
->
loadMetaData
(
metadata
);
RtmpMediaSource
::
setMetaData
(
metadata
);
}
/**
* 输入rtmp并解析
*/
void
onWrite
(
const
RtmpPacket
::
Ptr
&
pkt
,
bool
key_pos
=
true
)
override
{
_demuxer
->
inputRtmp
(
pkt
);
key_pos
=
_demuxer
->
inputRtmp
(
pkt
);
RtmpMediaSource
::
onWrite
(
pkt
,
key_pos
);
}
...
...
@@ -95,7 +103,7 @@ public:
*/
void
setProtocolTranslation
(
bool
enableRtsp
,
bool
enableHls
,
bool
enableMP4
)
{
//不重复生成rtmp
_muxer
=
std
::
make_shared
<
MultiMediaSourceMuxer
>
(
getVhost
(),
getApp
(),
getId
(),
0
,
enableRtsp
,
false
,
enableHls
,
enableMP4
);
_muxer
=
std
::
make_shared
<
MultiMediaSourceMuxer
>
(
getVhost
(),
getApp
(),
getId
(),
_demuxer
->
getDuration
()
,
enableRtsp
,
false
,
enableHls
,
enableMP4
);
_muxer
->
setListener
(
getListener
());
_muxer
->
setTrackListener
(
this
);
}
...
...
src/Rtsp/RtspDemuxer.cpp
查看文件 @
453660ab
...
...
@@ -34,7 +34,7 @@ using namespace std;
namespace
mediakit
{
RtspDemuxer
::
RtspDemuxer
(
const
string
&
sdp
)
{
void
RtspDemuxer
::
loadSdp
(
const
string
&
sdp
)
{
loadSdp
(
SdpParser
(
sdp
));
}
...
...
src/Rtsp/RtspDemuxer.h
查看文件 @
453660ab
...
...
@@ -40,8 +40,13 @@ namespace mediakit {
class
RtspDemuxer
:
public
Demuxer
{
public
:
typedef
std
::
shared_ptr
<
RtspDemuxer
>
Ptr
;
RtspDemuxer
(
const
string
&
sdp
);
virtual
~
RtspDemuxer
(){};
RtspDemuxer
()
=
default
;
virtual
~
RtspDemuxer
()
=
default
;
/**
* 加载sdp
*/
void
loadSdp
(
const
string
&
sdp
);
/**
* 开始解复用
...
...
src/Rtsp/RtspMediaSourceImp.h
查看文件 @
453660ab
...
...
@@ -45,15 +45,18 @@ public:
* @param id 流id
* @param ringSize 环形缓存大小
*/
RtspMediaSourceImp
(
const
string
&
vhost
,
const
string
&
app
,
const
string
&
id
,
int
ringSize
=
0
)
:
RtspMediaSource
(
vhost
,
app
,
id
,
ringSize
)
{}
RtspMediaSourceImp
(
const
string
&
vhost
,
const
string
&
app
,
const
string
&
id
,
int
ringSize
=
0
)
:
RtspMediaSource
(
vhost
,
app
,
id
,
ringSize
)
{
_demuxer
=
std
::
make_shared
<
RtspDemuxer
>
();
_demuxer
->
setTrackListener
(
this
);
}
~
RtspMediaSourceImp
()
=
default
;
/**
* 设置sdp
*/
void
setSdp
(
const
string
&
strSdp
)
override
{
_demuxer
=
std
::
make_shared
<
RtspDemuxer
>
(
strSdp
);
_demuxer
->
setTrackListener
(
this
);
_demuxer
->
loadSdp
(
strSdp
);
RtspMediaSource
::
setSdp
(
strSdp
);
}
...
...
@@ -61,9 +64,7 @@ public:
* 输入rtp并解析
*/
void
onWrite
(
const
RtpPacket
::
Ptr
&
rtp
,
bool
key_pos
)
override
{
if
(
_demuxer
)
{
key_pos
=
_demuxer
->
inputRtp
(
rtp
);
}
RtspMediaSource
::
onWrite
(
rtp
,
key_pos
);
}
...
...
@@ -93,7 +94,7 @@ public:
*/
void
setProtocolTranslation
(
bool
enableRtmp
,
bool
enableHls
,
bool
enableMP4
){
//不重复生成rtsp
_muxer
=
std
::
make_shared
<
MultiMediaSourceMuxer
>
(
getVhost
(),
getApp
(),
getId
(),
0
,
false
,
enableRtmp
,
enableHls
,
enableMP4
);
_muxer
=
std
::
make_shared
<
MultiMediaSourceMuxer
>
(
getVhost
(),
getApp
(),
getId
(),
_demuxer
->
getDuration
()
,
false
,
enableRtmp
,
enableHls
,
enableMP4
);
_muxer
->
setListener
(
getListener
());
_muxer
->
setTrackListener
(
this
);
}
...
...
src/Rtsp/RtspPlayerImp.h
查看文件 @
453660ab
...
...
@@ -66,7 +66,8 @@ private:
if
(
_pRtspMediaSrc
){
_pRtspMediaSrc
->
setSdp
(
sdp
);
}
_delegate
.
reset
(
new
RtspDemuxer
(
sdp
));
_delegate
.
reset
(
new
RtspDemuxer
);
_delegate
->
loadSdp
(
sdp
);
return
true
;
}
void
onRecvRTP
(
const
RtpPacket
::
Ptr
&
rtp
,
const
SdpTrack
::
Ptr
&
track
)
override
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论