mirror of
https://github.com/openharmony/multimedia_audio_lite.git
synced 2026-07-01 06:41:22 -04:00
update openharmony 1.0.1
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
### 该问题是怎么引起的?
|
||||
|
||||
|
||||
|
||||
### 重现步骤
|
||||
|
||||
|
||||
|
||||
### 报错信息
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
### 相关的Issue
|
||||
|
||||
|
||||
### 原因(目的、解决的问题等)
|
||||
|
||||
|
||||
### 描述(做了什么,变更了什么)
|
||||
|
||||
|
||||
### 测试用例(新增、改动、可能影响的功能)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
# Copyright (c) 2020 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.
|
||||
import("//build/lite/config/component/lite_component.gni")
|
||||
import("//build/lite/ndk/ndk.gni")
|
||||
|
||||
shared_library("audio_capturer") {
|
||||
sources = [
|
||||
"audio_capturer.cpp",
|
||||
"audio_capturer_impl.cpp",
|
||||
"audio_encoder/audio_encoder.cpp",
|
||||
"audio_source/audio_source.cpp",
|
||||
]
|
||||
cflags = ["-fPIC"]
|
||||
cflags += ["-Wall"]
|
||||
cflags_cc = cflags
|
||||
include_dirs = [
|
||||
"audio_encoder/include",
|
||||
"audio_source/include",
|
||||
"//foundation/multimedia/hals/camera_lite",
|
||||
"//drivers/hdf/lite/hdi/audio/include",
|
||||
"//drivers/hdf/lite/hdi/codec/include",
|
||||
"//drivers/hdf/lite/hdi/format/include",
|
||||
]
|
||||
outdir = rebase_path("$root_out_dir")
|
||||
public_configs = [":audio_external_library_config"]
|
||||
ldflags = [
|
||||
"-L$outdir",
|
||||
"-laudio_hw"
|
||||
]
|
||||
deps = [
|
||||
"//third_party/bounds_checking_function:libsec_shared",
|
||||
"//foundation/graphic/lite/frameworks/surface:surface",
|
||||
"//foundation/multimedia/utils/lite:media_common",
|
||||
]
|
||||
}
|
||||
|
||||
config("audio_external_library_config") {
|
||||
include_dirs = ["//foundation/multimedia/interfaces/kits/audio_lite"]
|
||||
include_dirs += ["//foundation/multimedia/utils/lite/include"]
|
||||
}
|
||||
@@ -1,177 +1,177 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
@@ -0,0 +1,52 @@
|
||||
# AUDIO\_LITE<a name="EN-US_TOPIC_0000001080430608"></a>
|
||||
|
||||
- [AUDIO\_LITE<a name="EN-US_TOPIC_0000001080430608"></a>](#audio_lite)
|
||||
- [Introduction<a name="section11660541593"></a>](#introduction)
|
||||
- [Directory Structure<a name="section178251437756"></a>](#directory-structure)
|
||||
- [Usage<a name="section1648194512427"></a>](#usage)
|
||||
- [Constraints<a name="section722512541395"></a>](#constraints)
|
||||
- [Repositories Involved<a name="section1371113476307"></a>](#repositories-involved)
|
||||
|
||||
## Introduction<a name="section11660541593"></a>
|
||||
|
||||
This repository provides the audio capability.
|
||||
|
||||
**Figure 1** Position of this repository \(in the dotted blue box\) in the multimedia subsystem<a name="fig584652218594"></a>
|
||||

|
||||
|
||||
## Directory Structure<a name="section178251437756"></a>
|
||||
|
||||
```
|
||||
foundation/multimedia/audio_lite
|
||||
├── frameworks # Framework code
|
||||
└── interfaces # APIs
|
||||
└── kits # External APIs
|
||||
```
|
||||
|
||||
## Usage<a name="section1648194512427"></a>
|
||||
|
||||
Build a single repository in the root directory.
|
||||
|
||||
```
|
||||
# Select the development board.
|
||||
hb set
|
||||
# Build this repository.
|
||||
hb build audio_manager_lite
|
||||
```
|
||||
|
||||
## Constraints<a name="section722512541395"></a>
|
||||
|
||||
- C++ 11 or later
|
||||
|
||||
## Repositories Involved<a name="section1371113476307"></a>
|
||||
|
||||
/hmf/multimedia/camera\_lite
|
||||
|
||||
/hmf/multimedia/audio\_lite
|
||||
|
||||
/hmf/multimedia/media\_lite
|
||||
|
||||
/hmf/multimedia/utils\_lite
|
||||
|
||||
/hmf/multimedia/service\_lite
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
# 媒体子系统AUDIO\_LITE组件<a name="ZH-CN_TOPIC_0000001080430608"></a>
|
||||
|
||||
- [媒体子系统AUDIO\_LITE组件<a name="ZH-CN_TOPIC_0000001080430608"></a>](#媒体子系统audio_lite组件)
|
||||
- [简介<a name="section11660541593"></a>](#简介)
|
||||
- [目录<a name="section178251437756"></a>](#目录)
|
||||
- [使用说明<a name="section1648194512427"></a>](#使用说明)
|
||||
- [约束<a name="section722512541395"></a>](#约束)
|
||||
- [相关仓<a name="section1371113476307"></a>](#相关仓)
|
||||
|
||||
## 简介<a name="section11660541593"></a>
|
||||
|
||||
AUDIO\_LITE组件提供音频能力的支持。
|
||||
|
||||
**图 1** 媒体子系统架构(蓝色虚线框是audio\_lite)<a name="fig584652218594"></a>
|
||||
")
|
||||
|
||||
## 目录<a name="section178251437756"></a>
|
||||
|
||||
```
|
||||
foundation/multimedia/audio_lite
|
||||
├── frameworks # 框架代码
|
||||
└── interfaces # 接口
|
||||
└── kits # 对外接口
|
||||
```
|
||||
|
||||
## 使用说明<a name="section1648194512427"></a>
|
||||
|
||||
单仓的编译构建,在根目录下进行单仓的构建和编译
|
||||
|
||||
```
|
||||
# 开发板选择
|
||||
hb set
|
||||
# 单仓构建和编译
|
||||
hb build audio_manager_lite
|
||||
```
|
||||
|
||||
## 约束<a name="section722512541395"></a>
|
||||
|
||||
- C++11版本或以上
|
||||
|
||||
## 相关仓<a name="section1371113476307"></a>
|
||||
|
||||
/hmf/multimedia/camera\_lite
|
||||
|
||||
/hmf/multimedia/audio\_lite
|
||||
|
||||
/hmf/multimedia/media\_lite
|
||||
|
||||
/hmf/multimedia/utils\_lite
|
||||
|
||||
/hmf/multimedia/service\_lite
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 53 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 40 KiB |
Executable
+49
@@ -0,0 +1,49 @@
|
||||
# Copyright (c) 2020-2021 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.
|
||||
import("//build/lite/config/component/lite_component.gni")
|
||||
import("//build/lite/ndk/ndk.gni")
|
||||
|
||||
shared_library("audio_capturer_lite") {
|
||||
sources = [
|
||||
"audio_capturer.cpp",
|
||||
"audio_capturer_impl.cpp",
|
||||
"audio_encoder/audio_encoder.cpp",
|
||||
"audio_source/audio_source.cpp",
|
||||
]
|
||||
cflags = [ "-fPIC" ]
|
||||
cflags += [ "-Wall" ]
|
||||
cflags_cc = cflags
|
||||
include_dirs = [
|
||||
"audio_encoder/include",
|
||||
"audio_source/include",
|
||||
"//drivers/peripheral/audio/interfaces/include",
|
||||
"//drivers/peripheral/codec/interfaces/include",
|
||||
"//drivers/peripheral/format/interfaces/include",
|
||||
]
|
||||
outdir = rebase_path("$root_out_dir")
|
||||
public_configs = [ ":audio_external_library_config" ]
|
||||
ldflags = [
|
||||
"-L$outdir",
|
||||
"-laudio_hw",
|
||||
]
|
||||
deps = [
|
||||
"//foundation/graphic/surface:lite_surface",
|
||||
"//foundation/multimedia/utils/lite:media_common",
|
||||
"//third_party/bounds_checking_function:libsec_shared",
|
||||
]
|
||||
}
|
||||
|
||||
config("audio_external_library_config") {
|
||||
include_dirs = [ "//foundation/multimedia/audio_lite/interfaces/kits" ]
|
||||
include_dirs += [ "//foundation/multimedia/utils/lite/include" ]
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2020-2021 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
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2020-2021 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
|
||||
@@ -12,11 +12,9 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "audio_capturer_impl.h"
|
||||
|
||||
#include <sys/select.h>
|
||||
|
||||
/* include */
|
||||
#include "audio_source.h"
|
||||
#include "audio_encoder.h"
|
||||
#include "media_log.h"
|
||||
@@ -26,8 +24,8 @@ namespace Audio {
|
||||
|
||||
using namespace OHOS::Media;
|
||||
|
||||
const unsigned long long TIME_CONVERSION_US_S = 1000000ULL; /* us to s */
|
||||
const unsigned long long TIME_CONVERSION_NS_US = 1000ULL; /* ns to us */
|
||||
const unsigned long long TIME_CONVERSION_US_S = 1000000ULL; /* ¦Ìs to s */
|
||||
const unsigned long long TIME_CONVERSION_NS_US = 1000ULL; /* ns to ¦Ìs */
|
||||
|
||||
|
||||
AudioCapturer::AudioCapturerImpl::AudioCapturerImpl()
|
||||
@@ -52,7 +50,7 @@ uint64_t AudioCapturer::AudioCapturerImpl::GetFrameCount()
|
||||
return audioSource_->GetFrameCount();
|
||||
}
|
||||
|
||||
State AudioCapturer::AudioCapturerImpl::GetStatus()
|
||||
State AudioCapturer::AudioCapturer::AudioCapturerImpl::GetStatus()
|
||||
{
|
||||
return status;
|
||||
}
|
||||
@@ -69,10 +67,10 @@ int32_t AudioCapturer::AudioCapturerImpl::SetCapturerInfo(const AudioCapturerInf
|
||||
std::vector<AudioDeviceDesc> devices;
|
||||
ret = audioSource_->EnumDeviceBySourceType(info.inputSource, devices);
|
||||
if (ret != SUCCESS || devices.empty()) {
|
||||
MEDIA_ERR_LOG("EnumDeviceBySourceType failed inputSource:%d", info.inputSource);
|
||||
MEDIA_ERR_LOG("EnumDeviceBySourceType failed inputSource:%d", info.inputSource);
|
||||
return ret;
|
||||
}
|
||||
MEDIA_INFO_LOG("info.sampleRate:%d", info.sampleRate);
|
||||
MEDIA_INFO_LOG("info.sampleRate %d", info.sampleRate);
|
||||
AudioSourceConfig sourceConfig;
|
||||
sourceConfig.deviceId = devices[0].deviceId;
|
||||
sourceConfig.audioFormat = info.audioFormat;
|
||||
@@ -83,7 +81,7 @@ int32_t AudioCapturer::AudioCapturerImpl::SetCapturerInfo(const AudioCapturerInf
|
||||
sourceConfig.streamUsage = TYPE_DEFAULT;
|
||||
ret = audioSource_->Initialize(sourceConfig);
|
||||
if (ret != SUCCESS) {
|
||||
MEDIA_ERR_LOG("Initialize failed inputSource:%d", info.inputSource);
|
||||
MEDIA_ERR_LOG("Initialize failed inputSource:%d", info.inputSource);
|
||||
return ret;
|
||||
}
|
||||
AudioEncodeConfig encodeConfig;
|
||||
@@ -92,14 +90,14 @@ int32_t AudioCapturer::AudioCapturerImpl::SetCapturerInfo(const AudioCapturerInf
|
||||
encodeConfig.sampleRate = info.sampleRate;
|
||||
encodeConfig.channelCount = info.channelCount;
|
||||
encodeConfig.bitWidth = info.bitWidth;
|
||||
MEDIA_INFO_LOG("audioEncoder_ info.bitRate:%d", info.bitRate);
|
||||
MEDIA_INFO_LOG("audioEncoder_ info.bitRate %d ", info.bitRate);
|
||||
ret = audioEncoder_->Initialize(encodeConfig);
|
||||
if (ret != SUCCESS) {
|
||||
MEDIA_ERR_LOG("Initialize failed inputSource:%d", info.inputSource);
|
||||
MEDIA_ERR_LOG("Initialize failed inputSource:%d", info.inputSource);
|
||||
return ret;
|
||||
}
|
||||
info_ = info;
|
||||
status = PREPARED;
|
||||
status = PREPPARED;
|
||||
MEDIA_INFO_LOG("Set Capturer Info SUCCESS");
|
||||
return SUCCESS;
|
||||
}
|
||||
@@ -113,9 +111,9 @@ int32_t AudioCapturer::AudioCapturerImpl::GetCapturerInfo(AudioCapturerInfo &inf
|
||||
|
||||
bool AudioCapturer::AudioCapturerImpl::Record()
|
||||
{
|
||||
if (status != PREPARED &&
|
||||
if (status != PREPPARED &&
|
||||
status != STOPPED) {
|
||||
MEDIA_ERR_LOG("Record ILLEGAL_STATE status:%u", status);
|
||||
MEDIA_ERR_LOG("Record ILLEGAL_STATE status:%u", status);
|
||||
return ERR_ILLEGAL_STATE;
|
||||
}
|
||||
int32_t ret = audioSource_->Start();
|
||||
@@ -148,11 +146,11 @@ bool AudioCapturer::AudioCapturerImpl::Record()
|
||||
int32_t AudioCapturer::AudioCapturerImpl::Read(uint8_t *buffer, size_t userSize, bool isBlockingRead)
|
||||
{
|
||||
if (buffer == NULL || userSize == 0) {
|
||||
MEDIA_ERR_LOG("Invalid buffer:%p userSize:%u", buffer, userSize);
|
||||
MEDIA_ERR_LOG("Invalid buffer %p userSize:%u", buffer, userSize);
|
||||
return ERR_INVALID_READ;
|
||||
}
|
||||
if (status != RECORDING) {
|
||||
MEDIA_ERR_LOG("ILLEGAL_STATE status:%u", status);
|
||||
MEDIA_ERR_LOG("ILLEGAL_STATE status:%u", status);
|
||||
return ERR_INVALID_READ;
|
||||
}
|
||||
AudioStream stream;
|
||||
@@ -160,7 +158,7 @@ int32_t AudioCapturer::AudioCapturerImpl::Read(uint8_t *buffer, size_t userSize,
|
||||
stream.bufferLen = userSize;
|
||||
int32_t readLen = audioEncoder_->ReadStream(stream, isBlockingRead);
|
||||
if (readLen == ERR_INVALID_READ) {
|
||||
MEDIA_ERR_LOG("audioEncoder_ ReadStream failed:0x%x", readLen);
|
||||
MEDIA_ERR_LOG("audioEncoder_ ReadStream fail,ret:0x%x", readLen);
|
||||
return ERR_INVALID_READ;
|
||||
}
|
||||
timestamp_.time.tv_sec = static_cast<time_t>(stream.timeStamp / TIME_CONVERSION_US_S); // us - s
|
||||
@@ -172,19 +170,19 @@ int32_t AudioCapturer::AudioCapturerImpl::Read(uint8_t *buffer, size_t userSize,
|
||||
bool AudioCapturer::AudioCapturerImpl::Stop()
|
||||
{
|
||||
if (status != RECORDING) {
|
||||
MEDIA_ERR_LOG("ILLEGAL_STATE status:%u", status);
|
||||
MEDIA_ERR_LOG("ILLEGAL_STATE status:%u", status);
|
||||
return ERR_ILLEGAL_STATE;
|
||||
}
|
||||
MEDIA_INFO_LOG("audioEncoder Stop");
|
||||
int32_t ret = audioEncoder_->Stop();
|
||||
if (ret != SUCCESS) {
|
||||
MEDIA_DEBUG_LOG("audioEncoder_ stop failed:0x%x", ret);
|
||||
MEDIA_DEBUG_LOG("audioEncoder_ stop fail,ret:0x%x", ret);
|
||||
return false;
|
||||
}
|
||||
MEDIA_INFO_LOG("audioSource Stop");
|
||||
ret = audioSource_->Stop();
|
||||
if (ret != SUCCESS) {
|
||||
MEDIA_ERR_LOG("audioSource_ stop failed:0x%x", ret);
|
||||
MEDIA_ERR_LOG("audioSource_ stop fail,ret:0x%x", ret);
|
||||
return false;
|
||||
}
|
||||
MEDIA_INFO_LOG("Stop Audio Capturer SUCCESS");
|
||||
@@ -199,7 +197,7 @@ bool AudioCapturer::AudioCapturerImpl::Release()
|
||||
return false;
|
||||
}
|
||||
if (status == RECORDING && Stop()) {
|
||||
MEDIA_ERR_LOG("Stop failed:%u", status);
|
||||
MEDIA_ERR_LOG("Stop failed: %u", status);
|
||||
return false;
|
||||
}
|
||||
status = RELEASED;
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2020-2021 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
|
||||
@@ -17,20 +17,18 @@
|
||||
#define AUDIO_CAPTURER_IMPL_H
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
#include "audio_capturer.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Audio {
|
||||
enum AudioChannel {
|
||||
AUDIO_CHANNEL_IN_MONO = 1,
|
||||
AUDIO_CHANNEL_IN_STEREO = 2,
|
||||
AUDIO_CHANNEL_IN_MONO = 1, /* mono */
|
||||
AUDIO_CHANNEL_IN_STEREO = 2, /* stereo */
|
||||
AUDIO_CHANNEL_BUTT
|
||||
};
|
||||
|
||||
class AudioSource;
|
||||
class AudioEncoder;
|
||||
|
||||
class AudioCapturer::AudioCapturerImpl {
|
||||
public:
|
||||
AudioCapturerImpl();
|
||||
@@ -46,7 +44,6 @@ public:
|
||||
uint64_t GetFrameCount();
|
||||
State GetStatus();
|
||||
bool GetTimestamp(Timestamp ×tamp, Timestamp::Timebase base);
|
||||
|
||||
private:
|
||||
std::unique_ptr<AudioSource> audioSource_;
|
||||
std::unique_ptr<AudioEncoder> audioEncoder_;
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2020-2021 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
|
||||
@@ -21,7 +21,7 @@ namespace OHOS {
|
||||
namespace Audio {
|
||||
using namespace OHOS::Media;
|
||||
|
||||
constexpr uint32_t AUDIO_READ_STREAM_TIME_OUT_MS = 1000;
|
||||
constexpr uint32_t AUDIO_READ_STREAM_TIME_OUT_MS = 1000; /* 1S */
|
||||
|
||||
constexpr uint32_t AUDIO_CHANNEL_MONO = 1;
|
||||
constexpr uint32_t AUDIO_CHANNEL_STEREO = 2;
|
||||
@@ -50,7 +50,7 @@ AudioEncoder::~AudioEncoder()
|
||||
static bool IsAudioCodecFormatSupported(AudioCodecFormat format)
|
||||
{
|
||||
if ((format < AAC_LC) || (format > AAC_ELD)) {
|
||||
MEDIA_ERR_LOG("Invalid format:%d", format);
|
||||
MEDIA_ERR_LOG("Invalid format: %d", format);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -70,7 +70,7 @@ static Profile GetProfileFromAudioCodecFormat(AudioCodecFormat format)
|
||||
case AAC_ELD:
|
||||
return AAC_ELD_PROFILE;
|
||||
default:
|
||||
MEDIA_ERR_LOG("Invalid format:0x%x", format);
|
||||
MEDIA_ERR_LOG("Invalid format: 0x%x", format);
|
||||
return AAC_LC_PROFILE;
|
||||
}
|
||||
}
|
||||
@@ -79,19 +79,29 @@ static AudioSampleRate ConvertSampleRate(uint32_t sampleRate)
|
||||
{
|
||||
switch (sampleRate) {
|
||||
case AUD_SAMPLE_RATE_8000:
|
||||
return AUD_SAMPLE_RATE_8000;
|
||||
case AUD_SAMPLE_RATE_11025:
|
||||
return AUD_SAMPLE_RATE_11025;
|
||||
case AUD_SAMPLE_RATE_12000:
|
||||
return AUD_SAMPLE_RATE_12000;
|
||||
case AUD_SAMPLE_RATE_16000:
|
||||
return AUD_SAMPLE_RATE_16000;
|
||||
case AUD_SAMPLE_RATE_22050:
|
||||
return AUD_SAMPLE_RATE_22050;
|
||||
case AUD_SAMPLE_RATE_24000:
|
||||
return AUD_SAMPLE_RATE_24000;
|
||||
case AUD_SAMPLE_RATE_32000:
|
||||
return AUD_SAMPLE_RATE_32000;
|
||||
case AUD_SAMPLE_RATE_44100:
|
||||
return AUD_SAMPLE_RATE_44100;
|
||||
case AUD_SAMPLE_RATE_48000:
|
||||
return AUD_SAMPLE_RATE_48000;
|
||||
case AUD_SAMPLE_RATE_64000:
|
||||
return AUD_SAMPLE_RATE_64000;
|
||||
case AUD_SAMPLE_RATE_96000:
|
||||
return static_cast<AudioSampleRate>(sampleRate);
|
||||
return AUD_SAMPLE_RATE_96000;
|
||||
default:
|
||||
MEDIA_ERR_LOG("Invalid sample_rate:%u", sampleRate);
|
||||
MEDIA_ERR_LOG("Invalid sample_rate: %d", sampleRate);
|
||||
return AUD_SAMPLE_RATE_48000;
|
||||
}
|
||||
}
|
||||
@@ -104,15 +114,15 @@ static AudioSoundMode ConvertSoundMode(uint32_t channelCount)
|
||||
case AUDIO_CHANNEL_STEREO:
|
||||
return AUD_SOUND_MODE_STEREO;
|
||||
default:
|
||||
MEDIA_ERR_LOG("Invalid soundMode:%u", channelCount);
|
||||
MEDIA_ERR_LOG("Invalid soundMode: %d", channelCount);
|
||||
return AUD_SOUND_MODE_MONO;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t AudioEncoder::InitAudioEncoderAttr(const AudioEncodeConfig &config)
|
||||
int32_t AudioEncoder::InitAencAttr(const AudioEncodeConfig &input)
|
||||
{
|
||||
if (!IsAudioCodecFormatSupported(config.audioFormat)) {
|
||||
MEDIA_ERR_LOG("config.audioFormat:0x%x is not support", config.audioFormat);
|
||||
if (!IsAudioCodecFormatSupported(input.audioFormat)) {
|
||||
MEDIA_ERR_LOG("input.audioFormat :0x%x is not support", input.audioFormat);
|
||||
return ERR_INVALID_PARAM;
|
||||
}
|
||||
uint32_t paramIndex = 0;
|
||||
@@ -126,22 +136,22 @@ int32_t AudioEncoder::InitAudioEncoderAttr(const AudioEncodeConfig &config)
|
||||
encAttr_[paramIndex].val = &codecMime_;
|
||||
encAttr_[paramIndex].size = sizeof(AvCodecMime);
|
||||
paramIndex++;
|
||||
profile_ = GetProfileFromAudioCodecFormat(config.audioFormat);
|
||||
profile_ = GetProfileFromAudioCodecFormat(input.audioFormat);
|
||||
encAttr_[paramIndex].key = KEY_AUDIO_PROFILE;
|
||||
encAttr_[paramIndex].val = &profile_;
|
||||
encAttr_[paramIndex].size = sizeof(Profile);
|
||||
paramIndex++;
|
||||
sampleRate_ = ConvertSampleRate(config.sampleRate);
|
||||
sampleRate_ = ConvertSampleRate(input.sampleRate);
|
||||
encAttr_[paramIndex].key = KEY_SAMPLE_RATE;
|
||||
encAttr_[paramIndex].val = &sampleRate_;
|
||||
encAttr_[paramIndex].size = sizeof(AudioSampleRate);
|
||||
paramIndex++;
|
||||
bitRate_ = config.bitRate;
|
||||
bitRate_ = input.bitRate;
|
||||
encAttr_[paramIndex].key = KEY_BITRATE;
|
||||
encAttr_[paramIndex].val = &bitRate_;
|
||||
encAttr_[paramIndex].size = sizeof(uint32_t);
|
||||
paramIndex++;
|
||||
soundMode_ = ConvertSoundMode(config.channelCount);
|
||||
soundMode_ = ConvertSoundMode(input.channelCount);
|
||||
encAttr_[paramIndex].key = KEY_SOUND_MODE;
|
||||
encAttr_[paramIndex].val = &soundMode_;
|
||||
encAttr_[paramIndex].size = sizeof(AudioSoundMode);
|
||||
@@ -158,17 +168,17 @@ int32_t AudioEncoder::InitAudioEncoderAttr(const AudioEncodeConfig &config)
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
int32_t AudioEncoder::Initialize(const AudioEncodeConfig &config)
|
||||
int32_t AudioEncoder::Initialize(const AudioEncodeConfig &input)
|
||||
{
|
||||
int32_t ret = InitAudioEncoderAttr(config);
|
||||
int32_t ret = InitAencAttr(input);
|
||||
if (ret != SUCCESS) {
|
||||
MEDIA_ERR_LOG("InitAudioEncoderAttr failed:%d", ret);
|
||||
MEDIA_ERR_LOG("InitAencAttr failed:%d", ret);
|
||||
return ret;
|
||||
}
|
||||
const char *audioEncName = "codec.aac.hardware.encoder";
|
||||
ret = CodecCreate(audioEncName, encAttr_, AUDIO_ENC_PARAM_NUM, &encHandle_);
|
||||
if (ret != SUCCESS) {
|
||||
MEDIA_ERR_LOG("CodecCreate failed:0x%x", ret);
|
||||
MEDIA_ERR_LOG("CodecCreate failed :0x%x", ret);
|
||||
return ret;
|
||||
}
|
||||
return SUCCESS;
|
||||
@@ -184,7 +194,7 @@ int32_t AudioEncoder::BindSource(uint32_t deviceId)
|
||||
params[0].size = sizeof(uint32_t);
|
||||
ret = CodecSetParameter(encHandle_, params, sizeof(params) / sizeof(params[0]));
|
||||
if (ret != SUCCESS) {
|
||||
MEDIA_ERR_LOG("CodecSetDevice failed:0x%x", ret);
|
||||
MEDIA_ERR_LOG("CodecSetDevice :0x%x", ret);
|
||||
return ret;
|
||||
}
|
||||
return SUCCESS;
|
||||
@@ -219,7 +229,7 @@ int32_t AudioEncoder::ReadStream(AudioStream &stream, bool isBlockingRead)
|
||||
return ERR_INVALID_READ;
|
||||
}
|
||||
if (stream.buffer == nullptr || stream.bufferLen == 0) {
|
||||
MEDIA_ERR_LOG("stream.buffer is nullptr");
|
||||
MEDIA_ERR_LOG("stream.buffer is nullptr");
|
||||
return ERR_INVALID_READ;
|
||||
}
|
||||
uint32_t timeoutMs;
|
||||
@@ -241,7 +251,7 @@ int32_t AudioEncoder::ReadStream(AudioStream &stream, bool isBlockingRead)
|
||||
errno_t retCopy = memcpy_s(stream.buffer, stream.bufferLen, outInfo.buffers[0].addr,
|
||||
outInfo.buffers[0].length);
|
||||
if (retCopy != EOK) {
|
||||
MEDIA_ERR_LOG("memcpy_s encData.encodedData:%p timeStamp:%lld failed:0x%x",
|
||||
MEDIA_ERR_LOG("memcpy_s encData.encodedData %p timeStamp:%lld failed :0x%x",
|
||||
outInfo.buffers[0].addr, outInfo.timeStamp, retCopy);
|
||||
return ERR_INVALID_OPERATION;
|
||||
} else {
|
||||
+15
-38
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2020-2021 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
|
||||
@@ -18,21 +18,19 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <time.h>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "codec_interface.h"
|
||||
#include "format.h"
|
||||
#include "media_errors.h"
|
||||
#include "media_info.h"
|
||||
|
||||
#include "format.h"
|
||||
#include "codec_interface.h"
|
||||
namespace OHOS {
|
||||
namespace Audio {
|
||||
|
||||
constexpr int32_t AUDIO_ENC_PARAM_NUM = 8;
|
||||
/* count of audio frame in Buffer */
|
||||
constexpr uint32_t AUDIO_FRAME_NUM_IN_BUF = 30;
|
||||
|
||||
/* sample per frame for all encoder(aacplus:2048) */
|
||||
constexpr uint32_t AUDIO_AUDIO_POINT_NUM = 1024;
|
||||
|
||||
@@ -56,63 +54,42 @@ public:
|
||||
~AudioEncoder();
|
||||
|
||||
/**
|
||||
* Initailizes the audio source according to a specific configuration.
|
||||
*
|
||||
* @param config a configuration of audio source.
|
||||
* @return Returns SUCCESS if success, other values otherwise.
|
||||
* 根据AudioSourceConfig 初始化当前source.
|
||||
*/
|
||||
int32_t Initialize(const AudioEncodeConfig &config);
|
||||
int32_t Initialize(const AudioEncodeConfig &input);
|
||||
|
||||
/**
|
||||
* Binds audio source to a specific device.
|
||||
*
|
||||
* @param deviceId specifies the identity of device to bind.
|
||||
* @return Returns SUCCESS if success, other values otherwise.
|
||||
* 获取当前的设备ID.
|
||||
*/
|
||||
int32_t BindSource(uint32_t deviceId);
|
||||
|
||||
/**
|
||||
* Gets mute status of current encoder, dummy implemented currently.
|
||||
*
|
||||
* @param muted holds mute status if success.
|
||||
* @return Returns SUCCESS if success, other values otherwise.
|
||||
* 获取当前编码是否mute
|
||||
*/
|
||||
int32_t GetMute(bool &muted);
|
||||
|
||||
/**
|
||||
* Sets mute status of current encoder, dummy implemented currently.
|
||||
*
|
||||
* @param muted mute status to set.
|
||||
* @return Returns SUCCESS if success, other values otherwise.
|
||||
* 获取当前编码是否mute
|
||||
*/
|
||||
int32_t SetMute(bool muted);
|
||||
|
||||
/**
|
||||
* Starts audio source.
|
||||
*
|
||||
* @return Returns SUCCESS if success, other values otherwise.
|
||||
* 启动源.
|
||||
*/
|
||||
int32_t Start();
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Reads stream from a audio source.
|
||||
*
|
||||
* @param stream source stream to read from.
|
||||
* @param isBlockingRead reading mode.
|
||||
* @return Returns size of data actually read.
|
||||
* 读取源数据,返回实际读取大小.
|
||||
*/
|
||||
int32_t ReadStream(AudioStream &stream, bool isBlockingRead);
|
||||
|
||||
/**
|
||||
* Stops audio source.
|
||||
*
|
||||
* @return Returns SUCCESS if success, other values otherwise.
|
||||
* 停止源.
|
||||
*/
|
||||
int32_t Stop();
|
||||
|
||||
private:
|
||||
int32_t InitAudioEncoderAttr(const AudioEncodeConfig &config);
|
||||
int32_t InitAencAttr(const AudioEncodeConfig &input);
|
||||
|
||||
private:
|
||||
CODEC_HANDLETYPE encHandle_;
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2020-2021 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
|
||||
@@ -12,7 +12,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "audio_source.h"
|
||||
#include "media_log.h"
|
||||
#include "securec.h"
|
||||
@@ -29,7 +28,6 @@ namespace Audio {
|
||||
|
||||
using namespace OHOS::Media;
|
||||
static AudioManager *g_audioManager = nullptr;
|
||||
|
||||
AudioSource::AudioSource()
|
||||
: initialized_(false),
|
||||
started_(false),
|
||||
@@ -38,12 +36,12 @@ AudioSource::AudioSource()
|
||||
{
|
||||
if (g_audioManager == nullptr) {
|
||||
g_audioManager = GetAudioManagerFuncs();
|
||||
MEDIA_DEBUG_LOG("g_audioManager:%p", g_audioManager);
|
||||
MEDIA_DEBUG_LOG("g_audioManager: %p", g_audioManager);
|
||||
}
|
||||
int size = 0;
|
||||
struct AudioAdapterDescriptor *descs = nullptr;
|
||||
g_audioManager->GetAllAdapters(g_audioManager, &descs, &size);
|
||||
MEDIA_DEBUG_LOG("GetAllAdapters size:%d", size);
|
||||
MEDIA_DEBUG_LOG("GetAllAdapters: %d ", size);
|
||||
|
||||
for (int index = 0; index < size; index++) {
|
||||
struct AudioAdapterDescriptor *desc = &descs[index];
|
||||
@@ -64,9 +62,9 @@ AudioSource::AudioSource()
|
||||
|
||||
AudioSource::~AudioSource()
|
||||
{
|
||||
MEDIA_DEBUG_LOG("audioAdapter_:%p", audioAdapter_);
|
||||
MEDIA_DEBUG_LOG("audioAdapter_ :%p", audioAdapter_);
|
||||
if (audioAdapter_ != nullptr) {
|
||||
MEDIA_INFO_LOG("UnloadModule audioAdapter_:%p", audioAdapter_);
|
||||
MEDIA_INFO_LOG("audioAdapter_ UnloadModule: %p", audioAdapter_);
|
||||
g_audioManager->UnloadAdapter(g_audioManager, audioAdapter_);
|
||||
audioAdapter_ = nullptr;
|
||||
}
|
||||
@@ -98,7 +96,7 @@ uint64_t AudioSource::GetFrameCount()
|
||||
uint64_t frameCount = 0;
|
||||
ret = audioCapture_->attr.GetFrameCount(reinterpret_cast<AudioHandle>(audioCapture_), &frameCount);
|
||||
if (ret != SUCCESS) {
|
||||
MEDIA_ERR_LOG("attr GetFrameCount failed:0x%x", ret);
|
||||
MEDIA_ERR_LOG("attr GetFrameCount failed 0x%x ", ret);
|
||||
return ret;
|
||||
}
|
||||
return frameCount;
|
||||
@@ -121,22 +119,22 @@ int32_t AudioSource::EnumDeviceBySourceType(AudioSourceType inputSource, std::ve
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
int32_t AudioSource::Initialize(const AudioSourceConfig &config)
|
||||
int32_t AudioSource::Initialize(const AudioSourceConfig &input)
|
||||
{
|
||||
AUDIO_RETURN_VAL_IF_NULL(audioAdapter_);
|
||||
|
||||
MEDIA_INFO_LOG("config.deviceId:0x%x config.sampleRate:%d", config.deviceId, config.sampleRate);
|
||||
MEDIA_INFO_LOG("deviceId:0x%x input.sampleRate:%d", input.deviceId, input.sampleRate);
|
||||
int32_t ret = SUCCESS;
|
||||
struct AudioDeviceDescriptor desc;
|
||||
struct AudioSampleAttributes attrs;
|
||||
attrs.type = AUDIO_IN_MEDIA;
|
||||
attrs.sampleRate = config.sampleRate;
|
||||
attrs.sampleRate = input.sampleRate;
|
||||
attrs.format = AUDIO_FORMAT_PCM_16_BIT;
|
||||
attrs.channelCount = config.channelCount;
|
||||
attrs.interleaved = config.interleaved;
|
||||
attrs.channelCount = input.channelCount;
|
||||
attrs.interleaved = input.interleaved;
|
||||
ret = audioAdapter_->CreateCapture(audioAdapter_, &desc, &attrs, &audioCapture_);
|
||||
if (ret != SUCCESS || audioCapture_ == nullptr) {
|
||||
MEDIA_ERR_LOG("CreateCapture failed:0x%x", ret);
|
||||
MEDIA_ERR_LOG("CreateCapture failed 0x%x", ret);
|
||||
return ret;
|
||||
}
|
||||
initialized_ = true;
|
||||
@@ -153,7 +151,7 @@ int32_t AudioSource::GetCurrentDeviceId(uint32_t &deviceId)
|
||||
AUDIO_RETURN_VAL_IF_NULL(audioCapture_);
|
||||
int32_t ret = audioCapture_->attr.GetCurrentChannelId(reinterpret_cast<AudioHandle>(audioCapture_), &deviceId);
|
||||
if (ret != SUCCESS) {
|
||||
MEDIA_ERR_LOG("GetCurrentChannelId failed:0x%x", ret);
|
||||
MEDIA_ERR_LOG("GetCurrentChannelId failed 0x%x", ret);
|
||||
return ret;
|
||||
}
|
||||
MEDIA_INFO_LOG("deviceId:0x%x", deviceId);
|
||||
@@ -170,7 +168,7 @@ int32_t AudioSource::Start()
|
||||
AUDIO_RETURN_VAL_IF_NULL(audioCapture_);
|
||||
ret = audioCapture_->control.Start(reinterpret_cast<AudioHandle>(audioCapture_));
|
||||
if (ret != SUCCESS) {
|
||||
MEDIA_ERR_LOG("audioCapture_ Start failed:0x%x", ret);
|
||||
MEDIA_ERR_LOG("audioCapture_ Start failed 0x%x", ret);
|
||||
return ret;
|
||||
}
|
||||
started_ = true;
|
||||
@@ -197,14 +195,14 @@ int32_t AudioSource::Stop()
|
||||
AUDIO_RETURN_VAL_IF_NULL(audioCapture_);
|
||||
ret = audioCapture_->control.Stop(reinterpret_cast<AudioHandle>(audioCapture_));
|
||||
if (ret != SUCCESS) {
|
||||
MEDIA_ERR_LOG("Stop failed:0x%x", ret);
|
||||
MEDIA_ERR_LOG("Stop failed 0x%x", ret);
|
||||
return ret;
|
||||
}
|
||||
ret = audioAdapter_->DestroyCapture(audioAdapter_, audioCapture_);
|
||||
audioCapture_ = nullptr;
|
||||
started_ = false;
|
||||
if (ret != SUCCESS) {
|
||||
MEDIA_ERR_LOG("Close failed:0x%x", ret);
|
||||
MEDIA_ERR_LOG("Close failed 0x%x", ret);
|
||||
return ret;
|
||||
}
|
||||
return SUCCESS;
|
||||
+13
-37
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2020-2021 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
|
||||
@@ -18,21 +18,20 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <time.h>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "audio_manager.h"
|
||||
#include "format.h"
|
||||
#include "media_errors.h"
|
||||
#include "media_info.h"
|
||||
#include "format.h"
|
||||
#include "audio_manager.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Audio {
|
||||
struct AudioSourceConfig {
|
||||
/**
|
||||
* Enumerates currently supported devices by audio source type,
|
||||
* and binds current audio source a specified device.
|
||||
* 根据EnumDeviceBySourceType 枚举到的设备,选择设置当前audio source 要使用的设备.
|
||||
*/
|
||||
uint32_t deviceId;
|
||||
AudioCodecFormat audioFormat;
|
||||
@@ -49,11 +48,7 @@ public:
|
||||
~AudioSource();
|
||||
|
||||
/**
|
||||
* Enumerates currently supported devices by audio source type.
|
||||
*
|
||||
* @param inputSource the type of source audio.
|
||||
* @param devices holds an array of statisfied audio device description, including name and identity.
|
||||
* @return Returns SUCCESS if success, other values otherwise.
|
||||
* 根据输入源类型枚举当前支持的设备,包括设备名和设备ID.
|
||||
*/
|
||||
int32_t EnumDeviceBySourceType(AudioSourceType inputSource, std::vector<AudioDeviceDesc> &devices);
|
||||
|
||||
@@ -77,51 +72,32 @@ public:
|
||||
uint64_t GetFrameCount();
|
||||
|
||||
/**
|
||||
* Initailizes the audio source according to a specific configuration.
|
||||
*
|
||||
* @param config a configuration of audio source.
|
||||
* @return Returns SUCCESS if success, other values otherwise.
|
||||
* 根据AudioSourceConfig 初始化当前source.
|
||||
*/
|
||||
int32_t Initialize(const AudioSourceConfig &config);
|
||||
int32_t Initialize(const AudioSourceConfig &input);
|
||||
|
||||
/**
|
||||
* Sets input device's identity when switching device.
|
||||
*
|
||||
* @param deviceId indentity to set.
|
||||
* @return Returns SUCCESS if set successfully, other values otherwise.
|
||||
* 设置设备ID,需要切换设备时调用.
|
||||
*/
|
||||
int32_t SetInputDevice(uint32_t deviceId);
|
||||
|
||||
/**
|
||||
* Gets current device's identity.
|
||||
*
|
||||
* @param deviceId holds the identity of current device, if success.
|
||||
* @return Returns SUCCESS if success, other values otherwise.
|
||||
* 获取当前的设备ID.
|
||||
*/
|
||||
int32_t GetCurrentDeviceId(uint32_t &deviceId);
|
||||
|
||||
/**
|
||||
* Starts audio source.
|
||||
*
|
||||
* @return Returns SUCCESS if success, other values otherwise.
|
||||
* 启动源.
|
||||
*/
|
||||
int32_t Start();
|
||||
|
||||
/**
|
||||
*
|
||||
* Reads frame from source.
|
||||
*
|
||||
* @param buffer source to read from.
|
||||
* @param bufferBytes size of buffer.
|
||||
* @param isBlockingRead reading mode.
|
||||
* @return Returns size of data actually read.
|
||||
* 读取源数据,返回实际读取大小.
|
||||
*/
|
||||
int32_t ReadFrame(uint8_t *buffer, size_t bufferBytes, bool isBlockingRead);
|
||||
|
||||
/**
|
||||
* Stops audio source.
|
||||
*
|
||||
* @return Returns SUCCESS if success, other values otherwise.
|
||||
* 停止源.
|
||||
*/
|
||||
int32_t Stop();
|
||||
|
||||
Executable
+253
@@ -0,0 +1,253 @@
|
||||
/*
|
||||
* Copyright (c) 2020-2021 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup MultiMedia_AudioCapturer
|
||||
* @{
|
||||
*
|
||||
* @brief Declares APIs in the <b>AudioCapturer</b> class for audio capture.
|
||||
*
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file audio_capturer.h
|
||||
*
|
||||
* @brief Provides the <b>AudioCapturer</b> class to implement operations related to audio capture.
|
||||
*
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
#ifndef AUDIO_CAPTURER_H
|
||||
#define AUDIO_CAPTURER_H
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <time.h>
|
||||
#include <memory>
|
||||
|
||||
#include "media_errors.h"
|
||||
#include "media_info.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Audio {
|
||||
/**
|
||||
* @brief Defines information about audio capture parameters, including the input source, audio codec format,sampling
|
||||
* rate (Hz), number of audio channels, bit rate, and bit width.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
struct AudioCapturerInfo {
|
||||
/** Audio source type */
|
||||
AudioSourceType inputSource = AUDIO_MIC;
|
||||
/** Audio codec format */
|
||||
AudioCodecFormat audioFormat = AUDIO_DEFAULT;
|
||||
/** Sampling rate */
|
||||
int32_t sampleRate = 0;
|
||||
/** Number of audio channels */
|
||||
int32_t channelCount = 0;
|
||||
/** Bit rate */
|
||||
int32_t bitRate = 0;
|
||||
/** Audio stream type */
|
||||
AudioStreamType streamType = TYPE_MEDIA;
|
||||
/** Bit width */
|
||||
AudioBitWidth bitWidth = BIT_WIDTH_16;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Represents timestamp information, including the frame position information and high-resolution time source.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
class Timestamp {
|
||||
public:
|
||||
Timestamp() : framePosition(0)
|
||||
{
|
||||
time.tv_sec = 0;
|
||||
time.tv_nsec = 0;
|
||||
}
|
||||
~Timestamp() = default;
|
||||
uint32_t framePosition;
|
||||
struct timespec time;
|
||||
|
||||
/**
|
||||
* @brief Enumerates the time base of this <b>Timestamp</b>. Different timing methods are supported.
|
||||
*
|
||||
*/
|
||||
enum class Timebase : int32_t {
|
||||
/** Monotonically increasing time, excluding the system sleep time */
|
||||
MONOTONIC = 0,
|
||||
/** Monotonically increasing time, including the system sleep time */
|
||||
BOOTTIME = 1
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Enumerates the recording states of the current device.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
enum State : uint32_t {
|
||||
/** Prepared */
|
||||
PREPPARED,
|
||||
/** Recording */
|
||||
RECORDING,
|
||||
/** Stopped */
|
||||
STOPPED,
|
||||
/** Released */
|
||||
RELEASED
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Provides functions for applications to implement audio capturing.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
class AudioCapturer {
|
||||
public:
|
||||
AudioCapturer();
|
||||
virtual ~AudioCapturer();
|
||||
|
||||
/**
|
||||
* @brief Obtains the minimum number of frames required in a specified condition, in bytes per sample.
|
||||
*
|
||||
* @param sampleRate Indicates the audio sampling rate, in Hz.
|
||||
* @param channelCount Indicates the number of audio recording channels.
|
||||
* @param audioFormat Indicates the audio data format.
|
||||
* @param frameCount Indicates the minimum number of frames, in bytes per sample.
|
||||
* @return Returns <b>true</b> if the minimum number of frames is successfully obtained; returns <b>false</b>
|
||||
* otherwise.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
static bool GetMinFrameCount(int32_t sampleRate, int32_t channelCount, AudioCodecFormat audioFormat,
|
||||
size_t &frameCount);
|
||||
|
||||
/**
|
||||
* @brief Obtains the number of frames required in the current condition, in bytes per sample.
|
||||
*
|
||||
* @return Returns the number of frames (in bytes per sample) if the operation is successful; returns <b>-1</b>
|
||||
* if an exception occurs.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
uint64_t GetFrameCount();
|
||||
|
||||
/**
|
||||
* @brief Sets audio capture parameters.
|
||||
*
|
||||
* @param info Indicates information about audio capture parameters to set. For details, see
|
||||
* {@link AudioCapturerInfo}.
|
||||
* @return Returns {@link SUCCESS} if the setting is successful; returns an error code defined
|
||||
* in {@link media_errors.h} otherwise.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
int32_t SetCapturerInfo(const AudioCapturerInfo info);
|
||||
|
||||
/**
|
||||
* @brief Obtains audio capture parameters.
|
||||
*
|
||||
* This function can be called after {@link SetCapturerInfo} is successful.
|
||||
*
|
||||
* @param info Indicates information about audio capture parameters. For details, see {@link AudioCapturerInfo}.
|
||||
* @return Returns {@link SUCCESS} if the parameter information is successfully obtained; returns an error code
|
||||
* defined in {@link media_errors.h} otherwise.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
int32_t GetCapturerInfo(AudioCapturerInfo &info);
|
||||
|
||||
/**
|
||||
* @brief Starts audio recording.
|
||||
*
|
||||
* @return Returns <b>true</b> if the recording is successfully started; returns <b>false</b> otherwise.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
bool Start();
|
||||
|
||||
/**
|
||||
* @brief Reads audio data.
|
||||
*
|
||||
* @param buffer Indicates the pointer to the buffer into which the audio data is to be written.
|
||||
* @param userSize Indicates the size of the buffer into which the audio data is to be written, in bytes.
|
||||
* <b>userSize >= frameCount * channelCount * BytesPerSample</b> must evaluate to <b>true</b>. You can call
|
||||
* {@link GetFrameCount} to obtain the <b>frameCount</b> value.
|
||||
* @param isBlockingRead Specifies whether data reading will be blocked.
|
||||
* @return Returns the size of the audio data read from the device. The value ranges from <b>0</b> to
|
||||
* <b>userSize</b>. If the reading fails, one of the following error codes is returned:
|
||||
* <b>ERR_INVALID_PARAM</b>: The input parameter is incorrect.
|
||||
* <b>ERR_ILLEGAL_STATE</b>: The <b>AudioCapturer</b> instance is not initialized.
|
||||
* <b>ERR_SOURCE_NOT_SET</b>: The state of hardware device instance is abnormal.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
int32_t Read(uint8_t *buffer, size_t userSize, bool isBlockingRead);
|
||||
|
||||
/**
|
||||
* @brief Obtains the audio capture state.
|
||||
*
|
||||
* @return Returns the audio capture state defined in {@link State}.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
State GetStatus();
|
||||
|
||||
/**
|
||||
* @brief Obtains the timestamp.
|
||||
*
|
||||
* @param timestamp Indicates a {@link Timestamp} instance reference provided by the caller.
|
||||
* @param base Indicates the time base, which can be {@link Timestamp.Timebase#BOOTTIME Timestamp.Timebase.BOOTTIME}
|
||||
* or {@link Timestamp.Timebase#MONOTONIC Timestamp.Timebase.MONOTONIC}.
|
||||
* @return Returns <b>true</b> if the timestamp is successfully obtained; returns <b>false</b> otherwise.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
bool GetAudioTime(Timestamp ×tamp, Timestamp::Timebase base);
|
||||
|
||||
/**
|
||||
* @brief Stops audio recording.
|
||||
*
|
||||
* @return Returns <b>true</b> if the recording is successfully stopped; returns <b>false</b> otherwise.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
bool Stop();
|
||||
|
||||
/**
|
||||
* @brief Releases a local <b>AudioCapturer</b> object.
|
||||
*
|
||||
* @return Returns <b>true</b> if the object is successfully released; returns <b>false</b> otherwise.
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
bool Release();
|
||||
|
||||
private:
|
||||
class AudioCapturerImpl;
|
||||
std::unique_ptr<AudioCapturerImpl> impl_;
|
||||
};
|
||||
} // namespace Audio
|
||||
} // namespace OHOS
|
||||
#endif // AUDIO_CAPTURER_H
|
||||
Reference in New Issue
Block a user