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
1ff490d1
Commit
1ff490d1
authored
Oct 25, 2018
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完成MediaSource生成器
parent
84dbe559
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
161 行增加
和
22 行删除
+161
-22
ZLToolKit
+1
-1
src/Common/MultiMediaSourceMuxer.h
+68
-0
src/Rtmp/RtmpMediaSource.h
+5
-1
src/RtmpMuxer/RtmpMediaSourceMuxer.h
+39
-4
src/RtmpMuxer/RtmpMuxer.h
+8
-2
src/Rtsp/RtspMediaSource.h
+6
-1
src/RtspMuxer/RtspMediaSourceMuxer.h
+26
-11
src/RtspMuxer/RtspMuxer.h
+8
-2
没有找到文件。
ZLToolKit
@
3a9c9164
Subproject commit
6e69a082a2f6e6161785b00c7421bf1a811ed34a
Subproject commit
3a9c916454897ad02c6ee4cba89f5e370718cd91
src/Common/MultiMediaSourceMuxer.h
0 → 100644
查看文件 @
1ff490d1
/*
* MIT License
*
* Copyright (c) 2016 xiongziliang <771730766@qq.com>
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef ZLMEDIAKIT_MULTIMEDIASOURCEMUXER_H
#define ZLMEDIAKIT_MULTIMEDIASOURCEMUXER_H
#include "RtspMuxer/RtspMediaSourceMuxer.h"
#include "RtmpMuxer/RtmpMediaSourceMuxer.h"
class
MultiMediaSourceMuxer
{
public
:
MultiMediaSourceMuxer
(
const
string
&
vhost
,
const
string
&
strApp
,
const
string
&
strId
,
float
dur_sec
=
0
.
0
){
_rtmp
=
std
::
make_shared
<
RtmpMediaSourceMuxer
>
(
vhost
,
strApp
,
strId
,
std
::
make_shared
<
TitleMete
>
(
dur_sec
));
_rtsp
=
std
::
make_shared
<
RtspMediaSourceMuxer
>
(
vhost
,
strApp
,
strId
,
std
::
make_shared
<
TitleSdp
>
(
dur_sec
));
}
virtual
~
MultiMediaSourceMuxer
(){}
/**
* 添加音视频媒体
* @param track 媒体描述
*/
void
addTrack
(
const
Track
::
Ptr
&
track
,
int
mtu
=
1400
)
{
_rtmp
->
addTrack
(
track
);
_rtsp
->
addTrack
(
track
,
0
,
mtu
);
}
/**
* 写入帧数据然后打包rtmp
* @param frame 帧数据
*/
void
inputFrame
(
const
Frame
::
Ptr
&
frame
)
{
_rtmp
->
inputFrame
(
frame
);
_rtsp
->
inputFrame
(
frame
);
}
private
:
RtmpMediaSourceMuxer
::
Ptr
_rtmp
;
RtspMediaSourceMuxer
::
Ptr
_rtsp
;
};
#endif //ZLMEDIAKIT_MULTIMEDIASOURCEMUXER_H
src/Rtmp/RtmpMediaSource.h
查看文件 @
1ff490d1
...
...
@@ -48,7 +48,7 @@ using namespace toolkit;
namespace
mediakit
{
class
RtmpMediaSource
:
public
MediaSource
{
class
RtmpMediaSource
:
public
MediaSource
,
public
RingDelegate
<
RtmpPacket
::
Ptr
>
{
public
:
typedef
std
::
shared_ptr
<
RtmpMediaSource
>
Ptr
;
typedef
RingBuffer
<
RtmpPacket
::
Ptr
>
RingType
;
...
...
@@ -107,6 +107,10 @@ private:
lock_guard
<
recursive_mutex
>
lock
(
_mtxMap
);
return
_iCfgFrameSize
!=
-
1
&&
_iCfgFrameSize
==
_mapCfgFrame
.
size
();
}
void
onWrite
(
const
RtmpPacket
::
Ptr
&
pkt
,
bool
isKey
=
true
)
override
{
onGetMedia
(
pkt
);
}
protected
:
AMFValue
_metadata
;
unordered_map
<
int
,
RtmpPacket
::
Ptr
>
_mapCfgFrame
;
...
...
src/
Device/MediaSourceMaker.cpp
→
src/
RtmpMuxer/RtmpMediaSourceMuxer.h
查看文件 @
1ff490d1
...
...
@@ -24,7 +24,43 @@
* SOFTWARE.
*/
#i
nclude "MediaSourceMaker.h"
namespace
mediakit
{
#i
fndef ZLMEDIAKIT_RTMPMEDIASOURCEMUXER_H
#define ZLMEDIAKIT_RTMPMEDIASOURCEMUXER_H
}
\ No newline at end of file
#include "RtmpMuxer/RtmpMuxer.h"
#include "Rtmp/RtmpMediaSource.h"
namespace
mediakit
{
class
RtmpMediaSourceMuxer
:
public
RtmpMuxer
{
public
:
typedef
std
::
shared_ptr
<
RtmpMediaSourceMuxer
>
Ptr
;
RtmpMediaSourceMuxer
(
const
string
&
vhost
,
const
string
&
strApp
,
const
string
&
strId
,
const
TitleMete
::
Ptr
&
title
=
nullptr
)
:
RtmpMuxer
(
title
){
_mediaSouce
=
std
::
make_shared
<
RtmpMediaSource
>
(
vhost
,
strApp
,
strId
);
getRtmpRing
()
->
setDelegate
(
_mediaSouce
);
}
virtual
~
RtmpMediaSourceMuxer
(){}
void
setListener
(
const
std
::
weak_ptr
<
MediaSourceEvent
>
&
listener
){
_mediaSouce
->
setListener
(
listener
);
}
private
:
void
onInited
()
override
{
_mediaSouce
->
onGetMetaData
(
getMetedata
());
}
private
:
RtmpMediaSource
::
Ptr
_mediaSouce
;
};
}
//namespace mediakit
#endif //ZLMEDIAKIT_RTMPMEDIASOURCEMUXER_H
src/RtmpMuxer/RtmpMuxer.h
查看文件 @
1ff490d1
...
...
@@ -33,11 +33,17 @@ namespace mediakit{
class
RtmpMuxer
{
public
:
typedef
std
::
shared_ptr
<
RtmpMuxer
>
Ptr
;
/**
* 构造函数
*/
RtmpMuxer
(
const
TitleMete
::
Ptr
&
title
=
std
::
make_shared
<
TitleMete
>
())
:
_metedata
(
AMF_OBJECT
){
_metedata
=
title
->
getMetedata
();
RtmpMuxer
(
const
TitleMete
::
Ptr
&
title
=
nullptr
)
:
_metedata
(
AMF_OBJECT
){
if
(
!
title
){
_metedata
=
std
::
make_shared
<
TitleMete
>
()
->
getMetedata
();
}
else
{
_metedata
=
title
->
getMetedata
();
}
_rtmpRing
=
std
::
make_shared
<
RtmpRingInterface
::
RingType
>
();
}
virtual
~
RtmpMuxer
(){}
...
...
src/Rtsp/RtspMediaSource.h
查看文件 @
1ff490d1
...
...
@@ -49,7 +49,7 @@ using namespace toolkit;
namespace
mediakit
{
class
RtspMediaSource
:
public
MediaSource
{
class
RtspMediaSource
:
public
MediaSource
,
public
RingDelegate
<
RtpPacket
::
Ptr
>
{
public
:
typedef
ResourcePool
<
RtpPacket
>
PoolType
;
typedef
std
::
shared_ptr
<
RtspMediaSource
>
Ptr
;
...
...
@@ -93,6 +93,11 @@ public:
trackRef
.
type
=
rtppt
->
type
;
_pRing
->
write
(
rtppt
,
keyPos
);
}
private
:
void
onWrite
(
const
RtpPacket
::
Ptr
&
rtppt
,
bool
keyPos
)
override
{
onGetRTP
(
rtppt
,
keyPos
);
}
protected
:
unordered_map
<
int
,
RtspTrack
>
_mapTracks
;
string
_strSdp
;
//媒体描述信息
...
...
src/
Device/MediaSourceMak
er.h
→
src/
RtspMuxer/RtspMediaSourceMux
er.h
查看文件 @
1ff490d1
...
...
@@ -24,23 +24,38 @@
* SOFTWARE.
*/
#ifndef ZLMEDIAKIT_
MEDIASOURCEMAK
ER_H
#define ZLMEDIAKIT_
MEDIASOURCEMAK
ER_H
#ifndef ZLMEDIAKIT_
RTSPMEDIASOURCEMUX
ER_H
#define ZLMEDIAKIT_
RTSPMEDIASOURCEMUX
ER_H
#include "
Player/Track
.h"
#include "
RtspMuxer/RtspMuxer
.h"
#include "Rtsp/RtspMediaSource.h"
#include "Rtmp/RtmpMediaSource.h"
namespace
mediakit
{
class
MediaSourceMak
er
{
class
RtspMediaSourceMuxer
:
public
RtspMux
er
{
public
:
MediaSourceMaker
()
{}
virtual
~
MediaSourceMaker
()
{}
typedef
std
::
shared_ptr
<
RtspMediaSourceMuxer
>
Ptr
;
RtspMediaSourceMuxer
(
const
string
&
vhost
,
const
string
&
strApp
,
const
string
&
strId
,
const
TitleSdp
::
Ptr
&
title
=
nullptr
)
:
RtspMuxer
(
title
){
_mediaSouce
=
std
::
make_shared
<
RtspMediaSource
>
(
vhost
,
strApp
,
strId
);
getRtpRing
()
->
setDelegate
(
_mediaSouce
);
}
virtual
~
RtspMediaSourceMuxer
(){}
void
setListener
(
const
std
::
weak_ptr
<
MediaSourceEvent
>
&
listener
){
_mediaSouce
->
setListener
(
listener
);
}
private
:
RtspMediaSource
::
Ptr
_rtspSrc
;
RtmpMediaSource
::
Ptr
_rtmpSrc
;
void
onInited
()
override
{
_mediaSouce
->
onGetSDP
(
getSdp
());
}
private
:
RtspMediaSource
::
Ptr
_mediaSouce
;
};
}
//namespace mediakit
#endif //ZLMEDIAKIT_MEDIASOURCEMAKER_H
}
//namespace mediakit
#endif //ZLMEDIAKIT_RTSPMEDIASOURCEMUXER_H
src/RtspMuxer/RtspMuxer.h
查看文件 @
1ff490d1
...
...
@@ -35,11 +35,17 @@ namespace mediakit{
*/
class
RtspMuxer
{
public
:
typedef
std
::
shared_ptr
<
RtspMuxer
>
Ptr
;
/**
* 构造函数
*/
RtspMuxer
(
const
TitleSdp
::
Ptr
&
title
=
std
::
make_shared
<
TitleSdp
>
()){
_sdp
=
title
->
getSdp
();
RtspMuxer
(
const
TitleSdp
::
Ptr
&
title
=
nullptr
){
if
(
!
title
){
_sdp
=
std
::
make_shared
<
TitleSdp
>
()
->
getSdp
();
}
else
{
_sdp
=
title
->
getSdp
();
}
_rtpRing
=
std
::
make_shared
<
RtpRingInterface
::
RingType
>
();
}
virtual
~
RtspMuxer
(){}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论