Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Multimedia Utils Lite
提交
9a9d0935
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 搜索 >>
提交
9a9d0935
编写于
8月 17, 2021
作者:
O
openharmony_ci
提交者:
Gitee
8月 17, 2021
浏览文件
操作
浏览文件
下载
差异文件
!15 支持PCM/G711/G726编解码格式音频采集
Merge pull request !15 from starfish/master
上级
808a6dd2
a268cef0
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
39 addition
and
28 deletion
+39
-28
interfaces/kits/media_info.h
interfaces/kits/media_info.h
+16
-6
src/format.cpp
src/format.cpp
+23
-22
未找到文件。
interfaces/kits/media_info.h
浏览文件 @
9a9d0935
...
...
@@ -175,17 +175,25 @@ typedef enum {
*/
typedef
enum
{
/** Default format */
AUDIO_DEFAULT
=
0
,
AUDIO_DEFAULT
=
0
,
/** PCM */
PCM
=
1
,
/** Advanced Audio Coding Low Complexity (AAC-LC) */
AAC_LC
=
1
,
AAC_LC
=
2
,
/** High-Efficiency Advanced Audio Coding (AAC-HE), previously known as AAC+ or aacPlus v1 */
AAC_HE_V1
=
2
,
AAC_HE_V1
=
3
,
/** AAC++ or aacPlus v2 */
AAC_HE_V2
=
3
,
AAC_HE_V2
=
4
,
/** Advanced Audio Coding Low Delay (AAC-LD) */
AAC_LD
=
4
,
AAC_LD
=
5
,
/** Advanced Audio Coding Enhanced Low Delay (AAC-ELD) */
AAC_ELD
=
5
,
AAC_ELD
=
6
,
/** G711 a-law*/
G711A
=
7
,
/** G711 u-law */
G711U
=
8
,
/** G726 */
G726
=
9
,
/** Invalid value */
FORMAT_BUTT
,
}
AudioCodecFormat
;
...
...
@@ -203,6 +211,8 @@ typedef enum {
BIT_WIDTH_16
=
16
,
/** 24-bit width */
BIT_WIDTH_24
=
24
,
/** 32-bit width */
BIT_WIDTH_32
=
32
,
/** Invalid value */
BIT_WIDTH_BUTT
,
}
AudioBitWidth
;
...
...
src/format.cpp
浏览文件 @
9a9d0935
...
...
@@ -15,6 +15,7 @@
#include "format.h"
#include <cstdio>
#include "media_log.h"
namespace
OHOS
{
namespace
Media
{
...
...
@@ -81,7 +82,7 @@ FormatData::~FormatData()
bool
FormatData
::
SetValue
(
int32_t
val
)
{
if
(
type_
!=
FORMAT_TYPE_INT32
)
{
printf
(
"FormatData set int32 value error, current type is %u"
,
type_
);
MEDIA_ERR_LOG
(
"FormatData set int32 value error, current type is %u"
,
type_
);
return
false
;
}
val_
.
int32Val
=
val
;
...
...
@@ -91,7 +92,7 @@ bool FormatData::SetValue(int32_t val)
bool
FormatData
::
SetValue
(
int64_t
val
)
{
if
(
type_
!=
FORMAT_TYPE_INT64
)
{
printf
(
"FormatData set int64 value error, current type is %u"
,
type_
);
MEDIA_ERR_LOG
(
"FormatData set int64 value error, current type is %u"
,
type_
);
return
false
;
}
val_
.
int64Val
=
val
;
...
...
@@ -101,7 +102,7 @@ bool FormatData::SetValue(int64_t val)
bool
FormatData
::
SetValue
(
float
val
)
{
if
(
type_
!=
FORMAT_TYPE_FLOAT
)
{
printf
(
"FormatData set float value error, current type is %u"
,
type_
);
MEDIA_ERR_LOG
(
"FormatData set float value error, current type is %u"
,
type_
);
return
false
;
}
val_
.
floatVal
=
val
;
...
...
@@ -111,7 +112,7 @@ bool FormatData::SetValue(float val)
bool
FormatData
::
SetValue
(
double
val
)
{
if
(
type_
!=
FORMAT_TYPE_DOUBLE
)
{
printf
(
"FormatData set double value error, current type is %u"
,
type_
);
MEDIA_ERR_LOG
(
"FormatData set double value error, current type is %u"
,
type_
);
return
false
;
}
val_
.
doubleVal
=
val
;
...
...
@@ -121,13 +122,13 @@ bool FormatData::SetValue(double val)
bool
FormatData
::
SetValue
(
const
std
::
string
&
val
)
{
if
(
type_
!=
FORMAT_TYPE_STRING
)
{
printf
(
"FormatData set string value error, current type is %u"
,
type_
);
MEDIA_ERR_LOG
(
"FormatData set string value error, current type is %u"
,
type_
);
return
false
;
}
val_
.
stringVal
=
new
(
std
::
nothrow
)
std
::
string
();
if
(
val_
.
stringVal
==
nullptr
)
{
type_
=
FORMAT_TYPE_NONE
;
printf
(
"FormatData set string value error, new string failed"
);
MEDIA_ERR_LOG
(
"FormatData set string value error, new string failed"
);
return
false
;
}
*
(
val_
.
stringVal
)
=
val
;
...
...
@@ -137,7 +138,7 @@ bool FormatData::SetValue(const std::string &val)
bool
FormatData
::
GetInt32Value
(
int32_t
&
val
)
const
{
if
(
type_
!=
FORMAT_TYPE_INT32
)
{
printf
(
"FormatData get int32 value error, current type is %u"
,
type_
);
MEDIA_ERR_LOG
(
"FormatData get int32 value error, current type is %u"
,
type_
);
return
false
;
}
val
=
val_
.
int32Val
;
...
...
@@ -147,7 +148,7 @@ bool FormatData::GetInt32Value(int32_t &val) const
bool
FormatData
::
GetInt64Value
(
int64_t
&
val
)
const
{
if
(
type_
!=
FORMAT_TYPE_INT64
)
{
printf
(
"FormatData get int64 value error, current type is %u"
,
type_
);
MEDIA_ERR_LOG
(
"FormatData get int64 value error, current type is %u"
,
type_
);
return
false
;
}
val
=
val_
.
int64Val
;
...
...
@@ -157,7 +158,7 @@ bool FormatData::GetInt64Value(int64_t &val) const
bool
FormatData
::
GetFloatValue
(
float
&
val
)
const
{
if
(
type_
!=
FORMAT_TYPE_FLOAT
)
{
printf
(
"FormatData get float value error, current type is %u"
,
type_
);
MEDIA_ERR_LOG
(
"FormatData get float value error, current type is %u"
,
type_
);
return
false
;
}
val
=
val_
.
floatVal
;
...
...
@@ -167,7 +168,7 @@ bool FormatData::GetFloatValue(float &val) const
bool
FormatData
::
GetDoubleValue
(
double
&
val
)
const
{
if
(
type_
!=
FORMAT_TYPE_DOUBLE
)
{
printf
(
"FormatData get double value error, current type is %u"
,
type_
);
MEDIA_ERR_LOG
(
"FormatData get double value error, current type is %u"
,
type_
);
return
false
;
}
val
=
val_
.
doubleVal
;
...
...
@@ -177,11 +178,11 @@ bool FormatData::GetDoubleValue(double &val) const
bool
FormatData
::
GetStringValue
(
std
::
string
&
val
)
const
{
if
(
type_
!=
FORMAT_TYPE_STRING
)
{
printf
(
"FormatData get string value error, current type is %u"
,
type_
);
MEDIA_ERR_LOG
(
"FormatData get string value error, current type is %u"
,
type_
);
return
false
;
}
if
(
val_
.
stringVal
==
nullptr
)
{
printf
(
"FormatData get string value error, stringVal is null"
);
MEDIA_ERR_LOG
(
"FormatData get string value error, stringVal is null"
);
return
false
;
}
val
=
*
(
val_
.
stringVal
);
...
...
@@ -238,11 +239,11 @@ bool Format::SetFormatCommon(const std::string &key, const T &value, FormatDataT
}
FormatData
*
data
=
new
(
std
::
nothrow
)
FormatData
(
type
);
if
(
data
==
nullptr
)
{
printf
(
"Format::SetFormatCommon new FormatData failed"
);
MEDIA_ERR_LOG
(
"Format::SetFormatCommon new FormatData failed"
);
return
false
;
}
if
(
!
data
->
SetValue
(
value
))
{
printf
(
"Format::SetFormatCommon failed. Key: %s"
,
key
.
c_str
());
MEDIA_ERR_LOG
(
"Format::SetFormatCommon failed. Key: %s"
,
key
.
c_str
());
delete
data
;
return
false
;
}
...
...
@@ -254,7 +255,7 @@ bool Format::GetStringValue(const std::string &key, std::string &value) const
{
auto
iter
=
formatMap_
.
find
(
key
);
if
(
iter
==
formatMap_
.
end
()
||
iter
->
second
==
nullptr
)
{
printf
(
"Format::GetFormat failed. Key: %s"
,
key
.
c_str
());
MEDIA_DEBUG_LOG
(
"Format::GetFormat failed. Key: %s"
,
key
.
c_str
());
return
false
;
}
...
...
@@ -265,7 +266,7 @@ bool Format::GetIntValue(const std::string &key, int32_t &value) const
{
auto
iter
=
formatMap_
.
find
(
key
);
if
((
iter
==
formatMap_
.
end
())
||
(
iter
->
second
==
nullptr
))
{
printf
(
"Format::GetFormat failed. Key: %s"
,
key
.
c_str
());
MEDIA_DEBUG_LOG
(
"Format::GetFormat failed. Key: %s"
,
key
.
c_str
());
return
false
;
}
...
...
@@ -276,7 +277,7 @@ bool Format::GetLongValue(const std::string &key, int64_t &value) const
{
auto
iter
=
formatMap_
.
find
(
key
);
if
((
iter
==
formatMap_
.
end
())
||
(
iter
->
second
==
nullptr
))
{
printf
(
"Format::GetFormat failed. Key: %s"
,
key
.
c_str
());
MEDIA_DEBUG_LOG
(
"Format::GetFormat failed. Key: %s"
,
key
.
c_str
());
return
false
;
}
...
...
@@ -287,7 +288,7 @@ bool Format::GetFloatValue(const std::string &key, float &value) const
{
auto
iter
=
formatMap_
.
find
(
key
);
if
((
iter
==
formatMap_
.
end
())
||
(
iter
->
second
==
nullptr
))
{
printf
(
"Format::GetFormat failed. Key: %s"
,
key
.
c_str
());
MEDIA_DEBUG_LOG
(
"Format::GetFormat failed. Key: %s"
,
key
.
c_str
());
return
false
;
}
...
...
@@ -298,7 +299,7 @@ bool Format::GetDoubleValue(const std::string &key, double &value) const
{
auto
iter
=
formatMap_
.
find
(
key
);
if
((
iter
==
formatMap_
.
end
())
||
(
iter
->
second
==
nullptr
))
{
printf
(
"Format::GetFormat failed. Key: %s"
,
key
.
c_str
());
MEDIA_DEBUG_LOG
(
"Format::GetFormat failed. Key: %s"
,
key
.
c_str
());
return
false
;
}
...
...
@@ -312,13 +313,13 @@ const std::map<std::string, FormatData *> &Format::GetFormatMap() const
bool
Format
::
CopyFrom
(
const
Format
&
format
)
{
printf
(
"CopyFrom begin"
);
MEDIA_INFO_LOG
(
"CopyFrom begin"
);
std
::
map
<
std
::
string
,
FormatData
*>
formatMap
=
format
.
GetFormatMap
();
for
(
auto
&
iter
:
formatMap
)
{
std
::
string
key
=
iter
.
first
;
FormatData
*
formatData
=
iter
.
second
;
if
(
formatData
==
nullptr
)
{
printf
(
"CopyFrom FormatData is null, key is %s"
,
key
.
c_str
());
MEDIA_ERR_LOG
(
"CopyFrom FormatData is null, key is %s"
,
key
.
c_str
());
continue
;
}
FormatDataType
type
=
formatData
->
GetType
();
...
...
@@ -344,7 +345,7 @@ bool Format::CopyFrom(const Format &format)
break
;
}
default:
{
printf
(
"CopyFrom unknown type, type is %d"
,
type
);
MEDIA_ERR_LOG
(
"CopyFrom unknown type, type is %d"
,
type
);
break
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录