Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
ceff932c
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
ceff932c
编写于
7月 01, 2023
作者:
戴
戴伟琦
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加audioNDk
Signed-off-by:
N
戴伟琦
<
daiweiqi@huawei.com
>
上级
9d79df53
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
341 addition
and
0 deletion
+341
-0
multimedia/audio/audio_js_standard/audio_ndk_test/entry/src/main/cpp/napi/audioTest.cpp
...dard/audio_ndk_test/entry/src/main/cpp/napi/audioTest.cpp
+187
-0
multimedia/audio/audio_js_standard/audio_ndk_test/entry/src/main/ets/test/NativeApiTest.ets
.../audio_ndk_test/entry/src/main/ets/test/NativeApiTest.ets
+154
-0
未找到文件。
multimedia/audio/audio_js_standard/audio_ndk_test/entry/src/main/cpp/napi/audioTest.cpp
浏览文件 @
ceff932c
...
@@ -597,6 +597,181 @@ static napi_value AudioRenderGetRendererInfo(napi_env env, napi_callback_info in
...
@@ -597,6 +597,181 @@ static napi_value AudioRenderGetRendererInfo(napi_env env, napi_callback_info in
napi_create_int32
(
env
,
result
,
&
res
);
napi_create_int32
(
env
,
result
,
&
res
);
return
res
;
return
res
;
}
}
// OH_AudioStreamBuilder_SetSamplingRate_001
static
napi_value
AudioStreamBuilderSetSamplingRate
(
napi_env
env
,
napi_callback_info
info
)
{
OH_AudioStreamBuilder
*
builder
;
OH_AudioStream_Type
type
=
AUDIOSTREAM_TYPE_CAPTURER
;
OH_AudioStreamBuilder_Create
(
&
builder
,
type
);
int32_t
samplingRate
=
48000
;
OH_AudioStreamBuilder_SetSamplingRate
(
builder
,
samplingRate
);
OH_AudioStream_Result
result
=
OH_AudioStreamBuilder_Destroy
(
builder
);
napi_value
res
;
napi_create_int32
(
env
,
result
,
&
res
);
return
res
;
}
// OH_AudioStreamBuilder_SetChannelCount_001
static
napi_value
AudioStreamBuilderSetChannelCount
(
napi_env
env
,
napi_callback_info
info
)
{
OH_AudioStreamBuilder
*
builder
;
OH_AudioStream_Type
type
=
AUDIOSTREAM_TYPE_CAPTURER
;
OH_AudioStreamBuilder_Create
(
&
builder
,
type
);
int32_t
channelCount
=
1
;
OH_AudioStream_Result
result
=
OH_AudioStreamBuilder_SetChannelCount
(
builder
,
channelCount
);
OH_AudioStreamBuilder_Destroy
(
builder
);
napi_value
res
;
napi_create_int32
(
env
,
result
,
&
res
);
return
res
;
}
// OH_AudioStreamBuilder_SetSampleFormat
static
napi_value
AudioStreamBuilderSetSampleFormat
(
napi_env
env
,
napi_callback_info
info
)
{
OH_AudioStreamBuilder
*
builder
;
OH_AudioStream_Type
type
=
AUDIOSTREAM_TYPE_CAPTURER
;
OH_AudioStreamBuilder_Create
(
&
builder
,
type
);
OH_AudioStream_SampleFormat
format
=
AUDIOSTREAM_SAMPLE_U8
;
OH_AudioStream_Result
result
=
OH_AudioStreamBuilder_SetSampleFormat
(
builder
,
format
);
OH_AudioStreamBuilder_Destroy
(
builder
);
napi_value
res
;
napi_create_int32
(
env
,
result
,
&
res
);
return
res
;
}
// OH_AudioStreamBuilder_SetEncodingType
static
napi_value
AudioStreamBuilderSetEncodingType
(
napi_env
env
,
napi_callback_info
info
)
{
OH_AudioStreamBuilder
*
builder
;
OH_AudioStream_Type
type
=
AUDIOSTREAM_TYPE_CAPTURER
;
OH_AudioStreamBuilder_Create
(
&
builder
,
type
);
OH_AudioStream_EncodingType
encodingType
=
AUDIOSTREAM_ENCODING_TYPE_RAW
;
OH_AudioStream_Result
result
=
OH_AudioStreamBuilder_SetEncodingType
(
builder
,
encodingType
);
OH_AudioStreamBuilder_Destroy
(
builder
);
napi_value
res
;
napi_create_int32
(
env
,
result
,
&
res
);
return
res
;
}
// OH_AudioStreamBuilder_SetLatencyMode
static
napi_value
AudioStreamBuilderSetLatencyMode
(
napi_env
env
,
napi_callback_info
info
)
{
OH_AudioStreamBuilder
*
builder
;
OH_AudioStream_Type
type
=
AUDIOSTREAM_TYPE_CAPTURER
;
OH_AudioStreamBuilder_Create
(
&
builder
,
type
);
OH_AudioStream_LatencyMode
latencyMode
=
AUDIOSTREAM_LATENCY_MODE_NORMAL
;
OH_AudioStreamBuilder_SetLatencyMode
(
builder
,
latencyMode
);
OH_AudioStream_Result
result
=
OH_AudioStreamBuilder_Destroy
(
builder
);
napi_value
res
;
napi_create_int32
(
env
,
result
,
&
res
);
return
res
;
}
// OH_AudioStreamBuilder_SetRendererInfo
static
napi_value
AudioStreamBuilderSetRendererInfo
(
napi_env
env
,
napi_callback_info
info
)
{
OH_AudioStreamBuilder
*
builder
;
OH_AudioStream_Type
type
=
AUDIOSTREAM_TYPE_RENDERER
;
OH_AudioStreamBuilder_Create
(
&
builder
,
type
);
OH_AudioStream_Usage
usage
=
AUDIOSTREAM_USAGE_MEDIA
;
OH_AudioStream_Content
content
=
AUDIOSTREAM_CONTENT_TYPE_MOVIE
;
OH_AudioStream_Result
result
=
OH_AudioStreamBuilder_SetRendererInfo
(
builder
,
usage
,
content
);
OH_AudioStreamBuilder_Destroy
(
builder
);
napi_value
res
;
napi_create_int32
(
env
,
result
,
&
res
);
return
res
;
}
// OH_AudioStreamBuilder_SetCapturerInfo
static
napi_value
AudioStreamBuilderSetCapturerInfo
(
napi_env
env
,
napi_callback_info
info
)
{
OH_AudioStreamBuilder
*
builder
;
OH_AudioStream_Type
type
=
AUDIOSTREAM_TYPE_CAPTURER
;
OH_AudioStreamBuilder_Create
(
&
builder
,
type
);
OH_AudioStream_SourceType
sourceType
=
AUDIOSTREAM_SOURCE_TYPE_MIC
;
OH_AudioStream_Result
result
=
OH_AudioStreamBuilder_SetCapturerInfo
(
builder
,
sourceType
);
OH_AudioStreamBuilder_Destroy
(
builder
);
napi_value
res
;
napi_create_int32
(
env
,
result
,
&
res
);
return
res
;
}
// OH_AudioStreamBuilder_SetRendererCallback
static
int32_t
AudioRendererOnWriteData
(
OH_AudioRenderer
*
capturer
,
void
*
userData
,
void
*
buffer
,
int32_t
bufferLen
)
{
return
0
;
}
static
napi_value
AudioStreamBuilderSetRendererCallback
(
napi_env
env
,
napi_callback_info
info
)
{
OH_AudioStreamBuilder
*
builder
;
OH_AudioStream_Type
type
=
AUDIOSTREAM_TYPE_RENDERER
;
OH_AudioStreamBuilder_Create
(
&
builder
,
type
);
OH_AudioRenderer_Callbacks
callbacks
;
callbacks
.
OH_AudioRenderer_OnWriteData
=
AudioRendererOnWriteData
;
OH_AudioStream_Result
result
=
OH_AudioStreamBuilder_SetRendererCallback
(
builder
,
callbacks
,
NULL
);
OH_AudioStreamBuilder_Destroy
(
builder
);
napi_value
res
;
napi_create_int32
(
env
,
result
,
&
res
);
return
res
;
}
// OH_AudioStreamBuilder_SetCapturerCallback
static
int32_t
AudioCapturerOnReadData
(
OH_AudioCapturer
*
capturer
,
void
*
userData
,
void
*
buffer
,
int32_t
bufferLen
)
{
return
0
;
}
static
napi_value
AudioStreamBuilderSetCapturerCallback
(
napi_env
env
,
napi_callback_info
info
)
{
OH_AudioStreamBuilder
*
builder
;
OH_AudioStream_Type
type
=
AUDIOSTREAM_TYPE_CAPTURER
;
OH_AudioStreamBuilder_Create
(
&
builder
,
type
);
OH_AudioCapturer_Callbacks
callbacks
;
callbacks
.
OH_AudioCapturer_OnReadData
=
AudioCapturerOnReadData
;
OH_AudioStream_Result
result
=
OH_AudioStreamBuilder_SetCapturerCallback
(
builder
,
callbacks
,
NULL
);
OH_AudioStreamBuilder_Destroy
(
builder
);
napi_value
res
;
napi_create_int32
(
env
,
result
,
&
res
);
return
res
;
}
// OH_AudioCapturer_GetChannelCount
static
napi_value
AudioCaptureGetChannelCount
(
napi_env
env
,
napi_callback_info
info
)
{
OH_AudioStreamBuilder
*
builder
=
CreateCapturerBuilder
();
OH_AudioCapturer
*
audioCapturer
;
OH_AudioStreamBuilder_GenerateCapturer
(
builder
,
&
audioCapturer
);
int32_t
ChannelCount
;
OH_AudioStream_Result
result
=
OH_AudioCapturer_GetChannelCount
(
audioCapturer
,
&
ChannelCount
);
OH_AudioStreamBuilder_Destroy
(
builder
);
napi_value
res
;
napi_create_int32
(
env
,
result
,
&
res
);
return
res
;
}
// OH_AudioRenderer_GetChannelCount
static
napi_value
AudioRenderGetChannelCount
(
napi_env
env
,
napi_callback_info
info
)
{
OH_AudioStreamBuilder
*
builder
=
CreateRenderBuilder
();
OH_AudioRenderer
*
audioRenderer
;
OH_AudioStreamBuilder_GenerateRenderer
(
builder
,
&
audioRenderer
);
int32_t
ChannelCount
;
OH_AudioStream_Result
result
=
OH_AudioRenderer_GetChannelCount
(
audioRenderer
,
&
ChannelCount
);
OH_AudioStreamBuilder_Destroy
(
builder
);
napi_value
res
;
napi_create_int32
(
env
,
result
,
&
res
);
return
res
;
}
EXTERN_C_START
EXTERN_C_START
static
napi_value
Init
(
napi_env
env
,
napi_value
exports
)
static
napi_value
Init
(
napi_env
env
,
napi_value
exports
)
{
{
...
@@ -640,6 +815,18 @@ static napi_value Init(napi_env env, napi_value exports)
...
@@ -640,6 +815,18 @@ static napi_value Init(napi_env env, napi_value exports)
{
"audioRenderGetSampleFormat"
,
nullptr
,
AudioRenderGetSampleFormat
,
nullptr
,
nullptr
,
nullptr
,
napi_default
,
nullptr
},
{
"audioRenderGetSampleFormat"
,
nullptr
,
AudioRenderGetSampleFormat
,
nullptr
,
nullptr
,
nullptr
,
napi_default
,
nullptr
},
{
"audioRenderGetEncodingType"
,
nullptr
,
AudioRenderGetEncodingType
,
nullptr
,
nullptr
,
nullptr
,
napi_default
,
nullptr
},
{
"audioRenderGetEncodingType"
,
nullptr
,
AudioRenderGetEncodingType
,
nullptr
,
nullptr
,
nullptr
,
napi_default
,
nullptr
},
{
"audioRenderGetRendererInfo"
,
nullptr
,
AudioRenderGetRendererInfo
,
nullptr
,
nullptr
,
nullptr
,
napi_default
,
nullptr
},
{
"audioRenderGetRendererInfo"
,
nullptr
,
AudioRenderGetRendererInfo
,
nullptr
,
nullptr
,
nullptr
,
napi_default
,
nullptr
},
{
"audioStreamBuilderSetSamplingRate"
,
nullptr
,
AudioStreamBuilderSetSamplingRate
,
nullptr
,
nullptr
,
nullptr
,
napi_default
,
nullptr
},
{
"audioStreamBuilderSetChannelCount"
,
nullptr
,
AudioStreamBuilderSetChannelCount
,
nullptr
,
nullptr
,
nullptr
,
napi_default
,
nullptr
},
{
"audioStreamBuilderSetSampleFormat"
,
nullptr
,
AudioStreamBuilderSetSampleFormat
,
nullptr
,
nullptr
,
nullptr
,
napi_default
,
nullptr
},
{
"audioStreamBuilderSetEncodingType"
,
nullptr
,
AudioStreamBuilderSetEncodingType
,
nullptr
,
nullptr
,
nullptr
,
napi_default
,
nullptr
},
{
"audioStreamBuilderSetLatencyMode"
,
nullptr
,
AudioStreamBuilderSetLatencyMode
,
nullptr
,
nullptr
,
nullptr
,
napi_default
,
nullptr
},
{
"audioStreamBuilderSetRendererInfo"
,
nullptr
,
AudioStreamBuilderSetRendererInfo
,
nullptr
,
nullptr
,
nullptr
,
napi_default
,
nullptr
},
{
"audioStreamBuilderSetCapturerInfo"
,
nullptr
,
AudioStreamBuilderSetCapturerInfo
,
nullptr
,
nullptr
,
nullptr
,
napi_default
,
nullptr
},
{
"audioStreamBuilderSetRendererCallback"
,
nullptr
,
AudioStreamBuilderSetRendererCallback
,
nullptr
,
nullptr
,
nullptr
,
napi_default
,
nullptr
},
{
"audioStreamBuilderSetCapturerCallback"
,
nullptr
,
AudioStreamBuilderSetCapturerCallback
,
nullptr
,
nullptr
,
nullptr
,
napi_default
,
nullptr
},
{
"audioCaptureGetChannelCount"
,
nullptr
,
AudioCaptureGetChannelCount
,
nullptr
,
nullptr
,
nullptr
,
napi_default
,
nullptr
},
{
"audioRenderGetChannelCount"
,
nullptr
,
AudioRenderGetChannelCount
,
nullptr
,
nullptr
,
nullptr
,
napi_default
,
nullptr
},
};
};
napi_define_properties
(
env
,
exports
,
sizeof
(
desc
)
/
sizeof
(
desc
[
0
]),
desc
);
napi_define_properties
(
env
,
exports
,
sizeof
(
desc
)
/
sizeof
(
desc
[
0
]),
desc
);
return
exports
;
return
exports
;
...
...
multimedia/audio/audio_js_standard/audio_ndk_test/entry/src/main/ets/test/NativeApiTest.ets
浏览文件 @
ceff932c
...
@@ -610,5 +610,159 @@ export default function nativeApiImageJsunit() {
...
@@ -610,5 +610,159 @@ export default function nativeApiImageJsunit() {
expect
(
a
)
.
assertEqual
(
0
)
expect
(
a
)
.
assertEqual
(
0
)
done
()
done
()
})
})
/* *
* @tc.number : TC_040
* @tc.name : Test OH_GetImageInfo, OH_AccessPixels, OH_UnAccessPixels
* @tc.desc :
* @tc.size :
* @tc.type : Functional
* @tc.level : FWK Layer
*/
it
(
'TC_040'
,
0
,
async
function
(
done
)
{
let
a
=
myaudioNdk
.
audioStreamBuilderSetSamplingRate
();
console
.
info
(
"TC_040-------------audioStreamBuilderSetSamplingRate:"
+
a
);
expect
(
a
)
.
assertEqual
(
0
)
done
()
})
/* *
* @tc.number : TC_041
* @tc.name : Test OH_GetImageInfo, OH_AccessPixels, OH_UnAccessPixels
* @tc.desc :
* @tc.size :
* @tc.type : Functional
* @tc.level : FWK Layer
*/
it
(
'TC_041'
,
0
,
async
function
(
done
)
{
let
a
=
myaudioNdk
.
audioStreamBuilderSetChannelCount
();
console
.
info
(
"TC_041-------------audioStreamBuilderSetChannelCount:"
+
a
);
expect
(
a
)
.
assertEqual
(
0
)
done
()
})
/* *
* @tc.number : TC_042
* @tc.name : Test OH_GetImageInfo, OH_AccessPixels, OH_UnAccessPixels
* @tc.desc :
* @tc.size :
* @tc.type : Functional
* @tc.level : FWK Layer
*/
it
(
'TC_042'
,
0
,
async
function
(
done
)
{
let
a
=
myaudioNdk
.
audioStreamBuilderSetSampleFormat
();
console
.
info
(
"TC_042-------------audioStreamBuilderSetSampleFormat:"
+
a
);
expect
(
a
)
.
assertEqual
(
0
)
done
()
})
/* *
* @tc.number : TC_043
* @tc.name : Test OH_GetImageInfo, OH_AccessPixels, OH_UnAccessPixels
* @tc.desc :
* @tc.size :
* @tc.type : Functional
* @tc.level : FWK Layer
*/
it
(
'TC_043'
,
0
,
async
function
(
done
)
{
let
a
=
myaudioNdk
.
audioStreamBuilderSetEncodingType
();
console
.
info
(
"TC_043-------------audioStreamBuilderSetEncodingType:"
+
a
);
expect
(
a
)
.
assertEqual
(
0
)
done
()
})
/* *
* @tc.number : TC_044
* @tc.name : Test OH_GetImageInfo, OH_AccessPixels, OH_UnAccessPixels
* @tc.desc :
* @tc.size :
* @tc.type : Functional
* @tc.level : FWK Layer
*/
it
(
'TC_044'
,
0
,
async
function
(
done
)
{
let
a
=
myaudioNdk
.
audioStreamBuilderSetLatencyMode
();
console
.
info
(
"TC_044-------------audioStreamBuilderSetLatencyMode:"
+
a
);
expect
(
a
)
.
assertEqual
(
0
)
done
()
})
/* *
* @tc.number : TC_045
* @tc.name : Test OH_GetImageInfo, OH_AccessPixels, OH_UnAccessPixels
* @tc.desc :
* @tc.size :
* @tc.type : Functional
* @tc.level : FWK Layer
*/
it
(
'TC_045'
,
0
,
async
function
(
done
)
{
let
a
=
myaudioNdk
.
audioStreamBuilderSetRendererInfo
();
console
.
info
(
"TC_045-------------audioStreamBuilderSetRendererInfo:"
+
a
);
expect
(
a
)
.
assertEqual
(
0
)
done
()
})
/* *
* @tc.number : TC_046
* @tc.name : Test OH_GetImageInfo, OH_AccessPixels, OH_UnAccessPixels
* @tc.desc :
* @tc.size :
* @tc.type : Functional
* @tc.level : FWK Layer
*/
it
(
'TC_046'
,
0
,
async
function
(
done
)
{
let
a
=
myaudioNdk
.
audioStreamBuilderSetCapturerInfo
();
console
.
info
(
"TC_046-------------audioStreamBuilderSetCapturerInfo:"
+
a
);
expect
(
a
)
.
assertEqual
(
0
)
done
()
})
/* *
* @tc.number : TC_047
* @tc.name : Test OH_GetImageInfo, OH_AccessPixels, OH_UnAccessPixels
* @tc.desc :
* @tc.size :
* @tc.type : Functional
* @tc.level : FWK Layer
*/
it
(
'TC_047'
,
0
,
async
function
(
done
)
{
let
a
=
myaudioNdk
.
audioStreamBuilderSetRendererCallback
();
console
.
info
(
"TC_047-------------audioStreamBuilderSetRendererCallback:"
+
a
);
expect
(
a
)
.
assertEqual
(
0
)
done
()
})
/* *
* @tc.number : TC_048
* @tc.name : Test OH_GetImageInfo, OH_AccessPixels, OH_UnAccessPixels
* @tc.desc :
* @tc.size :
* @tc.type : Functional
* @tc.level : FWK Layer
*/
it
(
'TC_048'
,
0
,
async
function
(
done
)
{
let
a
=
myaudioNdk
.
audioStreamBuilderSetCapturerCallback
();
console
.
info
(
"TC_048-------------audioStreamBuilderSetCapturerCallback:"
+
a
);
expect
(
a
)
.
assertEqual
(
0
)
done
()
})
/* *
* @tc.number : TC_049
* @tc.name : Test OH_GetImageInfo, OH_AccessPixels, OH_UnAccessPixels
* @tc.desc :
* @tc.size :
* @tc.type : Functional
* @tc.level : FWK Layer
*/
it
(
'TC_049'
,
0
,
async
function
(
done
)
{
let
a
=
myaudioNdk
.
audioCaptureGetChannelCount
();
console
.
info
(
"TC_049-------------audioCaptureGetChannelCount:"
+
a
);
expect
(
a
)
.
assertEqual
(
0
)
done
()
})
/* *
* @tc.number : TC_050
* @tc.name : Test OH_GetImageInfo, OH_AccessPixels, OH_UnAccessPixels
* @tc.desc :
* @tc.size :
* @tc.type : Functional
* @tc.level : FWK Layer
*/
it
(
'TC_050'
,
0
,
async
function
(
done
)
{
let
a
=
myaudioNdk
.
audioRenderGetChannelCount
();
console
.
info
(
"TC_050-------------audioRenderGetChannelCount:"
+
a
);
expect
(
a
)
.
assertEqual
(
0
)
done
()
})
})
})
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录