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
7baa35e5
Commit
7baa35e5
authored
Jul 24, 2019
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复hls由于缓存导致花屏的问题
parent
f50eaf86
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
101 行增加
和
2 行删除
+101
-2
src/Extension/Frame.cpp
+42
-0
src/Extension/Frame.h
+58
-1
src/MediaFile/TsMuxer.cpp
+1
-1
没有找到文件。
src/Extension/Frame.cpp
0 → 100644
查看文件 @
7baa35e5
/*
* MIT License
*
* Copyright (c) 2016-2019 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.
*/
#include "Frame.h"
using
namespace
std
;
using
namespace
toolkit
;
namespace
mediakit
{
Frame
::
Ptr
Frame
::
getCacheAbleFrame
(
const
Frame
::
Ptr
&
frame
){
if
(
frame
->
cacheAble
()){
return
frame
;
}
return
std
::
make_shared
<
FrameCacheAble
>
(
frame
);
}
}
//namespace mediakit
src/Extension/Frame.h
查看文件 @
7baa35e5
...
...
@@ -77,7 +77,7 @@ public:
/**
* 帧类型的抽象接口
*/
class
Frame
:
public
Buffer
,
public
CodecInfo
{
class
Frame
:
public
Buffer
,
public
CodecInfo
{
public
:
typedef
std
::
shared_ptr
<
Frame
>
Ptr
;
virtual
~
Frame
(){}
...
...
@@ -121,6 +121,12 @@ public:
* 是否可以缓存
*/
virtual
bool
cacheAble
()
const
{
return
true
;
}
/**
* 返回可缓存的frame
* @return
*/
static
Ptr
getCacheAbleFrame
(
const
Ptr
&
frame
);
};
/**
...
...
@@ -326,6 +332,57 @@ protected:
uint32_t
_prefixSize
;
};
class
FrameCacheAble
:
public
FrameNoCacheAble
{
public
:
typedef
std
::
shared_ptr
<
FrameCacheAble
>
Ptr
;
FrameCacheAble
(
const
Frame
::
Ptr
&
frame
){
if
(
frame
->
cacheAble
()){
_frame
=
frame
;
_ptr
=
frame
->
data
();
}
else
{
_buffer
=
std
::
make_shared
<
BufferRaw
>
();
_buffer
->
assign
(
frame
->
data
(),
frame
->
size
());
_ptr
=
_buffer
->
data
();
}
_size
=
frame
->
size
();
_dts
=
frame
->
dts
();
_pts
=
frame
->
pts
();
_prefixSize
=
frame
->
prefixSize
();
_trackType
=
frame
->
getTrackType
();
_codec
=
frame
->
getCodecId
();
_key
=
frame
->
keyFrame
();
}
virtual
~
FrameCacheAble
()
=
default
;
/**
* 可以被缓存
* @return
*/
bool
cacheAble
()
const
override
{
return
true
;
}
TrackType
getTrackType
()
const
override
{
return
_trackType
;
}
CodecId
getCodecId
()
const
override
{
return
_codec
;
}
bool
keyFrame
()
const
override
{
return
_key
;
}
private
:
Frame
::
Ptr
_frame
;
BufferRaw
::
Ptr
_buffer
;
TrackType
_trackType
;
CodecId
_codec
;
bool
_key
;
};
}
//namespace mediakit
...
...
src/MediaFile/TsMuxer.cpp
查看文件 @
7baa35e5
...
...
@@ -78,7 +78,7 @@ void TsMuxer::inputFrame(const Frame::Ptr &frame) {
mpeg_ts_write
(
_context
,
it
->
second
,
back
->
keyFrame
()
?
0x0001
:
0
,
back
->
pts
()
*
90LL
,
back
->
dts
()
*
90LL
,
merged_frame
->
data
(),
merged_frame
->
size
());
_frameCached
.
clear
();
}
_frameCached
.
emplace_back
(
frame
);
_frameCached
.
emplace_back
(
Frame
::
getCacheAbleFrame
(
frame
)
);
}
break
;
default
:
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论