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
10522e4e
Commit
10522e4e
authored
Aug 16, 2021
by
ziyue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完善getOriginUrl接口
parent
23226366
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
41 行增加
和
9 行删除
+41
-9
src/Common/MediaSource.cpp
+27
-4
src/Common/MediaSource.h
+2
-2
src/Common/MultiMediaSourceMuxer.cpp
+9
-1
src/Common/MultiMediaSourceMuxer.h
+1
-0
src/Rtp/RtpProcess.cpp
+2
-2
没有找到文件。
src/Common/MediaSource.cpp
查看文件 @
10522e4e
...
...
@@ -40,6 +40,17 @@ string getOriginTypeString(MediaOriginType type){
}
}
static
string
getOriginUrl_l
(
const
MediaSource
*
thiz
)
{
if
(
thiz
==
MediaSource
::
NullMediaSource
)
{
return
""
;
}
return
thiz
->
getSchema
()
+
"://"
+
thiz
->
getVhost
()
+
"/"
+
thiz
->
getApp
()
+
"/"
+
thiz
->
getId
();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
MediaSource
*
const
MediaSource
::
NullMediaSource
=
nullptr
;
MediaSource
::
MediaSource
(
const
string
&
schema
,
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream_id
){
GET_CONFIG
(
bool
,
enableVhost
,
General
::
kEnableVhost
);
if
(
!
enableVhost
)
{
...
...
@@ -136,9 +147,13 @@ MediaOriginType MediaSource::getOriginType() const {
string
MediaSource
::
getOriginUrl
()
const
{
auto
listener
=
_listener
.
lock
();
if
(
!
listener
)
{
return
""
;
return
getOriginUrl_l
(
this
);
}
auto
ret
=
listener
->
getOriginUrl
(
const_cast
<
MediaSource
&>
(
*
this
));
if
(
!
ret
.
empty
())
{
return
ret
;
}
return
listener
->
getOriginUrl
(
const_cast
<
MediaSource
&>
(
*
this
)
);
return
getOriginUrl_l
(
this
);
}
std
::
shared_ptr
<
SockInfo
>
MediaSource
::
getOriginSock
()
const
{
...
...
@@ -567,6 +582,10 @@ void MediaSourceEvent::onReaderChanged(MediaSource &sender, int size){
},
nullptr
);
}
string
MediaSourceEvent
::
getOriginUrl
(
MediaSource
&
sender
)
const
{
return
getOriginUrl_l
(
&
sender
);
}
MediaOriginType
MediaSourceEventInterceptor
::
getOriginType
(
MediaSource
&
sender
)
const
{
auto
listener
=
_listener
.
lock
();
if
(
!
listener
)
{
...
...
@@ -578,9 +597,13 @@ MediaOriginType MediaSourceEventInterceptor::getOriginType(MediaSource &sender)
string
MediaSourceEventInterceptor
::
getOriginUrl
(
MediaSource
&
sender
)
const
{
auto
listener
=
_listener
.
lock
();
if
(
!
listener
)
{
return
""
;
return
MediaSourceEvent
::
getOriginUrl
(
sender
);
}
auto
ret
=
listener
->
getOriginUrl
(
sender
);
if
(
!
ret
.
empty
())
{
return
ret
;
}
return
listener
->
getOriginUrl
(
sender
);
return
MediaSourceEvent
::
getOriginUrl
(
sender
);
}
std
::
shared_ptr
<
SockInfo
>
MediaSourceEventInterceptor
::
getOriginSock
(
MediaSource
&
sender
)
const
{
...
...
src/Common/MediaSource.h
查看文件 @
10522e4e
...
...
@@ -61,7 +61,7 @@ public:
// 获取媒体源类型
virtual
MediaOriginType
getOriginType
(
MediaSource
&
sender
)
const
{
return
MediaOriginType
::
unknown
;
}
// 获取媒体源url或者文件路径
virtual
string
getOriginUrl
(
MediaSource
&
sender
)
const
{
return
""
;
}
virtual
string
getOriginUrl
(
MediaSource
&
sender
)
const
;
// 获取媒体源客户端相关信息
virtual
std
::
shared_ptr
<
SockInfo
>
getOriginSock
(
MediaSource
&
sender
)
const
{
return
nullptr
;
}
...
...
@@ -198,7 +198,7 @@ private:
*/
class
MediaSource
:
public
TrackSource
,
public
enable_shared_from_this
<
MediaSource
>
{
public
:
static
constexpr
MediaSource
*
NullMediaSource
=
nullptr
;
static
MediaSource
*
const
NullMediaSource
;
using
Ptr
=
std
::
shared_ptr
<
MediaSource
>
;
using
StreamMap
=
unordered_map
<
string
,
weak_ptr
<
MediaSource
>
>
;
using
AppStreamMap
=
unordered_map
<
string
,
StreamMap
>
;
...
...
src/Common/MultiMediaSourceMuxer.cpp
查看文件 @
10522e4e
...
...
@@ -58,6 +58,14 @@ static string getTrackInfoStr(const TrackSource *track_src){
MultiMediaSourceMuxer
::
MultiMediaSourceMuxer
(
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream
,
float
dur_sec
,
bool
enable_rtsp
,
bool
enable_rtmp
,
bool
enable_hls
,
bool
enable_mp4
)
{
_get_origin_url
=
[
this
,
vhost
,
app
,
stream
]()
{
auto
ret
=
getOriginUrl
(
*
MediaSource
::
NullMediaSource
);
if
(
!
ret
.
empty
())
{
return
ret
;
}
return
vhost
+
"/"
+
app
+
"/"
+
stream
;
};
if
(
enable_rtmp
)
{
_rtmp
=
std
::
make_shared
<
RtmpMediaSourceMuxer
>
(
vhost
,
app
,
stream
,
std
::
make_shared
<
TitleMeta
>
(
dur_sec
));
}
...
...
@@ -286,7 +294,7 @@ void MultiMediaSourceMuxer::onAllTrackReady() {
if
(
listener
)
{
listener
->
onAllTrackReady
();
}
InfoL
<<
"stream: "
<<
getOriginUrl
(
*
MediaSource
::
NullMediaSource
)
<<
" , codec info: "
<<
getTrackInfoStr
(
this
);
InfoL
<<
"stream: "
<<
_get_origin_url
(
)
<<
" , codec info: "
<<
getTrackInfoStr
(
this
);
}
void
MultiMediaSourceMuxer
::
resetTracks
()
{
...
...
src/Common/MultiMediaSourceMuxer.h
查看文件 @
10522e4e
...
...
@@ -145,6 +145,7 @@ private:
Ticker
_last_check
;
Stamp
_stamp
[
2
];
std
::
weak_ptr
<
Listener
>
_track_listener
;
function
<
string
()
>
_get_origin_url
;
#if defined(ENABLE_RTPPROXY)
mutex
_rtp_sender_mtx
;
unordered_map
<
string
,
RtpSender
::
Ptr
>
_rtp_sender
;
...
...
src/Rtp/RtpProcess.cpp
查看文件 @
10522e4e
...
...
@@ -262,10 +262,10 @@ MediaOriginType RtpProcess::getOriginType(MediaSource &sender) const{
}
string
RtpProcess
::
getOriginUrl
(
MediaSource
&
sender
)
const
{
return
_media_info
.
_
full_url
;
return
_media_info
.
_
schema
+
"://"
+
_media_info
.
_vhost
+
"/"
+
_media_info
.
_app
+
"/"
+
_media_info
.
_streamid
;
}
std
::
shared_ptr
<
SockInfo
>
RtpProcess
::
getOriginSock
(
MediaSource
&
sender
)
const
{
std
::
shared_ptr
<
SockInfo
>
RtpProcess
::
getOriginSock
(
MediaSource
&
sender
)
const
{
return
const_cast
<
RtpProcess
*>
(
this
)
->
shared_from_this
();
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论