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
9ef5a115
Commit
9ef5a115
authored
May 18, 2017
by
xzl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加对rtmp play2命令的支持
parent
6d28fff6
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
26 行增加
和
17 行删除
+26
-17
src/Rtmp/RtmpSession.cpp
+24
-17
src/Rtmp/RtmpSession.h
+2
-0
没有找到文件。
src/Rtmp/RtmpSession.cpp
查看文件 @
9ef5a115
...
@@ -21,6 +21,7 @@ RtmpSession::RtmpSession(const std::shared_ptr<ThreadPool> &pTh, const Socket::P
...
@@ -21,6 +21,7 @@ RtmpSession::RtmpSession(const std::shared_ptr<ThreadPool> &pTh, const Socket::P
g_mapCmd
.
emplace
(
"publish"
,
&
RtmpSession
::
onCmd_publish
);
g_mapCmd
.
emplace
(
"publish"
,
&
RtmpSession
::
onCmd_publish
);
g_mapCmd
.
emplace
(
"deleteStream"
,
&
RtmpSession
::
onCmd_deleteStream
);
g_mapCmd
.
emplace
(
"deleteStream"
,
&
RtmpSession
::
onCmd_deleteStream
);
g_mapCmd
.
emplace
(
"play"
,
&
RtmpSession
::
onCmd_play
);
g_mapCmd
.
emplace
(
"play"
,
&
RtmpSession
::
onCmd_play
);
g_mapCmd
.
emplace
(
"play2"
,
&
RtmpSession
::
onCmd_play2
);
g_mapCmd
.
emplace
(
"seek"
,
&
RtmpSession
::
onCmd_seek
);
g_mapCmd
.
emplace
(
"seek"
,
&
RtmpSession
::
onCmd_seek
);
g_mapCmd
.
emplace
(
"pause"
,
&
RtmpSession
::
onCmd_pause
);},
[]()
{});
g_mapCmd
.
emplace
(
"pause"
,
&
RtmpSession
::
onCmd_pause
);},
[]()
{});
DebugL
<<
getPeerIp
();
DebugL
<<
getPeerIp
();
...
@@ -136,13 +137,7 @@ void RtmpSession::onCmd_deleteStream(AMFDecoder &dec) {
...
@@ -136,13 +137,7 @@ void RtmpSession::onCmd_deleteStream(AMFDecoder &dec) {
throw
std
::
runtime_error
(
StrPrinter
<<
"Stop publishing."
<<
endl
);
throw
std
::
runtime_error
(
StrPrinter
<<
"Stop publishing."
<<
endl
);
}
}
void
RtmpSession
::
onCmd_play
(
AMFDecoder
&
dec
)
{
void
RtmpSession
::
doPlay
(){
dec
.
load
<
AMFValue
>
();
/* NULL */
m_strId
=
dec
.
load
<
std
::
string
>
();
auto
iPos
=
m_strId
.
find
(
'?'
);
if
(
iPos
!=
string
::
npos
)
{
m_strId
.
erase
(
iPos
);
}
auto
src
=
RtmpMediaSource
::
find
(
m_strApp
,
m_strId
,
true
);
auto
src
=
RtmpMediaSource
::
find
(
m_strApp
,
m_strId
,
true
);
bool
ok
=
(
src
.
operator
bool
());
bool
ok
=
(
src
.
operator
bool
());
ok
=
ok
&&
src
->
ready
();
ok
=
ok
&&
src
->
ready
();
...
@@ -150,7 +145,7 @@ void RtmpSession::onCmd_play(AMFDecoder &dec) {
...
@@ -150,7 +145,7 @@ void RtmpSession::onCmd_play(AMFDecoder &dec) {
//stream begin
//stream begin
sendUserControl
(
CONTROL_STREAM_BEGIN
,
STREAM_MEDIA
);
sendUserControl
(
CONTROL_STREAM_BEGIN
,
STREAM_MEDIA
);
// onStatus(NetStream.Play.Reset)
// onStatus(NetStream.Play.Reset)
AMFValue
status
(
AMF_OBJECT
);
AMFValue
status
(
AMF_OBJECT
);
status
.
set
(
"level"
,
ok
?
"status"
:
"error"
);
status
.
set
(
"level"
,
ok
?
"status"
:
"error"
);
status
.
set
(
"code"
,
ok
?
"NetStream.Play.Reset"
:
"NetStream.Play.StreamNotFound"
);
status
.
set
(
"code"
,
ok
?
"NetStream.Play.Reset"
:
"NetStream.Play.StreamNotFound"
);
...
@@ -162,7 +157,7 @@ void RtmpSession::onCmd_play(AMFDecoder &dec) {
...
@@ -162,7 +157,7 @@ void RtmpSession::onCmd_play(AMFDecoder &dec) {
throw
std
::
runtime_error
(
StrPrinter
<<
"No such stream:"
<<
m_strApp
<<
" "
<<
m_strId
<<
endl
);
throw
std
::
runtime_error
(
StrPrinter
<<
"No such stream:"
<<
m_strApp
<<
" "
<<
m_strId
<<
endl
);
}
}
// onStatus(NetStream.Play.Start)
// onStatus(NetStream.Play.Start)
status
.
clear
();
status
.
clear
();
status
.
set
(
"level"
,
"status"
);
status
.
set
(
"level"
,
"status"
);
status
.
set
(
"code"
,
"NetStream.Play.Start"
);
status
.
set
(
"code"
,
"NetStream.Play.Start"
);
...
@@ -171,7 +166,7 @@ void RtmpSession::onCmd_play(AMFDecoder &dec) {
...
@@ -171,7 +166,7 @@ void RtmpSession::onCmd_play(AMFDecoder &dec) {
status
.
set
(
"clientid"
,
"0"
);
status
.
set
(
"clientid"
,
"0"
);
sendReply
(
"onStatus"
,
nullptr
,
status
);
sendReply
(
"onStatus"
,
nullptr
,
status
);
// |RtmpSampleAccess(true, true)
// |RtmpSampleAccess(true, true)
AMFEncoder
invoke
;
AMFEncoder
invoke
;
invoke
<<
"|RtmpSampleAccess"
<<
true
<<
true
;
invoke
<<
"|RtmpSampleAccess"
<<
true
<<
true
;
sendResponse
(
MSG_DATA
,
invoke
.
data
());
sendResponse
(
MSG_DATA
,
invoke
.
data
());
...
@@ -192,15 +187,15 @@ void RtmpSession::onCmd_play(AMFDecoder &dec) {
...
@@ -192,15 +187,15 @@ void RtmpSession::onCmd_play(AMFDecoder &dec) {
status
.
set
(
"clientid"
,
"0"
);
status
.
set
(
"clientid"
,
"0"
);
sendReply
(
"onStatus"
,
nullptr
,
status
);
sendReply
(
"onStatus"
,
nullptr
,
status
);
// onMetaData
// onMetaData
invoke
.
clear
();
invoke
.
clear
();
invoke
<<
"onMetaData"
<<
src
->
getMetaData
();
invoke
<<
"onMetaData"
<<
src
->
getMetaData
();
sendResponse
(
MSG_DATA
,
invoke
.
data
());
sendResponse
(
MSG_DATA
,
invoke
.
data
());
src
->
getConfigFrame
([
&
](
const
RtmpPacket
&
pkt
)
{
src
->
getConfigFrame
([
&
](
const
RtmpPacket
&
pkt
)
{
//DebugL<<"send initial frame";
//DebugL<<"send initial frame";
onSendMedia
(
pkt
);
onSendMedia
(
pkt
);
});
});
m_pRingReader
=
src
->
getRing
()
->
attach
();
m_pRingReader
=
src
->
getRing
()
->
attach
();
weak_ptr
<
RtmpSession
>
weakSelf
=
dynamic_pointer_cast
<
RtmpSession
>
(
shared_from_this
());
weak_ptr
<
RtmpSession
>
weakSelf
=
dynamic_pointer_cast
<
RtmpSession
>
(
shared_from_this
());
...
@@ -224,10 +219,22 @@ void RtmpSession::onCmd_play(AMFDecoder &dec) {
...
@@ -224,10 +219,22 @@ void RtmpSession::onCmd_play(AMFDecoder &dec) {
}
}
strongSelf
->
safeShutdown
();
strongSelf
->
safeShutdown
();
});
});
m_pPlayerSrc
=
src
;
m_pPlayerSrc
=
src
;
if
(
src
->
getRing
()
->
readerCount
()
==
1
){
if
(
src
->
getRing
()
->
readerCount
()
==
1
){
src
->
seekTo
(
0
);
src
->
seekTo
(
0
);
}
}
}
void
RtmpSession
::
onCmd_play2
(
AMFDecoder
&
dec
)
{
doPlay
();
}
void
RtmpSession
::
onCmd_play
(
AMFDecoder
&
dec
)
{
dec
.
load
<
AMFValue
>
();
/* NULL */
m_strId
=
dec
.
load
<
std
::
string
>
();
auto
iPos
=
m_strId
.
find
(
'?'
);
if
(
iPos
!=
string
::
npos
)
{
m_strId
.
erase
(
iPos
);
}
doPlay
();
}
}
void
RtmpSession
::
onCmd_pause
(
AMFDecoder
&
dec
)
{
void
RtmpSession
::
onCmd_pause
(
AMFDecoder
&
dec
)
{
...
...
src/Rtmp/RtmpSession.h
查看文件 @
9ef5a115
...
@@ -56,6 +56,8 @@ private:
...
@@ -56,6 +56,8 @@ private:
void
onCmd_deleteStream
(
AMFDecoder
&
dec
);
void
onCmd_deleteStream
(
AMFDecoder
&
dec
);
void
onCmd_play
(
AMFDecoder
&
dec
);
void
onCmd_play
(
AMFDecoder
&
dec
);
void
onCmd_play2
(
AMFDecoder
&
dec
);
void
doPlay
();
void
onCmd_seek
(
AMFDecoder
&
dec
);
void
onCmd_seek
(
AMFDecoder
&
dec
);
void
onCmd_pause
(
AMFDecoder
&
dec
);
void
onCmd_pause
(
AMFDecoder
&
dec
);
void
setMetaData
(
AMFDecoder
&
dec
);
void
setMetaData
(
AMFDecoder
&
dec
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论