Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Multimedia Utils Lite
提交
8d2b2db1
M
Multimedia Utils Lite
项目概览
OpenHarmony
/
Multimedia Utils Lite
9 个月 前同步成功
通知
1
Star
20
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
Multimedia Utils Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
8d2b2db1
编写于
3月 14, 2022
作者:
O
openharmony_ci
提交者:
Gitee
3月 14, 2022
浏览文件
操作
浏览文件
下载
差异文件
!29 Add DataStream to simplify stream source operation.
Merge pull request !29 from chenguodong/master
上级
390b9b2f
21f1eb53
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
219 addition
and
0 deletion
+219
-0
interfaces/kits/data_stream.h
interfaces/kits/data_stream.h
+186
-0
interfaces/kits/source.h
interfaces/kits/source.h
+22
-0
src/source.cpp
src/source.cpp
+11
-0
未找到文件。
interfaces/kits/data_stream.h
0 → 100644
浏览文件 @
8d2b2db1
/*
* Copyright (c) 2022-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MEDIA_DATA_STREAM
#define MEDIA_DATA_STREAM
#include <memory>
namespace
OHOS
{
namespace
Media
{
/**
* @enum MemoryType
*
* @since 1.0
* @version 1.0
*/
enum
class
MemoryType
{
VIRTUAL_ADDR
=
0
,
///< Virtual address
SURFACE_BUFFER
,
///< Surface
SHARE_MEMORY
,
///< Share Memory fd
};
/**
* @brief Data buffer, contains the data.
*
* @since 1.0
* @version 1.0
*/
class
DataBuffer
{
public:
virtual
~
DataBuffer
()
=
default
;
/**
* @brief Get the EOS status.
*
* @return Returns the EOS status, true if this is the end of steam.
* @since 1.0
* @version 1.0
*/
virtual
bool
IsEos
()
=
0
;
/**
* @brief Set the EOS status.
*
* @since 1.0
* @version 1.0
*/
virtual
void
SetEos
(
bool
isEos
)
=
0
;
/**
* @brief Get the buffer address.
*
* @since 1.0
* @version 1.0
*/
virtual
uint8_t
*
GetAddress
()
=
0
;
/**
* @brief Get the buffer capacity.
*
* @since 1.0
* @version 1.0
*/
virtual
size_t
GetCapacity
()
=
0
;
/**
* @brief Get the size of the valid data in this data buffer.
*
* @since 1.0
* @version 1.0
*/
virtual
size_t
GetSize
()
=
0
;
/**
* @brief Set the size of the valid data in this data buffer.
*
* @param size Indicates the size of the valid data.
* @since 1.0
* @version 1.0
*/
virtual
void
SetSize
(
size_t
size
)
=
0
;
};
/**
* @brief Data producer uses this interface to produce data.
*
* @since 1.0
* @version 1.0
*/
class
DataProducer
{
public:
virtual
~
DataProducer
()
=
default
;
/**
* @brief Get empty buffer.
*
* @param buffer Out parameter to obtain the buffer.
* @param timeout Indicates how much time (millisecond) to wait, default -1 means wait until buffer obtained.
* @since 1.0
* @version 1.0
*/
virtual
bool
GetEmptyBuffer
(
std
::
shared_ptr
<
DataBuffer
>&
buffer
,
int
timeout
=
-
1
)
=
0
;
/**
* @brief Queue data buffer.
*
* @param buffer the buffer contains data.
* @since 1.0
* @version 1.0
*/
virtual
bool
QueueDataBuffer
(
const
std
::
shared_ptr
<
DataBuffer
>&
buffer
)
=
0
;
};
/**
* @brief Data consumer uses this interface to consume data.
*
* @since 1.0
* @version 1.0
*/
class
DataConsumer
{
public:
virtual
~
DataConsumer
()
=
default
;
/**
* @brief Get data buffer.
*
* @param buffer Out parameter to obtain the buffer contains data.
* @param timeout Indicates how much time (millisecond) to wait, default -1 means wait until data buffer obtained.
* @since 1.0
* @version 1.0
*/
virtual
bool
GetDataBuffer
(
std
::
shared_ptr
<
DataBuffer
>&
buffer
,
int
timeout
=
-
1
)
=
0
;
/**
* @brief Use the shared_ptr of buffer to queue empty buffer to data stream.
*
* @param buffer Indicates the shared_ptr of the empty buffer.
* @since 1.0
* @version 1.0
*/
virtual
bool
QueueEmptyBuffer
(
const
std
::
shared_ptr
<
DataBuffer
>&
buffer
)
=
0
;
/**
* @brief Use the buffer address to queue empty buffer to data stream.
*
* @param address Indicates the address of the empty buffer.
* @since 1.0
* @version 1.0
*/
virtual
bool
QueueEmptyBuffer
(
uint8_t
*
address
)
=
0
;
};
/**
* @brief Data stream, extends DataConsumer and DataProducer.
*
* @since 1.0
* @version 1.0
*/
class
DataStream
:
public
DataConsumer
,
public
DataProducer
{
};
/**
* @brief The factory function to create {@link DataStream}.
*
* @param size Indicates the size of each buffer.
* @param count Indicates the count of buffers.
* @param type Indicates the memory type, default is virtual address.
* @since 1.0
* @version 1.0
*/
std
::
shared_ptr
<
DataStream
>
CreateDataStream
(
size_t
size
,
size_t
count
,
MemoryType
type
=
MemoryType
::
VIRTUAL_ADDR
);
}
// Media
}
// OHOS
#endif // MEDIA_DATA_STREAM
interfaces/kits/source.h
浏览文件 @
8d2b2db1
...
...
@@ -39,6 +39,7 @@
#include <memory>
#include <map>
#include <string>
#include "data_stream.h"
#include "format.h"
#ifndef SURFACE_DISABLED
#include "surface.h"
...
...
@@ -227,6 +228,15 @@ public:
*/
Source
(
const
std
::
shared_ptr
<
StreamSource
>
&
stream
,
const
Format
&
formats
);
/**
* @brief A constructor used to create a {@link Source} instance based on the data stream consumer.
*
* @param dataConsumer Indicates the data stream consumer. For details, see {@link DataConsumer}.
* @since 1.0
* @version 1.0
*/
explicit
Source
(
const
std
::
shared_ptr
<
DataConsumer
>
&
dataConsumer
);
~
Source
()
=
default
;
/**
...
...
@@ -280,12 +290,24 @@ public:
*/
const
Format
&
GetSourceStreamFormat
()
const
;
/**
* @brief Obtains the data stream consumer interface.
*
* This function is called only when the {@link SourceType} is {@link SOURCE_TYPE_STREAM}.
*
* @return Returns the data stream consumer interface. For details, see {@link DataConsumer}.
* @since 1.0
* @version 1.0
*/
const
std
::
shared_ptr
<
DataConsumer
>
&
GetDataConsumer
()
const
;
private:
std
::
string
uri_
;
SourceType
sourceType_
;
std
::
map
<
std
::
string
,
std
::
string
>
header_
;
std
::
shared_ptr
<
StreamSource
>
stream_
;
Format
format_
;
std
::
shared_ptr
<
DataConsumer
>
dataConsumer_
;
};
}
// namespace Media
}
// namespace OHOS
...
...
src/source.cpp
浏览文件 @
8d2b2db1
...
...
@@ -36,6 +36,12 @@ Source::Source(const std::shared_ptr<StreamSource> &stream, const Format &format
format_
.
CopyFrom
(
formats
);
}
Source
::
Source
(
const
std
::
shared_ptr
<
DataConsumer
>
&
dataConsumer
)
:
sourceType_
(
SourceType
::
SOURCE_TYPE_STREAM
),
dataConsumer_
(
dataConsumer
)
{
}
SourceType
Source
::
GetSourceType
()
const
{
return
sourceType_
;
...
...
@@ -60,6 +66,11 @@ const Format &Source::GetSourceStreamFormat() const
return
format_
;
}
const
std
::
shared_ptr
<
DataConsumer
>
&
Source
::
GetDataConsumer
()
const
{
return
dataConsumer_
;
}
StreamSource
::
StreamSource
()
#ifndef SURFACE_DISABLED
:
surface_
(
nullptr
),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录