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
09a8d531
Commit
09a8d531
authored
Jul 07, 2022
by
xiongguangjie
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
4108e81d
c4988e7c
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
50 行增加
和
12 行删除
+50
-12
api/source/mk_media.cpp
+0
-1
api/source/mk_track.cpp
+8
-5
api/tests/h264_media_server.c
+5
-1
src/Extension/Factory.cpp
+26
-0
src/Extension/Factory.h
+5
-0
webrtc/Sdp.cpp
+5
-4
webrtc/Sdp.h
+1
-1
没有找到文件。
api/source/mk_media.cpp
查看文件 @
09a8d531
...
...
@@ -187,7 +187,6 @@ API_EXPORT int API_CALL mk_media_init_video(mk_media ctx, int codec_id, int widt
info
.
iWidth
=
width
;
info
.
iHeight
=
height
;
info
.
iBitRate
=
bit_rate
;
(
*
obj
)
->
getChannel
()
->
initVideo
(
info
);
return
(
*
obj
)
->
getChannel
()
->
initVideo
(
info
);
}
...
...
api/source/mk_track.cpp
查看文件 @
09a8d531
...
...
@@ -10,12 +10,13 @@
#include "mk_track.h"
#include "Extension/Track.h"
#include "Extension/Factory.h"
using
namespace
std
;
using
namespace
toolkit
;
using
namespace
mediakit
;
class
VideoTrackForC
:
public
VideoTrack
{
class
VideoTrackForC
:
public
VideoTrack
,
public
std
::
enable_shared_from_this
<
VideoTrackForC
>
{
public
:
VideoTrackForC
(
int
codec_id
,
codec_args
*
args
)
{
_codec_id
=
(
CodecId
)
codec_id
;
...
...
@@ -49,7 +50,8 @@ public:
}
Track
::
Ptr
clone
()
override
{
return
std
::
make_shared
<
std
::
remove_reference
<
decltype
(
*
this
)
>::
type
>
(
*
this
);
auto
track_in
=
std
::
shared_ptr
<
Track
>
(
shared_from_this
());
return
Factory
::
getTrackByAbstractTrack
(
track_in
);
}
Sdp
::
Ptr
getSdp
()
override
{
...
...
@@ -61,15 +63,16 @@ private:
codec_args
_args
;
};
class
AudioTrackForC
:
public
AudioTrackImp
{
class
AudioTrackForC
:
public
AudioTrackImp
,
public
std
::
enable_shared_from_this
<
AudioTrackForC
>
{
public
:
~
AudioTrackForC
()
override
=
default
;
AudioTrackForC
(
int
codec_id
,
codec_args
*
args
)
:
AudioTrackImp
((
CodecId
)
codec_id
,
args
->
audio
.
sample_rate
,
args
->
audio
.
channels
,
16
)
{}
AudioTrackImp
((
CodecId
)
codec_id
,
args
->
audio
.
sample_rate
,
args
->
audio
.
channels
,
16
)
{}
Track
::
Ptr
clone
()
override
{
return
std
::
make_shared
<
std
::
remove_reference
<
decltype
(
*
this
)
>::
type
>
(
*
this
);
auto
track_in
=
std
::
shared_ptr
<
Track
>
(
shared_from_this
());
return
Factory
::
getTrackByAbstractTrack
(
track_in
);
}
Sdp
::
Ptr
getSdp
()
override
{
...
...
api/tests/h264_media_server.c
查看文件 @
09a8d531
...
...
@@ -64,8 +64,12 @@ int main(int argc, char *argv[]) {
mk_media
media
=
mk_media_create
(
"__defaultVhost__"
,
"live"
,
"test"
,
0
,
0
,
0
);
//h264的codec
mk_media_init_video
(
media
,
0
,
0
,
0
,
0
,
2
*
104
*
1024
);
//mk_media_init_video(media, 0, 0, 0, 0, 2 * 104 * 1024);
codec_args
v_args
=
{
0
};
mk_track
v_track
=
mk_track_create
(
MKCodecH264
,
&
v_args
);
mk_media_init_track
(
media
,
v_track
);
mk_media_init_complete
(
media
);
mk_track_unref
(
v_track
);
//创建h264分帧器
mk_h264_splitter
splitter
=
mk_h264_splitter_create
(
on_h264_frame
,
media
);
...
...
src/Extension/Factory.cpp
查看文件 @
09a8d531
...
...
@@ -95,6 +95,32 @@ Track::Ptr Factory::getTrackBySdp(const SdpTrack::Ptr &track) {
}
}
Track
::
Ptr
Factory
::
getTrackByAbstractTrack
(
const
Track
::
Ptr
&
track
)
{
auto
codec
=
track
->
getCodecId
();
switch
(
codec
)
{
case
CodecG711A
:
case
CodecG711U
:
{
auto
audio_track
=
dynamic_pointer_cast
<
AudioTrackImp
>
(
track
);
return
std
::
make_shared
<
G711Track
>
(
codec
,
audio_track
->
getAudioSampleRate
(),
audio_track
->
getAudioChannel
(),
16
);
}
case
CodecL16
:
{
auto
audio_track
=
dynamic_pointer_cast
<
AudioTrackImp
>
(
track
);
return
std
::
make_shared
<
L16Track
>
(
audio_track
->
getAudioSampleRate
(),
audio_track
->
getAudioChannel
());
}
case
CodecAAC
:
return
std
::
make_shared
<
AACTrack
>
();
case
CodecOpus
:
return
std
::
make_shared
<
OpusTrack
>
();
case
CodecH265
:
return
std
::
make_shared
<
H265Track
>
();
case
CodecH264
:
return
std
::
make_shared
<
H264Track
>
();
default
:
{
//其他codec不支持
WarnL
<<
"暂不支持该该编码类型创建Track:"
<<
track
->
getCodecName
();
return
nullptr
;
}
}
}
RtpCodec
::
Ptr
Factory
::
getRtpEncoderBySdp
(
const
Sdp
::
Ptr
&
sdp
)
{
GET_CONFIG
(
uint32_t
,
audio_mtu
,
Rtp
::
kAudioMtuSize
);
GET_CONFIG
(
uint32_t
,
video_mtu
,
Rtp
::
kVideoMtuSize
);
...
...
src/Extension/Factory.h
查看文件 @
09a8d531
...
...
@@ -28,6 +28,11 @@ public:
static
Track
::
Ptr
getTrackBySdp
(
const
SdpTrack
::
Ptr
&
track
);
/**
* 根据c api 抽象的Track生成具体Track对象
*/
static
Track
::
Ptr
getTrackByAbstractTrack
(
const
Track
::
Ptr
&
track
);
/**
* 根据sdp生成rtp编码器
* @param sdp sdp对象
*/
...
...
webrtc/Sdp.cpp
查看文件 @
09a8d531
...
...
@@ -771,7 +771,6 @@ void RtcSession::loadFrom(const string &str) {
session_name
=
sdp
.
getSessionName
();
session_info
=
sdp
.
getSessionInfo
();
connection
=
sdp
.
getConnection
();
bandwidth
=
sdp
.
getBandwidth
();
time
=
sdp
.
getSessionTime
();
msid_semantic
=
sdp
.
getItemClass
<
SdpAttrMsidSemantic
>
(
'a'
,
"msid-semantic"
);
for
(
auto
&
media
:
sdp
.
medias
)
{
...
...
@@ -783,6 +782,7 @@ void RtcSession::loadFrom(const string &str) {
rtc_media
.
type
=
mline
.
type
;
rtc_media
.
port
=
mline
.
port
;
rtc_media
.
addr
=
media
.
getItemClass
<
SdpConnection
>
(
'c'
);
rtc_media
.
bandwidth
=
media
.
getItemClass
<
SdpBandwidth
>
(
'b'
);
rtc_media
.
ice_ufrag
=
media
.
getStringItem
(
'a'
,
"ice-ufrag"
);
rtc_media
.
ice_pwd
=
media
.
getStringItem
(
'a'
,
"ice-pwd"
);
rtc_media
.
role
=
media
.
getItemClass
<
SdpAttrSetup
>
(
'a'
,
"setup"
).
role
;
...
...
@@ -1060,9 +1060,6 @@ RtcSessionSdp::Ptr RtcSession::toRtcSessionSdp() const{
if
(
connection
.
empty
()){
sdp
.
addItem
(
std
::
make_shared
<
SdpConnection
>
(
connection
));
}
if
(
!
bandwidth
.
empty
())
{
sdp
.
addItem
(
std
::
make_shared
<
SdpBandwidth
>
(
bandwidth
));
}
sdp
.
addAttr
(
std
::
make_shared
<
SdpAttrGroup
>
(
group
));
sdp
.
addAttr
(
std
::
make_shared
<
SdpAttrMsidSemantic
>
(
msid_semantic
));
for
(
auto
&
m
:
media
)
{
...
...
@@ -1080,6 +1077,9 @@ RtcSessionSdp::Ptr RtcSession::toRtcSessionSdp() const{
}
sdp_media
.
addItem
(
std
::
move
(
mline
));
sdp_media
.
addItem
(
std
::
make_shared
<
SdpConnection
>
(
m
.
addr
));
if
(
!
m
.
bandwidth
.
empty
()
&&
m
.
type
!=
TrackAudio
)
{
sdp_media
.
addItem
(
std
::
make_shared
<
SdpBandwidth
>
(
m
.
bandwidth
));
}
if
(
!
m
.
rtcp_addr
.
empty
())
{
sdp_media
.
addAttr
(
std
::
make_shared
<
SdpAttrRtcp
>
(
m
.
rtcp_addr
));
}
...
...
@@ -1631,6 +1631,7 @@ RETRY:
answer_media
.
proto
=
offer_media
.
proto
;
answer_media
.
port
=
offer_media
.
port
;
answer_media
.
addr
=
offer_media
.
addr
;
answer_media
.
bandwidth
=
offer_media
.
bandwidth
;
answer_media
.
rtcp_addr
=
offer_media
.
rtcp_addr
;
answer_media
.
rtcp_mux
=
offer_media
.
rtcp_mux
&&
configure
.
rtcp_mux
;
answer_media
.
rtcp_rsize
=
offer_media
.
rtcp_rsize
&&
configure
.
rtcp_rsize
;
...
...
webrtc/Sdp.h
查看文件 @
09a8d531
...
...
@@ -612,6 +612,7 @@ public:
std
::
string
mid
;
uint16_t
port
{
0
};
SdpConnection
addr
;
SdpBandwidth
bandwidth
;
std
::
string
proto
;
RtpDirection
direction
{
RtpDirection
::
invalid
};
std
::
vector
<
RtcCodecPlan
>
plan
;
...
...
@@ -666,7 +667,6 @@ public:
std
::
string
session_info
;
SdpTime
time
;
SdpConnection
connection
;
SdpBandwidth
bandwidth
;
SdpAttrMsidSemantic
msid_semantic
;
std
::
vector
<
RtcMedia
>
media
;
SdpAttrGroup
group
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论