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
9c3b8a6a
Commit
9c3b8a6a
authored
Aug 08, 2022
by
ziyue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
时间戳改为64位
parent
143580d7
隐藏空白字符变更
内嵌
并排
正在显示
44 个修改的文件
包含
143 行增加
和
143 行删除
+143
-143
api/include/mk_frame.h
+3
-3
api/include/mk_media.h
+6
-6
api/source/mk_frame.cpp
+4
-4
api/source/mk_media.cpp
+6
-6
src/Codec/Transcode.cpp
+3
-3
src/Codec/Transcode.h
+1
-1
src/Common/Device.cpp
+14
-14
src/Common/Device.h
+6
-6
src/Common/Stamp.cpp
+2
-2
src/Common/Stamp.h
+7
-7
src/Extension/AACRtp.cpp
+2
-2
src/Extension/AACRtp.h
+2
-2
src/Extension/Frame.h
+18
-18
src/Extension/H264Rtmp.cpp
+1
-1
src/Extension/H264Rtp.cpp
+7
-7
src/Extension/H264Rtp.h
+7
-7
src/Extension/H265Rtmp.cpp
+1
-1
src/Extension/H265Rtp.cpp
+3
-3
src/Extension/H265Rtp.h
+3
-3
src/FMP4/FMP4MediaSourceMuxer.h
+1
-1
src/Record/HlsMaker.cpp
+2
-2
src/Record/HlsMaker.h
+5
-5
src/Record/HlsMakerImp.cpp
+1
-1
src/Record/HlsMakerImp.h
+1
-1
src/Record/HlsRecorder.h
+1
-1
src/Record/MP4Demuxer.cpp
+4
-4
src/Record/MP4Muxer.cpp
+1
-1
src/Record/MP4Muxer.h
+1
-1
src/Record/MPEG.cpp
+3
-3
src/Record/MPEG.h
+3
-3
src/Rtp/Decoder.cpp
+7
-7
src/Rtp/PSEncoder.cpp
+1
-1
src/Rtp/PSEncoder.h
+1
-1
src/Rtp/RtpProcess.cpp
+1
-1
src/Rtp/RtpProcess.h
+2
-2
src/Rtp/RtpSelector.cpp
+2
-2
src/Rtp/RtpSelector.h
+1
-1
src/Rtsp/RtpCodec.cpp
+1
-1
src/Rtsp/RtpCodec.h
+1
-1
src/Rtsp/Rtsp.cpp
+2
-2
src/Rtsp/Rtsp.h
+1
-1
src/TS/TSMediaSource.h
+1
-1
src/TS/TSMediaSourceMuxer.h
+1
-1
tests/test_rtp.cpp
+2
-2
没有找到文件。
api/include/mk_frame.h
查看文件 @
9c3b8a6a
...
...
@@ -55,7 +55,7 @@ typedef void(API_CALL *on_mk_frame_data_release)(void *user_data, char *ptr);
* @param user_data data指针free释放回调用户指针
* @return frame对象引用
*/
API_EXPORT
mk_frame
API_CALL
mk_frame_create
(
int
codec_id
,
uint
32_t
dts
,
uint32
_t
pts
,
const
char
*
data
,
size_t
size
,
API_EXPORT
mk_frame
API_CALL
mk_frame_create
(
int
codec_id
,
uint
64_t
dts
,
uint64
_t
pts
,
const
char
*
data
,
size_t
size
,
on_mk_frame_data_release
cb
,
void
*
user_data
);
/**
...
...
@@ -104,12 +104,12 @@ API_EXPORT size_t API_CALL mk_frame_get_data_prefix_size(mk_frame frame);
/**
* 获取解码时间戳,单位毫秒
*/
API_EXPORT
uint
32
_t
API_CALL
mk_frame_get_dts
(
mk_frame
frame
);
API_EXPORT
uint
64
_t
API_CALL
mk_frame_get_dts
(
mk_frame
frame
);
/**
* 获取显示时间戳,单位毫秒
*/
API_EXPORT
uint
32
_t
API_CALL
mk_frame_get_pts
(
mk_frame
frame
);
API_EXPORT
uint
64
_t
API_CALL
mk_frame_get_pts
(
mk_frame
frame
);
/**
* 获取帧flag,请参考 MK_FRAME_FLAG
...
...
api/include/mk_media.h
查看文件 @
9c3b8a6a
...
...
@@ -99,7 +99,7 @@ API_EXPORT int API_CALL mk_media_input_frame(mk_media ctx, mk_frame frame);
* @param pts 播放时间戳,单位毫秒
* @return 1代表成功,0失败
*/
API_EXPORT
int
API_CALL
mk_media_input_h264
(
mk_media
ctx
,
const
void
*
data
,
int
len
,
uint
32_t
dts
,
uint32
_t
pts
);
API_EXPORT
int
API_CALL
mk_media_input_h264
(
mk_media
ctx
,
const
void
*
data
,
int
len
,
uint
64_t
dts
,
uint64
_t
pts
);
/**
* 输入单帧H265视频,帧起始字节00 00 01,00 00 00 01均可,请改用mk_media_input_frame方法
...
...
@@ -110,7 +110,7 @@ API_EXPORT int API_CALL mk_media_input_h264(mk_media ctx, const void *data, int
* @param pts 播放时间戳,单位毫秒
* @return 1代表成功,0失败
*/
API_EXPORT
int
API_CALL
mk_media_input_h265
(
mk_media
ctx
,
const
void
*
data
,
int
len
,
uint
32_t
dts
,
uint32
_t
pts
);
API_EXPORT
int
API_CALL
mk_media_input_h265
(
mk_media
ctx
,
const
void
*
data
,
int
len
,
uint
64_t
dts
,
uint64
_t
pts
);
/**
* 输入YUV视频数据
...
...
@@ -119,7 +119,7 @@ API_EXPORT int API_CALL mk_media_input_h265(mk_media ctx, const void *data, int
* @param linesize yuv420p linesize
* @param cts 视频采集时间戳,单位毫秒
*/
API_EXPORT
void
API_CALL
mk_media_input_yuv
(
mk_media
ctx
,
const
char
*
yuv
[
3
],
int
linesize
[
3
],
uint
32
_t
cts
);
API_EXPORT
void
API_CALL
mk_media_input_yuv
(
mk_media
ctx
,
const
char
*
yuv
[
3
],
int
linesize
[
3
],
uint
64
_t
cts
);
/**
* 输入单帧AAC音频(单独指定adts头),请改用mk_media_input_frame方法
...
...
@@ -130,7 +130,7 @@ API_EXPORT void API_CALL mk_media_input_yuv(mk_media ctx, const char *yuv[3], in
* @param adts adts头,可以为null
* @return 1代表成功,0失败
*/
API_EXPORT
int
API_CALL
mk_media_input_aac
(
mk_media
ctx
,
const
void
*
data
,
int
len
,
uint
32
_t
dts
,
void
*
adts
);
API_EXPORT
int
API_CALL
mk_media_input_aac
(
mk_media
ctx
,
const
void
*
data
,
int
len
,
uint
64
_t
dts
,
void
*
adts
);
/**
* 输入单帧PCM音频,启用ENABLE_FAAC编译时,该函数才有效
...
...
@@ -140,7 +140,7 @@ API_EXPORT int API_CALL mk_media_input_aac(mk_media ctx, const void *data, int l
* @param dts 时间戳,毫秒
* @return 1代表成功,0失败
*/
API_EXPORT
int
API_CALL
mk_media_input_pcm
(
mk_media
ctx
,
void
*
data
,
int
len
,
uint
32
_t
pts
);
API_EXPORT
int
API_CALL
mk_media_input_pcm
(
mk_media
ctx
,
void
*
data
,
int
len
,
uint
64
_t
pts
);
/**
* 输入单帧OPUS/G711音频帧,请改用mk_media_input_frame方法
...
...
@@ -150,7 +150,7 @@ API_EXPORT int API_CALL mk_media_input_pcm(mk_media ctx, void *data, int len, ui
* @param dts 时间戳,毫秒
* @return 1代表成功,0失败
*/
API_EXPORT
int
API_CALL
mk_media_input_audio
(
mk_media
ctx
,
const
void
*
data
,
int
len
,
uint
32
_t
dts
);
API_EXPORT
int
API_CALL
mk_media_input_audio
(
mk_media
ctx
,
const
void
*
data
,
int
len
,
uint
64
_t
dts
);
/**
* MediaSource.close()回调事件
...
...
api/source/mk_frame.cpp
查看文件 @
9c3b8a6a
...
...
@@ -70,7 +70,7 @@ private:
bool
_cache_able
;
};
static
mk_frame
mk_frame_create_complex
(
int
codec_id
,
uint
32_t
dts
,
uint32
_t
pts
,
uint32_t
frame_flags
,
size_t
prefix_size
,
static
mk_frame
mk_frame_create_complex
(
int
codec_id
,
uint
64_t
dts
,
uint64
_t
pts
,
uint32_t
frame_flags
,
size_t
prefix_size
,
char
*
data
,
size_t
size
,
on_mk_frame_data_release
cb
,
void
*
user_data
)
{
switch
(
codec_id
)
{
case
CodecH264
:
...
...
@@ -85,7 +85,7 @@ static mk_frame mk_frame_create_complex(int codec_id, uint32_t dts, uint32_t pts
}
}
API_EXPORT
mk_frame
API_CALL
mk_frame_create
(
int
codec_id
,
uint
32_t
dts
,
uint32
_t
pts
,
const
char
*
data
,
size_t
size
,
API_EXPORT
mk_frame
API_CALL
mk_frame_create
(
int
codec_id
,
uint
64_t
dts
,
uint64
_t
pts
,
const
char
*
data
,
size_t
size
,
on_mk_frame_data_release
cb
,
void
*
user_data
)
{
switch
(
codec_id
)
{
...
...
@@ -146,12 +146,12 @@ API_EXPORT size_t API_CALL mk_frame_get_data_prefix_size(mk_frame frame) {
return
(
*
((
Frame
::
Ptr
*
)
frame
))
->
prefixSize
();
}
API_EXPORT
uint
32
_t
API_CALL
mk_frame_get_dts
(
mk_frame
frame
)
{
API_EXPORT
uint
64
_t
API_CALL
mk_frame_get_dts
(
mk_frame
frame
)
{
assert
(
frame
);
return
(
*
((
Frame
::
Ptr
*
)
frame
))
->
dts
();
}
API_EXPORT
uint
32
_t
API_CALL
mk_frame_get_pts
(
mk_frame
frame
)
{
API_EXPORT
uint
64
_t
API_CALL
mk_frame_get_pts
(
mk_frame
frame
)
{
assert
(
frame
);
return
(
*
((
Frame
::
Ptr
*
)
frame
))
->
pts
();
}
...
...
api/source/mk_media.cpp
查看文件 @
9c3b8a6a
...
...
@@ -219,37 +219,37 @@ API_EXPORT int API_CALL mk_media_input_frame(mk_media ctx, mk_frame frame){
return
(
*
obj
)
->
getChannel
()
->
inputFrame
(
*
((
Frame
::
Ptr
*
)
frame
));
}
API_EXPORT
int
API_CALL
mk_media_input_h264
(
mk_media
ctx
,
const
void
*
data
,
int
len
,
uint
32_t
dts
,
uint32
_t
pts
)
{
API_EXPORT
int
API_CALL
mk_media_input_h264
(
mk_media
ctx
,
const
void
*
data
,
int
len
,
uint
64_t
dts
,
uint64
_t
pts
)
{
assert
(
ctx
&&
data
&&
len
>
0
);
MediaHelper
::
Ptr
*
obj
=
(
MediaHelper
::
Ptr
*
)
ctx
;
return
(
*
obj
)
->
getChannel
()
->
inputH264
((
const
char
*
)
data
,
len
,
dts
,
pts
);
}
API_EXPORT
int
API_CALL
mk_media_input_h265
(
mk_media
ctx
,
const
void
*
data
,
int
len
,
uint
32_t
dts
,
uint32
_t
pts
)
{
API_EXPORT
int
API_CALL
mk_media_input_h265
(
mk_media
ctx
,
const
void
*
data
,
int
len
,
uint
64_t
dts
,
uint64
_t
pts
)
{
assert
(
ctx
&&
data
&&
len
>
0
);
MediaHelper
::
Ptr
*
obj
=
(
MediaHelper
::
Ptr
*
)
ctx
;
return
(
*
obj
)
->
getChannel
()
->
inputH265
((
const
char
*
)
data
,
len
,
dts
,
pts
);
}
API_EXPORT
void
API_CALL
mk_media_input_yuv
(
mk_media
ctx
,
const
char
*
yuv
[
3
],
int
linesize
[
3
],
uint
32
_t
cts
)
{
API_EXPORT
void
API_CALL
mk_media_input_yuv
(
mk_media
ctx
,
const
char
*
yuv
[
3
],
int
linesize
[
3
],
uint
64
_t
cts
)
{
assert
(
ctx
&&
yuv
&&
linesize
);
MediaHelper
::
Ptr
*
obj
=
(
MediaHelper
::
Ptr
*
)
ctx
;
(
*
obj
)
->
getChannel
()
->
inputYUV
((
char
**
)
yuv
,
linesize
,
cts
);
}
API_EXPORT
int
API_CALL
mk_media_input_aac
(
mk_media
ctx
,
const
void
*
data
,
int
len
,
uint
32
_t
dts
,
void
*
adts
)
{
API_EXPORT
int
API_CALL
mk_media_input_aac
(
mk_media
ctx
,
const
void
*
data
,
int
len
,
uint
64
_t
dts
,
void
*
adts
)
{
assert
(
ctx
&&
data
&&
len
>
0
&&
adts
);
MediaHelper
::
Ptr
*
obj
=
(
MediaHelper
::
Ptr
*
)
ctx
;
return
(
*
obj
)
->
getChannel
()
->
inputAAC
((
const
char
*
)
data
,
len
,
dts
,
(
char
*
)
adts
);
}
API_EXPORT
int
API_CALL
mk_media_input_pcm
(
mk_media
ctx
,
void
*
data
,
int
len
,
uint
32
_t
pts
){
API_EXPORT
int
API_CALL
mk_media_input_pcm
(
mk_media
ctx
,
void
*
data
,
int
len
,
uint
64
_t
pts
){
assert
(
ctx
&&
data
&&
len
>
0
);
MediaHelper
::
Ptr
*
obj
=
(
MediaHelper
::
Ptr
*
)
ctx
;
return
(
*
obj
)
->
getChannel
()
->
inputPCM
((
char
*
)
data
,
len
,
pts
);
}
API_EXPORT
int
API_CALL
mk_media_input_audio
(
mk_media
ctx
,
const
void
*
data
,
int
len
,
uint
32
_t
dts
){
API_EXPORT
int
API_CALL
mk_media_input_audio
(
mk_media
ctx
,
const
void
*
data
,
int
len
,
uint
64
_t
dts
){
assert
(
ctx
&&
data
&&
len
>
0
);
MediaHelper
::
Ptr
*
obj
=
(
MediaHelper
::
Ptr
*
)
ctx
;
return
(
*
obj
)
->
getChannel
()
->
inputAudio
((
const
char
*
)
data
,
len
,
dts
);
...
...
src/Codec/Transcode.cpp
查看文件 @
9c3b8a6a
...
...
@@ -420,7 +420,7 @@ FFmpegDecoder::FFmpegDecoder(const Track::Ptr &track, int thread_num) {
FFmpegDecoder
::~
FFmpegDecoder
()
{
stopThread
(
true
);
if
(
_do_merger
)
{
_merger
.
inputFrame
(
nullptr
,
[
&
](
uint
32_t
dts
,
uint32
_t
pts
,
const
Buffer
::
Ptr
&
buffer
,
bool
have_idr
)
{
_merger
.
inputFrame
(
nullptr
,
[
&
](
uint
64_t
dts
,
uint64
_t
pts
,
const
Buffer
::
Ptr
&
buffer
,
bool
have_idr
)
{
decodeFrame
(
buffer
->
data
(),
buffer
->
size
(),
dts
,
pts
,
false
);
});
}
...
...
@@ -452,7 +452,7 @@ const AVCodecContext *FFmpegDecoder::getContext() const {
bool
FFmpegDecoder
::
inputFrame_l
(
const
Frame
::
Ptr
&
frame
,
bool
live
,
bool
enable_merge
)
{
if
(
_do_merger
&&
enable_merge
)
{
return
_merger
.
inputFrame
(
frame
,
[
&
](
uint
32_t
dts
,
uint32
_t
pts
,
const
Buffer
::
Ptr
&
buffer
,
bool
have_idr
)
{
return
_merger
.
inputFrame
(
frame
,
[
&
](
uint
64_t
dts
,
uint64
_t
pts
,
const
Buffer
::
Ptr
&
buffer
,
bool
have_idr
)
{
decodeFrame
(
buffer
->
data
(),
buffer
->
size
(),
dts
,
pts
,
live
);
});
}
...
...
@@ -478,7 +478,7 @@ bool FFmpegDecoder::inputFrame(const Frame::Ptr &frame, bool live, bool async, b
});
}
bool
FFmpegDecoder
::
decodeFrame
(
const
char
*
data
,
size_t
size
,
uint
32_t
dts
,
uint32
_t
pts
,
bool
live
)
{
bool
FFmpegDecoder
::
decodeFrame
(
const
char
*
data
,
size_t
size
,
uint
64_t
dts
,
uint64
_t
pts
,
bool
live
)
{
TimeTicker2
(
30
,
TraceL
);
auto
pkt
=
alloc_av_packet
();
...
...
src/Codec/Transcode.h
查看文件 @
9c3b8a6a
...
...
@@ -113,7 +113,7 @@ public:
private
:
void
onDecode
(
const
FFmpegFrame
::
Ptr
&
frame
);
bool
inputFrame_l
(
const
Frame
::
Ptr
&
frame
,
bool
live
,
bool
enable_merge
);
bool
decodeFrame
(
const
char
*
data
,
size_t
size
,
uint
32_t
dts
,
uint32
_t
pts
,
bool
live
);
bool
decodeFrame
(
const
char
*
data
,
size_t
size
,
uint
64_t
dts
,
uint64
_t
pts
,
bool
live
);
private
:
bool
_do_merger
=
false
;
...
...
src/Common/Device.cpp
查看文件 @
9c3b8a6a
...
...
@@ -28,7 +28,7 @@ using namespace std;
namespace
mediakit
{
bool
DevChannel
::
inputYUV
(
char
*
yuv
[
3
],
int
linesize
[
3
],
uint
32
_t
cts
)
{
bool
DevChannel
::
inputYUV
(
char
*
yuv
[
3
],
int
linesize
[
3
],
uint
64
_t
cts
)
{
#ifdef ENABLE_X264
//TimeTicker1(50);
if
(
!
_pH264Enc
)
{
...
...
@@ -54,7 +54,7 @@ bool DevChannel::inputYUV(char *yuv[3], int linesize[3], uint32_t cts) {
#endif //ENABLE_X264
}
bool
DevChannel
::
inputPCM
(
char
*
pcData
,
int
iDataLen
,
uint
32
_t
uiStamp
)
{
bool
DevChannel
::
inputPCM
(
char
*
pcData
,
int
iDataLen
,
uint
64
_t
uiStamp
)
{
#ifdef ENABLE_FAAC
if
(
!
_pAacEnc
)
{
_pAacEnc
.
reset
(
new
AACEncoder
());
...
...
@@ -77,11 +77,11 @@ bool DevChannel::inputPCM(char* pcData, int iDataLen, uint32_t uiStamp) {
#endif //ENABLE_FAAC
}
bool
DevChannel
::
inputH264
(
const
char
*
data
,
int
len
,
uint
32_t
dts
,
uint32
_t
pts
)
{
if
(
dts
==
0
)
{
dts
=
(
uint32_t
)
_aTicker
[
0
].
elapsedTime
();
bool
DevChannel
::
inputH264
(
const
char
*
data
,
int
len
,
uint
64_t
dts
,
uint64
_t
pts
)
{
if
(
dts
==
0
)
{
dts
=
_aTicker
[
0
].
elapsedTime
();
}
if
(
pts
==
0
)
{
if
(
pts
==
0
)
{
pts
=
dts
;
}
...
...
@@ -96,11 +96,11 @@ bool DevChannel::inputH264(const char *data, int len, uint32_t dts, uint32_t pts
return
inputFrame
(
frame
);
}
bool
DevChannel
::
inputH265
(
const
char
*
data
,
int
len
,
uint
32_t
dts
,
uint32
_t
pts
)
{
if
(
dts
==
0
)
{
dts
=
(
uint32_t
)
_aTicker
[
0
].
elapsedTime
();
bool
DevChannel
::
inputH265
(
const
char
*
data
,
int
len
,
uint
64_t
dts
,
uint64
_t
pts
)
{
if
(
dts
==
0
)
{
dts
=
_aTicker
[
0
].
elapsedTime
();
}
if
(
pts
==
0
)
{
if
(
pts
==
0
)
{
pts
=
dts
;
}
...
...
@@ -129,9 +129,9 @@ public:
}
};
bool
DevChannel
::
inputAAC
(
const
char
*
data_without_adts
,
int
len
,
uint
32
_t
dts
,
const
char
*
adts_header
){
bool
DevChannel
::
inputAAC
(
const
char
*
data_without_adts
,
int
len
,
uint
64
_t
dts
,
const
char
*
adts_header
){
if
(
dts
==
0
)
{
dts
=
(
uint32_t
)
_aTicker
[
1
].
elapsedTime
();
dts
=
_aTicker
[
1
].
elapsedTime
();
}
if
(
!
adts_header
)
{
...
...
@@ -152,9 +152,9 @@ bool DevChannel::inputAAC(const char *data_without_adts, int len, uint32_t dts,
}
bool
DevChannel
::
inputAudio
(
const
char
*
data
,
int
len
,
uint
32
_t
dts
){
bool
DevChannel
::
inputAudio
(
const
char
*
data
,
int
len
,
uint
64
_t
dts
){
if
(
dts
==
0
)
{
dts
=
(
uint32_t
)
_aTicker
[
1
].
elapsedTime
();
dts
=
_aTicker
[
1
].
elapsedTime
();
}
return
inputFrame
(
std
::
make_shared
<
FrameFromPtr
>
(
_audio
->
codecId
,
(
char
*
)
data
,
len
,
dts
,
0
));
}
...
...
src/Common/Device.h
查看文件 @
9c3b8a6a
...
...
@@ -75,7 +75,7 @@ public:
* @param dts 解码时间戳,单位毫秒;等于0时内部会自动生成时间戳
* @param pts 播放时间戳,单位毫秒;等于0时内部会赋值为dts
*/
bool
inputH264
(
const
char
*
data
,
int
len
,
uint
32_t
dts
,
uint32
_t
pts
=
0
);
bool
inputH264
(
const
char
*
data
,
int
len
,
uint
64_t
dts
,
uint64
_t
pts
=
0
);
/**
* 输入265帧
...
...
@@ -84,7 +84,7 @@ public:
* @param dts 解码时间戳,单位毫秒;等于0时内部会自动生成时间戳
* @param pts 播放时间戳,单位毫秒;等于0时内部会赋值为dts
*/
bool
inputH265
(
const
char
*
data
,
int
len
,
uint
32_t
dts
,
uint32
_t
pts
=
0
);
bool
inputH265
(
const
char
*
data
,
int
len
,
uint
64_t
dts
,
uint64
_t
pts
=
0
);
/**
* 输入aac帧
...
...
@@ -93,7 +93,7 @@ public:
* @param dts 时间戳,单位毫秒
* @param adts_header adts头
*/
bool
inputAAC
(
const
char
*
data_without_adts
,
int
len
,
uint
32
_t
dts
,
const
char
*
adts_header
);
bool
inputAAC
(
const
char
*
data_without_adts
,
int
len
,
uint
64
_t
dts
,
const
char
*
adts_header
);
/**
* 输入OPUS/G711音频帧
...
...
@@ -101,7 +101,7 @@ public:
* @param len 帧数据长度
* @param dts 时间戳,单位毫秒
*/
bool
inputAudio
(
const
char
*
data
,
int
len
,
uint
32
_t
dts
);
bool
inputAudio
(
const
char
*
data
,
int
len
,
uint
64
_t
dts
);
/**
* 输入yuv420p视频帧,内部会完成编码并调用inputH264方法
...
...
@@ -109,7 +109,7 @@ public:
* @param linesize yuv420p数据linesize
* @param cts 采集时间戳,单位毫秒
*/
bool
inputYUV
(
char
*
yuv
[
3
],
int
linesize
[
3
],
uint
32
_t
cts
);
bool
inputYUV
(
char
*
yuv
[
3
],
int
linesize
[
3
],
uint
64
_t
cts
);
/**
* 输入pcm数据,内部会完成编码并调用inputAAC方法
...
...
@@ -117,7 +117,7 @@ public:
* @param len pcm数据长度
* @param cts 采集时间戳,单位毫秒
*/
bool
inputPCM
(
char
*
data
,
int
len
,
uint
32
_t
cts
);
bool
inputPCM
(
char
*
data
,
int
len
,
uint
64
_t
cts
);
private
:
MediaOriginType
getOriginType
(
MediaSource
&
sender
)
const
override
;
...
...
src/Common/Stamp.cpp
查看文件 @
9c3b8a6a
...
...
@@ -137,7 +137,7 @@ int64_t Stamp::getRelativeStamp() const {
return
_relative_stamp
;
}
bool
DtsGenerator
::
getDts
(
uint
32_t
pts
,
uint32
_t
&
dts
){
bool
DtsGenerator
::
getDts
(
uint
64_t
pts
,
uint64
_t
&
dts
){
bool
ret
=
false
;
if
(
pts
==
_last_pts
)
{
//pts未变,说明dts也不会变,返回上次dts
...
...
@@ -167,7 +167,7 @@ bool DtsGenerator::getDts(uint32_t pts, uint32_t &dts){
//该算法核心思想是对pts进行排序,排序好的pts就是dts。
//排序有一定的滞后性,那么需要加上排序导致的时间戳偏移量
bool
DtsGenerator
::
getDts_l
(
uint
32_t
pts
,
uint32
_t
&
dts
){
bool
DtsGenerator
::
getDts_l
(
uint
64_t
pts
,
uint64
_t
&
dts
){
if
(
_sorter_max_size
==
1
){
//没有B帧,dts就等于pts
dts
=
pts
;
...
...
src/Common/Stamp.h
查看文件 @
9c3b8a6a
...
...
@@ -97,20 +97,20 @@ class DtsGenerator{
public
:
DtsGenerator
()
=
default
;
~
DtsGenerator
()
=
default
;
bool
getDts
(
uint
32_t
pts
,
uint32
_t
&
dts
);
bool
getDts
(
uint
64_t
pts
,
uint64
_t
&
dts
);
private
:
bool
getDts_l
(
uint
32_t
pts
,
uint32
_t
&
dts
);
bool
getDts_l
(
uint
64_t
pts
,
uint64
_t
&
dts
);
private
:
uint
32
_t
_dts_pts_offset
=
0
;
uint
32
_t
_last_dts
=
0
;
uint
32
_t
_last_pts
=
0
;
uint
32
_t
_last_max_pts
=
0
;
uint
64
_t
_dts_pts_offset
=
0
;
uint
64
_t
_last_dts
=
0
;
uint
64
_t
_last_pts
=
0
;
uint
64
_t
_last_max_pts
=
0
;
size_t
_frames_since_last_max_pts
=
0
;
size_t
_sorter_max_size
=
0
;
size_t
_count_sorter_max_size
=
0
;
std
::
set
<
uint
32
_t
>
_pts_sorter
;
std
::
set
<
uint
64
_t
>
_pts_sorter
;
};
class
NtpStamp
{
...
...
src/Extension/AACRtp.cpp
查看文件 @
9c3b8a6a
...
...
@@ -53,8 +53,8 @@ bool AACRtpEncoder::inputFrame(const Frame::Ptr &frame) {
return
len
>
0
;
}
void
AACRtpEncoder
::
makeAACRtp
(
const
void
*
data
,
size_t
len
,
bool
mark
,
uint
32_t
uiS
tamp
)
{
RtpCodec
::
inputRtp
(
makeRtp
(
getTrackType
(),
data
,
len
,
mark
,
uiS
tamp
),
false
);
void
AACRtpEncoder
::
makeAACRtp
(
const
void
*
data
,
size_t
len
,
bool
mark
,
uint
64_t
s
tamp
)
{
RtpCodec
::
inputRtp
(
makeRtp
(
getTrackType
(),
data
,
len
,
mark
,
s
tamp
),
false
);
}
/////////////////////////////////////////////////////////////////////////////////////
...
...
src/Extension/AACRtp.h
查看文件 @
9c3b8a6a
...
...
@@ -43,7 +43,7 @@ private:
void
flushData
();
private
:
uint
32
_t
_last_dts
=
0
;
uint
64
_t
_last_dts
=
0
;
std
::
string
_aac_cfg
;
FrameImp
::
Ptr
_frame
;
};
...
...
@@ -77,7 +77,7 @@ public:
bool
inputFrame
(
const
Frame
::
Ptr
&
frame
)
override
;
private
:
void
makeAACRtp
(
const
void
*
pData
,
size_t
uiLen
,
bool
bMark
,
uint32_t
uiS
tamp
);
void
makeAACRtp
(
const
void
*
data
,
size_t
len
,
bool
mark
,
uint64_t
s
tamp
);
private
:
unsigned
char
_section_buf
[
1600
];
...
...
src/Extension/Frame.h
查看文件 @
9c3b8a6a
...
...
@@ -112,12 +112,12 @@ public:
/**
* 返回解码时间戳,单位毫秒
*/
virtual
uint
32
_t
dts
()
const
=
0
;
virtual
uint
64
_t
dts
()
const
=
0
;
/**
* 返回显示时间戳,单位毫秒
*/
virtual
uint
32
_t
pts
()
const
{
return
dts
();
}
virtual
uint
64
_t
pts
()
const
{
return
dts
();
}
/**
* 前缀长度,譬如264前缀为0x00 00 00 01,那么前缀长度就是4
...
...
@@ -194,8 +194,8 @@ public:
char
*
data
()
const
override
{
return
(
char
*
)
_buffer
.
data
();
}
size_t
size
()
const
override
{
return
_buffer
.
size
();
}
uint
32
_t
dts
()
const
override
{
return
_dts
;
}
uint
32
_t
pts
()
const
override
{
return
_pts
?
_pts
:
_dts
;
}
uint
64
_t
dts
()
const
override
{
return
_dts
;
}
uint
64
_t
pts
()
const
override
{
return
_pts
?
_pts
:
_dts
;
}
size_t
prefixSize
()
const
override
{
return
_prefix_size
;
}
CodecId
getCodecId
()
const
override
{
return
_codec_id
;
}
bool
keyFrame
()
const
override
{
return
false
;
}
...
...
@@ -203,8 +203,8 @@ public:
public
:
CodecId
_codec_id
=
CodecInvalid
;
uint
32
_t
_dts
=
0
;
uint
32
_t
_pts
=
0
;
uint
64
_t
_dts
=
0
;
uint
64
_t
_pts
=
0
;
size_t
_prefix_size
=
0
;
toolkit
::
BufferLikeString
_buffer
;
...
...
@@ -248,7 +248,7 @@ class FrameTSInternal : public Parent {
public
:
typedef
std
::
shared_ptr
<
FrameTSInternal
>
Ptr
;
FrameTSInternal
(
const
Frame
::
Ptr
&
parent_frame
,
char
*
ptr
,
size_t
size
,
size_t
prefix_size
,
uint
32_t
dts
,
uint32
_t
pts
)
const
Frame
::
Ptr
&
parent_frame
,
char
*
ptr
,
size_t
size
,
size_t
prefix_size
,
uint
64_t
dts
,
uint64
_t
pts
)
:
Parent
(
ptr
,
size
,
dts
,
pts
,
prefix_size
)
{
_parent_frame
=
parent_frame
;
}
...
...
@@ -361,13 +361,13 @@ public:
typedef
std
::
shared_ptr
<
FrameFromPtr
>
Ptr
;
FrameFromPtr
(
CodecId
codec_id
,
char
*
ptr
,
size_t
size
,
uint
32_t
dts
,
uint32
_t
pts
=
0
,
size_t
prefix_size
=
0
,
CodecId
codec_id
,
char
*
ptr
,
size_t
size
,
uint
64_t
dts
,
uint64
_t
pts
=
0
,
size_t
prefix_size
=
0
,
bool
is_key
=
false
)
:
FrameFromPtr
(
ptr
,
size
,
dts
,
pts
,
prefix_size
,
is_key
)
{
_codec_id
=
codec_id
;
}
FrameFromPtr
(
char
*
ptr
,
size_t
size
,
uint
32_t
dts
,
uint32
_t
pts
=
0
,
size_t
prefix_size
=
0
,
bool
is_key
=
false
)
{
FrameFromPtr
(
char
*
ptr
,
size_t
size
,
uint
64_t
dts
,
uint64
_t
pts
=
0
,
size_t
prefix_size
=
0
,
bool
is_key
=
false
)
{
_ptr
=
ptr
;
_size
=
size
;
_dts
=
dts
;
...
...
@@ -378,8 +378,8 @@ public:
char
*
data
()
const
override
{
return
_ptr
;
}
size_t
size
()
const
override
{
return
_size
;
}
uint
32
_t
dts
()
const
override
{
return
_dts
;
}
uint
32
_t
pts
()
const
override
{
return
_pts
?
_pts
:
dts
();
}
uint
64
_t
dts
()
const
override
{
return
_dts
;
}
uint
64
_t
pts
()
const
override
{
return
_pts
?
_pts
:
dts
();
}
size_t
prefixSize
()
const
override
{
return
_prefix_size
;
}
bool
cacheAble
()
const
override
{
return
false
;
}
bool
keyFrame
()
const
override
{
return
_is_key
;
}
...
...
@@ -399,8 +399,8 @@ protected:
protected
:
bool
_is_key
;
char
*
_ptr
;
uint
32
_t
_dts
;
uint
32
_t
_pts
=
0
;
uint
64
_t
_dts
;
uint
64
_t
_pts
=
0
;
size_t
_size
;
size_t
_prefix_size
;
CodecId
_codec_id
=
CodecInvalid
;
...
...
@@ -464,8 +464,8 @@ public:
}
~
FrameStamp
()
override
{}
uint
32_t
dts
()
const
override
{
return
(
uint32
_t
)
_dts
;
}
uint
32_t
pts
()
const
override
{
return
(
uint32
_t
)
_pts
;
}
uint
64_t
dts
()
const
override
{
return
(
uint64
_t
)
_dts
;
}
uint
64_t
pts
()
const
override
{
return
(
uint64
_t
)
_pts
;
}
size_t
prefixSize
()
const
override
{
return
_frame
->
prefixSize
();
}
bool
keyFrame
()
const
override
{
return
_frame
->
keyFrame
();
}
bool
configFrame
()
const
override
{
return
_frame
->
configFrame
();
}
...
...
@@ -498,7 +498,7 @@ public:
* @param prefix 帧前缀长度
* @param offset buffer有效数据偏移量
*/
FrameWrapper
(
toolkit
::
Buffer
::
Ptr
buf
,
uint
32_t
dts
,
uint32
_t
pts
,
size_t
prefix
,
size_t
offset
)
FrameWrapper
(
toolkit
::
Buffer
::
Ptr
buf
,
uint
64_t
dts
,
uint64
_t
pts
,
size_t
prefix
,
size_t
offset
)
:
Parent
(
buf
->
data
()
+
offset
,
buf
->
size
()
-
offset
,
dts
,
pts
,
prefix
)
{
_buf
=
std
::
move
(
buf
);
}
...
...
@@ -512,7 +512,7 @@ public:
* @param offset buffer有效数据偏移量
* @param codec 帧类型
*/
FrameWrapper
(
toolkit
::
Buffer
::
Ptr
buf
,
uint
32_t
dts
,
uint32
_t
pts
,
size_t
prefix
,
size_t
offset
,
CodecId
codec
)
FrameWrapper
(
toolkit
::
Buffer
::
Ptr
buf
,
uint
64_t
dts
,
uint64
_t
pts
,
size_t
prefix
,
size_t
offset
,
CodecId
codec
)
:
Parent
(
codec
,
buf
->
data
()
+
offset
,
buf
->
size
()
-
offset
,
dts
,
pts
,
prefix
)
{
_buf
=
std
::
move
(
buf
);
}
...
...
@@ -531,7 +531,7 @@ private:
*/
class
FrameMerger
{
public
:
using
onOutput
=
std
::
function
<
void
(
uint
32_t
dts
,
uint32
_t
pts
,
const
toolkit
::
Buffer
::
Ptr
&
buffer
,
bool
have_key_frame
)
>
;
using
onOutput
=
std
::
function
<
void
(
uint
64_t
dts
,
uint64
_t
pts
,
const
toolkit
::
Buffer
::
Ptr
&
buffer
,
bool
have_key_frame
)
>
;
using
Ptr
=
std
::
shared_ptr
<
FrameMerger
>
;
enum
{
none
=
0
,
...
...
src/Extension/H264Rtmp.cpp
查看文件 @
9c3b8a6a
...
...
@@ -152,7 +152,7 @@ bool H264RtmpEncoder::inputFrame(const Frame::Ptr &frame) {
_rtmp_packet
->
buffer
.
resize
(
5
);
}
return
_merger
.
inputFrame
(
frame
,
[
this
](
uint
32_t
dts
,
uint32
_t
pts
,
const
Buffer
::
Ptr
&
,
bool
have_key_frame
)
{
return
_merger
.
inputFrame
(
frame
,
[
this
](
uint
64_t
dts
,
uint64
_t
pts
,
const
Buffer
::
Ptr
&
,
bool
have_key_frame
)
{
//flags
_rtmp_packet
->
buffer
[
0
]
=
FLV_CODEC_H264
|
((
have_key_frame
?
FLV_KEY_FRAME
:
FLV_INTER_FRAME
)
<<
4
);
//not config
...
...
src/Extension/H264Rtp.cpp
查看文件 @
9c3b8a6a
...
...
@@ -73,7 +73,7 @@ Table 1. Summary of NAL unit types and their payload structures
30-31 undefined -
*/
bool
H264RtpDecoder
::
singleFrame
(
const
RtpPacket
::
Ptr
&
rtp
,
const
uint8_t
*
ptr
,
ssize_t
size
,
uint
32
_t
stamp
){
bool
H264RtpDecoder
::
singleFrame
(
const
RtpPacket
::
Ptr
&
rtp
,
const
uint8_t
*
ptr
,
ssize_t
size
,
uint
64
_t
stamp
){
_frame
->
_buffer
.
assign
(
"
\x00\x00\x00\x01
"
,
4
);
_frame
->
_buffer
.
append
((
char
*
)
ptr
,
size
);
_frame
->
_pts
=
stamp
;
...
...
@@ -82,7 +82,7 @@ bool H264RtpDecoder::singleFrame(const RtpPacket::Ptr &rtp, const uint8_t *ptr,
return
key
;
}
bool
H264RtpDecoder
::
unpackStapA
(
const
RtpPacket
::
Ptr
&
rtp
,
const
uint8_t
*
ptr
,
ssize_t
size
,
uint
32
_t
stamp
)
{
bool
H264RtpDecoder
::
unpackStapA
(
const
RtpPacket
::
Ptr
&
rtp
,
const
uint8_t
*
ptr
,
ssize_t
size
,
uint
64
_t
stamp
)
{
//STAP-A 单一时间的组合包
auto
have_key_frame
=
false
;
auto
end
=
ptr
+
size
;
...
...
@@ -102,7 +102,7 @@ bool H264RtpDecoder::unpackStapA(const RtpPacket::Ptr &rtp, const uint8_t *ptr,
return
have_key_frame
;
}
bool
H264RtpDecoder
::
mergeFu
(
const
RtpPacket
::
Ptr
&
rtp
,
const
uint8_t
*
ptr
,
ssize_t
size
,
uint
32
_t
stamp
,
uint16_t
seq
){
bool
H264RtpDecoder
::
mergeFu
(
const
RtpPacket
::
Ptr
&
rtp
,
const
uint8_t
*
ptr
,
ssize_t
size
,
uint
64
_t
stamp
,
uint16_t
seq
){
auto
nal_suffix
=
*
ptr
&
(
~
0x1F
);
FuFlags
*
fu
=
(
FuFlags
*
)
(
ptr
+
1
);
if
(
fu
->
start_bit
)
{
...
...
@@ -197,7 +197,7 @@ H264RtpEncoder::H264RtpEncoder(uint32_t ssrc, uint32_t mtu, uint32_t sample_rate
:
RtpInfo
(
ssrc
,
mtu
,
sample_rate
,
pt
,
interleaved
)
{
}
void
H264RtpEncoder
::
insertConfigFrame
(
uint
32
_t
pts
){
void
H264RtpEncoder
::
insertConfigFrame
(
uint
64
_t
pts
){
if
(
!
_sps
||
!
_pps
)
{
return
;
}
...
...
@@ -206,7 +206,7 @@ void H264RtpEncoder::insertConfigFrame(uint32_t pts){
packRtp
(
_pps
->
data
()
+
_pps
->
prefixSize
(),
_pps
->
size
()
-
_pps
->
prefixSize
(),
pts
,
false
,
false
);
}
void
H264RtpEncoder
::
packRtp
(
const
char
*
ptr
,
size_t
len
,
uint
32
_t
pts
,
bool
is_mark
,
bool
gop_pos
){
void
H264RtpEncoder
::
packRtp
(
const
char
*
ptr
,
size_t
len
,
uint
64
_t
pts
,
bool
is_mark
,
bool
gop_pos
){
if
(
len
+
3
<=
getMaxSize
())
{
//STAP-A模式打包小于MTU
packRtpStapA
(
ptr
,
len
,
pts
,
is_mark
,
gop_pos
);
...
...
@@ -216,7 +216,7 @@ void H264RtpEncoder::packRtp(const char *ptr, size_t len, uint32_t pts, bool is_
}
}
void
H264RtpEncoder
::
packRtpFu
(
const
char
*
ptr
,
size_t
len
,
uint
32
_t
pts
,
bool
is_mark
,
bool
gop_pos
){
void
H264RtpEncoder
::
packRtpFu
(
const
char
*
ptr
,
size_t
len
,
uint
64
_t
pts
,
bool
is_mark
,
bool
gop_pos
){
auto
packet_size
=
getMaxSize
()
-
2
;
if
(
len
<=
packet_size
+
1
)
{
//小于FU-A打包最小字节长度要求,采用STAP-A模式
...
...
@@ -256,7 +256,7 @@ void H264RtpEncoder::packRtpFu(const char *ptr, size_t len, uint32_t pts, bool i
}
}
void
H264RtpEncoder
::
packRtpStapA
(
const
char
*
ptr
,
size_t
len
,
uint
32
_t
pts
,
bool
is_mark
,
bool
gop_pos
){
void
H264RtpEncoder
::
packRtpStapA
(
const
char
*
ptr
,
size_t
len
,
uint
64
_t
pts
,
bool
is_mark
,
bool
gop_pos
){
//如果帧长度不超过mtu,为了兼容性 webrtc,采用STAP-A模式打包
auto
rtp
=
makeRtp
(
getTrackType
(),
nullptr
,
len
+
3
,
is_mark
,
pts
);
uint8_t
*
payload
=
rtp
->
getPayload
();
...
...
src/Extension/H264Rtp.h
查看文件 @
9c3b8a6a
...
...
@@ -42,9 +42,9 @@ public:
}
private
:
bool
singleFrame
(
const
RtpPacket
::
Ptr
&
rtp
,
const
uint8_t
*
ptr
,
ssize_t
size
,
uint
32
_t
stamp
);
bool
unpackStapA
(
const
RtpPacket
::
Ptr
&
rtp
,
const
uint8_t
*
ptr
,
ssize_t
size
,
uint
32
_t
stamp
);
bool
mergeFu
(
const
RtpPacket
::
Ptr
&
rtp
,
const
uint8_t
*
ptr
,
ssize_t
size
,
uint
32
_t
stamp
,
uint16_t
seq
);
bool
singleFrame
(
const
RtpPacket
::
Ptr
&
rtp
,
const
uint8_t
*
ptr
,
ssize_t
size
,
uint
64
_t
stamp
);
bool
unpackStapA
(
const
RtpPacket
::
Ptr
&
rtp
,
const
uint8_t
*
ptr
,
ssize_t
size
,
uint
64
_t
stamp
);
bool
mergeFu
(
const
RtpPacket
::
Ptr
&
rtp
,
const
uint8_t
*
ptr
,
ssize_t
size
,
uint
64
_t
stamp
,
uint16_t
seq
);
bool
decodeRtp
(
const
RtpPacket
::
Ptr
&
rtp
);
H264Frame
::
Ptr
obtainFrame
();
...
...
@@ -86,11 +86,11 @@ public:
bool
inputFrame
(
const
Frame
::
Ptr
&
frame
)
override
;
private
:
void
insertConfigFrame
(
uint
32
_t
pts
);
void
insertConfigFrame
(
uint
64
_t
pts
);
bool
inputFrame_l
(
const
Frame
::
Ptr
&
frame
,
bool
is_mark
);
void
packRtp
(
const
char
*
data
,
size_t
len
,
uint
32
_t
pts
,
bool
is_mark
,
bool
gop_pos
);
void
packRtpFu
(
const
char
*
data
,
size_t
len
,
uint
32
_t
pts
,
bool
is_mark
,
bool
gop_pos
);
void
packRtpStapA
(
const
char
*
data
,
size_t
len
,
uint
32
_t
pts
,
bool
is_mark
,
bool
gop_pos
);
void
packRtp
(
const
char
*
data
,
size_t
len
,
uint
64
_t
pts
,
bool
is_mark
,
bool
gop_pos
);
void
packRtpFu
(
const
char
*
data
,
size_t
len
,
uint
64
_t
pts
,
bool
is_mark
,
bool
gop_pos
);
void
packRtpStapA
(
const
char
*
data
,
size_t
len
,
uint
64
_t
pts
,
bool
is_mark
,
bool
gop_pos
);
private
:
Frame
::
Ptr
_sps
;
...
...
src/Extension/H265Rtmp.cpp
查看文件 @
9c3b8a6a
...
...
@@ -172,7 +172,7 @@ bool H265RtmpEncoder::inputFrame(const Frame::Ptr &frame) {
_rtmp_packet
->
buffer
.
resize
(
5
);
}
return
_merger
.
inputFrame
(
frame
,
[
this
](
uint
32_t
dts
,
uint32
_t
pts
,
const
Buffer
::
Ptr
&
,
bool
have_key_frame
)
{
return
_merger
.
inputFrame
(
frame
,
[
this
](
uint
64_t
dts
,
uint64
_t
pts
,
const
Buffer
::
Ptr
&
,
bool
have_key_frame
)
{
//flags
_rtmp_packet
->
buffer
[
0
]
=
FLV_CODEC_H265
|
((
have_key_frame
?
FLV_KEY_FRAME
:
FLV_INTER_FRAME
)
<<
4
);
//not config
...
...
src/Extension/H265Rtp.cpp
查看文件 @
9c3b8a6a
...
...
@@ -69,7 +69,7 @@ H265Frame::Ptr H265RtpDecoder::obtainFrame() {
| : ...OPTIONAL RTP padding |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
bool
H265RtpDecoder
::
unpackAp
(
const
RtpPacket
::
Ptr
&
rtp
,
const
uint8_t
*
ptr
,
ssize_t
size
,
uint
32
_t
stamp
){
bool
H265RtpDecoder
::
unpackAp
(
const
RtpPacket
::
Ptr
&
rtp
,
const
uint8_t
*
ptr
,
ssize_t
size
,
uint
64
_t
stamp
){
bool
have_key_frame
=
false
;
//忽略PayloadHdr
CHECK_SIZE
(
size
,
2
,
have_key_frame
);
...
...
@@ -119,7 +119,7 @@ bool H265RtpDecoder::unpackAp(const RtpPacket::Ptr &rtp, const uint8_t *ptr, ssi
+---------------+
*/
bool
H265RtpDecoder
::
mergeFu
(
const
RtpPacket
::
Ptr
&
rtp
,
const
uint8_t
*
ptr
,
ssize_t
size
,
uint
32
_t
stamp
,
uint16_t
seq
){
bool
H265RtpDecoder
::
mergeFu
(
const
RtpPacket
::
Ptr
&
rtp
,
const
uint8_t
*
ptr
,
ssize_t
size
,
uint
64
_t
stamp
,
uint16_t
seq
){
CHECK_SIZE
(
size
,
4
,
false
);
auto
s_bit
=
ptr
[
2
]
>>
7
;
auto
e_bit
=
(
ptr
[
2
]
>>
6
)
&
0x01
;
...
...
@@ -216,7 +216,7 @@ bool H265RtpDecoder::decodeRtp(const RtpPacket::Ptr &rtp) {
}
}
bool
H265RtpDecoder
::
singleFrame
(
const
RtpPacket
::
Ptr
&
rtp
,
const
uint8_t
*
ptr
,
ssize_t
size
,
uint
32
_t
stamp
){
bool
H265RtpDecoder
::
singleFrame
(
const
RtpPacket
::
Ptr
&
rtp
,
const
uint8_t
*
ptr
,
ssize_t
size
,
uint
64
_t
stamp
){
_frame
->
_buffer
.
assign
(
"
\x00\x00\x00\x01
"
,
4
);
_frame
->
_buffer
.
append
((
char
*
)
ptr
,
size
);
_frame
->
_pts
=
stamp
;
...
...
src/Extension/H265Rtp.h
查看文件 @
9c3b8a6a
...
...
@@ -42,9 +42,9 @@ public:
}
private
:
bool
unpackAp
(
const
RtpPacket
::
Ptr
&
rtp
,
const
uint8_t
*
ptr
,
ssize_t
size
,
uint
32
_t
stamp
);
bool
mergeFu
(
const
RtpPacket
::
Ptr
&
rtp
,
const
uint8_t
*
ptr
,
ssize_t
size
,
uint
32
_t
stamp
,
uint16_t
seq
);
bool
singleFrame
(
const
RtpPacket
::
Ptr
&
rtp
,
const
uint8_t
*
ptr
,
ssize_t
size
,
uint
32
_t
stamp
);
bool
unpackAp
(
const
RtpPacket
::
Ptr
&
rtp
,
const
uint8_t
*
ptr
,
ssize_t
size
,
uint
64
_t
stamp
);
bool
mergeFu
(
const
RtpPacket
::
Ptr
&
rtp
,
const
uint8_t
*
ptr
,
ssize_t
size
,
uint
64
_t
stamp
,
uint16_t
seq
);
bool
singleFrame
(
const
RtpPacket
::
Ptr
&
rtp
,
const
uint8_t
*
ptr
,
ssize_t
size
,
uint
64
_t
stamp
);
bool
decodeRtp
(
const
RtpPacket
::
Ptr
&
rtp
);
H265Frame
::
Ptr
obtainFrame
();
...
...
src/FMP4/FMP4MediaSourceMuxer.h
查看文件 @
9c3b8a6a
...
...
@@ -72,7 +72,7 @@ public:
}
protected
:
void
onSegmentData
(
std
::
string
string
,
uint
32
_t
stamp
,
bool
key_frame
)
override
{
void
onSegmentData
(
std
::
string
string
,
uint
64
_t
stamp
,
bool
key_frame
)
override
{
if
(
string
.
empty
())
{
return
;
}
...
...
src/Record/HlsMaker.cpp
查看文件 @
9c3b8a6a
...
...
@@ -75,7 +75,7 @@ void HlsMaker::makeIndexFile(bool eof) {
}
void
HlsMaker
::
inputData
(
void
*
data
,
size_t
len
,
uint
32
_t
timestamp
,
bool
is_idr_fast_packet
)
{
void
HlsMaker
::
inputData
(
void
*
data
,
size_t
len
,
uint
64
_t
timestamp
,
bool
is_idr_fast_packet
)
{
if
(
data
&&
len
)
{
if
(
timestamp
<
_last_timestamp
)
{
//时间戳回退了,切片时长重新计时
...
...
@@ -117,7 +117,7 @@ void HlsMaker::delOldSegment() {
}
}
void
HlsMaker
::
addNewSegment
(
uint
32
_t
stamp
)
{
void
HlsMaker
::
addNewSegment
(
uint
64
_t
stamp
)
{
if
(
!
_last_file_name
.
empty
()
&&
stamp
-
_last_seg_timestamp
<
_seg_duration
*
1000
)
{
//存在上个切片,并且未到分片时间
return
;
...
...
src/Record/HlsMaker.h
查看文件 @
9c3b8a6a
...
...
@@ -38,7 +38,7 @@ public:
* @param timestamp 毫秒时间戳
* @param is_idr_fast_packet 是否为关键帧第一个包
*/
void
inputData
(
void
*
data
,
size_t
len
,
uint
32
_t
timestamp
,
bool
is_idr_fast_packet
);
void
inputData
(
void
*
data
,
size_t
len
,
uint
64
_t
timestamp
,
bool
is_idr_fast_packet
);
/**
* 是否为直播
...
...
@@ -85,7 +85,7 @@ protected:
* 上一个 ts 切片写入完成, 可在这里进行通知处理
* @param duration_ms 上一个 ts 切片的时长, 单位为毫秒
*/
virtual
void
onFlushLastSegment
(
uint
32
_t
duration_ms
)
{};
virtual
void
onFlushLastSegment
(
uint
64
_t
duration_ms
)
{};
/**
* 关闭上个ts切片并且写入m3u8索引
...
...
@@ -109,14 +109,14 @@ private:
* 添加新的ts切片
* @param timestamp
*/
void
addNewSegment
(
uint
32
_t
timestamp
);
void
addNewSegment
(
uint
64
_t
timestamp
);
private
:
float
_seg_duration
=
0
;
uint32_t
_seg_number
=
0
;
bool
_seg_keep
=
false
;
uint
32
_t
_last_timestamp
=
0
;
uint
32
_t
_last_seg_timestamp
=
0
;
uint
64
_t
_last_timestamp
=
0
;
uint
64
_t
_last_seg_timestamp
=
0
;
uint64_t
_file_index
=
0
;
std
::
string
_last_file_name
;
std
::
deque
<
std
::
tuple
<
int
,
std
::
string
>
>
_seg_dur_list
;
...
...
src/Record/HlsMakerImp.cpp
查看文件 @
9c3b8a6a
...
...
@@ -130,7 +130,7 @@ void HlsMakerImp::onWriteHls(const std::string &data) {
//DebugL << "\r\n" << string(data,len);
}
void
HlsMakerImp
::
onFlushLastSegment
(
uint
32
_t
duration_ms
)
{
void
HlsMakerImp
::
onFlushLastSegment
(
uint
64
_t
duration_ms
)
{
//关闭并flush文件到磁盘
_file
=
nullptr
;
...
...
src/Record/HlsMakerImp.h
查看文件 @
9c3b8a6a
...
...
@@ -54,7 +54,7 @@ protected:
void
onDelSegment
(
uint64_t
index
)
override
;
void
onWriteSegment
(
const
char
*
data
,
size_t
len
)
override
;
void
onWriteHls
(
const
std
::
string
&
data
)
override
;
void
onFlushLastSegment
(
uint
32
_t
duration_ms
)
override
;
void
onFlushLastSegment
(
uint
64
_t
duration_ms
)
override
;
private
:
std
::
shared_ptr
<
FILE
>
makeFile
(
const
std
::
string
&
file
,
bool
setbuf
=
false
);
...
...
src/Record/HlsRecorder.h
查看文件 @
9c3b8a6a
...
...
@@ -75,7 +75,7 @@ public:
}
private
:
void
onWrite
(
std
::
shared_ptr
<
toolkit
::
Buffer
>
buffer
,
uint
32
_t
timestamp
,
bool
key_pos
)
override
{
void
onWrite
(
std
::
shared_ptr
<
toolkit
::
Buffer
>
buffer
,
uint
64
_t
timestamp
,
bool
key_pos
)
override
{
if
(
!
buffer
)
{
_hls
->
inputData
(
nullptr
,
0
,
timestamp
,
key_pos
);
}
else
{
...
...
src/Record/MP4Demuxer.cpp
查看文件 @
9c3b8a6a
...
...
@@ -233,10 +233,10 @@ Frame::Ptr MP4Demuxer::makeFrame(uint32_t track_id, const Buffer::Ptr &buf, int6
offset
+=
(
frame_len
+
4
);
}
if
(
codec
==
CodecH264
)
{
ret
=
std
::
make_shared
<
FrameWrapper
<
H264FrameNoCacheAble
>
>
(
buf
,
(
uint
32_t
)
dts
,
(
uint32
_t
)
pts
,
4
,
DATA_OFFSET
);
ret
=
std
::
make_shared
<
FrameWrapper
<
H264FrameNoCacheAble
>
>
(
buf
,
(
uint
64_t
)
dts
,
(
uint64
_t
)
pts
,
4
,
DATA_OFFSET
);
break
;
}
ret
=
std
::
make_shared
<
FrameWrapper
<
H265FrameNoCacheAble
>
>
(
buf
,
(
uint
32_t
)
dts
,
(
uint32
_t
)
pts
,
4
,
DATA_OFFSET
);
ret
=
std
::
make_shared
<
FrameWrapper
<
H265FrameNoCacheAble
>
>
(
buf
,
(
uint
64_t
)
dts
,
(
uint64
_t
)
pts
,
4
,
DATA_OFFSET
);
break
;
}
...
...
@@ -245,14 +245,14 @@ Frame::Ptr MP4Demuxer::makeFrame(uint32_t track_id, const Buffer::Ptr &buf, int6
assert
(
track
);
//加上adts头
dumpAacConfig
(
track
->
getAacCfg
(),
buf
->
size
()
-
DATA_OFFSET
,
(
uint8_t
*
)
buf
->
data
()
+
(
DATA_OFFSET
-
ADTS_HEADER_LEN
),
ADTS_HEADER_LEN
);
ret
=
std
::
make_shared
<
FrameWrapper
<
FrameFromPtr
>
>
(
buf
,
(
uint
32_t
)
dts
,
(
uint32
_t
)
pts
,
ADTS_HEADER_LEN
,
DATA_OFFSET
-
ADTS_HEADER_LEN
,
codec
);
ret
=
std
::
make_shared
<
FrameWrapper
<
FrameFromPtr
>
>
(
buf
,
(
uint
64_t
)
dts
,
(
uint64
_t
)
pts
,
ADTS_HEADER_LEN
,
DATA_OFFSET
-
ADTS_HEADER_LEN
,
codec
);
break
;
}
case
CodecOpus
:
case
CodecG711A
:
case
CodecG711U
:
{
ret
=
std
::
make_shared
<
FrameWrapper
<
FrameFromPtr
>
>
(
buf
,
(
uint
32_t
)
dts
,
(
uint32
_t
)
pts
,
0
,
DATA_OFFSET
,
codec
);
ret
=
std
::
make_shared
<
FrameWrapper
<
FrameFromPtr
>
>
(
buf
,
(
uint
64_t
)
dts
,
(
uint64
_t
)
pts
,
0
,
DATA_OFFSET
,
codec
);
break
;
}
...
...
src/Record/MP4Muxer.cpp
查看文件 @
9c3b8a6a
...
...
@@ -93,7 +93,7 @@ bool MP4MuxerInterface::inputFrame(const Frame::Ptr &frame) {
case
CodecH264
:
case
CodecH265
:
{
//这里的代码逻辑是让SPS、PPS、IDR这些时间戳相同的帧打包到一起当做一个帧处理,
_frame_merger
.
inputFrame
(
frame
,
[
&
](
uint
32_t
dts
,
uint32
_t
pts
,
const
Buffer
::
Ptr
&
buffer
,
bool
have_idr
)
{
_frame_merger
.
inputFrame
(
frame
,
[
&
](
uint
64_t
dts
,
uint64
_t
pts
,
const
Buffer
::
Ptr
&
buffer
,
bool
have_idr
)
{
track_info
.
stamp
.
revise
(
dts
,
pts
,
dts_out
,
pts_out
);
mp4_writer_write
(
_mov_writter
.
get
(),
track_info
.
track_id
,
...
...
src/Record/MP4Muxer.h
查看文件 @
9c3b8a6a
...
...
@@ -134,7 +134,7 @@ protected:
* @param stamp 切片末尾时间戳
* @param key_frame 是否有关键帧
*/
virtual
void
onSegmentData
(
std
::
string
string
,
uint
32
_t
stamp
,
bool
key_frame
)
=
0
;
virtual
void
onSegmentData
(
std
::
string
string
,
uint
64
_t
stamp
,
bool
key_frame
)
=
0
;
protected
:
MP4FileIO
::
Writer
createWriter
()
override
;
...
...
src/Record/MPEG.cpp
查看文件 @
9c3b8a6a
...
...
@@ -63,10 +63,10 @@ bool MpegMuxer::inputFrame(const Frame::Ptr &frame) {
case
CodecH264
:
case
CodecH265
:
{
//这里的代码逻辑是让SPS、PPS、IDR这些时间戳相同的帧打包到一起当做一个帧处理,
return
_frame_merger
.
inputFrame
(
frame
,[
&
](
uint
32_t
dts
,
uint32
_t
pts
,
const
Buffer
::
Ptr
&
buffer
,
bool
have_idr
)
{
return
_frame_merger
.
inputFrame
(
frame
,[
&
](
uint
64_t
dts
,
uint64
_t
pts
,
const
Buffer
::
Ptr
&
buffer
,
bool
have_idr
)
{
_key_pos
=
have_idr
;
//取视频时间戳为TS的时间戳
_timestamp
=
(
uint32_t
)
dts
;
_timestamp
=
dts
;
_max_cache_size
=
512
+
1.2
*
buffer
->
size
();
mpeg_muxer_input
((
::
mpeg_muxer_t
*
)
_context
,
track_id
,
have_idr
?
0x0001
:
0
,
pts
*
90LL
,
dts
*
90LL
,
buffer
->
data
(),
buffer
->
size
());
flushCache
();
...
...
@@ -83,7 +83,7 @@ bool MpegMuxer::inputFrame(const Frame::Ptr &frame) {
default
:
{
if
(
!
_have_video
)
{
//没有视频时,才以音频时间戳为TS的时间戳
_timestamp
=
(
uint32_t
)
frame
->
dts
();
_timestamp
=
frame
->
dts
();
}
_max_cache_size
=
512
+
1.2
*
frame
->
size
();
mpeg_muxer_input
((
::
mpeg_muxer_t
*
)
_context
,
track_id
,
frame
->
keyFrame
()
?
0x0001
:
0
,
frame
->
pts
()
*
90LL
,
frame
->
dts
()
*
90LL
,
frame
->
data
(),
frame
->
size
());
...
...
src/Record/MPEG.h
查看文件 @
9c3b8a6a
...
...
@@ -52,7 +52,7 @@ protected:
* @param timestamp 时间戳,单位毫秒
* @param key_pos 是否为关键帧的第一个ts/ps包,用于确保ts切片第一帧为关键帧
*/
virtual
void
onWrite
(
std
::
shared_ptr
<
toolkit
::
Buffer
>
buffer
,
uint
32
_t
timestamp
,
bool
key_pos
)
=
0
;
virtual
void
onWrite
(
std
::
shared_ptr
<
toolkit
::
Buffer
>
buffer
,
uint
64
_t
timestamp
,
bool
key_pos
)
=
0
;
private
:
void
createContext
();
...
...
@@ -65,7 +65,7 @@ private:
bool
_have_video
=
false
;
bool
_key_pos
=
false
;
uint32_t
_max_cache_size
=
0
;
uint
32
_t
_timestamp
=
0
;
uint
64
_t
_timestamp
=
0
;
struct
mpeg_muxer_t
*
_context
=
nullptr
;
std
::
unordered_map
<
int
,
int
/*track_id*/
>
_codec_to_trackid
;
FrameMerger
_frame_merger
{
FrameMerger
::
h264_prefix
};
...
...
@@ -90,7 +90,7 @@ public:
bool
inputFrame
(
const
Frame
::
Ptr
&
frame
)
override
{
return
false
;
}
protected
:
virtual
void
onWrite
(
std
::
shared_ptr
<
toolkit
::
Buffer
>
buffer
,
uint
32
_t
timestamp
,
bool
key_pos
)
=
0
;
virtual
void
onWrite
(
std
::
shared_ptr
<
toolkit
::
Buffer
>
buffer
,
uint
64
_t
timestamp
,
bool
key_pos
)
=
0
;
};
}
//namespace mediakit
...
...
src/Rtp/Decoder.cpp
查看文件 @
9c3b8a6a
...
...
@@ -165,8 +165,8 @@ void DecoderImp::onDecode(int stream,int codecid,int flags,int64_t pts,int64_t d
if
(
!
_tracks
[
TrackVideo
])
{
onTrack
(
std
::
make_shared
<
H264Track
>
());
}
auto
frame
=
std
::
make_shared
<
H264FrameNoCacheAble
>
((
char
*
)
data
,
bytes
,
(
uint
32_t
)
dts
,
(
uint32
_t
)
pts
,
prefixSize
((
char
*
)
data
,
bytes
));
_merger
.
inputFrame
(
frame
,[
this
](
uint
32_t
dts
,
uint32
_t
pts
,
const
Buffer
::
Ptr
&
buffer
,
bool
)
{
auto
frame
=
std
::
make_shared
<
H264FrameNoCacheAble
>
((
char
*
)
data
,
bytes
,
(
uint
64_t
)
dts
,
(
uint64
_t
)
pts
,
prefixSize
((
char
*
)
data
,
bytes
));
_merger
.
inputFrame
(
frame
,[
this
](
uint
64_t
dts
,
uint64
_t
pts
,
const
Buffer
::
Ptr
&
buffer
,
bool
)
{
onFrame
(
std
::
make_shared
<
FrameWrapper
<
H264FrameNoCacheAble
>
>
(
buffer
,
dts
,
pts
,
prefixSize
(
buffer
->
data
(),
buffer
->
size
()),
0
));
});
break
;
...
...
@@ -176,8 +176,8 @@ void DecoderImp::onDecode(int stream,int codecid,int flags,int64_t pts,int64_t d
if
(
!
_tracks
[
TrackVideo
])
{
onTrack
(
std
::
make_shared
<
H265Track
>
());
}
auto
frame
=
std
::
make_shared
<
H265FrameNoCacheAble
>
((
char
*
)
data
,
bytes
,
(
uint
32_t
)
dts
,
(
uint32
_t
)
pts
,
prefixSize
((
char
*
)
data
,
bytes
));
_merger
.
inputFrame
(
frame
,[
this
](
uint
32_t
dts
,
uint32
_t
pts
,
const
Buffer
::
Ptr
&
buffer
,
bool
)
{
auto
frame
=
std
::
make_shared
<
H265FrameNoCacheAble
>
((
char
*
)
data
,
bytes
,
(
uint
64_t
)
dts
,
(
uint64
_t
)
pts
,
prefixSize
((
char
*
)
data
,
bytes
));
_merger
.
inputFrame
(
frame
,[
this
](
uint
64_t
dts
,
uint64
_t
pts
,
const
Buffer
::
Ptr
&
buffer
,
bool
)
{
onFrame
(
std
::
make_shared
<
FrameWrapper
<
H265FrameNoCacheAble
>
>
(
buffer
,
dts
,
pts
,
prefixSize
(
buffer
->
data
(),
buffer
->
size
()),
0
));
});
break
;
...
...
@@ -193,7 +193,7 @@ void DecoderImp::onDecode(int stream,int codecid,int flags,int64_t pts,int64_t d
if
(
!
_tracks
[
TrackAudio
])
{
onTrack
(
std
::
make_shared
<
AACTrack
>
());
}
onFrame
(
std
::
make_shared
<
FrameFromPtr
>
(
CodecAAC
,
(
char
*
)
data
,
bytes
,
(
uint
32
_t
)
dts
,
0
,
ADTS_HEADER_LEN
));
onFrame
(
std
::
make_shared
<
FrameFromPtr
>
(
CodecAAC
,
(
char
*
)
data
,
bytes
,
(
uint
64
_t
)
dts
,
0
,
ADTS_HEADER_LEN
));
break
;
}
...
...
@@ -204,7 +204,7 @@ void DecoderImp::onDecode(int stream,int codecid,int flags,int64_t pts,int64_t d
//G711传统只支持 8000/1/16的规格,FFmpeg貌似做了扩展,但是这里不管它了
onTrack
(
std
::
make_shared
<
G711Track
>
(
codec
,
8000
,
1
,
16
));
}
onFrame
(
std
::
make_shared
<
FrameFromPtr
>
(
codec
,
(
char
*
)
data
,
bytes
,
(
uint
32
_t
)
dts
));
onFrame
(
std
::
make_shared
<
FrameFromPtr
>
(
codec
,
(
char
*
)
data
,
bytes
,
(
uint
64
_t
)
dts
));
break
;
}
...
...
@@ -212,7 +212,7 @@ void DecoderImp::onDecode(int stream,int codecid,int flags,int64_t pts,int64_t d
if
(
!
_tracks
[
TrackAudio
])
{
onTrack
(
std
::
make_shared
<
OpusTrack
>
());
}
onFrame
(
std
::
make_shared
<
FrameFromPtr
>
(
CodecOpus
,
(
char
*
)
data
,
bytes
,
(
uint
32
_t
)
dts
));
onFrame
(
std
::
make_shared
<
FrameFromPtr
>
(
CodecOpus
,
(
char
*
)
data
,
bytes
,
(
uint
64
_t
)
dts
));
break
;
}
...
...
src/Rtp/PSEncoder.cpp
查看文件 @
9c3b8a6a
...
...
@@ -32,7 +32,7 @@ PSEncoderImp::~PSEncoderImp() {
InfoL
<<
this
<<
" "
<<
printSSRC
(
_rtp_encoder
->
getSsrc
());
}
void
PSEncoderImp
::
onWrite
(
std
::
shared_ptr
<
Buffer
>
buffer
,
uint
32
_t
stamp
,
bool
key_pos
)
{
void
PSEncoderImp
::
onWrite
(
std
::
shared_ptr
<
Buffer
>
buffer
,
uint
64
_t
stamp
,
bool
key_pos
)
{
if
(
!
buffer
)
{
return
;
}
...
...
src/Rtp/PSEncoder.h
查看文件 @
9c3b8a6a
...
...
@@ -30,7 +30,7 @@ protected:
virtual
void
onRTP
(
toolkit
::
Buffer
::
Ptr
rtp
,
bool
is_key
=
false
)
=
0
;
protected
:
void
onWrite
(
std
::
shared_ptr
<
toolkit
::
Buffer
>
buffer
,
uint
32
_t
stamp
,
bool
key_pos
)
override
;
void
onWrite
(
std
::
shared_ptr
<
toolkit
::
Buffer
>
buffer
,
uint
64
_t
stamp
,
bool
key_pos
)
override
;
private
:
std
::
shared_ptr
<
CommonRtpEncoder
>
_rtp_encoder
;
...
...
src/Rtp/RtpProcess.cpp
查看文件 @
9c3b8a6a
...
...
@@ -64,7 +64,7 @@ RtpProcess::~RtpProcess() {
}
}
bool
RtpProcess
::
inputRtp
(
bool
is_udp
,
const
Socket
::
Ptr
&
sock
,
const
char
*
data
,
size_t
len
,
const
struct
sockaddr
*
addr
,
uint
32
_t
*
dts_out
)
{
bool
RtpProcess
::
inputRtp
(
bool
is_udp
,
const
Socket
::
Ptr
&
sock
,
const
char
*
data
,
size_t
len
,
const
struct
sockaddr
*
addr
,
uint
64
_t
*
dts_out
)
{
auto
is_busy
=
_busy_flag
.
test_and_set
();
if
(
is_busy
)
{
//其他线程正在执行本函数
...
...
src/Rtp/RtpProcess.h
查看文件 @
9c3b8a6a
...
...
@@ -35,7 +35,7 @@ public:
* @param dts_out 解析出最新的dts
* @return 是否解析成功
*/
bool
inputRtp
(
bool
is_udp
,
const
toolkit
::
Socket
::
Ptr
&
sock
,
const
char
*
data
,
size_t
len
,
const
struct
sockaddr
*
addr
,
uint
32
_t
*
dts_out
=
nullptr
);
bool
inputRtp
(
bool
is_udp
,
const
toolkit
::
Socket
::
Ptr
&
sock
,
const
char
*
data
,
size_t
len
,
const
struct
sockaddr
*
addr
,
uint
64
_t
*
dts_out
=
nullptr
);
/**
* 是否超时,用于超时移除对象
...
...
@@ -86,7 +86,7 @@ private:
void
doCachedFunc
();
private
:
uint
32
_t
_dts
=
0
;
uint
64
_t
_dts
=
0
;
uint64_t
_total_bytes
=
0
;
std
::
unique_ptr
<
sockaddr_storage
>
_addr
;
toolkit
::
Socket
::
Ptr
_sock
;
...
...
src/Rtp/RtpSelector.cpp
查看文件 @
9c3b8a6a
...
...
@@ -25,8 +25,8 @@ void RtpSelector::clear(){
_map_rtp_process
.
clear
();
}
bool
RtpSelector
::
inputRtp
(
const
Socket
::
Ptr
&
sock
,
const
char
*
data
,
size_t
data_len
,
const
struct
sockaddr
*
addr
,
uint32
_t
*
dts_out
)
{
bool
RtpSelector
::
inputRtp
(
const
Socket
::
Ptr
&
sock
,
const
char
*
data
,
size_t
data_len
,
const
struct
sockaddr
*
addr
,
uint64
_t
*
dts_out
)
{
uint32_t
ssrc
=
0
;
if
(
!
getSSRC
(
data
,
data_len
,
ssrc
))
{
WarnL
<<
"get ssrc from rtp failed:"
<<
data_len
;
...
...
src/Rtp/RtpSelector.h
查看文件 @
9c3b8a6a
...
...
@@ -64,7 +64,7 @@ public:
* @return 是否成功
*/
bool
inputRtp
(
const
toolkit
::
Socket
::
Ptr
&
sock
,
const
char
*
data
,
size_t
data_len
,
const
struct
sockaddr
*
addr
,
uint
32
_t
*
dts_out
=
nullptr
);
const
struct
sockaddr
*
addr
,
uint
64
_t
*
dts_out
=
nullptr
);
/**
* 获取一个rtp处理器
...
...
src/Rtsp/RtpCodec.cpp
查看文件 @
9c3b8a6a
...
...
@@ -12,7 +12,7 @@
namespace
mediakit
{
RtpPacket
::
Ptr
RtpInfo
::
makeRtp
(
TrackType
type
,
const
void
*
data
,
size_t
len
,
bool
mark
,
uint
32
_t
stamp
)
{
RtpPacket
::
Ptr
RtpInfo
::
makeRtp
(
TrackType
type
,
const
void
*
data
,
size_t
len
,
bool
mark
,
uint
64
_t
stamp
)
{
uint16_t
payload_len
=
(
uint16_t
)
(
len
+
RtpPacket
::
kRtpHeaderSize
);
auto
rtp
=
RtpPacket
::
create
();
rtp
->
setCapacity
(
payload_len
+
RtpPacket
::
kRtpTcpHeaderSize
);
...
...
src/Rtsp/RtpCodec.h
查看文件 @
9c3b8a6a
...
...
@@ -84,7 +84,7 @@ public:
return
_ssrc
;
}
RtpPacket
::
Ptr
makeRtp
(
TrackType
type
,
const
void
*
data
,
size_t
len
,
bool
mark
,
uint
32
_t
stamp
);
RtpPacket
::
Ptr
makeRtp
(
TrackType
type
,
const
void
*
data
,
size_t
len
,
bool
mark
,
uint
64
_t
stamp
);
private
:
uint8_t
_pt
;
...
...
src/Rtsp/Rtsp.cpp
查看文件 @
9c3b8a6a
...
...
@@ -558,8 +558,8 @@ uint32_t RtpPacket::getStamp() const {
return
ntohl
(
getHeader
()
->
stamp
);
}
uint
32
_t
RtpPacket
::
getStampMS
(
bool
ntp
)
const
{
return
ntp
?
ntp_stamp
&
0xFFFFFFFF
:
getStamp
()
*
uint64_t
(
1000
)
/
sample_rate
;
uint
64
_t
RtpPacket
::
getStampMS
(
bool
ntp
)
const
{
return
ntp
?
ntp_stamp
:
getStamp
()
*
uint64_t
(
1000
)
/
sample_rate
;
}
uint32_t
RtpPacket
::
getSSRC
()
const
{
...
...
src/Rtsp/Rtsp.h
查看文件 @
9c3b8a6a
...
...
@@ -159,7 +159,7 @@ public:
uint16_t
getSeq
()
const
;
uint32_t
getStamp
()
const
;
//主机字节序的时间戳,已经转换为毫秒
uint
32
_t
getStampMS
(
bool
ntp
=
true
)
const
;
uint
64
_t
getStampMS
(
bool
ntp
=
true
)
const
;
//主机字节序的ssrc
uint32_t
getSSRC
()
const
;
//有效负载,跳过csrc、ext
...
...
src/TS/TSMediaSource.h
查看文件 @
9c3b8a6a
...
...
@@ -27,7 +27,7 @@ public:
~
TSPacket
()
override
=
default
;
public
:
uint
32
_t
time_stamp
=
0
;
uint
64
_t
time_stamp
=
0
;
};
//TS直播源
...
...
src/TS/TSMediaSourceMuxer.h
查看文件 @
9c3b8a6a
...
...
@@ -66,7 +66,7 @@ public:
}
protected
:
void
onWrite
(
std
::
shared_ptr
<
toolkit
::
Buffer
>
buffer
,
uint
32
_t
timestamp
,
bool
key_pos
)
override
{
void
onWrite
(
std
::
shared_ptr
<
toolkit
::
Buffer
>
buffer
,
uint
64
_t
timestamp
,
bool
key_pos
)
override
{
if
(
!
buffer
)
{
return
;
}
...
...
tests/test_rtp.cpp
查看文件 @
9c3b8a6a
...
...
@@ -34,7 +34,7 @@ static bool loadFile(const char *path){
return
false
;
}
uint
32
_t
timeStamp_last
=
0
;
uint
64
_t
timeStamp_last
=
0
;
uint16_t
len
;
char
rtp
[
0xFFFF
];
struct
sockaddr_storage
addr
=
{
0
};
...
...
@@ -57,7 +57,7 @@ static bool loadFile(const char *path){
break
;
}
total_size
+=
len
;
uint
32
_t
timeStamp
;
uint
64
_t
timeStamp
;
RtpSelector
::
Instance
().
inputRtp
(
sock
,
rtp
,
len
,
(
struct
sockaddr
*
)
&
addr
,
&
timeStamp
);
auto
diff
=
timeStamp
-
timeStamp_last
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论