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
66a3b7a9
Commit
66a3b7a9
authored
Dec 26, 2020
by
Liu Jiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
RTSP推流增加L16动态payload type支持(RFC 3551 Section 4.5.11, RFC 2586)
parent
bc125e65
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
109 行增加
和
0 行删除
+109
-0
src/Extension/Factory.cpp
+7
-0
src/Extension/Frame.h
+1
-0
src/Extension/L16.cpp
+26
-0
src/Extension/L16.h
+75
-0
没有找到文件。
src/Extension/Factory.cpp
查看文件 @
66a3b7a9
...
...
@@ -20,6 +20,7 @@
#include "CommonRtp.h"
#include "Opus.h"
#include "G711.h"
#include "L16.h"
#include "Common/Parser.h"
namespace
mediakit
{
...
...
@@ -56,6 +57,10 @@ Track::Ptr Factory::getTrackBySdp(const SdpTrack::Ptr &track) {
return
std
::
make_shared
<
G711Track
>
(
CodecG711U
,
track
->
_samplerate
,
track
->
_channel
,
16
);
}
if
(
strcasecmp
(
track
->
_codec
.
data
(),
"L16"
)
==
0
)
{
return
std
::
make_shared
<
L16Track
>
(
track
->
_samplerate
,
track
->
_channel
);
}
if
(
strcasecmp
(
track
->
_codec
.
data
(),
"h264"
)
==
0
)
{
//a=fmtp:96 packetization-mode=1;profile-level-id=42C01F;sprop-parameter-sets=Z0LAH9oBQBboQAAAAwBAAAAPI8YMqA==,aM48gA==
auto
map
=
Parser
::
parseArgs
(
FindField
(
track
->
_fmtp
.
data
(),
" "
,
nullptr
),
";"
,
"="
);
...
...
@@ -123,6 +128,7 @@ RtpCodec::Ptr Factory::getRtpEncoderBySdp(const Sdp::Ptr &sdp) {
case
CodecH264
:
return
std
::
make_shared
<
H264RtpEncoder
>
(
ssrc
,
mtu
,
sample_rate
,
pt
,
interleaved
);
case
CodecH265
:
return
std
::
make_shared
<
H265RtpEncoder
>
(
ssrc
,
mtu
,
sample_rate
,
pt
,
interleaved
);
case
CodecAAC
:
return
std
::
make_shared
<
AACRtpEncoder
>
(
ssrc
,
mtu
,
sample_rate
,
pt
,
interleaved
);
case
CodecL16
:
case
CodecOpus
:
case
CodecG711A
:
case
CodecG711U
:
return
std
::
make_shared
<
CommonRtpEncoder
>
(
codec_id
,
ssrc
,
mtu
,
sample_rate
,
pt
,
interleaved
);
...
...
@@ -135,6 +141,7 @@ RtpCodec::Ptr Factory::getRtpDecoderByTrack(const Track::Ptr &track) {
case
CodecH264
:
return
std
::
make_shared
<
H264RtpDecoder
>
();
case
CodecH265
:
return
std
::
make_shared
<
H265RtpDecoder
>
();
case
CodecAAC
:
return
std
::
make_shared
<
AACRtpDecoder
>
(
track
->
clone
());
case
CodecL16
:
case
CodecOpus
:
case
CodecG711A
:
case
CodecG711U
:
return
std
::
make_shared
<
CommonRtpDecoder
>
(
track
->
getCodecId
());
...
...
src/Extension/Frame.h
查看文件 @
66a3b7a9
...
...
@@ -28,6 +28,7 @@ typedef enum {
CodecAAC
,
CodecG711A
,
CodecG711U
,
CodecL16
,
CodecOpus
,
CodecMax
=
0x7FFF
}
CodecId
;
...
...
src/Extension/L16.cpp
0 → 100644
查看文件 @
66a3b7a9
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors
* may be found in the AUTHORS file in the root of the source tree.
*/
#include "L16.h"
namespace
mediakit
{
Sdp
::
Ptr
L16Track
::
getSdp
()
{
WarnL
<<
"Enter L16Track::getSdp function"
;
if
(
!
ready
()){
WarnL
<<
getCodecName
()
<<
" Track未准备好"
;
return
nullptr
;
}
return
std
::
make_shared
<
L16Sdp
>
(
getCodecId
(),
getAudioSampleRate
(),
getAudioChannel
(),
getBitRate
()
/
1024
);
}
}
//namespace mediakit
src/Extension/L16.h
0 → 100644
查看文件 @
66a3b7a9
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors
* may be found in the AUTHORS file in the root of the source tree.
*/
#ifndef ZLMEDIAKIT_L16_H
#define ZLMEDIAKIT_L16_H
#include "Frame.h"
#include "Track.h"
namespace
mediakit
{
/**
* L16音频通道
*/
class
L16Track
:
public
AudioTrackImp
{
public
:
typedef
std
::
shared_ptr
<
L16Track
>
Ptr
;
L16Track
(
int
sample_rate
,
int
channels
)
:
AudioTrackImp
(
CodecL16
,
sample_rate
,
channels
,
16
){}
private
:
//克隆该Track
Track
::
Ptr
clone
()
override
{
return
std
::
make_shared
<
std
::
remove_reference
<
decltype
(
*
this
)
>::
type
>
(
*
this
);
}
//生成sdp
Sdp
::
Ptr
getSdp
()
override
;
};
/**
* L16类型SDP
*/
class
L16Sdp
:
public
Sdp
{
public
:
/**
* L16采样位数固定为16位
* @param codecId CodecL16
* @param sample_rate 音频采样率
* @param payload_type rtp payload
* @param bitrate 比特率
*/
L16Sdp
(
CodecId
codecId
,
int
sample_rate
,
int
channels
,
int
bitrate
=
128
,
int
payload_type
=
98
)
:
Sdp
(
sample_rate
,
payload_type
),
_codecId
(
codecId
){
_printer
<<
"m=audio 0 RTP/AVP "
<<
payload_type
<<
"
\r\n
"
;
if
(
bitrate
)
{
_printer
<<
"b=AS:"
<<
bitrate
<<
"
\r\n
"
;
}
_printer
<<
"a=rtpmap:"
<<
payload_type
<<
" L16/"
<<
sample_rate
<<
"/"
<<
channels
<<
"
\r\n
"
;
_printer
<<
"a=control:trackID="
<<
(
int
)
TrackAudio
<<
"
\r\n
"
;
}
string
getSdp
()
const
override
{
return
_printer
;
}
CodecId
getCodecId
()
const
override
{
return
_codecId
;
}
private
:
_StrPrinter
_printer
;
CodecId
_codecId
;
};
}
//namespace mediakit
#endif //ZLMEDIAKIT_L16_H
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论