diff --git a/BUILD.gn b/BUILD.gn
index 5d33a819a6b886fdce647fd2d05bb15d007b064d..5e89fd0e61593c4fe20b279ce78534e1883c2d5a 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -14,11 +14,10 @@
import("//build/ohos.gni")
group("audio_packages") {
- public_deps = [
- "interfaces/innerkits/native/audiocapturer:audio_capturer",
- "interfaces/innerkits/native/audiorenderer:audio_renderer",
- "interfaces/innerkits/native/audiorecorder:audio_recorder",
- "services:audio_service",
- "interfaces/innerkits/native/audiomanager:audio_client",
+ public_deps = [
+ "interfaces/innerkits/native/audiocapturer:audio_capturer",
+ "interfaces/innerkits/native/audiomanager:audio_client",
+ "interfaces/innerkits/native/audiorenderer:audio_renderer",
+ "services:audio_service",
]
}
diff --git a/README.md b/README.md
index 660d5e8b010d540a1e64b8bcfe677c7134438f61..cae0866f9f79c733369bb30a17dc44ddc6c65d88 100644
--- a/README.md
+++ b/README.md
@@ -95,54 +95,54 @@ You can use APIs provided in this repository to convert audio data into audible
8. Call audioRenderer->**Drain**() to drain the playback stream.
9. Call audioRenderer->**Stop()** function to Stop rendering.
-10. After the playback task is complete, call the audioRenderer->**Release**() function on the AudioRenderer instance to release the resources.
+10. After the playback task is complete, call the audioRenderer->**Release**() function on the AudioRenderer instance to release the stream resources.
Provided the basic playback usecase above. Please refer [**audio_renderer.h**](https://gitee.com/openharmony/multimedia_audio_standard/blob/master/interfaces/innerkits/native/audiorenderer/include/audio_renderer.h) and [**audio_info.h**](https://gitee.com/openharmony/multimedia_audio_standard/blob/master/interfaces/innerkits/native/audiocommon/include/audio_info.h) for more APIs.
### Audio Recording
-You can use the APIs provided in this repository for your application to record voices using input devices, convert the voices into audio data, and manage recording tasks. The following steps describe how to use AudioReorder to develop the audio recording function:
+You can use the APIs provided in this repository for your application to record voices using input devices, convert the voices into audio data, and manage recording tasks. The following steps describe how to use AudioCapturer to develop the audio recording function:
-1. Use **Create** API with required stream type to get **AudioRecorder** instance.
+1. Use **Create** API with required stream type to get **AudioCapturer** instance.
```
AudioStreamType streamType = STREAM_MUSIC;
- std::unique_ptr audioRecorder = AudioRecorder::Create(streamType);
+ std::unique_ptr audioCapturer = AudioCapturer::Create(streamType);
```
2. (Optional) Static APIs **GetSupportedFormats**(), **GetSupportedChannels**(), **GetSupportedEncodingTypes**(), **GetSupportedSamplingRates()** can be used to get the supported values of the params.
3. To Prepare the device, call **SetParams** on the instance.
```
- AudioRecorderParams recorderParams;
- recorderParams.sampleFormat = SAMPLE_S16LE;
- recorderParams.sampleRate = SAMPLE_RATE_44100;
- recorderParams.channelCount = STEREO;
- recorderParams.encodingType = ENCODING_PCM;
+ AudioCapturerParams capturerParams;
+ capturerParams.sampleFormat = SAMPLE_S16LE;
+ capturerParams.sampleRate = SAMPLE_RATE_44100;
+ capturerParams.channelCount = STEREO;
+ capturerParams.encodingType = ENCODING_PCM;
- audioRecorder->SetParams(recorderParams);
- ```
-4. (Optional) use audioRecorder->**GetParams**(recorderParams) to validate SetParams()
-5. Call audioRenderer->**Start**() function on the AudioRecorder instance to start the recording task.
+ audioCapturer->SetParams(capturerParams);
+ ```h
+4. (Optional) use audioCapturer->**GetParams**(capturerParams) to validate SetParams()
+5. Call audioRenderer->**Start**() function on the AudioCapturer instance to start the recording task.
6. Get the buffer length to be read, using **GetBufferSize** API.
```
- audioRecorder->GetBufferSize(bufferLen);
+ audioCapturer->GetBufferSize(bufferLen);
```
-7. Read the recorded audio data and convert it to a byte stream. Call the read function repeatedly to read data untill you want to stop recording
+7. Read the captured audio data and convert it to a byte stream. Call the read function repeatedly to read data untill you want to stop recording
```
- bytesRead = audioRecorder->Read(*buffer, bufferLen, isBlocking); // set isBlocking = true/false for blocking/non-blocking read
- while (numBuffersToRecord) {
- bytesRead = audioRecorder->Read(*buffer, bufferLen, isBlockingRead);
+ bytesRead = audioCapturer->Read(*buffer, bufferLen, isBlocking); // set isBlocking = true/false for blocking/non-blocking read
+ while (numBuffersToCapture) {
+ bytesRead = audioCapturer->Read(*buffer, bufferLen, isBlockingRead);
if (bytesRead < 0) {
break;
} else if (bytesRead > 0) {
fwrite(buffer, size, bytesRead, recFile); // example shows writes the recored data into a file
- numBuffersToRecord--;
+ numBuffersToCapture--;
}
}
```
-8. (Optional) Call audioRecorder->**Flush**() to flush the record buffer of this stream.
-9. Call the audioRecorder->**Stop**() function on the AudioRecorder instance to stop the recording.
-10. After the recording task is complete, call the audioRecorder->**Release**() function on the AudioRecorder instance to release resources.
+8. (Optional) Call audioCapturer->**Flush**() to flush the capture buffer of this stream.
+9. Call the audioCapturer->**Stop**() function on the AudioCapturer instance to stop the recording.
+10. After the recording task is complete, call the audioCapturer->**Release**() function on the AudioCapturer instance to release the stream resources.
-Provided the basic recording usecase above. Please refer [**audio_recorder.h**](https://gitee.com/openharmony/multimedia_audio_standard/blob/master/interfaces/innerkits/native/audiorecorder/include/audio_recorder.h) and [**audio_info.h**](https://gitee.com/openharmony/multimedia_audio_standard/blob/master/interfaces/innerkits/native/audiocommon/include/audio_info.h) for more APIs.
+Provided the basic recording usecase above. Please refer [**audio_capturer.h**](https://gitee.com/openharmony/multimedia_audio_standard/blob/master/interfaces/innerkits/native/audiocapturer/include/audio_capturer.h) and [**audio_info.h**](https://gitee.com/openharmony/multimedia_audio_standard/blob/master/interfaces/innerkits/native/audiocommon/include/audio_info.h) for more APIs.
### Audio Management
diff --git a/frameworks/innerkitsimpl/audiocapturer/include/audio_capturer_impl.h b/frameworks/innerkitsimpl/audiocapturer/include/audio_capturer_impl.h
deleted file mode 100755
index 210f6c3f3b26106b34010499f0c44874de083d1c..0000000000000000000000000000000000000000
--- a/frameworks/innerkitsimpl/audiocapturer/include/audio_capturer_impl.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 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.
- */
-
-#ifndef AUDIO_CAPTURER_IMPL_H
-#define AUDIO_CAPTURER_IMPL_H
-
-#include "audio_capturer.h"
-
-#include
-
-namespace OHOS {
-namespace Audio {
-enum AudioChannel {
- AUDIO_CHANNEL_IN_MONO = 1, /* mono */
- AUDIO_CHANNEL_IN_STEREO = 2, /* stereo */
- AUDIO_CHANNEL_BUTT
-};
-
-class AudioSource;
-class AudioEncoder;
-class AudioCapturer::AudioCapturerImpl {
-public:
- AudioCapturerImpl();
- virtual ~AudioCapturerImpl();
- static bool GetMinFrameCount(int32_t sampleRate, int32_t channelCount, AudioCodecFormat audioFormat,
- size_t &frameCount);
- int32_t SetCapturerInfo(const AudioCapturerInfo info);
- int32_t GetCapturerInfo(AudioCapturerInfo &info);
- bool Record();
- bool Stop();
- bool Release();
- int32_t Read(uint8_t &buffer, size_t userSize, bool isBlockingRead);
- uint64_t GetFrameCount();
- State GetStatus();
- bool GetTimestamp(Timestamp ×tamp, Timestamp::Timebase base);
-private:
- std::unique_ptr audioSource_;
- std::unique_ptr audioEncoder_;
- State status = RELEASED;
- AudioCapturerInfo info_;
- Timestamp timestamp_;
- int32_t inputDeviceId_ = 0;
-};
-} // namespace Audio
-} // namespace OHOS
-#endif // AUDIO_CAPTURER_IMPL_H
diff --git a/frameworks/innerkitsimpl/audiorecorder/include/audio_recorder_private.h b/frameworks/innerkitsimpl/audiocapturer/include/audio_capturer_private.h
similarity index 74%
rename from frameworks/innerkitsimpl/audiorecorder/include/audio_recorder_private.h
rename to frameworks/innerkitsimpl/audiocapturer/include/audio_capturer_private.h
index 03354f80e78265d344350662e350d66cd449345f..8e780ff1e86b7d8c83f92110ed0a0da39573cbe5 100644
--- a/frameworks/innerkitsimpl/audiorecorder/include/audio_recorder_private.h
+++ b/frameworks/innerkitsimpl/audiocapturer/include/audio_capturer_private.h
@@ -13,29 +13,29 @@
* limitations under the License.
*/
-#include "audio_recorder.h"
+#include "audio_capturer.h"
#include "audio_stream.h"
namespace OHOS {
namespace AudioStandard {
-class AudioRecorderPrivate : public AudioRecorder {
+class AudioCapturerPrivate : public AudioCapturer {
public:
int32_t GetFrameCount(uint32_t &frameCount) const override;
- int32_t SetParams(const AudioRecorderParams params) const override;
- int32_t GetParams(AudioRecorderParams ¶ms) const override;
+ int32_t SetParams(const AudioCapturerParams params) const override;
+ int32_t GetParams(AudioCapturerParams ¶ms) const override;
bool Start() const override;
int32_t Read(uint8_t &buffer, size_t userSize, bool isBlockingRead) const override;
- RecorderState GetStatus() const override;
+ CapturerState GetStatus() const override;
bool GetAudioTime(Timestamp ×tamp, Timestamp::Timestampbase base) const override;
bool Stop() const override;
bool Flush() const override;
bool Release() const override;
int32_t GetBufferSize(size_t &bufferSize) const override;
- std::unique_ptr audioRecorder;
+ std::unique_ptr audioCapturer;
- explicit AudioRecorderPrivate(AudioStreamType audioStreamType);
- virtual ~AudioRecorderPrivate();
+ explicit AudioCapturerPrivate(AudioStreamType audioStreamType);
+ virtual ~AudioCapturerPrivate();
};
} // namespace AudioStandard
} // namespace OHOS
diff --git a/frameworks/innerkitsimpl/audiocapturer/include/audio_encoder.h b/frameworks/innerkitsimpl/audiocapturer/include/audio_encoder.h
deleted file mode 100755
index 4c0a2b832eb00bb8d0e4c77e433c1e844f406e00..0000000000000000000000000000000000000000
--- a/frameworks/innerkitsimpl/audiocapturer/include/audio_encoder.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (C) 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.
- */
-
-#ifndef AUDIO_ENCODER_H
-#define AUDIO_ENCODER_H
-
-#include
-#include
-#include
-#include
-#include
-#include "audio_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:1024) */
-constexpr uint32_t AUDIO_POINT_NUM = 1024;
-
-struct AudioEncodeConfig {
- AudioCodecFormat audioFormat;
- uint32_t bitRate = 0;
- uint32_t sampleRate = 0;
- uint32_t channelCount = 0;
- AudioBitWidth bitWidth = BIT_WIDTH_16;
-};
-
-struct AudioStream {
- uint8_t *buffer = nullptr; /* the virtual address of stream */
- uint32_t bufferLen = 0; /* stream length, by bytes */
- int64_t timeStamp = 0;
-};
-
-class AudioEncoder {
-public:
- AudioEncoder();
- virtual ~AudioEncoder();
-
- /**
- * Init audio encoder with AudioEncodeConfig.
- */
- int32_t Initialize(const AudioEncodeConfig &input);
-
- /**
- * Binds the source deviceId.
- */
- int32_t BindSource(uint32_t deviceId);
-
- /**
- * Obtains whether the current encoding is muted.
- */
- int32_t GetMute(bool &muted);
-
- /**
- * Sets whether the current encoding is muted.
- */
- int32_t SetMute(bool muted);
-
- /**
- * Start the audio encoder.
- */
- int32_t Start();
-
- /**
- * Reads the source data and returns the actual read size.
- */
- int32_t ReadStream(AudioStream &stream, bool isBlockingRead);
-
- /**
- * Stop the audio encoder.
- */
- int32_t Stop();
-
-private:
- int32_t InitAudioEncoderAttr(const AudioEncodeConfig &input);
-
-private:
- CODEC_HANDLETYPE encHandle_;
- CodecType domainKind_ = AUDIO_ENCODER;
- AvCodecMime codecMime_ = MEDIA_MIMETYPE_AUDIO_AAC;
- Profile profile_ = INVALID_PROFILE;
- AudioSampleRate sampleRate_ = AUD_SAMPLE_RATE_INVALID;
- uint32_t bitRate_ = 0;
- AudioSoundMode soundMode_ = AUD_SOUND_MODE_INVALID;
- uint32_t ptNumPerFrm_ = AUDIO_POINT_NUM;
- uint32_t bufSize_ = AUDIO_FRAME_NUM_IN_BUF;
- Param encAttr_[AUDIO_ENC_PARAM_NUM];
- bool started_;
-};
-} // namespace Audio
-} // namespace OHOS
-#endif // AUDIO_ENCODER_H
diff --git a/frameworks/innerkitsimpl/audiocapturer/include/audio_source.h b/frameworks/innerkitsimpl/audiocapturer/include/audio_source.h
deleted file mode 100755
index a540a0542be5b9ab715400ef2b8d6cde2d2c690d..0000000000000000000000000000000000000000
--- a/frameworks/innerkitsimpl/audiocapturer/include/audio_source.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (C) 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.
- */
-
-#ifndef AUDIO_SOURCE_H
-#define AUDIO_SOURCE_H
-
-#include
-#include
-#include
-#include
-#include
-
-#include "audio_errors.h"
-#include "media_info.h"
-#include "format.h"
-#include "audio_manager.h"
-
-namespace OHOS {
-namespace Audio {
-struct AudioSourceConfig {
- /**
- * Select the device to be used for setting the current audio source based on the device enumerated by
- * EnumDeviceBySourceType.
- */
- uint32_t deviceId;
- AudioCodecFormat audioFormat;
- int32_t sampleRate = 0;
- int32_t channelCount = 0;
- bool interleaved;
- AudioBitWidth bitWidth = BIT_WIDTH_16;
- AudioStreamType streamUsage;
-};
-
-class AudioSource {
-public:
- AudioSource();
- virtual ~AudioSource();
-
- /**
- * Enumerates supported devices based on the input source type, including device names and device IDs.
- */
- int32_t EnumDeviceBySourceType(AudioSourceType inputSource, std::vector &devices);
-
- /**
- * Obtains the minimum frame count (in BytesPerSample) required in the specified conditions.
- *
- * @param sampleRate Indicates the sampling rate (Hz).
- * @param channelCount Indicates the audio channel count.
- * @param audioFormat Indicates the audio data format.
- * @param frameCount the minimum frame count (in BytesPerSample).
- * @return Returns {@code true} if success; returns {@code false} otherwise.
- */
- static bool GetMinFrameCount(int32_t sampleRate, int32_t channelCount,
- AudioCodecFormat audioFormat, size_t &frameCount);
-
- /**
- * Obtains the frame count (in BytesPerSample) required in the current conditions.
- *
- * @return Returns the frame count (in BytesPerSample); returns {@code -1} if an exception occurs.
- */
- uint64_t GetFrameCount();
-
- /**
- * Initializes the current source based on AudioSourceConfig.
- */
- int32_t Initialize(const AudioSourceConfig &input);
-
- /**
- * Set the input device ID, which is used when a device needs to be switched.
- */
- int32_t SetInputDevice(uint32_t deviceId);
-
- /**
- * Obtains the current device ID.
- */
- int32_t GetCurrentDeviceId(uint32_t &deviceId);
-
- /**
- * Start the source.
- */
- int32_t Start();
-
- /**
- * Reads the source data and returns the actual read size.
- */
- int32_t ReadFrame(uint8_t &buffer, size_t bufferBytes, bool isBlockingRead);
-
- /**
- * Stop the source.
- */
- int32_t Stop();
-
-private:
- int32_t InitCheck();
-
-private:
- bool initialized_;
- bool started_;
- AudioAdapter *audioAdapter_;
- AudioCapture *audioCapture_;
- AudioPort capturePort_ = {};
-};
-} // namespace Audio
-} // namespace OHOS
-#endif // AUDIO_SOURCE_H
diff --git a/frameworks/innerkitsimpl/audiocapturer/src/audio_capturer.cpp b/frameworks/innerkitsimpl/audiocapturer/src/audio_capturer.cpp
old mode 100755
new mode 100644
index fd34fad19938803c4957b603f8222223ef77859b..4aae73c40b966807c3c23241654ed7553911b5e5
--- a/frameworks/innerkitsimpl/audiocapturer/src/audio_capturer.cpp
+++ b/frameworks/innerkitsimpl/audiocapturer/src/audio_capturer.cpp
@@ -13,68 +13,116 @@
* limitations under the License.
*/
+#include
+
+#include "audio_errors.h"
#include "audio_capturer.h"
-#include "audio_capturer_impl.h"
+#include "audio_capturer_private.h"
+#include "audio_stream.h"
namespace OHOS {
-namespace Audio {
-AudioCapturer::AudioCapturer() : impl_(new(std::nothrow) AudioCapturerImpl())
+namespace AudioStandard {
+AudioCapturer::~AudioCapturer() = default;
+AudioCapturerPrivate::~AudioCapturerPrivate() = default;
+
+std::unique_ptr AudioCapturer::Create(AudioStreamType audioStreamType)
+{
+ return std::make_unique(audioStreamType);
+}
+
+AudioCapturerPrivate::AudioCapturerPrivate(AudioStreamType audioStreamType)
+{
+ audioCapturer = std::make_unique(audioStreamType, AUDIO_MODE_RECORD);
+}
+
+int32_t AudioCapturerPrivate::GetFrameCount(uint32_t &frameCount) const
+{
+ return audioCapturer->GetFrameCount(frameCount);
+}
+
+int32_t AudioCapturerPrivate::SetParams(const AudioCapturerParams params) const
+{
+ AudioStreamParams audioStreamParams;
+ audioStreamParams.format = params.audioSampleFormat;
+ audioStreamParams.samplingRate = params.samplingRate;
+ audioStreamParams.channels = params.audioChannel;
+ audioStreamParams.encoding = params.audioEncoding;
+
+ return audioCapturer->SetAudioStreamInfo(audioStreamParams);
+}
+
+int32_t AudioCapturerPrivate::GetParams(AudioCapturerParams ¶ms) const
+{
+ AudioStreamParams audioStreamParams;
+ int32_t result = audioCapturer->GetAudioStreamInfo(audioStreamParams);
+ if (SUCCESS == result) {
+ params.audioSampleFormat = static_cast(audioStreamParams.format);
+ params.samplingRate = static_cast(audioStreamParams.samplingRate);
+ params.audioChannel = static_cast(audioStreamParams.channels);
+ params.audioEncoding = static_cast(audioStreamParams.encoding);
+ }
+
+ return result;
+}
+
+bool AudioCapturerPrivate::Start() const
{
+ return audioCapturer->StartAudioStream();
}
-AudioCapturer::~AudioCapturer()
+int32_t AudioCapturerPrivate::Read(uint8_t &buffer, size_t userSize, bool isBlockingRead) const
{
+ return audioCapturer->Read(buffer, userSize, isBlockingRead);
}
-bool AudioCapturer::GetMinFrameCount(int32_t sampleRate, int32_t channelCount,
- AudioCodecFormat audioFormat, size_t &frameCount)
+CapturerState AudioCapturerPrivate::GetStatus() const
{
- return AudioCapturerImpl::GetMinFrameCount(sampleRate, channelCount, audioFormat, frameCount);
+ return (CapturerState)audioCapturer->GetState();
}
-uint64_t AudioCapturer::GetFrameCount()
+bool AudioCapturerPrivate::GetAudioTime(Timestamp ×tamp, Timestamp::Timestampbase base) const
{
- return impl_->GetFrameCount();
+ return audioCapturer->GetAudioTime(timestamp, base);
}
-State AudioCapturer::GetStatus()
+bool AudioCapturerPrivate::Stop() const
{
- return impl_->GetStatus();
+ return audioCapturer->StopAudioStream();
}
-bool AudioCapturer::GetAudioTime(Timestamp ×tamp, Timestamp::Timebase base)
+bool AudioCapturerPrivate::Flush() const
{
- return impl_->GetTimestamp(timestamp, base);
+ return audioCapturer->FlushAudioStream();
}
-int32_t AudioCapturer::SetCapturerInfo(const AudioCapturerInfo info)
+bool AudioCapturerPrivate::Release() const
{
- return impl_->SetCapturerInfo(info);
+ return audioCapturer->ReleaseAudioStream();
}
-int32_t AudioCapturer::GetCapturerInfo(AudioCapturerInfo &info)
+int32_t AudioCapturerPrivate::GetBufferSize(size_t &bufferSize) const
{
- return impl_->GetCapturerInfo(info);
+ return audioCapturer->GetBufferSize(bufferSize);
}
-bool AudioCapturer::Start()
+std::vector AudioCapturer::GetSupportedFormats()
{
- return impl_->Record();
+ return AUDIO_SUPPORTED_FORMATS;
}
-bool AudioCapturer::Stop()
+std::vector AudioCapturer::GetSupportedChannels()
{
- return impl_->Stop();
+ return AUDIO_SUPPORTED_CHANNELS;
}
-bool AudioCapturer::Release()
+std::vector AudioCapturer::GetSupportedEncodingTypes()
{
- return impl_->Release();
+ return AUDIO_SUPPORTED_ENCODING_TYPES;
}
-int32_t AudioCapturer::Read(uint8_t &buffer, size_t userSize, bool isBlockingRead)
+std::vector AudioCapturer::GetSupportedSamplingRates()
{
- return impl_->Read(buffer, userSize, isBlockingRead);
+ return AUDIO_SUPPORTED_SAMPLING_RATES;
}
-} // namespace Audio
-} // namespace OHOS
+} // namespace AudioStandard
+} // namespace OHOS
\ No newline at end of file
diff --git a/frameworks/innerkitsimpl/audiocapturer/src/audio_capturer_impl.cpp b/frameworks/innerkitsimpl/audiocapturer/src/audio_capturer_impl.cpp
deleted file mode 100755
index 7035b166b9477c9190d912f8ae2f64c6938681b1..0000000000000000000000000000000000000000
--- a/frameworks/innerkitsimpl/audiocapturer/src/audio_capturer_impl.cpp
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Copyright (C) 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.
- */
-
-#include "audio_capturer_impl.h"
-#include "audio_encoder.h"
-#include "audio_source.h"
-#include "media_log.h"
-
-#include
-
-namespace OHOS {
-namespace Audio {
-using namespace OHOS::Media;
-using namespace OHOS::AudioStandard;
-
-const unsigned long long TIME_CONVERSION_US_S = 1000000ULL; /* us to s */
-const unsigned long long TIME_CONVERSION_NS_US = 1000ULL; /* ns to us */
-
-
-AudioCapturer::AudioCapturerImpl::AudioCapturerImpl() : audioSource_(new(std::nothrow) AudioSource()),
- audioEncoder_(new(std::nothrow) AudioEncoder())
-{
- MEDIA_DEBUG_LOG("ctor");
-}
-
-AudioCapturer::AudioCapturerImpl::~AudioCapturerImpl()
-{
- Release();
-}
-
-bool AudioCapturer::AudioCapturerImpl::GetMinFrameCount(int32_t sampleRate, int32_t channelCount,
- AudioCodecFormat audioFormat, size_t &frameCount)
-{
- return AudioSource::GetMinFrameCount(sampleRate, channelCount, audioFormat, frameCount);
-}
-
-uint64_t AudioCapturer::AudioCapturerImpl::GetFrameCount()
-{
- return audioSource_->GetFrameCount();
-}
-
-State AudioCapturer::AudioCapturer::AudioCapturerImpl::GetStatus()
-{
- return status;
-}
-
-bool AudioCapturer::AudioCapturerImpl::GetTimestamp(Timestamp ×tamp, Timestamp::Timebase base)
-{
- timestamp = timestamp_;
- return true;
-}
-
-int32_t AudioCapturer::AudioCapturerImpl::SetCapturerInfo(const AudioCapturerInfo info)
-{
- int32_t ret = SUCCESS;
- std::vector devices;
- ret = audioSource_->EnumDeviceBySourceType(info.inputSource, devices);
- if (ret != SUCCESS || devices.empty()) {
- MEDIA_ERR_LOG("EnumDeviceBySourceType failed inputSource:%d", info.inputSource);
- return ret;
- }
- MEDIA_INFO_LOG("info.sampleRate %d", info.sampleRate);
- AudioSourceConfig sourceConfig;
- sourceConfig.deviceId = devices[0].deviceId; // use the first device as default
- sourceConfig.audioFormat = info.audioFormat;
- sourceConfig.sampleRate = info.sampleRate;
- sourceConfig.channelCount = info.channelCount;
- sourceConfig.interleaved = false;
- sourceConfig.bitWidth = info.bitWidth;
- sourceConfig.streamUsage = TYPE_DEFAULT;
- ret = audioSource_->Initialize(sourceConfig);
- if (ret != SUCCESS) {
- MEDIA_ERR_LOG("Initialize failed inputSource:%d", info.inputSource);
- return ret;
- }
- AudioEncodeConfig encodeConfig;
- encodeConfig.audioFormat = info.audioFormat;
- encodeConfig.bitRate = info.bitRate;
- encodeConfig.sampleRate = info.sampleRate;
- encodeConfig.channelCount = info.channelCount;
- encodeConfig.bitWidth = info.bitWidth;
- 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);
- return ret;
- }
- info_ = info;
- status = PREPPARED;
- MEDIA_INFO_LOG("Set Capturer Info SUCCESS");
- return SUCCESS;
-}
-
-
-int32_t AudioCapturer::AudioCapturerImpl::GetCapturerInfo(AudioCapturerInfo &info)
-{
- info = info_;
- return SUCCESS;
-}
-
-bool AudioCapturer::AudioCapturerImpl::Record()
-{
- if (status != PREPPARED &&
- status != STOPPED) {
- MEDIA_ERR_LOG("Record ILLEGAL_STATE status:%u", status);
- return ERR_ILLEGAL_STATE;
- }
- int32_t ret = audioSource_->Start();
- if (ret != SUCCESS) {
- MEDIA_ERR_LOG("audioSource_ Start failed:0x%x", ret);
- return false;
- }
- uint32_t deviceId = 0;
- ret = audioSource_->GetCurrentDeviceId(deviceId);
- if (ret != SUCCESS) {
- MEDIA_ERR_LOG("audioSource_ GetCurrentDevice failed:0x%x", ret);
- return false;
- }
- inputDeviceId_ = deviceId;
- ret = audioEncoder_->BindSource(deviceId);
- if (ret != SUCCESS) {
- MEDIA_ERR_LOG("audioEncoder_ BindSource failed:0x%x", ret);
- return false;
- }
- ret = audioEncoder_->Start();
- if (ret != SUCCESS) {
- MEDIA_ERR_LOG("audioEncoder_ Start failed:0x%x", ret);
- return false;
- }
- status = RECORDING;
- MEDIA_INFO_LOG("Start Audio Capturer SUCCESS");
- return true;
-}
-
-int32_t AudioCapturer::AudioCapturerImpl::Read(uint8_t &buffer, size_t userSize, bool isBlockingRead)
-{
- if (userSize == 0) {
- MEDIA_ERR_LOG("Invalid userSize:%zu", userSize);
- return ERR_INVALID_READ;
- }
- if (status != RECORDING) {
- MEDIA_ERR_LOG("ILLEGAL_STATE status:%u", status);
- return ERR_INVALID_READ;
- }
- AudioStream stream;
- stream.buffer = &buffer;
- stream.bufferLen = userSize;
- int32_t readLen = audioEncoder_->ReadStream(stream, isBlockingRead);
- if (readLen == ERR_INVALID_READ) {
- MEDIA_ERR_LOG("audioEncoder_ ReadStream fail,ret:0x%x", readLen);
- return ERR_INVALID_READ;
- }
- timestamp_.time.tv_sec = static_cast(stream.timeStamp / TIME_CONVERSION_US_S); // us - s
- timestamp_.time.tv_nsec = static_cast((stream.timeStamp - timestamp_.time.tv_sec * TIME_CONVERSION_US_S) *
- TIME_CONVERSION_NS_US);
- return readLen;
-}
-
-bool AudioCapturer::AudioCapturerImpl::Stop()
-{
- if (status != RECORDING) {
- 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 fail,ret:0x%x", ret);
- return false;
- }
- MEDIA_INFO_LOG("audioSource Stop");
- ret = audioSource_->Stop();
- if (ret != SUCCESS) {
- MEDIA_ERR_LOG("audioSource_ stop fail,ret:0x%x", ret);
- return false;
- }
- MEDIA_INFO_LOG("Stop Audio Capturer SUCCESS");
- status = STOPPED;
- return true;
-}
-
-bool AudioCapturer::AudioCapturerImpl::Release()
-{
- if (status == RELEASED) {
- MEDIA_ERR_LOG("illegal state: status = %u", status);
- return false;
- }
- if (status == RECORDING && Stop()) {
- MEDIA_ERR_LOG("Stop failed: %u", status);
- return false;
- }
- status = RELEASED;
- MEDIA_INFO_LOG("Release Audio Capturer SUCCESS");
- return true;
-}
-} // namespace Audio
-} // namespace OHOS
diff --git a/frameworks/innerkitsimpl/audiocapturer/src/audio_encoder.cpp b/frameworks/innerkitsimpl/audiocapturer/src/audio_encoder.cpp
deleted file mode 100755
index fa9fed58ed7c88117f16eba36853cf0af7fd6c50..0000000000000000000000000000000000000000
--- a/frameworks/innerkitsimpl/audiocapturer/src/audio_encoder.cpp
+++ /dev/null
@@ -1,275 +0,0 @@
-/*
- * Copyright (C) 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.
- */
-
-#include "audio_encoder.h"
-#include "media_log.h"
-#include "securec.h"
-
-namespace OHOS {
-namespace Audio {
-using namespace OHOS::Media;
-using namespace OHOS::AudioStandard;
-
-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;
-
-AudioEncoder::AudioEncoder()
- : encHandle_(nullptr),
- started_(false)
-{
- for (int i = 0; i < AUDIO_ENC_PARAM_NUM; i++) {
- encAttr_[i] = {};
- }
- CodecInit();
- MEDIA_INFO_LOG("AudioEncoder ctor");
-}
-
-AudioEncoder::~AudioEncoder()
-{
- if (encHandle_ != nullptr) {
- CodecDestroy(encHandle_);
- encHandle_ = nullptr;
- }
- CodecDeinit();
- MEDIA_INFO_LOG("AudioEncoder dtor");
-}
-
-static bool IsAudioCodecFormatSupported(AudioCodecFormat format)
-{
- if ((format < AAC_LC) || (format > AAC_ELD)) {
- MEDIA_ERR_LOG("Invalid format: 0x%x", format);
- return false;
- }
- return true;
-}
-
-static Profile GetProfileFromAudioCodecFormat(AudioCodecFormat format)
-{
- switch (format) {
- case AAC_LC:
- return AAC_LC_PROFILE;
- case AAC_HE_V1:
- return AAC_HE_V1_PROFILE;
- case AAC_HE_V2:
- return AAC_HE_V2_PROFILE;
- case AAC_LD:
- return AAC_LD_PROFILE;
- case AAC_ELD:
- return AAC_ELD_PROFILE;
- default:
- MEDIA_ERR_LOG("Invalid format: 0x%x", format);
- return AAC_LC_PROFILE;
- }
-}
-
-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_24000;
- 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 AUD_SAMPLE_RATE_96000;
- default:
- MEDIA_ERR_LOG("Invalid sample_rate: %u", sampleRate);
- return AUD_SAMPLE_RATE_48000;
- }
-}
-
-static AudioSoundMode ConvertSoundMode(uint32_t channelCount)
-{
- switch (channelCount) {
- case AUDIO_CHANNEL_MONO:
- return AUD_SOUND_MODE_MONO;
- case AUDIO_CHANNEL_STEREO:
- return AUD_SOUND_MODE_STEREO;
- default:
- MEDIA_ERR_LOG("Invalid soundMode: %u", channelCount);
- return AUD_SOUND_MODE_MONO;
- }
-}
-
-int32_t AudioEncoder::InitAudioEncoderAttr(const AudioEncodeConfig &input)
-{
- if (!IsAudioCodecFormatSupported(input.audioFormat)) {
- MEDIA_ERR_LOG("input.audioFormat :0x%x is not supported", input.audioFormat);
- return ERR_INVALID_PARAM;
- }
-
- uint32_t paramIndex = 0;
- domainKind_ = AUDIO_ENCODER;
- encAttr_[paramIndex].key = KEY_CODEC_TYPE;
- encAttr_[paramIndex].val = &domainKind_;
- encAttr_[paramIndex].size = sizeof(CodecType);
- paramIndex++;
- codecMime_ = MEDIA_MIMETYPE_AUDIO_AAC;
- encAttr_[paramIndex].key = KEY_MIMETYPE;
- encAttr_[paramIndex].val = &codecMime_;
- encAttr_[paramIndex].size = sizeof(AvCodecMime);
- paramIndex++;
- profile_ = GetProfileFromAudioCodecFormat(input.audioFormat);
- encAttr_[paramIndex].key = KEY_AUDIO_PROFILE;
- encAttr_[paramIndex].val = &profile_;
- encAttr_[paramIndex].size = sizeof(Profile);
- paramIndex++;
- sampleRate_ = ConvertSampleRate(input.sampleRate);
- encAttr_[paramIndex].key = KEY_SAMPLE_RATE;
- encAttr_[paramIndex].val = &sampleRate_;
- encAttr_[paramIndex].size = sizeof(AudioSampleRate);
- paramIndex++;
- bitRate_ = input.bitRate;
- encAttr_[paramIndex].key = KEY_BITRATE;
- encAttr_[paramIndex].val = &bitRate_;
- encAttr_[paramIndex].size = sizeof(uint32_t);
- paramIndex++;
- soundMode_ = ConvertSoundMode(input.channelCount);
- encAttr_[paramIndex].key = KEY_SOUND_MODE;
- encAttr_[paramIndex].val = &soundMode_;
- encAttr_[paramIndex].size = sizeof(AudioSoundMode);
- paramIndex++;
- ptNumPerFrm_ = AUDIO_POINT_NUM;
- encAttr_[paramIndex].key = KEY_POINT_NUM_PER_FRAME;
- encAttr_[paramIndex].val = &ptNumPerFrm_;
- encAttr_[paramIndex].size = sizeof(uint32_t);
- paramIndex++;
- bufSize_ = AUDIO_FRAME_NUM_IN_BUF;
- encAttr_[paramIndex].key = KEY_BUFFERSIZE;
- encAttr_[paramIndex].val = &bufSize_;
- encAttr_[paramIndex].size = sizeof(uint32_t);
- return SUCCESS;
-}
-
-int32_t AudioEncoder::Initialize(const AudioEncodeConfig &input)
-{
- int32_t ret = InitAudioEncoderAttr(input);
- if (ret != SUCCESS) {
- MEDIA_ERR_LOG("InitAudioEncoderAttr 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);
- return ret;
- }
- return SUCCESS;
-}
-
-int32_t AudioEncoder::BindSource(uint32_t deviceId)
-{
- int32_t ret = SUCCESS;
- Param params[1]; // only deviceId needed.
- (void) memset_s(params, sizeof(params), 0x00, sizeof(params));
- params[0].key = KEY_DEVICE_ID;
- params[0].val = reinterpret_cast(&deviceId);
- params[0].size = sizeof(uint32_t);
- ret = CodecSetParameter(encHandle_, params, sizeof(params) / sizeof(params[0]));
- if (ret != SUCCESS) {
- MEDIA_ERR_LOG("CodecSetParameter :0x%x", ret);
- return ret;
- }
- return SUCCESS;
-}
-
-int32_t AudioEncoder::GetMute(bool &muted)
-{
- return ERR_UNKNOWN;
-}
-
-int32_t AudioEncoder::SetMute(bool muted)
-{
- return ERR_UNKNOWN;
-}
-
-int32_t AudioEncoder::Start()
-{
- int32_t ret = SUCCESS;
- ret = CodecStart(encHandle_);
- if (ret != SUCCESS) {
- MEDIA_ERR_LOG("CodecStart failed:0x%x", ret);
- return ret;
- }
- started_ = true;
- return ret;
-}
-
-int32_t AudioEncoder::ReadStream(AudioStream &stream, bool isBlockingRead)
-{
- if (!started_) {
- MEDIA_ERR_LOG("Codec not Started");
- return ERR_INVALID_READ;
- }
- if (stream.buffer == nullptr || stream.bufferLen == 0) {
- MEDIA_ERR_LOG("stream.buffer is nullptr");
- return ERR_INVALID_READ;
- }
- uint32_t timeoutMs;
- if (isBlockingRead) {
- timeoutMs = AUDIO_READ_STREAM_TIME_OUT_MS;
- } else {
- timeoutMs = 0;
- }
- OutputInfo outInfo;
- CodecBufferInfo outBuf;
- outInfo.bufferCnt = 1; // buffer count is 1.
- outInfo.buffers = &outBuf;
- int32_t ret = CodecDequeueOutput(encHandle_, timeoutMs, nullptr, &outInfo);
- if ((ret != SUCCESS) && (outInfo.buffers[0].addr == nullptr)) {
- MEDIA_ERR_LOG("CodecDequeueOutput failed:0x%x", ret);
- return ERR_INVALID_READ;
- }
- int32_t readLen = 0;
- 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 timeStamp:%lld failed:0x%x", outInfo.timeStamp, retCopy);
- return ERR_INVALID_OPERATION;
- } else {
- readLen = outInfo.buffers[0].length;
- }
- stream.timeStamp = outInfo.timeStamp;
- (void)CodecQueueOutput(encHandle_, &outInfo, timeoutMs, -1);
- return readLen;
-}
-
-int32_t AudioEncoder::Stop()
-{
- MEDIA_DEBUG_LOG("AudioEncoder::Stop");
- if (!started_) {
- MEDIA_ERR_LOG("Codec not Started");
- }
- return CodecStop(encHandle_);
-}
-} // namespace Audio
-} // namespace OHOS
diff --git a/frameworks/innerkitsimpl/audiocapturer/src/audio_source.cpp b/frameworks/innerkitsimpl/audiocapturer/src/audio_source.cpp
deleted file mode 100755
index d17860fe8aab8ce26e84ba2d6a3f27c47bdfda18..0000000000000000000000000000000000000000
--- a/frameworks/innerkitsimpl/audiocapturer/src/audio_source.cpp
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Copyright (C) 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.
- */
-
-#include "audio_source.h"
-#include "media_log.h"
-#include "securec.h"
-
-namespace OHOS {
-namespace Audio {
-#define AUDIO_RETURN_VAL_IF_NULL(condition) \
- do { \
- if ((condition) == nullptr) { \
- return ERR_ILLEGAL_STATE; \
- } \
- } while (0)
-
-using namespace OHOS::Media;
-using namespace OHOS::AudioStandard;
-static AudioManager *g_audioManager = nullptr;
-AudioSource::AudioSource()
- : initialized_(false),
- started_(false),
- audioAdapter_(nullptr),
- audioCapture_(nullptr)
-{
- if (g_audioManager == nullptr) {
- g_audioManager = GetAudioManagerFuncs();
- MEDIA_DEBUG_LOG("try to get g_audioManager.");
- }
- int size = 0;
- struct AudioAdapterDescriptor *descs = nullptr;
- g_audioManager->GetAllAdapters(g_audioManager, &descs, &size);
- MEDIA_DEBUG_LOG("GetAllAdapters: %d ", size);
-
- for (int index = 0; index < size; index++) {
- struct AudioAdapterDescriptor *desc = &descs[index];
- for (int port = 0; (desc != nullptr && port < static_cast(desc->portNum)); port++) {
- if (desc->ports[port].dir == PORT_IN &&
- (g_audioManager->LoadAdapter(g_audioManager, desc, &audioAdapter_)) == 0) {
- (void)audioAdapter_->InitAllPorts(audioAdapter_);
- if (memcpy_s(&capturePort_, sizeof(struct AudioPort),
- &desc->ports[port], sizeof(struct AudioPort)) != 0) {
- MEDIA_WARNING_LOG("memcpy_s capturePort_ failed");
- }
- break;
- }
- }
- }
- MEDIA_DEBUG_LOG("LoadAdapter audioAdapter_.");
-}
-
-AudioSource::~AudioSource()
-{
- MEDIA_DEBUG_LOG("Destroys the AudioSource");
- if (audioAdapter_ == nullptr) {
- return;
- }
- if (g_audioManager != nullptr) {
- g_audioManager->UnloadAdapter(g_audioManager, audioAdapter_);
- }
- audioAdapter_ = nullptr;
-}
-
-int32_t AudioSource::InitCheck()
-{
- if (!initialized_) {
- MEDIA_ERR_LOG("not initialized");
- return ERR_ILLEGAL_STATE;
- }
- return SUCCESS;
-}
-
-bool AudioSource::GetMinFrameCount(int32_t sampleRate, int32_t channelCount,
- AudioCodecFormat audioFormat, size_t &frameCount)
-{
- (void) sampleRate;
- (void) channelCount;
- (void) audioFormat;
- frameCount = 0;
- return true;
-}
-
-uint64_t AudioSource::GetFrameCount()
-{
- int32_t ret;
- if ((ret = InitCheck()) != SUCCESS) {
- return ret;
- }
- AUDIO_RETURN_VAL_IF_NULL(audioCapture_);
- uint64_t frameCount = 0;
- ret = audioCapture_->attr.GetFrameCount(reinterpret_cast(audioCapture_), &frameCount);
- if (ret != SUCCESS) {
- MEDIA_ERR_LOG("attr GetFrameCount failed 0x%x ", ret);
- return ret;
- }
- return frameCount;
-}
-
-int32_t AudioSource::EnumDeviceBySourceType(AudioSourceType inputSource, std::vector &devices)
-{
- if (inputSource != AUDIO_MIC) {
- MEDIA_ERR_LOG("AudioSource only support AUDIO_MIC, actual inputSource(%d)", inputSource);
- return ERR_INVALID_PARAM;
- }
- AUDIO_RETURN_VAL_IF_NULL(audioAdapter_);
-
- struct AudioPortCapability capability;
- audioAdapter_->GetPortCapability(audioAdapter_, &capturePort_, &capability);
- AudioDeviceDesc deviceDesc;
- deviceDesc.deviceId = capability.deviceId;
- deviceDesc.inputSourceType = AUDIO_MIC;
- devices.push_back(deviceDesc);
- return SUCCESS;
-}
-
-int32_t AudioSource::Initialize(const AudioSourceConfig &input)
-{
- AUDIO_RETURN_VAL_IF_NULL(audioAdapter_);
-
- MEDIA_INFO_LOG("input.sampleRate:%d", input.sampleRate);
- int32_t ret = SUCCESS;
- struct AudioDeviceDescriptor desc;
- struct AudioSampleAttributes attrs;
- attrs.type = AUDIO_IN_MEDIA;
- attrs.sampleRate = input.sampleRate;
- attrs.format = AUDIO_FORMAT_PCM_16_BIT;
- 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);
- return ret;
- }
- initialized_ = true;
- return SUCCESS;
-}
-
-int32_t AudioSource::SetInputDevice(uint32_t deviceId)
-{
- return SUCCESS;
-}
-
-int32_t AudioSource::GetCurrentDeviceId(uint32_t &deviceId)
-{
- AUDIO_RETURN_VAL_IF_NULL(audioCapture_);
- int32_t ret = audioCapture_->attr.GetCurrentChannelId(reinterpret_cast(audioCapture_), &deviceId);
- if (ret != SUCCESS) {
- MEDIA_ERR_LOG("GetCurrentChannelId failed 0x%x", ret);
- return ret;
- }
- return SUCCESS;
-}
-
-int32_t AudioSource::Start()
-{
- int32_t ret;
- if ((ret = InitCheck()) != SUCCESS) {
- return ret;
- }
-
- AUDIO_RETURN_VAL_IF_NULL(audioCapture_);
- ret = audioCapture_->control.Start(reinterpret_cast(audioCapture_));
- if (ret != SUCCESS) {
- MEDIA_ERR_LOG("audioCapture_ Start failed 0x%x", ret);
- return ret;
- }
- started_ = true;
- return SUCCESS;
-}
-
-int32_t AudioSource::ReadFrame(uint8_t &buffer, size_t bufferBytes, bool isBlockingRead)
-{
- if (!started_) {
- MEDIA_ERR_LOG("AudioSource not Started");
- return ERR_ILLEGAL_STATE;
- }
- return SUCCESS;
-}
-
-int32_t AudioSource::Stop()
-{
- MEDIA_INFO_LOG("AudioSource::Stop");
- int32_t ret;
- if ((ret = InitCheck()) != SUCCESS) {
- return ret;
- }
-
- AUDIO_RETURN_VAL_IF_NULL(audioCapture_);
- ret = audioCapture_->control.Stop(reinterpret_cast(audioCapture_));
- if (ret != SUCCESS) {
- 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);
- return ret;
- }
- return SUCCESS;
-}
-} // namespace Audio
-} // namespace OHOS
diff --git a/frameworks/innerkitsimpl/audiorecorder/src/audio_recorder.cpp b/frameworks/innerkitsimpl/audiorecorder/src/audio_recorder.cpp
deleted file mode 100644
index f7346036ce4ce5cd825e359c095117282e190d4d..0000000000000000000000000000000000000000
--- a/frameworks/innerkitsimpl/audiorecorder/src/audio_recorder.cpp
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright (C) 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.
- */
-
-#include
-
-#include "audio_errors.h"
-#include "audio_recorder.h"
-#include "audio_recorder_private.h"
-#include "audio_stream.h"
-
-namespace OHOS {
-namespace AudioStandard {
-AudioRecorder::~AudioRecorder() = default;
-AudioRecorderPrivate::~AudioRecorderPrivate() = default;
-
-std::unique_ptr AudioRecorder::Create(AudioStreamType audioStreamType)
-{
- return std::make_unique(audioStreamType);
-}
-
-AudioRecorderPrivate::AudioRecorderPrivate(AudioStreamType audioStreamType)
-{
- audioRecorder = std::make_unique(audioStreamType, AUDIO_MODE_RECORD);
-}
-
-int32_t AudioRecorderPrivate::GetFrameCount(uint32_t &frameCount) const
-{
- return audioRecorder->GetFrameCount(frameCount);
-}
-
-int32_t AudioRecorderPrivate::SetParams(const AudioRecorderParams params) const
-{
- AudioStreamParams audioStreamParams;
- audioStreamParams.format = params.audioSampleFormat;
- audioStreamParams.samplingRate = params.samplingRate;
- audioStreamParams.channels = params.audioChannel;
- audioStreamParams.encoding = params.audioEncoding;
-
- return audioRecorder->SetAudioStreamInfo(audioStreamParams);
-}
-
-int32_t AudioRecorderPrivate::GetParams(AudioRecorderParams ¶ms) const
-{
- AudioStreamParams audioStreamParams;
- int32_t result = audioRecorder->GetAudioStreamInfo(audioStreamParams);
- if (SUCCESS == result) {
- params.audioSampleFormat = static_cast(audioStreamParams.format);
- params.samplingRate = static_cast(audioStreamParams.samplingRate);
- params.audioChannel = static_cast(audioStreamParams.channels);
- params.audioEncoding = static_cast(audioStreamParams.encoding);
- }
-
- return result;
-}
-
-bool AudioRecorderPrivate::Start() const
-{
- return audioRecorder->StartAudioStream();
-}
-
-int32_t AudioRecorderPrivate::Read(uint8_t &buffer, size_t userSize, bool isBlockingRead) const
-{
- return audioRecorder->Read(buffer, userSize, isBlockingRead);
-}
-
-RecorderState AudioRecorderPrivate::GetStatus() const
-{
- return (RecorderState)audioRecorder->GetState();
-}
-
-bool AudioRecorderPrivate::GetAudioTime(Timestamp ×tamp, Timestamp::Timestampbase base) const
-{
- return audioRecorder->GetAudioTime(timestamp, base);
-}
-
-bool AudioRecorderPrivate::Stop() const
-{
- return audioRecorder->StopAudioStream();
-}
-
-bool AudioRecorderPrivate::Flush() const
-{
- return audioRecorder->FlushAudioStream();
-}
-
-bool AudioRecorderPrivate::Release() const
-{
- return audioRecorder->ReleaseAudioStream();
-}
-
-int32_t AudioRecorderPrivate::GetBufferSize(size_t &bufferSize) const
-{
- return audioRecorder->GetBufferSize(bufferSize);
-}
-
-std::vector AudioRecorder::GetSupportedFormats()
-{
- return AUDIO_SUPPORTED_FORMATS;
-}
-
-std::vector AudioRecorder::GetSupportedChannels()
-{
- return AUDIO_SUPPORTED_CHANNELS;
-}
-
-std::vector AudioRecorder::GetSupportedEncodingTypes()
-{
- return AUDIO_SUPPORTED_ENCODING_TYPES;
-}
-
-std::vector AudioRecorder::GetSupportedSamplingRates()
-{
- return AUDIO_SUPPORTED_SAMPLING_RATES;
-}
-} // namespace AudioStandard
-} // namespace OHOS
\ No newline at end of file
diff --git a/frameworks/innerkitsimpl/audiorenderer/include/audio_renderer_private.h b/frameworks/innerkitsimpl/audiorenderer/include/audio_renderer_private.h
index 997439e025c509a81812dce1b7ee0207c57cf60e..39cecf0fc068cedaf59afb1459dfd938779dcfc2 100644
--- a/frameworks/innerkitsimpl/audiorenderer/include/audio_renderer_private.h
+++ b/frameworks/innerkitsimpl/audiorenderer/include/audio_renderer_private.h
@@ -13,8 +13,8 @@
* limitations under the License.
*/
-#ifndef AUDIO_RECORDER_PRIVATE_H
-#define AUDIO_RECORDER_PRIVATE_H
+#ifndef AUDIO_RENDERER_PRIVATE_H
+#define AUDIO_RENDERER_PRIVATE_H
#include "audio_renderer.h"
#include "audio_stream.h"
@@ -45,4 +45,4 @@ public:
};
} // namespace AudioStandard
} // namespace OHOS
-#endif // AUDIO_RECORDER_PRIVATE_H
+#endif // AUDIO_RENDERER_PRIVATE_H
diff --git a/frameworks/innerkitsimpl/test/BUILD.gn b/frameworks/innerkitsimpl/test/BUILD.gn
index 3d04355e2145eb1d5cc26f51f58be7381712106c..34d5d007dc1fa6aa87fbf56742ff1295983c89dc 100644
--- a/frameworks/innerkitsimpl/test/BUILD.gn
+++ b/frameworks/innerkitsimpl/test/BUILD.gn
@@ -16,7 +16,7 @@ group("audio_module_test") {
deps = [
"moduletest/audiopolicy:audio_policy_module_test",
- "moduletest/recorder_test:audio_recorder_module_test",
+ "moduletest/capturer_test:audio_capturer_module_test",
"moduletest/renderer_test:audio_renderer_module_test",
]
}
diff --git a/frameworks/innerkitsimpl/test/moduletest/recorder_test/BUILD.gn b/frameworks/innerkitsimpl/test/moduletest/capturer_test/BUILD.gn
similarity index 83%
rename from frameworks/innerkitsimpl/test/moduletest/recorder_test/BUILD.gn
rename to frameworks/innerkitsimpl/test/moduletest/capturer_test/BUILD.gn
index 80b30020c6c3c85f0ffbde52f295d1d2f7faa916..1e0df6574fec852bf18e785427b6a0276aeca9bf 100644
--- a/frameworks/innerkitsimpl/test/moduletest/recorder_test/BUILD.gn
+++ b/frameworks/innerkitsimpl/test/moduletest/capturer_test/BUILD.gn
@@ -13,9 +13,9 @@
import("//build/test.gni")
-module_output_path = "audio_standard/audio_recorder"
+module_output_path = "audio_standard/audio_capturer"
-ohos_moduletest("audio_recorder_module_test") {
+ohos_moduletest("audio_capturer_module_test") {
module_out_path = module_output_path
include_dirs = [
"./include",
@@ -28,7 +28,7 @@ ohos_moduletest("audio_recorder_module_test") {
"-Werror",
]
- sources = [ "src/audio_recorder_module_test.cpp" ]
+ sources = [ "src/audio_capturer_module_test.cpp" ]
- deps = [ "//foundation/multimedia/audio_standard/interfaces/innerkits/native/audiorecorder:audio_recorder" ]
+ deps = [ "//foundation/multimedia/audio_standard/interfaces/innerkits/native/audiocapturer:audio_capturer" ]
}
diff --git a/frameworks/innerkitsimpl/test/moduletest/recorder_test/include/audio_recorder_module_test.h b/frameworks/innerkitsimpl/test/moduletest/capturer_test/include/audio_capturer_module_test.h
similarity index 84%
rename from frameworks/innerkitsimpl/test/moduletest/recorder_test/include/audio_recorder_module_test.h
rename to frameworks/innerkitsimpl/test/moduletest/capturer_test/include/audio_capturer_module_test.h
index a5a11c8d90bcf5d073d41271c8a27f8597d7d958..809197d6aeec9f0b0c2b2a362258929bf9d949bd 100644
--- a/frameworks/innerkitsimpl/test/moduletest/recorder_test/include/audio_recorder_module_test.h
+++ b/frameworks/innerkitsimpl/test/moduletest/capturer_test/include/audio_capturer_module_test.h
@@ -13,12 +13,12 @@
* limitations under the License.
*/
-#include "audio_recorder.h"
+#include "audio_capturer.h"
#include "gtest/gtest.h"
namespace OHOS {
namespace AudioStandard {
-class AudioRecorderModuleTest : public testing::Test {
+class AudioCapturerModuleTest : public testing::Test {
public:
// SetUpTestCase: Called before all test cases
static void SetUpTestCase(void);
@@ -28,8 +28,8 @@ public:
void SetUp(void);
// TearDown: Called after each test cases
void TearDown(void);
- // Init Recorder
- static int32_t InitializeRecorder(std::unique_ptr &audioRecorder);
+ // Init Capturer
+ static int32_t InitializeCapturer(std::unique_ptr &audioCapturer);
};
} // namespace AudioStandard
} // namespace OHOS
diff --git a/frameworks/innerkitsimpl/test/moduletest/recorder_test/src/audio_recorder_module_test.cpp b/frameworks/innerkitsimpl/test/moduletest/capturer_test/src/audio_capturer_module_test.cpp
similarity index 36%
rename from frameworks/innerkitsimpl/test/moduletest/recorder_test/src/audio_recorder_module_test.cpp
rename to frameworks/innerkitsimpl/test/moduletest/capturer_test/src/audio_capturer_module_test.cpp
index e61b937d6016a484cac244d14a6e8ab4c8c80bd3..6625df9fee70b7acfe5836f61c98a73637734a69 100644
--- a/frameworks/innerkitsimpl/test/moduletest/recorder_test/src/audio_recorder_module_test.cpp
+++ b/frameworks/innerkitsimpl/test/moduletest/capturer_test/src/audio_capturer_module_test.cpp
@@ -13,11 +13,11 @@
* limitations under the License.
*/
-#include "audio_recorder_module_test.h"
+#include "audio_capturer_module_test.h"
+#include "audio_capturer.h"
#include "audio_errors.h"
#include "audio_info.h"
-#include "audio_recorder.h"
using namespace std;
using namespace testing::ext;
@@ -25,964 +25,964 @@ using namespace testing::ext;
namespace OHOS {
namespace AudioStandard {
namespace {
- const string AUDIO_RECORD_FILE1 = "/data/audiorecordtest_blocking.pcm";
- const string AUDIO_RECORD_FILE2 = "/data/audiorecordtest_nonblocking.pcm";
+ const string AUDIO_CAPTURE_FILE1 = "/data/audiocapturetest_blocking.pcm";
+ const string AUDIO_CAPTURE_FILE2 = "/data/audiocapturetest_nonblocking.pcm";
const int32_t READ_BUFFERS_COUNT = 128;
const int32_t VALUE_ZERO = 0;
} // namespace
-void AudioRecorderModuleTest::SetUpTestCase(void) {}
-void AudioRecorderModuleTest::TearDownTestCase(void) {}
-void AudioRecorderModuleTest::SetUp(void) {}
-void AudioRecorderModuleTest::TearDown(void) {}
+void AudioCapturerModuleTest::SetUpTestCase(void) {}
+void AudioCapturerModuleTest::TearDownTestCase(void) {}
+void AudioCapturerModuleTest::SetUp(void) {}
+void AudioCapturerModuleTest::TearDown(void) {}
-int32_t AudioRecorderModuleTest::InitializeRecorder(unique_ptr &audioRecorder)
+int32_t AudioCapturerModuleTest::InitializeCapturer(unique_ptr &audioCapturer)
{
- AudioRecorderParams recorderParams;
- recorderParams.audioSampleFormat = SAMPLE_S16LE;
- recorderParams.samplingRate = SAMPLE_RATE_44100;
- recorderParams.audioChannel = STEREO;
- recorderParams.audioEncoding = ENCODING_PCM;
+ AudioCapturerParams capturerParams;
+ capturerParams.audioSampleFormat = SAMPLE_S16LE;
+ capturerParams.samplingRate = SAMPLE_RATE_44100;
+ capturerParams.audioChannel = STEREO;
+ capturerParams.audioEncoding = ENCODING_PCM;
- return audioRecorder->SetParams(recorderParams);
+ return audioCapturer->SetParams(capturerParams);
}
/**
* @tc.name : Test GetSupportedFormats API
-* @tc.number: Audio_Recorder_GetSupportedFormats_001
+* @tc.number: Audio_Capturer_GetSupportedFormats_001
* @tc.desc : Test GetSupportedFormats interface. Returns supported Formats on success.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_GetSupportedFormats_001, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_GetSupportedFormats_001, TestSize.Level1)
{
- vector supportedFormatList = AudioRecorder::GetSupportedFormats();
+ vector supportedFormatList = AudioCapturer::GetSupportedFormats();
EXPECT_EQ(AUDIO_SUPPORTED_FORMATS.size(), supportedFormatList.size());
}
/**
* @tc.name : Test GetSupportedChannels API
-* @tc.number: Audio_Recorder_GetSupportedChannels_001
+* @tc.number: Audio_Capturer_GetSupportedChannels_001
* @tc.desc : Test GetSupportedChannels interface. Returns supported Channels on success.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_GetSupportedChannels_001, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_GetSupportedChannels_001, TestSize.Level1)
{
- vector supportedChannelList = AudioRecorder::GetSupportedChannels();
+ vector supportedChannelList = AudioCapturer::GetSupportedChannels();
EXPECT_EQ(AUDIO_SUPPORTED_CHANNELS.size(), supportedChannelList.size());
}
/**
* @tc.name : Test GetSupportedEncodingTypes API
-* @tc.number: Audio_Recorder_GetSupportedEncodingTypes_001
+* @tc.number: Audio_Capturer_GetSupportedEncodingTypes_001
* @tc.desc : Test GetSupportedEncodingTypes interface. Returns supported Encoding types on success.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_GetSupportedEncodingTypes_001, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_GetSupportedEncodingTypes_001, TestSize.Level1)
{
vector supportedEncodingTypes
- = AudioRecorder::GetSupportedEncodingTypes();
+ = AudioCapturer::GetSupportedEncodingTypes();
EXPECT_EQ(AUDIO_SUPPORTED_ENCODING_TYPES.size(), supportedEncodingTypes.size());
}
/**
* @tc.name : Test GetSupportedSamplingRates API
-* @tc.number: Audio_Recorder_GetSupportedSamplingRates_001
+* @tc.number: Audio_Capturer_GetSupportedSamplingRates_001
* @tc.desc : Test GetSupportedSamplingRates interface. Returns supported Sampling rates on success.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_GetSupportedSamplingRates_001, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_GetSupportedSamplingRates_001, TestSize.Level1)
{
- vector supportedSamplingRates = AudioRecorder::GetSupportedSamplingRates();
+ vector supportedSamplingRates = AudioCapturer::GetSupportedSamplingRates();
EXPECT_EQ(AUDIO_SUPPORTED_SAMPLING_RATES.size(), supportedSamplingRates.size());
}
/**
* @tc.name : Test Create API via legal input.
-* @tc.number: Audio_Recorder_Create_001
-* @tc.desc : Test Create interface with STREAM_MUSIC. Returns audioRecorder instance, if create is successful.
+* @tc.number: Audio_Capturer_Create_001
+* @tc.desc : Test Create interface with STREAM_MUSIC. Returns audioCapturer instance, if create is successful.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_Create_001, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_Create_001, TestSize.Level1)
{
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- EXPECT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ EXPECT_NE(nullptr, audioCapturer);
}
/**
* @tc.name : Test Create API via legal input.
-* @tc.number: Audio_Recorder_Create_002
-* @tc.desc : Test Create interface with STREAM_RING. Returns audioRecorder instance, if create is successful.
+* @tc.number: Audio_Capturer_Create_002
+* @tc.desc : Test Create interface with STREAM_RING. Returns audioCapturer instance, if create is successful.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_Create_002, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_Create_002, TestSize.Level1)
{
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_RING);
- EXPECT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_RING);
+ EXPECT_NE(nullptr, audioCapturer);
}
/**
* @tc.name : Test Create API via legal input.
-* @tc.number: Audio_Recorder_Create_003
-* @tc.desc : Test Create interface with STREAM_VOICE_CALL. Returns audioRecorder instance if create is successful.
+* @tc.number: Audio_Capturer_Create_003
+* @tc.desc : Test Create interface with STREAM_VOICE_CALL. Returns audioCapturer instance if create is successful.
* Note: instance will be created but functional support for STREAM_VOICE_CALL not available yet.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_Create_003, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_Create_003, TestSize.Level1)
{
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_VOICE_CALL);
- EXPECT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_VOICE_CALL);
+ EXPECT_NE(nullptr, audioCapturer);
}
/**
* @tc.name : Test Create API via legal input.
-* @tc.number: Audio_Recorder_Create_004
-* @tc.desc : Test Create interface with STREAM_SYSTEM. Returns audioRecorder instance, if create is successful.
+* @tc.number: Audio_Capturer_Create_004
+* @tc.desc : Test Create interface with STREAM_SYSTEM. Returns audioCapturer instance, if create is successful.
* Note: instance will be created but functional support for STREAM_SYSTEM not available yet.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_Create_004, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_Create_004, TestSize.Level1)
{
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_SYSTEM);
- EXPECT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_SYSTEM);
+ EXPECT_NE(nullptr, audioCapturer);
}
/**
* @tc.name : Test Create API via legal input.
-* @tc.number: Audio_Recorder_Create_005
-* @tc.desc : Test Create interface with STREAM_BLUETOOTH_SCO. Returns audioRecorder instance, if create is successful.
+* @tc.number: Audio_Capturer_Create_005
+* @tc.desc : Test Create interface with STREAM_BLUETOOTH_SCO. Returns audioCapturer instance, if create is successful.
* Note: instance will be created but functional support for STREAM_BLUETOOTH_SCO not available yet
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_Create_005, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_Create_005, TestSize.Level1)
{
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_BLUETOOTH_SCO);
- EXPECT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_BLUETOOTH_SCO);
+ EXPECT_NE(nullptr, audioCapturer);
}
/**
* @tc.name : Test Create API via legal input.
-* @tc.number: Audio_Recorder_Create_006
-* @tc.desc : Test Create interface with STREAM_ALARM. Returns audioRecorder instance, if create is successful.
+* @tc.number: Audio_Capturer_Create_006
+* @tc.desc : Test Create interface with STREAM_ALARM. Returns audioCapturer instance, if create is successful.
* Note: instance will be created but functional support for STREAM_ALARM not available yet.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_Create_006, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_Create_006, TestSize.Level1)
{
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_ALARM);
- EXPECT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_ALARM);
+ EXPECT_NE(nullptr, audioCapturer);
}
/**
* @tc.name : Test Create API via legal input.
-* @tc.number: Audio_Recorder_Create_007
-* @tc.desc : Test Create interface with STREAM_NOTIFICATION. Returns audioRecorder instance, if create is successful.
+* @tc.number: Audio_Capturer_Create_007
+* @tc.desc : Test Create interface with STREAM_NOTIFICATION. Returns audioCapturer instance, if create is successful.
* Note: instance will be created but functional support for STREAM_NOTIFICATION not available yet.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_Create_007, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_Create_007, TestSize.Level1)
{
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_NOTIFICATION);
- EXPECT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_NOTIFICATION);
+ EXPECT_NE(nullptr, audioCapturer);
}
/**
* @tc.name : Test SetParams API via legal input
-* @tc.number: Audio_Recorder_SetParams_001
+* @tc.number: Audio_Capturer_SetParams_001
* @tc.desc : Test SetParams interface. Returns 0 {SUCCESS}, if the setting is successful.
-* recorderParams.audioSampleFormat = SAMPLE_S16LE;
-* recorderParams.samplingRate = SAMPLE_RATE_44100;
-* recorderParams.audioChannel = STEREO;
-* recorderParams.audioEncoding = ENCODING_PCM;
+* capturerParams.audioSampleFormat = SAMPLE_S16LE;
+* capturerParams.samplingRate = SAMPLE_RATE_44100;
+* capturerParams.audioChannel = STEREO;
+* capturerParams.audioEncoding = ENCODING_PCM;
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_SetParams_001, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_SetParams_001, TestSize.Level1)
{
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- AudioRecorderParams recorderParams;
- recorderParams.audioSampleFormat = SAMPLE_S16LE;
- recorderParams.samplingRate = SAMPLE_RATE_44100;
- recorderParams.audioChannel = STEREO;
- recorderParams.audioEncoding = ENCODING_PCM;
+ AudioCapturerParams capturerParams;
+ capturerParams.audioSampleFormat = SAMPLE_S16LE;
+ capturerParams.samplingRate = SAMPLE_RATE_44100;
+ capturerParams.audioChannel = STEREO;
+ capturerParams.audioEncoding = ENCODING_PCM;
- int32_t ret = audioRecorder->SetParams(recorderParams);
+ int32_t ret = audioCapturer->SetParams(capturerParams);
EXPECT_EQ(SUCCESS, ret);
- audioRecorder->Release();
+ audioCapturer->Release();
}
/**
* @tc.name : Test SetParams API via legal input.
-* @tc.number: Audio_Recorder_SetParams_002
+* @tc.number: Audio_Capturer_SetParams_002
* @tc.desc : Test SetParams interface. Returns 0 {SUCCESS}, if the setting is successful.
-* recorderParams.audioSampleFormat = SAMPLE_S16LE;
-* recorderParams.samplingRate = SAMPLE_RATE_8000;
-* recorderParams.audioChannel = MONO;
-* recorderParams.audioEncoding = ENCODING_PCM;
+* capturerParams.audioSampleFormat = SAMPLE_S16LE;
+* capturerParams.samplingRate = SAMPLE_RATE_8000;
+* capturerParams.audioChannel = MONO;
+* capturerParams.audioEncoding = ENCODING_PCM;
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_SetParams_002, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_SetParams_002, TestSize.Level1)
{
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- AudioRecorderParams recorderParams;
- recorderParams.audioSampleFormat = SAMPLE_S16LE;
- recorderParams.samplingRate = SAMPLE_RATE_8000;
- recorderParams.audioChannel = MONO;
- recorderParams.audioEncoding = ENCODING_PCM;
+ AudioCapturerParams capturerParams;
+ capturerParams.audioSampleFormat = SAMPLE_S16LE;
+ capturerParams.samplingRate = SAMPLE_RATE_8000;
+ capturerParams.audioChannel = MONO;
+ capturerParams.audioEncoding = ENCODING_PCM;
- int32_t ret = audioRecorder->SetParams(recorderParams);
+ int32_t ret = audioCapturer->SetParams(capturerParams);
EXPECT_EQ(SUCCESS, ret);
- audioRecorder->Release();
+ audioCapturer->Release();
}
/**
* @tc.name : Test SetParams API via legal input.
-* @tc.number: Audio_Recorder_SetParams_003
+* @tc.number: Audio_Capturer_SetParams_003
* @tc.desc : Test SetParams interface. Returns 0 {SUCCESS}, if the setting is successful.
-* recorderParams.audioSampleFormat = SAMPLE_S16LE;
-* recorderParams.samplingRate = SAMPLE_RATE_11025;
-* recorderParams.audioChannel = STEREO;
-* recorderParams.audioEncoding = ENCODING_PCM;
+* capturerParams.audioSampleFormat = SAMPLE_S16LE;
+* capturerParams.samplingRate = SAMPLE_RATE_11025;
+* capturerParams.audioChannel = STEREO;
+* capturerParams.audioEncoding = ENCODING_PCM;
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_SetParams_003, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_SetParams_003, TestSize.Level1)
{
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- AudioRecorderParams recorderParams;
- recorderParams.audioSampleFormat = SAMPLE_S16LE;
- recorderParams.samplingRate = SAMPLE_RATE_11025;
- recorderParams.audioChannel = STEREO;
- recorderParams.audioEncoding = ENCODING_PCM;
+ AudioCapturerParams capturerParams;
+ capturerParams.audioSampleFormat = SAMPLE_S16LE;
+ capturerParams.samplingRate = SAMPLE_RATE_11025;
+ capturerParams.audioChannel = STEREO;
+ capturerParams.audioEncoding = ENCODING_PCM;
- int32_t ret = audioRecorder->SetParams(recorderParams);
+ int32_t ret = audioCapturer->SetParams(capturerParams);
EXPECT_EQ(SUCCESS, ret);
- audioRecorder->Release();
+ audioCapturer->Release();
}
/**
* @tc.name : Test SetParams API via legal input.
-* @tc.number: Audio_Recorder_SetParams_004
+* @tc.number: Audio_Capturer_SetParams_004
* @tc.desc : Test SetParams interface. Returns 0 {SUCCESS}, if the setting is successful.
-* recorderParams.audioSampleFormat = SAMPLE_S16LE;
-* recorderParams.samplingRate = SAMPLE_RATE_22050;
-* recorderParams.audioChannel = MONO;
-* recorderParams.audioEncoding = ENCODING_PCM;
+* capturerParams.audioSampleFormat = SAMPLE_S16LE;
+* capturerParams.samplingRate = SAMPLE_RATE_22050;
+* capturerParams.audioChannel = MONO;
+* capturerParams.audioEncoding = ENCODING_PCM;
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_SetParams_004, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_SetParams_004, TestSize.Level1)
{
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- AudioRecorderParams recorderParams;
- recorderParams.audioSampleFormat = SAMPLE_S16LE;
- recorderParams.samplingRate = SAMPLE_RATE_22050;
- recorderParams.audioChannel = MONO;
- recorderParams.audioEncoding = ENCODING_PCM;
+ AudioCapturerParams capturerParams;
+ capturerParams.audioSampleFormat = SAMPLE_S16LE;
+ capturerParams.samplingRate = SAMPLE_RATE_22050;
+ capturerParams.audioChannel = MONO;
+ capturerParams.audioEncoding = ENCODING_PCM;
- int32_t ret = audioRecorder->SetParams(recorderParams);
+ int32_t ret = audioCapturer->SetParams(capturerParams);
EXPECT_EQ(SUCCESS, ret);
- audioRecorder->Release();
+ audioCapturer->Release();
}
/**
* @tc.name : Test SetParams API via legal input.
-* @tc.number: Audio_Recorder_SetParams_005
+* @tc.number: Audio_Capturer_SetParams_005
* @tc.desc : Test SetParams interface. Returns 0 {SUCCESS}, if the setting is successful.
-* recorderParams.audioSampleFormat = SAMPLE_S16LE;
-* recorderParams.samplingRate = SAMPLE_RATE_96000;
-* recorderParams.audioChannel = MONO;
-* recorderParams.audioEncoding = ENCODING_PCM;
+* capturerParams.audioSampleFormat = SAMPLE_S16LE;
+* capturerParams.samplingRate = SAMPLE_RATE_96000;
+* capturerParams.audioChannel = MONO;
+* capturerParams.audioEncoding = ENCODING_PCM;
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_SetParams_005, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_SetParams_005, TestSize.Level1)
{
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- AudioRecorderParams recorderParams;
- recorderParams.audioSampleFormat = SAMPLE_S16LE;
- recorderParams.samplingRate = SAMPLE_RATE_96000;
- recorderParams.audioChannel = MONO;
- recorderParams.audioEncoding = ENCODING_PCM;
+ AudioCapturerParams capturerParams;
+ capturerParams.audioSampleFormat = SAMPLE_S16LE;
+ capturerParams.samplingRate = SAMPLE_RATE_96000;
+ capturerParams.audioChannel = MONO;
+ capturerParams.audioEncoding = ENCODING_PCM;
- int32_t ret = audioRecorder->SetParams(recorderParams);
+ int32_t ret = audioCapturer->SetParams(capturerParams);
EXPECT_EQ(SUCCESS, ret);
}
/**
* @tc.name : Test SetParams API via legal input.
-* @tc.number: Audio_Recorder_SetParams_006
+* @tc.number: Audio_Capturer_SetParams_006
* @tc.desc : Test SetParams interface. Returns 0 {SUCCESS}, if the setting is successful.
-* recorderParams.audioSampleFormat = SAMPLE_S24LE;
-* recorderParams.samplingRate = SAMPLE_RATE_64000;
-* recorderParams.audioChannel = MONO;
-* recorderParams.audioEncoding = ENCODING_PCM;
+* capturerParams.audioSampleFormat = SAMPLE_S24LE;
+* capturerParams.samplingRate = SAMPLE_RATE_64000;
+* capturerParams.audioChannel = MONO;
+* capturerParams.audioEncoding = ENCODING_PCM;
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_SetParams_006, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_SetParams_006, TestSize.Level1)
{
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- AudioRecorderParams recorderParams;
- recorderParams.audioSampleFormat = SAMPLE_S24LE;
- recorderParams.samplingRate = SAMPLE_RATE_64000;
- recorderParams.audioChannel = MONO;
- recorderParams.audioEncoding = ENCODING_PCM;
+ AudioCapturerParams capturerParams;
+ capturerParams.audioSampleFormat = SAMPLE_S24LE;
+ capturerParams.samplingRate = SAMPLE_RATE_64000;
+ capturerParams.audioChannel = MONO;
+ capturerParams.audioEncoding = ENCODING_PCM;
- int32_t ret = audioRecorder->SetParams(recorderParams);
+ int32_t ret = audioCapturer->SetParams(capturerParams);
EXPECT_EQ(SUCCESS, ret);
}
/**
* @tc.name : Test SetParams API via illegal input.
-* @tc.number: Audio_Recorder_SetParams_007
+* @tc.number: Audio_Capturer_SetParams_007
* @tc.desc : Test SetParams interface. Returns 0 {SUCCESS}, if the setting is successful.
-* recorderParams.audioSampleFormat = SAMPLE_S16LE;
-* recorderParams.samplingRate = SAMPLE_RATE_16000;
-* recorderParams.audioChannel = STEREO;
-* recorderParams.audioEncoding = ENCODING_PCM;
+* capturerParams.audioSampleFormat = SAMPLE_S16LE;
+* capturerParams.samplingRate = SAMPLE_RATE_16000;
+* capturerParams.audioChannel = STEREO;
+* capturerParams.audioEncoding = ENCODING_PCM;
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_SetParams_007, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_SetParams_007, TestSize.Level1)
{
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- AudioRecorderParams recorderParams;
- recorderParams.audioSampleFormat = SAMPLE_S16LE;
- recorderParams.samplingRate = SAMPLE_RATE_16000;
- recorderParams.audioChannel = STEREO;
- recorderParams.audioEncoding = ENCODING_PCM;
+ AudioCapturerParams capturerParams;
+ capturerParams.audioSampleFormat = SAMPLE_S16LE;
+ capturerParams.samplingRate = SAMPLE_RATE_16000;
+ capturerParams.audioChannel = STEREO;
+ capturerParams.audioEncoding = ENCODING_PCM;
- int32_t ret = audioRecorder->SetParams(recorderParams);
+ int32_t ret = audioCapturer->SetParams(capturerParams);
EXPECT_EQ(SUCCESS, ret);
- audioRecorder->Release();
+ audioCapturer->Release();
}
/**
* @tc.name : Test GetParams API via legal input.
-* @tc.number: Audio_Recorder_GetParams_001
+* @tc.number: Audio_Capturer_GetParams_001
* @tc.desc : Test GetParams interface. Returns 0 {SUCCESS}, if the getting is successful.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_GetParams_001, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_GetParams_001, TestSize.Level1)
{
int32_t ret = -1;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- AudioRecorderParams recorderParams;
- recorderParams.audioSampleFormat = SAMPLE_S16LE;
- recorderParams.samplingRate = SAMPLE_RATE_44100;
- recorderParams.audioChannel = STEREO;
- recorderParams.audioEncoding = ENCODING_PCM;
- ret = audioRecorder->SetParams(recorderParams);
+ AudioCapturerParams capturerParams;
+ capturerParams.audioSampleFormat = SAMPLE_S16LE;
+ capturerParams.samplingRate = SAMPLE_RATE_44100;
+ capturerParams.audioChannel = STEREO;
+ capturerParams.audioEncoding = ENCODING_PCM;
+ ret = audioCapturer->SetParams(capturerParams);
EXPECT_EQ(SUCCESS, ret);
- AudioRecorderParams getRecorderParams;
- ret = audioRecorder->GetParams(getRecorderParams);
+ AudioCapturerParams getCapturerParams;
+ ret = audioCapturer->GetParams(getCapturerParams);
EXPECT_EQ(SUCCESS, ret);
- EXPECT_EQ(recorderParams.audioSampleFormat, getRecorderParams.audioSampleFormat);
- EXPECT_EQ(recorderParams.samplingRate, getRecorderParams.samplingRate);
- EXPECT_EQ(recorderParams.audioChannel, getRecorderParams.audioChannel);
- EXPECT_EQ(recorderParams.audioEncoding, getRecorderParams.audioEncoding);
+ EXPECT_EQ(capturerParams.audioSampleFormat, getCapturerParams.audioSampleFormat);
+ EXPECT_EQ(capturerParams.samplingRate, getCapturerParams.samplingRate);
+ EXPECT_EQ(capturerParams.audioChannel, getCapturerParams.audioChannel);
+ EXPECT_EQ(capturerParams.audioEncoding, getCapturerParams.audioEncoding);
- audioRecorder->Release();
+ audioCapturer->Release();
}
/**
-* @tc.name : Test GetParams API via legal state, RECORDER_RUNNING: GetParams after Start.
-* @tc.number: Audio_Recorder_GetParams_002
+* @tc.name : Test GetParams API via legal state, CAPTURER_RUNNING: GetParams after Start.
+* @tc.number: Audio_Capturer_GetParams_002
* @tc.desc : Test GetParams interface. Returns 0 {SUCCESS} if the getting is successful.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_GetParams_002, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_GetParams_002, TestSize.Level1)
{
int32_t ret = -1;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- AudioRecorderParams recorderParams;
- recorderParams.audioSampleFormat = SAMPLE_S16LE;
- recorderParams.samplingRate = SAMPLE_RATE_44100;
- recorderParams.audioChannel = MONO;
- recorderParams.audioEncoding = ENCODING_PCM;
- ret = audioRecorder->SetParams(recorderParams);
+ AudioCapturerParams capturerParams;
+ capturerParams.audioSampleFormat = SAMPLE_S16LE;
+ capturerParams.samplingRate = SAMPLE_RATE_44100;
+ capturerParams.audioChannel = MONO;
+ capturerParams.audioEncoding = ENCODING_PCM;
+ ret = audioCapturer->SetParams(capturerParams);
EXPECT_EQ(SUCCESS, ret);
- bool isStarted = audioRecorder->Start();
+ bool isStarted = audioCapturer->Start();
EXPECT_EQ(true, isStarted);
- AudioRecorderParams getRecorderParams;
- ret = audioRecorder->GetParams(getRecorderParams);
+ AudioCapturerParams getCapturerParams;
+ ret = audioCapturer->GetParams(getCapturerParams);
EXPECT_EQ(SUCCESS, ret);
- audioRecorder->Release();
+ audioCapturer->Release();
}
/**
-* @tc.name : Test GetParams API via illegal state, RECORDER_NEW: Call GetParams without SetParams.
-* @tc.number: Audio_Recorder_GetParams_003
-* @tc.desc : Test GetParams interface. Returns error code, if the recorder state is RECORDER_NEW.
+* @tc.name : Test GetParams API via illegal state, CAPTURER_NEW: Call GetParams without SetParams.
+* @tc.number: Audio_Capturer_GetParams_003
+* @tc.desc : Test GetParams interface. Returns error code, if the capturer state is CAPTURER_NEW.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_GetParams_003, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_GetParams_003, TestSize.Level1)
{
int32_t ret = -1;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- AudioRecorderParams recorderParams;
- recorderParams.audioSampleFormat = SAMPLE_S16LE;
- recorderParams.samplingRate = SAMPLE_RATE_44100;
- recorderParams.audioChannel = MONO;
- recorderParams.audioEncoding = ENCODING_PCM;
+ AudioCapturerParams capturerParams;
+ capturerParams.audioSampleFormat = SAMPLE_S16LE;
+ capturerParams.samplingRate = SAMPLE_RATE_44100;
+ capturerParams.audioChannel = MONO;
+ capturerParams.audioEncoding = ENCODING_PCM;
- AudioRecorderParams getRecorderParams;
- ret = audioRecorder->GetParams(getRecorderParams);
+ AudioCapturerParams getCapturerParams;
+ ret = audioCapturer->GetParams(getCapturerParams);
EXPECT_EQ(ERR_OPERATION_FAILED, ret);
}
/**
-* @tc.name : Test GetParams API via illegal state, RECORDER_RELEASED: Call GetParams after Release.
-* @tc.number: Audio_Recorder_GetParams_004
-* @tc.desc : Test GetParams interface. Returns error code, if the recorder state is RECORDER_RELEASED.
+* @tc.name : Test GetParams API via illegal state, CAPTURER_RELEASED: Call GetParams after Release.
+* @tc.number: Audio_Capturer_GetParams_004
+* @tc.desc : Test GetParams interface. Returns error code, if the capturer state is CAPTURER_RELEASED.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_GetParams_004, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_GetParams_004, TestSize.Level1)
{
int32_t ret = -1;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- ret = AudioRecorderModuleTest::InitializeRecorder(audioRecorder);
+ ret = AudioCapturerModuleTest::InitializeCapturer(audioCapturer);
EXPECT_EQ(SUCCESS, ret);
- bool isReleased = audioRecorder->Release();
+ bool isReleased = audioCapturer->Release();
EXPECT_EQ(true, isReleased);
- AudioRecorderParams getRecorderParams;
- ret = audioRecorder->GetParams(getRecorderParams);
+ AudioCapturerParams getCapturerParams;
+ ret = audioCapturer->GetParams(getCapturerParams);
EXPECT_EQ(ERR_OPERATION_FAILED, ret);
}
/**
-* @tc.name : Test GetParams API via legal state, RECORDER_STOPPED: GetParams after Stop.
-* @tc.number: Audio_Recorder_GetParams_005
+* @tc.name : Test GetParams API via legal state, CAPTURER_STOPPED: GetParams after Stop.
+* @tc.number: Audio_Capturer_GetParams_005
* @tc.desc : Test GetParams interface. Returns 0 {SUCCESS}, if the getting is successful.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_GetParams_005, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_GetParams_005, TestSize.Level1)
{
int32_t ret = -1;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- ret = AudioRecorderModuleTest::InitializeRecorder(audioRecorder);
+ ret = AudioCapturerModuleTest::InitializeCapturer(audioCapturer);
EXPECT_EQ(SUCCESS, ret);
- bool isStarted = audioRecorder->Start();
+ bool isStarted = audioCapturer->Start();
EXPECT_EQ(true, isStarted);
- bool isStopped = audioRecorder->Stop();
+ bool isStopped = audioCapturer->Stop();
EXPECT_EQ(true, isStopped);
- AudioRecorderParams getRecorderParams;
- ret = audioRecorder->GetParams(getRecorderParams);
+ AudioCapturerParams getCapturerParams;
+ ret = audioCapturer->GetParams(getCapturerParams);
EXPECT_EQ(SUCCESS, ret);
- audioRecorder->Release();
+ audioCapturer->Release();
}
/**
* @tc.name : Test GetBufferSize API via legal input.
-* @tc.number: Audio_Recorder_GetBufferSize_001
+* @tc.number: Audio_Capturer_GetBufferSize_001
* @tc.desc : Test GetBufferSize interface. Returns 0 {SUCCESS}, if the getting is successful.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_GetBufferSize_001, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_GetBufferSize_001, TestSize.Level1)
{
int32_t ret = -1;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- ret = AudioRecorderModuleTest::InitializeRecorder(audioRecorder);
+ ret = AudioCapturerModuleTest::InitializeCapturer(audioCapturer);
EXPECT_EQ(SUCCESS, ret);
size_t bufferLen;
- ret = audioRecorder->GetBufferSize(bufferLen);
+ ret = audioCapturer->GetBufferSize(bufferLen);
EXPECT_EQ(SUCCESS, ret);
- audioRecorder->Release();
+ audioCapturer->Release();
}
/**
-* @tc.name : Test GetBufferSize API via illegal state, RECORDER_NEW: without initializing the recorder.
-* @tc.number: Audio_Recorder_GetBufferSize_002
-* @tc.desc : Test GetBufferSize interface. Returns error code, if the recorder state is RECORDER_NEW.
+* @tc.name : Test GetBufferSize API via illegal state, CAPTURER_NEW: without initializing the capturer.
+* @tc.number: Audio_Capturer_GetBufferSize_002
+* @tc.desc : Test GetBufferSize interface. Returns error code, if the capturer state is CAPTURER_NEW.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_GetBufferSize_002, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_GetBufferSize_002, TestSize.Level1)
{
int32_t ret = -1;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
size_t bufferLen;
- ret = audioRecorder->GetBufferSize(bufferLen);
+ ret = audioCapturer->GetBufferSize(bufferLen);
EXPECT_EQ(ERR_OPERATION_FAILED, ret);
}
/**
-* @tc.name : Test GetBufferSize API via illegal state, RECORDER_RELEASED: call Release before GetBufferSize
-* @tc.number: Audio_Recorder_GetBufferSize_003
-* @tc.desc : Test GetBufferSize interface. Returns error code, if the recorder state is RECORDER_RELEASED.
+* @tc.name : Test GetBufferSize API via illegal state, CAPTURER_RELEASED: call Release before GetBufferSize
+* @tc.number: Audio_Capturer_GetBufferSize_003
+* @tc.desc : Test GetBufferSize interface. Returns error code, if the capturer state is CAPTURER_RELEASED.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_GetBufferSize_003, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_GetBufferSize_003, TestSize.Level1)
{
int32_t ret = -1;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- ret = AudioRecorderModuleTest::InitializeRecorder(audioRecorder);
+ ret = AudioCapturerModuleTest::InitializeCapturer(audioCapturer);
EXPECT_EQ(SUCCESS, ret);
- bool isReleased = audioRecorder->Release();
+ bool isReleased = audioCapturer->Release();
EXPECT_EQ(true, isReleased);
size_t bufferLen;
- ret = audioRecorder->GetBufferSize(bufferLen);
+ ret = audioCapturer->GetBufferSize(bufferLen);
EXPECT_EQ(ERR_OPERATION_FAILED, ret);
}
/**
-* @tc.name : Test GetBufferSize API via legal state, RECORDER_STOPPED: call Stop before GetBufferSize
-* @tc.number: Audio_Recorder_GetBufferSize_004
+* @tc.name : Test GetBufferSize API via legal state, CAPTURER_STOPPED: call Stop before GetBufferSize
+* @tc.number: Audio_Capturer_GetBufferSize_004
* @tc.desc : Test GetBufferSize interface. Returns 0 {SUCCESS}, if the getting is successful.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_GetBufferSize_004, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_GetBufferSize_004, TestSize.Level1)
{
int32_t ret = -1;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- ret = AudioRecorderModuleTest::InitializeRecorder(audioRecorder);
+ ret = AudioCapturerModuleTest::InitializeCapturer(audioCapturer);
EXPECT_EQ(SUCCESS, ret);
- bool isStarted = audioRecorder->Start();
+ bool isStarted = audioCapturer->Start();
EXPECT_EQ(true, isStarted);
- bool isStopped = audioRecorder->Stop();
+ bool isStopped = audioCapturer->Stop();
EXPECT_EQ(true, isStopped);
size_t bufferLen;
- ret = audioRecorder->GetBufferSize(bufferLen);
+ ret = audioCapturer->GetBufferSize(bufferLen);
EXPECT_EQ(SUCCESS, ret);
- audioRecorder->Release();
+ audioCapturer->Release();
}
/**
-* @tc.name : Test GetBufferSize API via legal state, RECORDER_RUNNING: call Start before GetBufferSize
-* @tc.number: Audio_Recorder_GetBufferSize_005
+* @tc.name : Test GetBufferSize API via legal state, CAPTURER_RUNNING: call Start before GetBufferSize
+* @tc.number: Audio_Capturer_GetBufferSize_005
* @tc.desc : test GetBufferSize interface. Returns 0 {SUCCESS}, if the getting is successful.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_GetBufferSize_005, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_GetBufferSize_005, TestSize.Level1)
{
int32_t ret = -1;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- ret = AudioRecorderModuleTest::InitializeRecorder(audioRecorder);
+ ret = AudioCapturerModuleTest::InitializeCapturer(audioCapturer);
EXPECT_EQ(SUCCESS, ret);
- bool isStarted = audioRecorder->Start();
+ bool isStarted = audioCapturer->Start();
EXPECT_EQ(true, isStarted);
size_t bufferLen;
- ret = audioRecorder->GetBufferSize(bufferLen);
+ ret = audioCapturer->GetBufferSize(bufferLen);
EXPECT_EQ(SUCCESS, ret);
- audioRecorder->Release();
+ audioCapturer->Release();
}
/**
* @tc.name : Test GetFrameCount API via legal input.
-* @tc.number: Audio_Recorder_GetFrameCount_001
+* @tc.number: Audio_Capturer_GetFrameCount_001
* @tc.desc : test GetFrameCount interface, Returns 0 {SUCCESS}, if the getting is successful.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_GetFrameCount_001, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_GetFrameCount_001, TestSize.Level1)
{
int32_t ret = -1;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- ret = AudioRecorderModuleTest::InitializeRecorder(audioRecorder);
+ ret = AudioCapturerModuleTest::InitializeCapturer(audioCapturer);
EXPECT_EQ(SUCCESS, ret);
uint32_t frameCount;
- ret = audioRecorder->GetFrameCount(frameCount);
+ ret = audioCapturer->GetFrameCount(frameCount);
EXPECT_EQ(SUCCESS, ret);
- audioRecorder->Release();
+ audioCapturer->Release();
}
/**
-* @tc.name : Test GetFrameCount API via illegal state, RECORDER_NEW: without initialiing the recorder.
-* @tc.number: Audio_Recorder_GetFrameCount_002
-* @tc.desc : Test GetFrameCount interface. Returns error code, if the recorder state is RECORDER_NEW.
+* @tc.name : Test GetFrameCount API via illegal state, CAPTURER_NEW: without initialiing the capturer.
+* @tc.number: Audio_Capturer_GetFrameCount_002
+* @tc.desc : Test GetFrameCount interface. Returns error code, if the capturer state is CAPTURER_NEW.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_GetFrameCount_002, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_GetFrameCount_002, TestSize.Level1)
{
int32_t ret = -1;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
uint32_t frameCount;
- ret = audioRecorder->GetFrameCount(frameCount);
+ ret = audioCapturer->GetFrameCount(frameCount);
EXPECT_EQ(ERR_OPERATION_FAILED, ret);
}
/**
-* @tc.name : Test GetFrameCount API via legal state, RECORDER_RUNNING: call Start before GetFrameCount.
-* @tc.number: Audio_Recorder_GetFrameCount_003
+* @tc.name : Test GetFrameCount API via legal state, CAPTURER_RUNNING: call Start before GetFrameCount.
+* @tc.number: Audio_Capturer_GetFrameCount_003
* @tc.desc : Test GetFrameCount interface. Returns 0 {SUCCESS}, if the getting is successful.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_GetFrameCount_003, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_GetFrameCount_003, TestSize.Level1)
{
int32_t ret = -1;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- ret = AudioRecorderModuleTest::InitializeRecorder(audioRecorder);
+ ret = AudioCapturerModuleTest::InitializeCapturer(audioCapturer);
EXPECT_EQ(SUCCESS, ret);
- bool isStarted = audioRecorder->Start();
+ bool isStarted = audioCapturer->Start();
EXPECT_EQ(true, isStarted);
uint32_t frameCount;
- ret = audioRecorder->GetFrameCount(frameCount);
+ ret = audioCapturer->GetFrameCount(frameCount);
EXPECT_EQ(SUCCESS, ret);
- audioRecorder->Release();
+ audioCapturer->Release();
}
/**
-* @tc.name : Test GetFrameCount API via legal state, RECORDER_STOPPED: call Stop before GetFrameCount
-* @tc.number: Audio_Recorder_GetFrameCount_004
+* @tc.name : Test GetFrameCount API via legal state, CAPTURER_STOPPED: call Stop before GetFrameCount
+* @tc.number: Audio_Capturer_GetFrameCount_004
* @tc.desc : Test GetFrameCount interface. Returns 0 {SUCCESS}, if the getting is successful.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_GetFrameCount_004, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_GetFrameCount_004, TestSize.Level1)
{
int32_t ret = -1;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- ret = AudioRecorderModuleTest::InitializeRecorder(audioRecorder);
+ ret = AudioCapturerModuleTest::InitializeCapturer(audioCapturer);
EXPECT_EQ(SUCCESS, ret);
- bool isStarted = audioRecorder->Start();
+ bool isStarted = audioCapturer->Start();
EXPECT_EQ(true, isStarted);
- bool isStopped = audioRecorder->Stop();
+ bool isStopped = audioCapturer->Stop();
EXPECT_EQ(true, isStopped);
uint32_t frameCount;
- ret = audioRecorder->GetFrameCount(frameCount);
+ ret = audioCapturer->GetFrameCount(frameCount);
EXPECT_EQ(SUCCESS, ret);
- audioRecorder->Release();
+ audioCapturer->Release();
}
/**
-* @tc.name : Test GetFrameCount API via illegal state, RECORDER_RELEASED: call Release before GetFrameCount
-* @tc.number: Audio_Recorder_GetFrameCount_005
-* @tc.desc : Test GetFrameCount interface. Returns error code, if the state is RECORDER_RELEASED.
+* @tc.name : Test GetFrameCount API via illegal state, CAPTURER_RELEASED: call Release before GetFrameCount
+* @tc.number: Audio_Capturer_GetFrameCount_005
+* @tc.desc : Test GetFrameCount interface. Returns error code, if the state is CAPTURER_RELEASED.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_GetFrameCount_005, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_GetFrameCount_005, TestSize.Level1)
{
int32_t ret = -1;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- ret = AudioRecorderModuleTest::InitializeRecorder(audioRecorder);
+ ret = AudioCapturerModuleTest::InitializeCapturer(audioCapturer);
EXPECT_EQ(SUCCESS, ret);
- bool isReleased = audioRecorder->Release();
+ bool isReleased = audioCapturer->Release();
EXPECT_EQ(true, isReleased);
uint32_t frameCount;
- ret = audioRecorder->GetFrameCount(frameCount);
+ ret = audioCapturer->GetFrameCount(frameCount);
EXPECT_EQ(ERR_OPERATION_FAILED, ret);
}
/**
-* @tc.name : Test Start API via legal state, RECORDER_PREPARED.
-* @tc.number: Audio_Recorder_Start_001
+* @tc.name : Test Start API via legal state, CAPTURER_PREPARED.
+* @tc.number: Audio_Capturer_Start_001
* @tc.desc : Test Start interface. Returns true if start is successful.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_Start_001, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_Start_001, TestSize.Level1)
{
int32_t ret = -1;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- ret = AudioRecorderModuleTest::InitializeRecorder(audioRecorder);
+ ret = AudioCapturerModuleTest::InitializeCapturer(audioCapturer);
EXPECT_EQ(SUCCESS, ret);
- bool isStarted = audioRecorder->Start();
+ bool isStarted = audioCapturer->Start();
EXPECT_EQ(true, isStarted);
- audioRecorder->Release();
+ audioCapturer->Release();
}
/**
-* @tc.name : Test Start API via illegal state, RECORDER_NEW: without initializing the recorder.
-* @tc.number: Audio_Recorder_Start_002
-* @tc.desc : Test Start interface. Returns false, if the recorder state is RECORDER_NEW.
+* @tc.name : Test Start API via illegal state, CAPTURER_NEW: without initializing the capturer.
+* @tc.number: Audio_Capturer_Start_002
+* @tc.desc : Test Start interface. Returns false, if the capturer state is CAPTURER_NEW.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_Start_002, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_Start_002, TestSize.Level1)
{
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- bool isStarted = audioRecorder->Start();
+ bool isStarted = audioCapturer->Start();
EXPECT_EQ(false, isStarted);
}
/**
-* @tc.name : Test Start API via illegal state, RECORDER_RELEASED: call Start after Release
-* @tc.number: Audio_Recorder_Start_003
-* @tc.desc : Test Start interface. Returns false, if the recorder state is RECORDER_RELEASED.
+* @tc.name : Test Start API via illegal state, CAPTURER_RELEASED: call Start after Release
+* @tc.number: Audio_Capturer_Start_003
+* @tc.desc : Test Start interface. Returns false, if the capturer state is CAPTURER_RELEASED.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_Start_003, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_Start_003, TestSize.Level1)
{
int32_t ret = -1;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- ret = AudioRecorderModuleTest::InitializeRecorder(audioRecorder);
+ ret = AudioCapturerModuleTest::InitializeCapturer(audioCapturer);
EXPECT_EQ(SUCCESS, ret);
- bool isReleased = audioRecorder->Release();
+ bool isReleased = audioCapturer->Release();
EXPECT_EQ(true, isReleased);
- bool isStarted = audioRecorder->Start();
+ bool isStarted = audioCapturer->Start();
EXPECT_EQ(false, isStarted);
- audioRecorder->Release();
+ audioCapturer->Release();
}
/**
-* @tc.name : Test Start API via legal state, RECORDER_STOPPED: Start Stop and then Start again
-* @tc.number: Audio_Recorder_Start_004
+* @tc.name : Test Start API via legal state, CAPTURER_STOPPED: Start Stop and then Start again
+* @tc.number: Audio_Capturer_Start_004
* @tc.desc : Test Start interface. Returns true, if the start is successful.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_Start_004, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_Start_004, TestSize.Level1)
{
int32_t ret = -1;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- ret = AudioRecorderModuleTest::InitializeRecorder(audioRecorder);
+ ret = AudioCapturerModuleTest::InitializeCapturer(audioCapturer);
EXPECT_EQ(SUCCESS, ret);
- bool isStarted = audioRecorder->Start();
+ bool isStarted = audioCapturer->Start();
EXPECT_EQ(true, isStarted);
- bool isStopped = audioRecorder->Stop();
+ bool isStopped = audioCapturer->Stop();
EXPECT_EQ(true, isStopped);
- isStarted = audioRecorder->Start();
+ isStarted = audioCapturer->Start();
EXPECT_EQ(true, isStarted);
- audioRecorder->Release();
+ audioCapturer->Release();
}
/**
-* @tc.name : Test Start API via illegal state, RECORDER_RUNNING : call Start repeatedly
-* @tc.number: Audio_Recorder_Start_005
-* @tc.desc : Test Start interface. Returns false, if the recorder state is RECORDER_RUNNING.
+* @tc.name : Test Start API via illegal state, CAPTURER_RUNNING : call Start repeatedly
+* @tc.number: Audio_Capturer_Start_005
+* @tc.desc : Test Start interface. Returns false, if the capturer state is CAPTURER_RUNNING.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_Start_005, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_Start_005, TestSize.Level1)
{
int32_t ret = -1;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- ret = AudioRecorderModuleTest::InitializeRecorder(audioRecorder);
+ ret = AudioCapturerModuleTest::InitializeCapturer(audioCapturer);
EXPECT_EQ(SUCCESS, ret);
- bool isStarted = audioRecorder->Start();
+ bool isStarted = audioCapturer->Start();
EXPECT_EQ(true, isStarted);
- isStarted = audioRecorder->Start();
+ isStarted = audioCapturer->Start();
EXPECT_EQ(false, isStarted);
- audioRecorder->Release();
+ audioCapturer->Release();
}
/**
* @tc.name : Test Read API via isBlockingRead = true.
-* @tc.number: Audio_Recorder_Read_001
+* @tc.number: Audio_Capturer_Read_001
* @tc.desc : Test Read interface. Returns number of bytes read, if the read is successful.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_Read_001, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_Read_001, TestSize.Level1)
{
int32_t ret = -1;
bool isBlockingRead = true;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- ret = AudioRecorderModuleTest::InitializeRecorder(audioRecorder);
+ ret = AudioCapturerModuleTest::InitializeCapturer(audioCapturer);
EXPECT_EQ(SUCCESS, ret);
- bool isStarted = audioRecorder->Start();
+ bool isStarted = audioCapturer->Start();
EXPECT_EQ(true, isStarted);
size_t bufferLen;
- ret = audioRecorder->GetBufferSize(bufferLen);
+ ret = audioCapturer->GetBufferSize(bufferLen);
EXPECT_EQ(SUCCESS, ret);
uint8_t *buffer = (uint8_t *) malloc(bufferLen);
ASSERT_NE(nullptr, buffer);
- FILE *recFile = fopen(AUDIO_RECORD_FILE1.c_str(), "wb");
- ASSERT_NE(nullptr, recFile);
+ FILE *capFile = fopen(AUDIO_CAPTURE_FILE1.c_str(), "wb");
+ ASSERT_NE(nullptr, capFile);
size_t size = 1;
int32_t bytesRead = 0;
- int32_t numBuffersToRecord = READ_BUFFERS_COUNT;
+ int32_t numBuffersToCapture = READ_BUFFERS_COUNT;
- while (numBuffersToRecord) {
- bytesRead = audioRecorder->Read(*buffer, bufferLen, isBlockingRead);
+ while (numBuffersToCapture) {
+ bytesRead = audioCapturer->Read(*buffer, bufferLen, isBlockingRead);
if (bytesRead < 0) {
break;
} else if (bytesRead > 0) {
- fwrite(buffer, size, bytesRead, recFile);
- numBuffersToRecord--;
+ fwrite(buffer, size, bytesRead, capFile);
+ numBuffersToCapture--;
}
}
- audioRecorder->Flush();
- audioRecorder->Stop();
- audioRecorder->Release();
+ audioCapturer->Flush();
+ audioCapturer->Stop();
+ audioCapturer->Release();
free(buffer);
- fclose(recFile);
+ fclose(capFile);
}
/**
* @tc.name : Test Read API via isBlockingRead = false.
-* @tc.number: Audio_Recorder_Read_002
+* @tc.number: Audio_Capturer_Read_002
* @tc.desc : Test Read interface. Returns number of bytes read, if the read is successful.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_Read_002, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_Read_002, TestSize.Level1)
{
int32_t ret = -1;
bool isBlockingRead = false;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- ret = AudioRecorderModuleTest::InitializeRecorder(audioRecorder);
+ ret = AudioCapturerModuleTest::InitializeCapturer(audioCapturer);
EXPECT_EQ(SUCCESS, ret);
- bool isStarted = audioRecorder->Start();
+ bool isStarted = audioCapturer->Start();
EXPECT_EQ(true, isStarted);
size_t bufferLen;
- ret = audioRecorder->GetBufferSize(bufferLen);
+ ret = audioCapturer->GetBufferSize(bufferLen);
EXPECT_EQ(SUCCESS, ret);
uint8_t *buffer = (uint8_t *) malloc(bufferLen);
ASSERT_NE(nullptr, buffer);
- FILE *recFile = fopen(AUDIO_RECORD_FILE2.c_str(), "wb");
- ASSERT_NE(nullptr, recFile);
+ FILE *capFile = fopen(AUDIO_CAPTURE_FILE2.c_str(), "wb");
+ ASSERT_NE(nullptr, capFile);
size_t size = 1;
int32_t bytesRead = 0;
- int32_t numBuffersToRecord = READ_BUFFERS_COUNT;
+ int32_t numBuffersToCapture = READ_BUFFERS_COUNT;
- while (numBuffersToRecord) {
- bytesRead = audioRecorder->Read(*buffer, bufferLen, isBlockingRead);
+ while (numBuffersToCapture) {
+ bytesRead = audioCapturer->Read(*buffer, bufferLen, isBlockingRead);
if (bytesRead < 0) {
break;
} else if (bytesRead > 0) {
- fwrite(buffer, size, bytesRead, recFile);
- numBuffersToRecord--;
+ fwrite(buffer, size, bytesRead, capFile);
+ numBuffersToCapture--;
}
}
- audioRecorder->Flush();
- audioRecorder->Stop();
- audioRecorder->Release();
+ audioCapturer->Flush();
+ audioCapturer->Stop();
+ audioCapturer->Release();
free(buffer);
- fclose(recFile);
+ fclose(capFile);
}
/**
-* @tc.name : Test Read API via illegl state, RECORDER_NEW : without Initializing the recorder.
-* @tc.number: Audio_Recorder_Read_003
-* @tc.desc : Test Read interface. Returns error code, if the recorder state is RECORDER_NEW.
+* @tc.name : Test Read API via illegl state, CAPTURER_NEW : without Initializing the capturer.
+* @tc.number: Audio_Capturer_Read_003
+* @tc.desc : Test Read interface. Returns error code, if the capturer state is CAPTURER_NEW.
* : bufferLen is invalid here, firstly bufferLen is validated in Read. So it returns ERR_INVALID_PARAM.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_Read_003, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_Read_003, TestSize.Level1)
{
int32_t ret = -1;
bool isBlockingRead = true;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- bool isStarted = audioRecorder->Start();
+ bool isStarted = audioCapturer->Start();
EXPECT_EQ(false, isStarted);
size_t bufferLen;
- ret = audioRecorder->GetBufferSize(bufferLen);
+ ret = audioCapturer->GetBufferSize(bufferLen);
EXPECT_EQ(ERR_OPERATION_FAILED, ret);
uint8_t *buffer = (uint8_t *) malloc(bufferLen);
ASSERT_NE(nullptr, buffer);
- int32_t bytesRead = audioRecorder->Read(*buffer, bufferLen, isBlockingRead);
+ int32_t bytesRead = audioCapturer->Read(*buffer, bufferLen, isBlockingRead);
EXPECT_EQ(ERR_INVALID_PARAM, bytesRead);
- audioRecorder->Flush();
- audioRecorder->Stop();
- audioRecorder->Release();
+ audioCapturer->Flush();
+ audioCapturer->Stop();
+ audioCapturer->Release();
free(buffer);
}
/**
-* @tc.name : Test Read API via illegl state, RECORDER_PREPARED : Read without Start.
-* @tc.number: Audio_Recorder_Read_004
-* @tc.desc : Test Read interface. Returns error code, if the recorder state is not RECORDER_RUNNING.
+* @tc.name : Test Read API via illegl state, CAPTURER_PREPARED : Read without Start.
+* @tc.number: Audio_Capturer_Read_004
+* @tc.desc : Test Read interface. Returns error code, if the capturer state is not CAPTURER_RUNNING.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_Read_004, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_Read_004, TestSize.Level1)
{
int32_t ret = -1;
bool isBlockingRead = true;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- ret = AudioRecorderModuleTest::InitializeRecorder(audioRecorder);
+ ret = AudioCapturerModuleTest::InitializeCapturer(audioCapturer);
EXPECT_EQ(SUCCESS, ret);
size_t bufferLen;
- ret = audioRecorder->GetBufferSize(bufferLen);
+ ret = audioCapturer->GetBufferSize(bufferLen);
EXPECT_EQ(SUCCESS, ret);
uint8_t *buffer = (uint8_t *) malloc(bufferLen);
ASSERT_NE(nullptr, buffer);
- int32_t bytesRead = audioRecorder->Read(*buffer, bufferLen, isBlockingRead);
+ int32_t bytesRead = audioCapturer->Read(*buffer, bufferLen, isBlockingRead);
EXPECT_EQ(ERR_ILLEGAL_STATE, bytesRead);
- audioRecorder->Flush();
- audioRecorder->Stop();
- audioRecorder->Release();
+ audioCapturer->Flush();
+ audioCapturer->Stop();
+ audioCapturer->Release();
free(buffer);
}
/**
* @tc.name : Test Read API via illegal input, bufferLength = 0.
-* @tc.number: Audio_Recorder_Read_005
+* @tc.number: Audio_Capturer_Read_005
* @tc.desc : Test Read interface. Returns error code, if the bufferLength <= 0.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_Read_005, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_Read_005, TestSize.Level1)
{
int32_t ret = -1;
bool isBlockingRead = true;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- ret = AudioRecorderModuleTest::InitializeRecorder(audioRecorder);
+ ret = AudioCapturerModuleTest::InitializeCapturer(audioCapturer);
EXPECT_EQ(SUCCESS, ret);
- bool isStarted = audioRecorder->Start();
+ bool isStarted = audioCapturer->Start();
EXPECT_EQ(true, isStarted);
size_t bufferLen = 0;
@@ -990,81 +990,81 @@ HWTEST(AudioRecorderModuleTest, Audio_Recorder_Read_005, TestSize.Level1)
uint8_t *buffer = (uint8_t *) malloc(bufferLen);
ASSERT_NE(nullptr, buffer);
- int32_t bytesRead = audioRecorder->Read(*buffer, bufferLen, isBlockingRead);
+ int32_t bytesRead = audioCapturer->Read(*buffer, bufferLen, isBlockingRead);
EXPECT_EQ(ERR_INVALID_PARAM, bytesRead);
- audioRecorder->Flush();
- audioRecorder->Stop();
- audioRecorder->Release();
+ audioCapturer->Flush();
+ audioCapturer->Stop();
+ audioCapturer->Release();
free(buffer);
}
/**
-* @tc.name : Test Read API via illegal state, RECORDER_STOPPED: Read after Stop.
-* @tc.number: Audio_Recorder_Read_006
-* @tc.desc : Test Read interface. Returns error code, if the recorder state is not RECORDER_RUNNING.
+* @tc.name : Test Read API via illegal state, CAPTURER_STOPPED: Read after Stop.
+* @tc.number: Audio_Capturer_Read_006
+* @tc.desc : Test Read interface. Returns error code, if the capturer state is not CAPTURER_RUNNING.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_Read_006, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_Read_006, TestSize.Level1)
{
int32_t ret = -1;
bool isBlockingRead = true;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- ret = AudioRecorderModuleTest::InitializeRecorder(audioRecorder);
+ ret = AudioCapturerModuleTest::InitializeCapturer(audioCapturer);
EXPECT_EQ(SUCCESS, ret);
- bool isStarted = audioRecorder->Start();
+ bool isStarted = audioCapturer->Start();
EXPECT_EQ(true, isStarted);
size_t bufferLen;
- ret = audioRecorder->GetBufferSize(bufferLen);
+ ret = audioCapturer->GetBufferSize(bufferLen);
EXPECT_EQ(SUCCESS, ret);
uint8_t *buffer = (uint8_t *) malloc(bufferLen);
ASSERT_NE(nullptr, buffer);
- bool isStopped = audioRecorder->Stop();
+ bool isStopped = audioCapturer->Stop();
EXPECT_EQ(true, isStopped);
- int32_t bytesRead = audioRecorder->Read(*buffer, bufferLen, isBlockingRead);
+ int32_t bytesRead = audioCapturer->Read(*buffer, bufferLen, isBlockingRead);
EXPECT_EQ(ERR_ILLEGAL_STATE, bytesRead);
- audioRecorder->Release();
+ audioCapturer->Release();
free(buffer);
}
/**
-* @tc.name : Test Read API via illegal state, RECORDER_RELEASED: Read after Release.
-* @tc.number: Audio_Recorder_Read_007
-* @tc.desc : Test Read interface. Returns error code, if the recorder state is not RECORDER_RUNNING.
+* @tc.name : Test Read API via illegal state, CAPTURER_RELEASED: Read after Release.
+* @tc.number: Audio_Capturer_Read_007
+* @tc.desc : Test Read interface. Returns error code, if the capturer state is not CAPTURER_RUNNING.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_Read_007, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_Read_007, TestSize.Level1)
{
int32_t ret = -1;
bool isBlockingRead = true;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- ret = AudioRecorderModuleTest::InitializeRecorder(audioRecorder);
+ ret = AudioCapturerModuleTest::InitializeCapturer(audioCapturer);
EXPECT_EQ(SUCCESS, ret);
- bool isStarted = audioRecorder->Start();
+ bool isStarted = audioCapturer->Start();
EXPECT_EQ(true, isStarted);
size_t bufferLen;
- ret = audioRecorder->GetBufferSize(bufferLen);
+ ret = audioCapturer->GetBufferSize(bufferLen);
EXPECT_EQ(SUCCESS, ret);
uint8_t *buffer = (uint8_t *) malloc(bufferLen);
ASSERT_NE(nullptr, buffer);
- bool isReleased = audioRecorder->Release();
+ bool isReleased = audioCapturer->Release();
EXPECT_EQ(true, isReleased);
- int32_t bytesRead = audioRecorder->Read(*buffer, bufferLen, isBlockingRead);
+ int32_t bytesRead = audioCapturer->Read(*buffer, bufferLen, isBlockingRead);
EXPECT_EQ(ERR_ILLEGAL_STATE, bytesRead);
free(buffer);
@@ -1072,637 +1072,637 @@ HWTEST(AudioRecorderModuleTest, Audio_Recorder_Read_007, TestSize.Level1)
/**
* @tc.name : Test GetAudioTime API via legal input.
-* @tc.number: Audio_Recorder_GetAudioTime_001
+* @tc.number: Audio_Capturer_GetAudioTime_001
* @tc.desc : Test GetAudioTime interface. Returns true, if the getting is successful.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_GetAudioTime_001, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_GetAudioTime_001, TestSize.Level1)
{
int32_t ret = -1;
bool isBlockingRead = true;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- ret = AudioRecorderModuleTest::InitializeRecorder(audioRecorder);
+ ret = AudioCapturerModuleTest::InitializeCapturer(audioCapturer);
EXPECT_EQ(SUCCESS, ret);
- bool isStarted = audioRecorder->Start();
+ bool isStarted = audioCapturer->Start();
EXPECT_EQ(true, isStarted);
size_t bufferLen;
- ret = audioRecorder->GetBufferSize(bufferLen);
+ ret = audioCapturer->GetBufferSize(bufferLen);
EXPECT_EQ(SUCCESS, ret);
uint8_t *buffer = (uint8_t *) malloc(bufferLen);
ASSERT_NE(nullptr, buffer);
- int32_t bytesRead = audioRecorder->Read(*buffer, bufferLen, isBlockingRead);
+ int32_t bytesRead = audioCapturer->Read(*buffer, bufferLen, isBlockingRead);
EXPECT_GE(bytesRead, VALUE_ZERO);
Timestamp timeStamp;
- bool getAudioTime = audioRecorder->GetAudioTime(timeStamp, Timestamp::Timestampbase::MONOTONIC);
+ bool getAudioTime = audioCapturer->GetAudioTime(timeStamp, Timestamp::Timestampbase::MONOTONIC);
EXPECT_EQ(true, getAudioTime);
EXPECT_GE(timeStamp.time.tv_sec, (const long)VALUE_ZERO);
EXPECT_GE(timeStamp.time.tv_nsec, (const long)VALUE_ZERO);
- audioRecorder->Flush();
- audioRecorder->Stop();
- audioRecorder->Release();
+ audioCapturer->Flush();
+ audioCapturer->Stop();
+ audioCapturer->Release();
free(buffer);
}
/**
-* @tc.name : Test GetAudioTime API via illegal state, RECORDER_NEW: GetAudioTime without initializing the recorder.
-* @tc.number: Audio_Recorder_GetAudioTime_002
-* @tc.desc : Test GetAudioTime interface. Returns false, if the recorder state is RECORDER_NEW.
+* @tc.name : Test GetAudioTime API via illegal state, CAPTURER_NEW: GetAudioTime without initializing the capturer.
+* @tc.number: Audio_Capturer_GetAudioTime_002
+* @tc.desc : Test GetAudioTime interface. Returns false, if the capturer state is CAPTURER_NEW.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_GetAudioTime_002, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_GetAudioTime_002, TestSize.Level1)
{
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
Timestamp timeStamp;
- bool getAudioTime = audioRecorder->GetAudioTime(timeStamp, Timestamp::Timestampbase::MONOTONIC);
+ bool getAudioTime = audioCapturer->GetAudioTime(timeStamp, Timestamp::Timestampbase::MONOTONIC);
EXPECT_EQ(false, getAudioTime);
}
/**
-* @tc.name : Test GetAudioTime API via legal state, RECORDER_RUNNING.
-* @tc.number: Audio_Recorder_GetAudioTime_003
+* @tc.name : Test GetAudioTime API via legal state, CAPTURER_RUNNING.
+* @tc.number: Audio_Capturer_GetAudioTime_003
* @tc.desc : test GetAudioTime interface. Returns true, if the getting is successful.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_GetAudioTime_003, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_GetAudioTime_003, TestSize.Level1)
{
int32_t ret = -1;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- ret = AudioRecorderModuleTest::InitializeRecorder(audioRecorder);
+ ret = AudioCapturerModuleTest::InitializeCapturer(audioCapturer);
EXPECT_EQ(SUCCESS, ret);
- bool isStarted = audioRecorder->Start();
+ bool isStarted = audioCapturer->Start();
EXPECT_EQ(true, isStarted);
Timestamp timeStamp;
- bool getAudioTime = audioRecorder->GetAudioTime(timeStamp, Timestamp::Timestampbase::MONOTONIC);
+ bool getAudioTime = audioCapturer->GetAudioTime(timeStamp, Timestamp::Timestampbase::MONOTONIC);
EXPECT_EQ(true, getAudioTime);
- audioRecorder->Release();
+ audioCapturer->Release();
}
/**
-* @tc.name : Test GetAudioTime API via legal state, RECORDER_STOPPED.
-* @tc.number: Audio_Recorder_GetAudioTime_004
+* @tc.name : Test GetAudioTime API via legal state, CAPTURER_STOPPED.
+* @tc.number: Audio_Capturer_GetAudioTime_004
* @tc.desc : Test GetAudioTime interface. Returns true, if the getting is successful.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_GetAudioTime_004, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_GetAudioTime_004, TestSize.Level1)
{
int32_t ret = -1;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- ret = AudioRecorderModuleTest::InitializeRecorder(audioRecorder);
+ ret = AudioCapturerModuleTest::InitializeCapturer(audioCapturer);
EXPECT_EQ(SUCCESS, ret);
- bool isStarted = audioRecorder->Start();
+ bool isStarted = audioCapturer->Start();
EXPECT_EQ(true, isStarted);
- bool isStopped = audioRecorder->Stop();
+ bool isStopped = audioCapturer->Stop();
EXPECT_EQ(true, isStopped);
Timestamp timeStamp;
- bool getAudioTime = audioRecorder->GetAudioTime(timeStamp, Timestamp::Timestampbase::MONOTONIC);
+ bool getAudioTime = audioCapturer->GetAudioTime(timeStamp, Timestamp::Timestampbase::MONOTONIC);
EXPECT_EQ(true, getAudioTime);
- audioRecorder->Release();
+ audioCapturer->Release();
}
/**
-* @tc.name : Test GetAudioTime API via illegal state, RECORDER_RELEASED: GetAudioTime after Release.
-* @tc.number: Audio_Recorder_GetAudioTime_005
-* @tc.desc : Test GetAudioTime interface. Returns false, if the recorder state is RECORDER_RELEASED
+* @tc.name : Test GetAudioTime API via illegal state, CAPTURER_RELEASED: GetAudioTime after Release.
+* @tc.number: Audio_Capturer_GetAudioTime_005
+* @tc.desc : Test GetAudioTime interface. Returns false, if the capturer state is CAPTURER_RELEASED
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_GetAudioTime_005, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_GetAudioTime_005, TestSize.Level1)
{
int32_t ret = -1;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- ret = AudioRecorderModuleTest::InitializeRecorder(audioRecorder);
+ ret = AudioCapturerModuleTest::InitializeCapturer(audioCapturer);
EXPECT_EQ(SUCCESS, ret);
- bool isStarted = audioRecorder->Start();
+ bool isStarted = audioCapturer->Start();
EXPECT_EQ(true, isStarted);
- bool isStopped = audioRecorder->Stop();
+ bool isStopped = audioCapturer->Stop();
EXPECT_EQ(true, isStopped);
- bool isReleased = audioRecorder->Release();
+ bool isReleased = audioCapturer->Release();
EXPECT_EQ(true, isReleased);
Timestamp timeStamp;
- bool getAudioTime = audioRecorder->GetAudioTime(timeStamp, Timestamp::Timestampbase::MONOTONIC);
+ bool getAudioTime = audioCapturer->GetAudioTime(timeStamp, Timestamp::Timestampbase::MONOTONIC);
EXPECT_EQ(false, getAudioTime);
}
/**
* @tc.name : Test Flush API.
-* @tc.number: Audio_Recorder_Flush_001
+* @tc.number: Audio_Capturer_Flush_001
* @tc.desc : Test Flush interface. Returns true, if the flush is successful.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_Flush_001, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_Flush_001, TestSize.Level1)
{
int32_t ret = -1;
bool isBlockingRead = true;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- ret = AudioRecorderModuleTest::InitializeRecorder(audioRecorder);
+ ret = AudioCapturerModuleTest::InitializeCapturer(audioCapturer);
EXPECT_EQ(SUCCESS, ret);
- bool isStarted = audioRecorder->Start();
+ bool isStarted = audioCapturer->Start();
EXPECT_EQ(true, isStarted);
size_t bufferLen;
- ret = audioRecorder->GetBufferSize(bufferLen);
+ ret = audioCapturer->GetBufferSize(bufferLen);
EXPECT_EQ(SUCCESS, ret);
uint8_t *buffer = (uint8_t *) malloc(bufferLen);
ASSERT_NE(nullptr, buffer);
- int32_t bytesRead = audioRecorder->Read(*buffer, bufferLen, isBlockingRead);
+ int32_t bytesRead = audioCapturer->Read(*buffer, bufferLen, isBlockingRead);
EXPECT_GE(bytesRead, VALUE_ZERO);
- bool isFlushed = audioRecorder->Flush();
+ bool isFlushed = audioCapturer->Flush();
EXPECT_EQ(true, isFlushed);
- audioRecorder->Stop();
- audioRecorder->Release();
+ audioCapturer->Stop();
+ audioCapturer->Release();
free(buffer);
}
/**
-* @tc.name : Test Flush API via illegal state, RECORDER_NEW: Without initializing the recorder.
-* @tc.number: Audio_Recorder_Flush_002
-* @tc.desc : Test Flush interface. Returns false, if the recorder state is not RECORDER_RUNNING.
+* @tc.name : Test Flush API via illegal state, CAPTURER_NEW: Without initializing the capturer.
+* @tc.number: Audio_Capturer_Flush_002
+* @tc.desc : Test Flush interface. Returns false, if the capturer state is not CAPTURER_RUNNING.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_Flush_002, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_Flush_002, TestSize.Level1)
{
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- bool isFlushed = audioRecorder->Flush();
+ bool isFlushed = audioCapturer->Flush();
EXPECT_EQ(false, isFlushed);
- audioRecorder->Release();
+ audioCapturer->Release();
}
/**
-* @tc.name : Test Flush API via illegal state, RECORDER_PREPARED: Without Start.
-* @tc.number: Audio_Recorder_Flush_003
-* @tc.desc : Test Flush interface. Returns false, if the recorder state is not RECORDER_RUNNING.
+* @tc.name : Test Flush API via illegal state, CAPTURER_PREPARED: Without Start.
+* @tc.number: Audio_Capturer_Flush_003
+* @tc.desc : Test Flush interface. Returns false, if the capturer state is not CAPTURER_RUNNING.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_Flush_003, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_Flush_003, TestSize.Level1)
{
int32_t ret = -1;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- ret = AudioRecorderModuleTest::InitializeRecorder(audioRecorder);
+ ret = AudioCapturerModuleTest::InitializeCapturer(audioCapturer);
EXPECT_EQ(SUCCESS, ret);
- bool isFlushed = audioRecorder->Flush();
+ bool isFlushed = audioCapturer->Flush();
EXPECT_EQ(false, isFlushed);
- audioRecorder->Release();
+ audioCapturer->Release();
}
/**
-* @tc.name : Test Flush API via illegal state, RECORDER_STOPPED: call Stop before Flush.
-* @tc.number: Audio_Recorder_Flush_004
-* @tc.desc : Test Flush interface. Returns false, if the recorder state is not RECORDER_RUNNING.
+* @tc.name : Test Flush API via illegal state, CAPTURER_STOPPED: call Stop before Flush.
+* @tc.number: Audio_Capturer_Flush_004
+* @tc.desc : Test Flush interface. Returns false, if the capturer state is not CAPTURER_RUNNING.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_Flush_004, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_Flush_004, TestSize.Level1)
{
int32_t ret = -1;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- ret = AudioRecorderModuleTest::InitializeRecorder(audioRecorder);
+ ret = AudioCapturerModuleTest::InitializeCapturer(audioCapturer);
EXPECT_EQ(SUCCESS, ret);
- bool isStarted = audioRecorder->Start();
+ bool isStarted = audioCapturer->Start();
EXPECT_EQ(true, isStarted);
- bool isStopped = audioRecorder->Stop();
+ bool isStopped = audioCapturer->Stop();
EXPECT_EQ(true, isStopped);
- bool isFlushed = audioRecorder->Flush();
+ bool isFlushed = audioCapturer->Flush();
EXPECT_EQ(false, isFlushed);
- audioRecorder->Release();
+ audioCapturer->Release();
}
/**
-* @tc.name : Test Flush API via illegal state, RECORDER_RELEASED: call Release before Flush.
-* @tc.number: Audio_Recorder_Flush_005
-* @tc.desc : Test Flush interface. Returns false, if the recorder state is not RECORDER_RUNNING.
+* @tc.name : Test Flush API via illegal state, CAPTURER_RELEASED: call Release before Flush.
+* @tc.number: Audio_Capturer_Flush_005
+* @tc.desc : Test Flush interface. Returns false, if the capturer state is not CAPTURER_RUNNING.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_Flush_005, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_Flush_005, TestSize.Level1)
{
int32_t ret = -1;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- ret = AudioRecorderModuleTest::InitializeRecorder(audioRecorder);
+ ret = AudioCapturerModuleTest::InitializeCapturer(audioCapturer);
EXPECT_EQ(SUCCESS, ret);
- bool isStarted = audioRecorder->Start();
+ bool isStarted = audioCapturer->Start();
EXPECT_EQ(true, isStarted);
- bool isReleased = audioRecorder->Release();
+ bool isReleased = audioCapturer->Release();
EXPECT_EQ(true, isReleased);
- bool isFlushed = audioRecorder->Flush();
+ bool isFlushed = audioCapturer->Flush();
EXPECT_EQ(false, isFlushed);
- audioRecorder->Release();
+ audioCapturer->Release();
}
/**
* @tc.name : Test Stop API.
-* @tc.number: Audio_Recorder_Stop_001
+* @tc.number: Audio_Capturer_Stop_001
* @tc.desc : Test Stop interface. Returns true, if the stop is successful.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_Stop_001, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_Stop_001, TestSize.Level1)
{
int32_t ret = -1;
bool isBlockingRead = true;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- ret = AudioRecorderModuleTest::InitializeRecorder(audioRecorder);
+ ret = AudioCapturerModuleTest::InitializeCapturer(audioCapturer);
EXPECT_EQ(SUCCESS, ret);
- bool isStarted = audioRecorder->Start();
+ bool isStarted = audioCapturer->Start();
EXPECT_EQ(true, isStarted);
size_t bufferLen;
- ret = audioRecorder->GetBufferSize(bufferLen);
+ ret = audioCapturer->GetBufferSize(bufferLen);
EXPECT_EQ(SUCCESS, ret);
uint8_t *buffer = (uint8_t *) malloc(bufferLen);
ASSERT_NE(nullptr, buffer);
- int32_t bytesRead = audioRecorder->Read(*buffer, bufferLen, isBlockingRead);
+ int32_t bytesRead = audioCapturer->Read(*buffer, bufferLen, isBlockingRead);
EXPECT_GE(bytesRead, VALUE_ZERO);
- audioRecorder->Flush();
+ audioCapturer->Flush();
- bool isStopped = audioRecorder->Stop();
+ bool isStopped = audioCapturer->Stop();
EXPECT_EQ(true, isStopped);
- audioRecorder->Release();
+ audioCapturer->Release();
free(buffer);
}
/**
-* @tc.name : Test Stop API via illegal state, RECORDER_NEW: call Stop without Initializing the recorder.
-* @tc.number: Audio_Recorder_Stop_002
-* @tc.desc : Test Stop interface. Returns false, if the recorder state is not RECORDER_RUNNING.
+* @tc.name : Test Stop API via illegal state, CAPTURER_NEW: call Stop without Initializing the capturer.
+* @tc.number: Audio_Capturer_Stop_002
+* @tc.desc : Test Stop interface. Returns false, if the capturer state is not CAPTURER_RUNNING.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_Stop_002, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_Stop_002, TestSize.Level1)
{
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- bool isStopped = audioRecorder->Stop();
+ bool isStopped = audioCapturer->Stop();
EXPECT_EQ(false, isStopped);
}
/**
-* @tc.name : Test Stop API via illegal state, RECORDER_PREPARED: call Stop without Start.
-* @tc.number: Audio_Recorder_Stop_003
-* @tc.desc : Test Stop interface. Returns false, if the recorder state is not RECORDER_RUNNING.
+* @tc.name : Test Stop API via illegal state, CAPTURER_PREPARED: call Stop without Start.
+* @tc.number: Audio_Capturer_Stop_003
+* @tc.desc : Test Stop interface. Returns false, if the capturer state is not CAPTURER_RUNNING.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_Stop_003, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_Stop_003, TestSize.Level1)
{
int32_t ret = -1;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- ret = AudioRecorderModuleTest::InitializeRecorder(audioRecorder);
+ ret = AudioCapturerModuleTest::InitializeCapturer(audioCapturer);
EXPECT_EQ(SUCCESS, ret);
- bool isStopped = audioRecorder->Stop();
+ bool isStopped = audioCapturer->Stop();
EXPECT_EQ(false, isStopped);
- audioRecorder->Release();
+ audioCapturer->Release();
}
/**
-* @tc.name : Test Stop API via illegal state, RECORDER_RELEASED: call Stop after Release.
-* @tc.number: Audio_Recorder_Stop_004
-* @tc.desc : Test Stop interface. Returns false, if the recorder state is not RECORDER_RUNNING.
+* @tc.name : Test Stop API via illegal state, CAPTURER_RELEASED: call Stop after Release.
+* @tc.number: Audio_Capturer_Stop_004
+* @tc.desc : Test Stop interface. Returns false, if the capturer state is not CAPTURER_RUNNING.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_Stop_004, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_Stop_004, TestSize.Level1)
{
int32_t ret = -1;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- ret = AudioRecorderModuleTest::InitializeRecorder(audioRecorder);
+ ret = AudioCapturerModuleTest::InitializeCapturer(audioCapturer);
EXPECT_EQ(SUCCESS, ret);
- bool isStarted = audioRecorder->Start();
+ bool isStarted = audioCapturer->Start();
EXPECT_EQ(true, isStarted);
- bool isReleased = audioRecorder->Release();
+ bool isReleased = audioCapturer->Release();
EXPECT_EQ(true, isReleased);
- bool isStopped = audioRecorder->Stop();
+ bool isStopped = audioCapturer->Stop();
EXPECT_EQ(false, isStopped);
}
/**
* @tc.name : Test Stop API via legal state. call Start, Stop, Start and Stop again
-* @tc.number: Audio_Recorder_Stop_005
+* @tc.number: Audio_Capturer_Stop_005
* @tc.desc : Test Stop interface. Returns true , if the stop is successful.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_Stop_005, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_Stop_005, TestSize.Level1)
{
int32_t ret = -1;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- ret = AudioRecorderModuleTest::InitializeRecorder(audioRecorder);
+ ret = AudioCapturerModuleTest::InitializeCapturer(audioCapturer);
EXPECT_EQ(SUCCESS, ret);
- bool isStarted = audioRecorder->Start();
+ bool isStarted = audioCapturer->Start();
EXPECT_EQ(true, isStarted);
- bool isStopped = audioRecorder->Stop();
+ bool isStopped = audioCapturer->Stop();
EXPECT_EQ(true, isStopped);
- isStarted = audioRecorder->Start();
+ isStarted = audioCapturer->Start();
EXPECT_EQ(true, isStarted);
- isStopped = audioRecorder->Stop();
+ isStopped = audioCapturer->Stop();
EXPECT_EQ(true, isStopped);
}
/**
* @tc.name : Test Release API.
-* @tc.number: Audio_Recorder_Release_001
+* @tc.number: Audio_Capturer_Release_001
* @tc.desc : Test Release interface. Returns true, if the release is successful.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_Release_001, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_Release_001, TestSize.Level1)
{
int32_t ret = -1;
bool isBlockingRead = true;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- ret = AudioRecorderModuleTest::InitializeRecorder(audioRecorder);
+ ret = AudioCapturerModuleTest::InitializeCapturer(audioCapturer);
EXPECT_EQ(SUCCESS, ret);
- bool isStarted = audioRecorder->Start();
+ bool isStarted = audioCapturer->Start();
EXPECT_EQ(true, isStarted);
size_t bufferLen;
- ret = audioRecorder->GetBufferSize(bufferLen);
+ ret = audioCapturer->GetBufferSize(bufferLen);
EXPECT_EQ(SUCCESS, ret);
uint8_t *buffer = (uint8_t *) malloc(bufferLen);
ASSERT_NE(nullptr, buffer);
- int32_t bytesRead = audioRecorder->Read(*buffer, bufferLen, isBlockingRead);
+ int32_t bytesRead = audioCapturer->Read(*buffer, bufferLen, isBlockingRead);
EXPECT_GE(bytesRead, VALUE_ZERO);
- audioRecorder->Flush();
- audioRecorder->Stop();
+ audioCapturer->Flush();
+ audioCapturer->Stop();
- bool isReleased = audioRecorder->Release();
+ bool isReleased = audioCapturer->Release();
EXPECT_EQ(true, isReleased);
free(buffer);
}
/**
-* @tc.name : Test Release API via illegal state, RECORDER_NEW: Call Release without initializing the recorder.
-* @tc.number: Audio_Recorder_Release_002
-* @tc.desc : Test Release interface, Returns false, if the state is RECORDER_NEW.
+* @tc.name : Test Release API via illegal state, CAPTURER_NEW: Call Release without initializing the capturer.
+* @tc.number: Audio_Capturer_Release_002
+* @tc.desc : Test Release interface, Returns false, if the state is CAPTURER_NEW.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_Release_002, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_Release_002, TestSize.Level1)
{
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- bool isReleased = audioRecorder->Release();
+ bool isReleased = audioCapturer->Release();
EXPECT_EQ(false, isReleased);
}
/**
-* @tc.name : Test Release API via illegal state, RECORDER_RELEASED: call Release repeatedly.
-* @tc.number: Audio_Recorder_Release_003
-* @tc.desc : Test Release interface. Returns false, if the state is already RECORDER_RELEASED.
+* @tc.name : Test Release API via illegal state, CAPTURER_RELEASED: call Release repeatedly.
+* @tc.number: Audio_Capturer_Release_003
+* @tc.desc : Test Release interface. Returns false, if the state is already CAPTURER_RELEASED.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_Release_003, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_Release_003, TestSize.Level1)
{
int32_t ret = -1;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- ret = AudioRecorderModuleTest::InitializeRecorder(audioRecorder);
+ ret = AudioCapturerModuleTest::InitializeCapturer(audioCapturer);
EXPECT_EQ(SUCCESS, ret);
- bool isReleased = audioRecorder->Release();
+ bool isReleased = audioCapturer->Release();
EXPECT_EQ(true, isReleased);
- isReleased = audioRecorder->Release();
+ isReleased = audioCapturer->Release();
EXPECT_EQ(false, isReleased);
}
/**
-* @tc.name : Test Release API via legal state, RECORDER_RUNNING: call Release after Start
-* @tc.number: Audio_Recorder_Release_004
+* @tc.name : Test Release API via legal state, CAPTURER_RUNNING: call Release after Start
+* @tc.number: Audio_Capturer_Release_004
* @tc.desc : Test Release interface. Returns true, if the release is successful.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_Release_004, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_Release_004, TestSize.Level1)
{
int32_t ret = -1;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- ret = AudioRecorderModuleTest::InitializeRecorder(audioRecorder);
+ ret = AudioCapturerModuleTest::InitializeCapturer(audioCapturer);
EXPECT_EQ(SUCCESS, ret);
- bool isStarted = audioRecorder->Start();
+ bool isStarted = audioCapturer->Start();
EXPECT_EQ(true, isStarted);
- bool isReleased = audioRecorder->Release();
+ bool isReleased = audioCapturer->Release();
EXPECT_EQ(true, isReleased);
}
/**
-* @tc.name : Test Release API via legal state, RECORDER_STOPPED: call release after Start and Stop
-* @tc.number: Audio_Recorder_Release_005
+* @tc.name : Test Release API via legal state, CAPTURER_STOPPED: call release after Start and Stop
+* @tc.number: Audio_Capturer_Release_005
* @tc.desc : Test Release interface. Returns true, if the release is successful.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_Release_005, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_Release_005, TestSize.Level1)
{
int32_t ret = -1;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- ret = AudioRecorderModuleTest::InitializeRecorder(audioRecorder);
+ ret = AudioCapturerModuleTest::InitializeCapturer(audioCapturer);
EXPECT_EQ(SUCCESS, ret);
- bool isStarted = audioRecorder->Start();
+ bool isStarted = audioCapturer->Start();
EXPECT_EQ(true, isStarted);
- bool isStopped = audioRecorder->Stop();
+ bool isStopped = audioCapturer->Stop();
EXPECT_EQ(true, isStopped);
- bool isReleased = audioRecorder->Release();
+ bool isReleased = audioCapturer->Release();
EXPECT_EQ(true, isReleased);
}
/**
* @tc.name : Test GetStatus API.
-* @tc.number: Audio_Recorder_GetStatus_001
+* @tc.number: Audio_Capturer_GetStatus_001
* @tc.desc : Test GetStatus interface. Returns correct state on success.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_GetStatus_001, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_GetStatus_001, TestSize.Level1)
{
int32_t ret = -1;
- RecorderState state = RECORDER_INVALID;
+ CapturerState state = CAPTURER_INVALID;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
- state = audioRecorder->GetStatus();
- EXPECT_EQ(RECORDER_NEW, state);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
+ state = audioCapturer->GetStatus();
+ EXPECT_EQ(CAPTURER_NEW, state);
- AudioRecorderParams recorderParams;
- recorderParams.audioSampleFormat = SAMPLE_S16LE;
- recorderParams.samplingRate = SAMPLE_RATE_44100;
- recorderParams.audioChannel = STEREO;
- recorderParams.audioEncoding = ENCODING_PCM;
- ret = audioRecorder->SetParams(recorderParams);
+ AudioCapturerParams capturerParams;
+ capturerParams.audioSampleFormat = SAMPLE_S16LE;
+ capturerParams.samplingRate = SAMPLE_RATE_44100;
+ capturerParams.audioChannel = STEREO;
+ capturerParams.audioEncoding = ENCODING_PCM;
+ ret = audioCapturer->SetParams(capturerParams);
EXPECT_EQ(SUCCESS, ret);
- state = audioRecorder->GetStatus();
- EXPECT_EQ(RECORDER_PREPARED, state);
+ state = audioCapturer->GetStatus();
+ EXPECT_EQ(CAPTURER_PREPARED, state);
- bool isStarted = audioRecorder->Start();
+ bool isStarted = audioCapturer->Start();
EXPECT_EQ(true, isStarted);
- state = audioRecorder->GetStatus();
- EXPECT_EQ(RECORDER_RUNNING, state);
+ state = audioCapturer->GetStatus();
+ EXPECT_EQ(CAPTURER_RUNNING, state);
- bool isStopped = audioRecorder->Stop();
+ bool isStopped = audioCapturer->Stop();
EXPECT_EQ(true, isStopped);
- state = audioRecorder->GetStatus();
- EXPECT_EQ(RECORDER_STOPPED, state);
+ state = audioCapturer->GetStatus();
+ EXPECT_EQ(CAPTURER_STOPPED, state);
- bool isReleased = audioRecorder->Release();
+ bool isReleased = audioCapturer->Release();
EXPECT_EQ(true, isReleased);
- state = audioRecorder->GetStatus();
- EXPECT_EQ(RECORDER_RELEASED, state);
+ state = audioCapturer->GetStatus();
+ EXPECT_EQ(CAPTURER_RELEASED, state);
}
/**
-* @tc.name : Test GetStatus API, call Start without Initializing the recorder
-* @tc.number: Audio_Recorder_GetStatus_002
-* @tc.desc : Test GetStatus interface. Not changes to RECORDER_RUNNING, if the current state is RECORDER_NEW.
+* @tc.name : Test GetStatus API, call Start without Initializing the capturer
+* @tc.number: Audio_Capturer_GetStatus_002
+* @tc.desc : Test GetStatus interface. Not changes to CAPTURER_RUNNING, if the current state is CAPTURER_NEW.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_GetStatus_002, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_GetStatus_002, TestSize.Level1)
{
- RecorderState state = RECORDER_INVALID;
+ CapturerState state = CAPTURER_INVALID;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- bool isStarted = audioRecorder->Start();
+ bool isStarted = audioCapturer->Start();
EXPECT_EQ(false, isStarted);
- state = audioRecorder->GetStatus();
- EXPECT_NE(RECORDER_RUNNING, state);
- EXPECT_EQ(RECORDER_NEW, state);
+ state = audioCapturer->GetStatus();
+ EXPECT_NE(CAPTURER_RUNNING, state);
+ EXPECT_EQ(CAPTURER_NEW, state);
}
/**
* @tc.name : Test GetStatus API, call Stop without Start
-* @tc.desc : Test GetStatus interface. Not changes to RECORDER_STOPPED, if the current state is RECORDER_PREPARED.
+* @tc.desc : Test GetStatus interface. Not changes to CAPTURER_STOPPED, if the current state is CAPTURER_PREPARED.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_GetStatus_003, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_GetStatus_003, TestSize.Level1)
{
int32_t ret = -1;
- RecorderState state = RECORDER_INVALID;
+ CapturerState state = CAPTURER_INVALID;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- ret = AudioRecorderModuleTest::InitializeRecorder(audioRecorder);
+ ret = AudioCapturerModuleTest::InitializeCapturer(audioCapturer);
EXPECT_EQ(SUCCESS, ret);
- bool isStopped = audioRecorder->Stop();
+ bool isStopped = audioCapturer->Stop();
EXPECT_EQ(false, isStopped);
- state = audioRecorder->GetStatus();
- EXPECT_NE(RECORDER_STOPPED, state);
- EXPECT_EQ(RECORDER_PREPARED, state);
+ state = audioCapturer->GetStatus();
+ EXPECT_NE(CAPTURER_STOPPED, state);
+ EXPECT_EQ(CAPTURER_PREPARED, state);
- audioRecorder->Release();
+ audioCapturer->Release();
}
/**
* @tc.name : Test GetStatus API, call Start, Stop and then Start again
-* @tc.number: Audio_Recorder_GetStatus_004
+* @tc.number: Audio_Capturer_GetStatus_004
* @tc.desc : Test GetStatus interface. Returns correct state on success.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_GetStatus_004, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_GetStatus_004, TestSize.Level1)
{
int32_t ret = -1;
- RecorderState state = RECORDER_INVALID;
+ CapturerState state = CAPTURER_INVALID;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- ret = AudioRecorderModuleTest::InitializeRecorder(audioRecorder);
+ ret = AudioCapturerModuleTest::InitializeCapturer(audioCapturer);
EXPECT_EQ(SUCCESS, ret);
- bool isStarted = audioRecorder->Start();
+ bool isStarted = audioCapturer->Start();
EXPECT_EQ(true, isStarted);
- state = audioRecorder->GetStatus();
- EXPECT_EQ(RECORDER_RUNNING, state);
+ state = audioCapturer->GetStatus();
+ EXPECT_EQ(CAPTURER_RUNNING, state);
- bool isStopped = audioRecorder->Stop();
+ bool isStopped = audioCapturer->Stop();
EXPECT_EQ(true, isStopped);
- state = audioRecorder->GetStatus();
- EXPECT_EQ(RECORDER_STOPPED, state);
+ state = audioCapturer->GetStatus();
+ EXPECT_EQ(CAPTURER_STOPPED, state);
- isStarted = audioRecorder->Start();
+ isStarted = audioCapturer->Start();
EXPECT_EQ(true, isStarted);
- state = audioRecorder->GetStatus();
- EXPECT_EQ(RECORDER_RUNNING, state);
+ state = audioCapturer->GetStatus();
+ EXPECT_EQ(CAPTURER_RUNNING, state);
- audioRecorder->Release();
+ audioCapturer->Release();
}
/**
* @tc.name : Test GetStatus API, call Release without initializing
-* @tc.number: Audio_Recorder_GetStatus_005
-* @tc.desc : Test GetStatus interface. Not changes to RECORDER_RELEASED, if the current state is RECORDER_NEW.
+* @tc.number: Audio_Capturer_GetStatus_005
+* @tc.desc : Test GetStatus interface. Not changes to CAPTURER_RELEASED, if the current state is CAPTURER_NEW.
*/
-HWTEST(AudioRecorderModuleTest, Audio_Recorder_GetStatus_005, TestSize.Level1)
+HWTEST(AudioCapturerModuleTest, Audio_Capturer_GetStatus_005, TestSize.Level1)
{
- RecorderState state = RECORDER_INVALID;
+ CapturerState state = CAPTURER_INVALID;
- unique_ptr audioRecorder = AudioRecorder::Create(STREAM_MUSIC);
- ASSERT_NE(nullptr, audioRecorder);
+ unique_ptr audioCapturer = AudioCapturer::Create(STREAM_MUSIC);
+ ASSERT_NE(nullptr, audioCapturer);
- bool isReleased = audioRecorder->Release();
+ bool isReleased = audioCapturer->Release();
EXPECT_EQ(false, isReleased);
- state = audioRecorder->GetStatus();
- EXPECT_NE(RECORDER_RELEASED, state);
- EXPECT_EQ(RECORDER_NEW, state);
+ state = audioCapturer->GetStatus();
+ EXPECT_NE(CAPTURER_RELEASED, state);
+ EXPECT_EQ(CAPTURER_NEW, state);
}
} // namespace AudioStandard
} // namespace OHOS
diff --git a/interfaces/innerkits/native/audiocapturer/BUILD.gn b/interfaces/innerkits/native/audiocapturer/BUILD.gn
index 29ab3eef889156b5f09433669dacec9a71358a38..2fd5a9411470f8d5065797f448e211a2455d7530 100644
--- a/interfaces/innerkits/native/audiocapturer/BUILD.gn
+++ b/interfaces/innerkits/native/audiocapturer/BUILD.gn
@@ -13,40 +13,43 @@
import("//build/ohos.gni")
-ohos_shared_library("audio_capturer") {
- install_enable = true
- sources = [
- "//foundation/multimedia/audio_standard/frameworks/innerkitsimpl/audiocapturer/src/audio_capturer.cpp",
- "//foundation/multimedia/audio_standard/frameworks/innerkitsimpl/audiocapturer/src/audio_capturer_impl.cpp",
- "//foundation/multimedia/audio_standard/frameworks/innerkitsimpl/audiocapturer/src/audio_encoder.cpp",
- "//foundation/multimedia/audio_standard/frameworks/innerkitsimpl/audiocapturer/src/audio_source.cpp",
- ]
- cflags = [ "-fPIC" ]
- cflags += [ "-Wall" ]
- cflags_cc = cflags
+pulseaudio_dir = "//third_party/pulseaudio"
+
+group("audio_capturer_test_packages") {
+ deps = [ ":audio_capturer_test" ]
+}
+
+config("audio_capturer_config") {
include_dirs = [
+ "//foundation/multimedia/audio_standard/interfaces/innerkits/native/audiocapturer/include",
"//foundation/multimedia/audio_standard/frameworks/innerkitsimpl/audiocapturer/include",
"//foundation/multimedia/audio_standard/frameworks/innerkitsimpl/common/include",
- "//foundation/multimedia/media_standard/interfaces/innerkits/native/media/include",
- "//utils/native/base/include",
- "//base/hiviewdfx/hilog/interfaces/native/innerkits/include",
- "//drivers/peripheral/audio/interfaces/include",
- "//drivers/peripheral/codec/interfaces/include",
- "//third_party/bounds_checking_function/include",
- ]
- public_configs = [ ":audio_external_library_config" ]
- ldflags = [
- "-lcodec",
- "-laudio_hw",
+ "//foundation/multimedia/audio_standard/interfaces/innerkits/native/audiocommon/include",
+ "//foundation/multimedia/audio_standard/interfaces/innerkits/native/audiostream/include",
+ "//foundation/multimedia/audio_standard/interfaces/innerkits/native/audiosession/include",
+ "//foundation/multimedia/audio_standard/services/include",
+ "//foundation/multimedia/audio_standard/services/include/client",
+ "$pulseaudio_dir/src",
+ "$pulseaudio_dir/confgure/src",
]
- ldflags += [
- "-L../../device/hisilicon/hardware/media/hal/codec/hi3516dv300/llvm/ext/libs",
- "-L../../device/hisilicon/hardware/media/hal/audio/hi3516dv300/llvm/ext/libs",
- ]
- deps = [
- "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog",
- "//third_party/bounds_checking_function:libsec_static",
+
+ cflags = [
+ "-Wall",
+ "-Werror",
]
+}
+
+ohos_shared_library("audio_capturer") {
+ install_enable = true
+
+ configs = [ ":audio_capturer_config" ]
+
+ sources = [ "//foundation/multimedia/audio_standard/frameworks/innerkitsimpl/audiocapturer/src/audio_capturer.cpp" ]
+
+ deps = [ "//foundation/multimedia/audio_standard/interfaces/innerkits/native/audiomanager:audio_client" ]
+
+ public_configs = [ ":audio_external_library_config" ]
+
part_name = "multimedia_audio_standard"
subsystem_name = "multimedia"
}
@@ -54,3 +57,18 @@ ohos_shared_library("audio_capturer") {
config("audio_external_library_config") {
include_dirs = [ "//foundation/multimedia/audio_standard/interfaces/innerkits/native/audiocapturer/include" ]
}
+
+ohos_executable("audio_capturer_test") {
+ install_enable = true
+
+ sources = [ "//foundation/multimedia/audio_standard/services/test/audio_capturer_test.cpp" ]
+
+ configs = [ ":audio_capturer_config" ]
+
+ deps = [ "//foundation/multimedia/audio_standard/interfaces/innerkits/native/audiocapturer:audio_capturer" ]
+
+ external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
+
+ part_name = "multimedia_audio_standard"
+ subsystem_name = "multimedia"
+}
diff --git a/interfaces/innerkits/native/audiocapturer/include/audio_capturer.h b/interfaces/innerkits/native/audiocapturer/include/audio_capturer.h
old mode 100755
new mode 100644
index 9bc0e94e3968e90a068fa27a2311f231ccfd57f6..c794a788568d2f4f2886d7394527f28bf0e88cdb
--- a/interfaces/innerkits/native/audiocapturer/include/audio_capturer.h
+++ b/interfaces/innerkits/native/audiocapturer/include/audio_capturer.h
@@ -13,182 +13,102 @@
* limitations under the License.
*/
-/**
- * @addtogroup MultiMedia_AudioCapturer
- * @{
- *
- * @brief Declares APIs in the AudioCapturer class for audio capture.
- *
- *
- * @since 1.0
- * @version 1.0
- */
-
-/**
- * @file audio_capturer.h
- *
- * @brief Provides the AudioCapturer class to implement operations related to audio capture.
- *
- *
- * @since 1.0
- * @version 1.0
- */
-
#ifndef AUDIO_CAPTURER_H
#define AUDIO_CAPTURER_H
-#include
-#include
-#include
#include
-#include "media_errors.h"
-#include "media_info.h"
+#include "audio_info.h"
+#include "timestamp.h"
namespace OHOS {
-namespace Audio {
+namespace AudioStandard {
/**
- * @brief Defines information about audio capture parameters, including the input source, audio codec format,sampling
- * rate (Hz), number of audio channels, bit rate, stream type and bit width.
- *
- * @since 1.0
- * @version 1.0
+ * @brief Defines information about audio capturer parameters
*/
-struct AudioCapturerInfo {
+struct AudioCapturerParams {
/** Audio source type */
AudioSourceType inputSource = AUDIO_MIC;
/** Audio codec format */
- AudioCodecFormat audioFormat = AUDIO_DEFAULT;
+ AudioEncodingType audioEncoding = ENCODING_PCM;
/** Sampling rate */
- int32_t sampleRate = 0;
+ AudioSamplingRate samplingRate = SAMPLE_RATE_44100;
/** Number of audio channels */
- int32_t channelCount = 0;
- /** Bit rate */
- int32_t bitRate = 0;
+ AudioChannel audioChannel = MONO;
/** Audio stream type */
- AudioStreamType streamType = TYPE_MEDIA;
- /** Bit width */
- AudioBitWidth bitWidth = BIT_WIDTH_16;
+ AudioStreamType streamType = STREAM_MEDIA;
+ /** audioSampleFormat */
+ AudioSampleFormat audioSampleFormat = SAMPLE_S16LE;
};
/**
- * @brief Represents timestamp information, including the frame position information and high-resolution time source.
- *
- * @since 1.0
- * @version 1.0
+ * @brief Enumerates the capturing states of the current device.
*/
-class Timestamp {
-public:
- Timestamp() : framePosition(0)
- {
- time.tv_sec = 0;
- time.tv_nsec = 0;
- }
- virtual ~Timestamp() = default;
- uint32_t framePosition;
- struct timespec time;
-
- /**
- * @brief Enumerates the time base of this Timestamp. 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
+enum CapturerState {
+ /** Create new capturer instance */
+ CAPTURER_NEW,
+ /** Capturer Prepared state */
+ CAPTURER_PREPARED,
+ /** Capturer Running state */
+ CAPTURER_RUNNING,
+ /** Capturer Stopped state */
+ CAPTURER_STOPPED,
+ /** Capturer Released state */
+ CAPTURER_RELEASED,
+ /** Capturer INVALID state */
+ CAPTURER_INVALID
};
/**
* @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 true if the minimum number of frames is successfully obtained; returns false
- * otherwise.
- * @since 1.0
- * @version 1.0
- */
- static bool GetMinFrameCount(int32_t sampleRate, int32_t channelCount, AudioCodecFormat audioFormat,
- size_t &frameCount);
+ * @brief creater capturer instance.
+ */
+ static std::unique_ptr Create(AudioStreamType audioStreamType);
/**
* @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 -1
- * if an exception occurs.
- * @since 1.0
- * @version 1.0
+ * @param frameCount Indicates the pointer in which framecount will be written
+ * @return Returns {@link SUCCESS} if frameCount is successfully obtained; returns an error code
+ * defined in {@link audio_errors.h} otherwise.
*/
- uint64_t GetFrameCount();
+ virtual int32_t GetFrameCount(uint32_t &frameCount) const = 0;
/**
* @brief Sets audio capture parameters.
*
- * @param info Indicates information about audio capture parameters to set. For details, see
- * {@link AudioCapturerInfo}.
+ * @param params Indicates information about audio capture parameters to set. For details, see
+ * {@link AudioCapturerParams}.
* @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
+ * in {@link audio_errors.h} otherwise.
*/
- int32_t SetCapturerInfo(const AudioCapturerInfo info);
+ virtual int32_t SetParams(const AudioCapturerParams params) const = 0;
/**
- * @brief Obtains audio capture parameters.
+ * @brief Obtains audio capturer parameters.
*
- * This function can be called after {@link SetCapturerInfo} is successful.
+ * This function can be called after {@link SetParams} is successful.
*
- * @param info Indicates information about audio capture parameters. For details, see {@link AudioCapturerInfo}.
+ * @param params Indicates information about audio capturer parameters.For details,see
+ * {@link AudioCapturerParams}.
* @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
+ * defined in {@link audio_errors.h} otherwise.
*/
- int32_t GetCapturerInfo(AudioCapturerInfo &info);
+ virtual int32_t GetParams(AudioCapturerParams ¶ms) const = 0;
/**
- * @brief Starts audio recording.
+ * @brief Starts audio capturing.
*
- * @return Returns true if the recording is successfully started; returns false otherwise.
- * @since 1.0
- * @version 1.0
+ * @return Returns true if the capturing is successfully started; returns false otherwise.
*/
- bool Start();
+ virtual bool Start() const = 0;
/**
- * @brief Reads audio data.
+ * @brief capture 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.
@@ -199,55 +119,87 @@ public:
* userSize. If the reading fails, one of the following error codes is returned.
* ERR_INVALID_PARAM: The input parameter is incorrect.
* ERR_ILLEGAL_STATE: The AudioCapturer instance is not initialized.
- * ERR_SOURCE_NOT_SET: The state of hardware device instance is abnormal.
- * @since 1.0
- * @version 1.0
+ * ERR_INVALID_READ: The read size < 0.
*/
- int32_t Read(uint8_t &buffer, size_t userSize, bool isBlockingRead);
+ virtual int32_t Read(uint8_t &buffer, size_t userSize, bool isBlockingRead) const = 0;
/**
* @brief Obtains the audio capture state.
*
- * @return Returns the audio capture state defined in {@link State}.
- * @since 1.0
- * @version 1.0
+ * @return Returns the audio capture state defined in {@link CapturerState}.
*/
- State GetStatus();
+ virtual CapturerState GetStatus() const = 0;
/**
- * @brief Obtains the timestamp.
+ * @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} or
- * {@link Timestamp.Timebase#MONOTONIC}.
+ * @param base Indicates the time base, which can be {@link Timestamp.Timestampbase#BOOTTIME} or
+ * {@link Timestamp.Timestampbase#MONOTONIC}.
* @return Returns true if the timestamp is successfully obtained; returns false otherwise.
- * @since 1.0
- * @version 1.0
*/
- bool GetAudioTime(Timestamp ×tamp, Timestamp::Timebase base);
+ virtual bool GetAudioTime(Timestamp ×tamp, Timestamp::Timestampbase base) const = 0;
/**
- * @brief Stops audio recording.
+ * @brief Stops audio capturing.
*
- * @return Returns true if the recording is successfully stopped; returns false otherwise.
- * @since 1.0
- * @version 1.0
+ * @return Returns true if the capturing is successfully stopped; returns false otherwise.
*/
- bool Stop();
+ virtual bool Stop() const = 0;
+ /**
+ * @brief flush capture stream.
+ *
+ * @return Returns true if the object is successfully flushed; returns false otherwise.
+ */
+ virtual bool Flush() const = 0;
/**
* @brief Releases a local AudioCapturer object.
*
* @return Returns true if the object is successfully released; returns false otherwise.
- * @since 1.0
- * @version 1.0
*/
- bool Release();
+ virtual bool Release() const = 0;
+
+ /**
+ * @brief Obtains a reasonable minimum buffer size for capturer, however, the capturer can
+ * accept other read sizes as well.
+ *
+ * @param bufferSize Indicates a buffersize pointer value that wil be written.
+ * @return Returns {@link SUCCESS} if bufferSize is successfully obtained; returns an error code
+ * defined in {@link audio_errors.h} otherwise.
+ */
+ virtual int32_t GetBufferSize(size_t &bufferSize) const = 0;
+
+ /**
+ * @brief Obtains the capturer supported formats.
+ *
+ * @return vector with capturer supported formats.
+ */
+ static std::vector GetSupportedFormats();
-private:
- class AudioCapturerImpl;
- std::unique_ptr impl_;
+ /**
+ * @brief Obtains the capturer supported channels.
+ *
+ * @return vector with capturer supported channels.
+ */
+ static std::vector GetSupportedChannels();
+
+ /**
+ * @brief Obtains the capturer supported encoding types.
+ *
+ * @return vector with capturer supported encoding types.
+ */
+ static std::vector GetSupportedEncodingTypes();
+
+ /**
+ * @brief Obtains the capturer supported SupportedSamplingRates.
+ *
+ * @return vector with capturer supported SupportedSamplingRates.
+ */
+ static std::vector GetSupportedSamplingRates();
+
+ virtual ~AudioCapturer();
};
-} // namespace Audio
+} // namespace AudioStandard
} // namespace OHOS
#endif // AUDIO_CAPTURER_H
diff --git a/interfaces/innerkits/native/audiocommon/include/audio_info.h b/interfaces/innerkits/native/audiocommon/include/audio_info.h
index 21c16df9d7a9e7fd468cfd3beb4e57af2b784251..9c3d99e499ff5b37a545802867160079106bda0d 100644
--- a/interfaces/innerkits/native/audiocommon/include/audio_info.h
+++ b/interfaces/innerkits/native/audiocommon/include/audio_info.h
@@ -208,7 +208,7 @@ struct AudioStreamParams {
uint8_t channels;
};
-// Supported audio parameters for both renderer and recorder
+// Supported audio parameters for both renderer and capturer
const std::vector AUDIO_SUPPORTED_FORMATS {
SAMPLE_U8,
SAMPLE_S16LE,
diff --git a/interfaces/innerkits/native/audiorecorder/BUILD.gn b/interfaces/innerkits/native/audiorecorder/BUILD.gn
deleted file mode 100644
index 12029f91354fe7f5d07bdb59ac8984fbb2b3139f..0000000000000000000000000000000000000000
--- a/interfaces/innerkits/native/audiorecorder/BUILD.gn
+++ /dev/null
@@ -1,92 +0,0 @@
-# Copyright (C) 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/ohos.gni")
-
-pulseaudio_dir = "//third_party/pulseaudio"
-
-group("audio_recorder_test_packages") {
- deps = [
- ":audio_recorder_test",
- ]
-}
-
-config("audio_recorder_config") {
- include_dirs = [
- "//foundation/multimedia/audio_standard/interfaces/innerkits/native/audiorecorder/include",
- "//foundation/multimedia/audio_standard/frameworks/innerkitsimpl/audiorecorder/include",
- "//foundation/multimedia/audio_standard/frameworks/innerkitsimpl/common/include",
- "//foundation/multimedia/audio_standard/interfaces/innerkits/native/audiocommon/include",
- "//foundation/multimedia/audio_standard/interfaces/innerkits/native/audiostream/include",
- "//foundation/multimedia/audio_standard/interfaces/innerkits/native/audiosession/include",
- "//foundation/multimedia/audio_standard/services/include",
- "//foundation/multimedia/audio_standard/services/include/client",
- "$pulseaudio_dir/src",
- "$pulseaudio_dir/confgure/src",
- ]
-
- cflags = [
- "-Wall",
- "-Werror",
- ]
-
-}
-
-ohos_shared_library("audio_recorder") {
- install_enable = true
-
- configs = [
- ":audio_recorder_config",
- ]
-
- sources = [
- "//foundation/multimedia/audio_standard/frameworks/innerkitsimpl/audiorecorder/src/audio_recorder.cpp",
- ]
-
- deps = [
- "//foundation/multimedia/audio_standard/interfaces/innerkits/native/audiomanager:audio_client",
- ]
-
- public_configs = [ ":audio_external_library_config" ]
-
- part_name = "multimedia_audio_standard"
- subsystem_name = "multimedia"
-}
-
-config("audio_external_library_config") {
- include_dirs = [ "//foundation/multimedia/audio_standard/interfaces/innerkits/native/audiorecorder/include" ]
-}
-
-ohos_executable("audio_recorder_test") {
-
- install_enable = true
-
- sources = [
- "//foundation/multimedia/audio_standard/services/test/audio_recorder_test.cpp",
- ]
-
- configs = [
- ":audio_recorder_config",
- ]
-
- deps = [
- "//foundation/multimedia/audio_standard/interfaces/innerkits/native/audiorecorder:audio_recorder",
- ]
-
- external_deps = [
- "hiviewdfx_hilog_native:libhilog",
- ]
-
- part_name = "multimedia_audio_standard"
- subsystem_name = "multimedia"
-}
diff --git a/interfaces/innerkits/native/audiorecorder/include/audio_recorder.h b/interfaces/innerkits/native/audiorecorder/include/audio_recorder.h
deleted file mode 100644
index f557908842850e08a93beb7e647bac9a225ad6a0..0000000000000000000000000000000000000000
--- a/interfaces/innerkits/native/audiorecorder/include/audio_recorder.h
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * Copyright (C) 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.
- */
-
-#ifndef AUDIO_RECORDER_H
-#define AUDIO_RECORDER_H
-
-#include
-
-#include "audio_info.h"
-#include "timestamp.h"
-
-namespace OHOS {
-namespace AudioStandard {
-/**
- * @brief Defines information about audio record parameters
- */
-struct AudioRecorderParams {
- /** Audio source type */
- AudioSourceType inputSource = AUDIO_MIC;
- /** Audio codec format */
- AudioEncodingType audioEncoding = ENCODING_PCM;
- /** Sampling rate */
- AudioSamplingRate samplingRate = SAMPLE_RATE_44100;
- /** Number of audio channels */
- AudioChannel audioChannel = MONO;
- /** Audio stream type */
- AudioStreamType streamType = STREAM_MEDIA;
- /** audioSampleFormat */
- AudioSampleFormat audioSampleFormat = SAMPLE_S16LE;
-};
-
-/**
- * @brief Enumerates the recording states of the current device.
- */
-enum RecorderState {
- /** Create new recorder instance */
- RECORDER_NEW,
- /** Recorder Prepared state */
- RECORDER_PREPARED,
- /** Recorder Running state */
- RECORDER_RUNNING,
- /** Recorder Stopped state */
- RECORDER_STOPPED,
- /** Recorder Released state */
- RECORDER_RELEASED,
- /** Recorder INVALID state */
- RECORDER_INVALID
-};
-
-/**
- * @brief Provides functions for applications to implement audio recording.
- */
-class AudioRecorder {
-public:
- /**
- * @brief creater recorder instance.
- */
- static std::unique_ptr Create(AudioStreamType audioStreamType);
-
- /**
- * @brief Obtains the number of frames required in the current condition, in bytes per sample.
- *
- * @param frameCount Indicates the pointer in which framecount will be written
- * @return Returns {@link SUCCESS} if frameCount is successfully obtained; returns an error code
- * defined in {@link audio_errors.h} otherwise.
- */
- virtual int32_t GetFrameCount(uint32_t &frameCount) const = 0;
-
- /**
- * @brief Sets audio record parameters.
- *
- * @param params Indicates information about audio record parameters to set. For details, see
- * {@link AudioRecorderParams}.
- * @return Returns {@link SUCCESS} if the setting is successful; returns an error code defined
- * in {@link audio_errors.h} otherwise.
- */
- virtual int32_t SetParams(const AudioRecorderParams params) const = 0;
-
- /**
- * @brief Obtains audio recorder parameters.
- *
- * This function can be called after {@link SetParams} is successful.
- *
- * @param params Indicates information about audio recorder parameters.For details,see
- * {@link AudioRecorderParams}.
- * @return Returns {@link SUCCESS} if the parameter information is successfully obtained; returns an error code
- * defined in {@link audio_errors.h} otherwise.
- */
- virtual int32_t GetParams(AudioRecorderParams ¶ms) const = 0;
-
- /**
- * @brief Starts audio recording.
- *
- * @return Returns true if the recording is successfully started; returns false otherwise.
- */
- virtual bool Start() const = 0;
-
- /**
- * @brief record 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.
- * userSize >= frameCount * channelCount * BytesPerSample must evaluate to true. You can call
- * {@link GetFrameCount} to obtain the frameCount 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 0 to
- * userSize. If the reading fails, one of the following error codes is returned.
- * ERR_INVALID_PARAM: The input parameter is incorrect.
- * ERR_ILLEGAL_STATE: The AudioRecorder instance is not initialized.
- * ERR_INVALID_READ: The read size < 0.
- */
- virtual int32_t Read(uint8_t &buffer, size_t userSize, bool isBlockingRead) const = 0;
-
- /**
- * @brief Obtains the audio record state.
- *
- * @return Returns the audio record state defined in {@link RecorderState}.
- */
- virtual RecorderState GetStatus() const = 0;
-
- /**
- * @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.Timestampbase#BOOTTIME} or
- * {@link Timestamp.Timestampbase#MONOTONIC}.
- * @return Returns true if the timestamp is successfully obtained; returns false otherwise.
- */
- virtual bool GetAudioTime(Timestamp ×tamp, Timestamp::Timestampbase base) const = 0;
-
- /**
- * @brief Stops audio recording.
- *
- * @return Returns true if the recording is successfully stopped; returns false otherwise.
- */
- virtual bool Stop() const = 0;
- /**
- * @brief flush record stream.
- *
- * @return Returns true if the object is successfully flushed; returns false otherwise.
- */
- virtual bool Flush() const = 0;
-
- /**
- * @brief Releases a local AudioRecorder object.
- *
- * @return Returns true if the object is successfully released; returns false otherwise.
- */
- virtual bool Release() const = 0;
-
- /**
- * @brief Obtains a reasonable minimum buffer size for recorder, however, the recorder can
- * accept other read sizes as well.
- *
- * @param bufferSize Indicates a buffersize pointer value that wil be written.
- * @return Returns {@link SUCCESS} if bufferSize is successfully obtained; returns an error code
- * defined in {@link audio_errors.h} otherwise.
- */
- virtual int32_t GetBufferSize(size_t &bufferSize) const = 0;
-
- /**
- * @brief Obtains the recorder supported formats.
- *
- * @return vector with recorder supported formats.
- */
- static std::vector GetSupportedFormats();
-
- /**
- * @brief Obtains the recorder supported channels.
- *
- * @return vector with recorder supported channels.
- */
- static std::vector GetSupportedChannels();
-
- /**
- * @brief Obtains the recorder supported encoding types.
- *
- * @return vector with recorder supported encoding types.
- */
- static std::vector GetSupportedEncodingTypes();
-
- /**
- * @brief Obtains the recorder supported SupportedSamplingRates.
- *
- * @return vector with recorder supported SupportedSamplingRates.
- */
- static std::vector GetSupportedSamplingRates();
-
- virtual ~AudioRecorder();
-};
-} // namespace AudioStandard
-} // namespace OHOS
-#endif // AUDIO_RECORDER_H
diff --git a/interfaces/innerkits/native/audiorenderer/BUILD.gn b/interfaces/innerkits/native/audiorenderer/BUILD.gn
index 26cb43c9ecde6c5c27adf959d63974c6b221d090..bfbc38953851adbf90bc08bcc8ca943da4ea3fb0 100644
--- a/interfaces/innerkits/native/audiorenderer/BUILD.gn
+++ b/interfaces/innerkits/native/audiorenderer/BUILD.gn
@@ -17,7 +17,7 @@ pulseaudio_dir = "//third_party/pulseaudio"
config("audio_renderer_config") {
include_dirs = [
- "//foundation/multimedia/audio_standard/interfaces/innerkits/native/audiorecorder/include",
+ "//foundation/multimedia/audio_standard/interfaces/innerkits/native/audiorenderer/include",
"//foundation/multimedia/audio_standard/frameworks/innerkitsimpl/audiorenderer/include",
"//foundation/multimedia/audio_standard/frameworks/innerkitsimpl/common/include",
"//foundation/multimedia/audio_standard/interfaces/innerkits/native/audiocommon/include",
@@ -33,7 +33,6 @@ config("audio_renderer_config") {
"-Wall",
"-Werror",
]
-
}
ohos_shared_library("audio_renderer") {
@@ -52,7 +51,6 @@ ohos_shared_library("audio_renderer") {
}
ohos_executable("audio_renderer_test") {
-
install_enable = true
sources = [ "//foundation/multimedia/audio_standard/services/test/audio_renderer_test.cpp" ]
diff --git a/interfaces/innerkits/native/audiostream/include/audio_stream.h b/interfaces/innerkits/native/audiostream/include/audio_stream.h
index 66694d6f6ea7cda09d9f350f30f6da529583c996..a84edc539a72c08555e956aa1ace1d66a392a110 100644
--- a/interfaces/innerkits/native/audiostream/include/audio_stream.h
+++ b/interfaces/innerkits/native/audiostream/include/audio_stream.h
@@ -79,7 +79,7 @@ public:
bool DrainAudioStream();
size_t Write(uint8_t *buffer, size_t buffer_size);
- // Recorder related APIs
+ // Recording related APIs
int32_t Read(uint8_t &buffer, size_t userSize, bool isBlockingRead);
private:
AudioStreamType eStreamType_;
diff --git a/ohos.build b/ohos.build
index 0b0e2dfe7cc30e8bc94cefb50c98a7390a5a9237..8c3cc5b08b677d815882e89d184afd3c2f4b4b5b 100644
--- a/ohos.build
+++ b/ohos.build
@@ -13,7 +13,7 @@
"//foundation/multimedia/audio_standard/interfaces/kits/js/audio_manager:audio_js",
"//foundation/multimedia/audio_standard/frameworks/innerkitsimpl/pulseaudio:pulseaudio_packages",
"//foundation/multimedia/audio_standard/interfaces/innerkits/native/audiomanager:audio_client_test_packages",
- "//foundation/multimedia/audio_standard/interfaces/innerkits/native/audiorecorder:audio_recorder_test_packages",
+ "//foundation/multimedia/audio_standard/interfaces/innerkits/native/audiocapturer:audio_capturer_test_packages",
"//foundation/multimedia/audio_standard/interfaces/innerkits/native/audiorenderer:audio_renderer_test",
"//foundation/multimedia/audio_standard/services:audio_policy_service_packages",
"//foundation/multimedia/audio_standard/sa_profile:audio_policy_service_sa_profile",
@@ -45,21 +45,11 @@
"name": "//foundation/multimedia/audio_standard/interfaces/innerkits/native/audiocapturer:audio_capturer",
"header": {
"header_files": [
- "audio_capturer.h"
- ],
- "header_base": "//foundation/multimedia/audio_standard/interfaces/innerkits/native/audiocapturer/include"
- }
- },
- {
- "type": "none",
- "name": "//foundation/multimedia/audio_standard/interfaces/innerkits/native/audiorecorder:audio_recorder",
- "header": {
- "header_files": [
- "audio_recorder.h",
+ "audio_capturer.h",
"audio_info.h"
],
"header_base": [
- "//foundation/multimedia/audio_standard/interfaces/innerkits/native/audiorecorder/include",
+ "//foundation/multimedia/audio_standard/interfaces/innerkits/native/audiocapturer/include",
"//foundation/multimedia/audio_standard/interfaces/innerkits/native/audiocommon/include"
]
}
diff --git a/services/include/client/audio_service_client.h b/services/include/client/audio_service_client.h
index a9374d1df27e6b0c15e1a584a165f72e1d7297f6..a51c7ab91d1e7184e0480ba07b8727e5c56beac8 100644
--- a/services/include/client/audio_service_client.h
+++ b/services/include/client/audio_service_client.h
@@ -65,9 +65,9 @@ public:
virtual void OnEventCb(AudioServiceEventTypes error) const = 0;
};
-class AudioRecorderCallbacks {
+class AudioCapturerCallbacks {
public:
- virtual ~AudioRecorderCallbacks();
+ virtual ~AudioCapturerCallbacks();
virtual void OnSourceDeviceUpdatedCb() const = 0;
// Need to check required state changes to update applications
virtual void OnStreamStateChangeCb() const = 0;
@@ -264,7 +264,7 @@ public:
* @param cb indicates pointer for registered callbacks
* @return none
*/
- void RegisterAudioRecorderCallbacks(const AudioRecorderCallbacks &cb);
+ void RegisterAudioCapturerCallbacks(const AudioCapturerCallbacks &cb);
private:
pa_threaded_mainloop *mainLoop;
@@ -287,7 +287,7 @@ private:
// To be set while using audio stream
// functionality for callbacks
AudioRendererCallbacks* mAudioRendererCallbacks;
- AudioRecorderCallbacks* mAudioRecorderCallbacks;
+ AudioCapturerCallbacks* mAudioCapturerCallbacks;
std::map sinkDevices;
std::map sourceDevices;
diff --git a/services/src/client/audio_service_client.cpp b/services/src/client/audio_service_client.cpp
index a20a575a87727e760ee54e1a03a3e91127df0b3a..e0a1048ce5f8064025e0e38d1e43549cd345f395 100644
--- a/services/src/client/audio_service_client.cpp
+++ b/services/src/client/audio_service_client.cpp
@@ -22,7 +22,7 @@ using namespace std;
namespace OHOS {
namespace AudioStandard {
AudioRendererCallbacks::~AudioRendererCallbacks() = default;
-AudioRecorderCallbacks::~AudioRecorderCallbacks() = default;
+AudioCapturerCallbacks::~AudioCapturerCallbacks() = default;
const uint64_t LATENCY_IN_MSEC = 200UL;
@@ -202,7 +202,7 @@ AudioServiceClient::AudioServiceClient()
clientInfo.clear();
mAudioRendererCallbacks = NULL;
- mAudioRecorderCallbacks = NULL;
+ mAudioCapturerCallbacks = NULL;
internalReadBuffer = NULL;
mainLoop = NULL;
paStream = NULL;
@@ -258,7 +258,7 @@ void AudioServiceClient::ResetPAAudioClient()
clientInfo.clear();
mAudioRendererCallbacks = NULL;
- mAudioRecorderCallbacks = NULL;
+ mAudioCapturerCallbacks = NULL;
internalReadBuffer = NULL;
mainLoop = NULL;
@@ -1077,10 +1077,10 @@ void AudioServiceClient::RegisterAudioRendererCallbacks(const AudioRendererCallb
mAudioRendererCallbacks = (AudioRendererCallbacks *) &cb;
}
-void AudioServiceClient::RegisterAudioRecorderCallbacks(const AudioRecorderCallbacks &cb)
+void AudioServiceClient::RegisterAudioCapturerCallbacks(const AudioCapturerCallbacks &cb)
{
MEDIA_INFO_LOG("Registering audio record callbacks");
- mAudioRecorderCallbacks = (AudioRecorderCallbacks *) &cb;
+ mAudioCapturerCallbacks = (AudioCapturerCallbacks *) &cb;
}
} // namespace AudioStandard
} // namespace OHOS
diff --git a/services/src/client/audio_stream.cpp b/services/src/client/audio_stream.cpp
index 7a47380d3365d1bba786998b33df8f3f69bf0ee7..8627146b5445c21a936e8b6be747d3cc6f243ded 100644
--- a/services/src/client/audio_stream.cpp
+++ b/services/src/client/audio_stream.cpp
@@ -183,7 +183,7 @@ int32_t AudioStream::SetAudioStreamInfo(const AudioStreamParams info)
ret = Initialize(AUDIO_SERVICE_CLIENT_PLAYBACK);
break;
case AUDIO_MODE_RECORD:
- MEDIA_DEBUG_LOG("AudioStream: Initialize recorder");
+ MEDIA_DEBUG_LOG("AudioStream: Initialize recording");
ret = Initialize(AUDIO_SERVICE_CLIENT_RECORD);
break;
default:
diff --git a/services/test/audio_recorder_test.cpp b/services/test/audio_capturer_test.cpp
similarity index 60%
rename from services/test/audio_recorder_test.cpp
rename to services/test/audio_capturer_test.cpp
index 9c355b3fd4be8d72b916fdf985c04715044c24fd..8100cd6c418e9942e7f0cc42cad61e1285d25c04 100644
--- a/services/test/audio_recorder_test.cpp
+++ b/services/test/audio_capturer_test.cpp
@@ -15,7 +15,7 @@
#include
-#include "audio_recorder.h"
+#include "audio_capturer.h"
#include "media_log.h"
using namespace std;
@@ -30,115 +30,109 @@ namespace AudioTestConstants {
constexpr int32_t SUCCESS = 0;
}
-class AudioRecorderTest {
+class AudioCapturerTest {
public:
void CheckSupportedParams() const
{
- vector supportedFormatList = AudioRecorder::GetSupportedFormats();
+ vector supportedFormatList = AudioCapturer::GetSupportedFormats();
MEDIA_INFO_LOG("Supported formats:");
for (auto i = supportedFormatList.begin(); i != supportedFormatList.end(); ++i) {
MEDIA_INFO_LOG("Format %{public}d", *i);
}
- vector supportedChannelList = AudioRecorder::GetSupportedChannels();
+ vector supportedChannelList = AudioCapturer::GetSupportedChannels();
MEDIA_INFO_LOG("Supported channels:");
for (auto i = supportedChannelList.begin(); i != supportedChannelList.end(); ++i) {
MEDIA_INFO_LOG("channel %{public}d", *i);
}
vector supportedEncodingTypes
- = AudioRecorder::GetSupportedEncodingTypes();
+ = AudioCapturer::GetSupportedEncodingTypes();
MEDIA_INFO_LOG("Supported encoding types:");
for (auto i = supportedEncodingTypes.begin(); i != supportedEncodingTypes.end(); ++i) {
MEDIA_INFO_LOG("encoding type %{public}d", *i);
}
- vector supportedSamplingRates = AudioRecorder::GetSupportedSamplingRates();
+ vector supportedSamplingRates = AudioCapturer::GetSupportedSamplingRates();
MEDIA_INFO_LOG("Supported sampling rates:");
for (auto i = supportedSamplingRates.begin(); i != supportedSamplingRates.end(); ++i) {
MEDIA_INFO_LOG("sampling rate %{public}d", *i);
}
}
- bool InitRecord(const unique_ptr &audioRecorder, const AudioRecorderParams &recorderParams) const
+ bool InitCapture(const unique_ptr &audioCapturer, const AudioCapturerParams &capturerParams) const
{
- if (audioRecorder->SetParams(recorderParams) != AudioTestConstants::SUCCESS) {
+ if (audioCapturer->SetParams(capturerParams) != AudioTestConstants::SUCCESS) {
MEDIA_ERR_LOG("Set audio stream parameters failed");
- audioRecorder->Release();
+ audioCapturer->Release();
return false;
}
- MEDIA_INFO_LOG("Record stream created");
+ MEDIA_INFO_LOG("Capture stream created");
MEDIA_INFO_LOG("Starting Stream");
- if (!audioRecorder->Start()) {
+ if (!audioCapturer->Start()) {
MEDIA_ERR_LOG("Start stream failed");
- audioRecorder->Release();
+ audioCapturer->Release();
return false;
}
- MEDIA_INFO_LOG("Recording started");
+ MEDIA_INFO_LOG("Capturing started");
MEDIA_INFO_LOG("Get Audio parameters:");
- AudioRecorderParams getRecorderParams;
- if (audioRecorder->GetParams(getRecorderParams) == AudioTestConstants::SUCCESS) {
- MEDIA_INFO_LOG("Get Audio format: %{public}d", getRecorderParams.audioSampleFormat);
- MEDIA_INFO_LOG("Get Audio sampling rate: %{public}d", getRecorderParams.samplingRate);
- MEDIA_INFO_LOG("Get Audio channels: %{public}d", getRecorderParams.audioChannel);
+ AudioCapturerParams getCapturerParams;
+ if (audioCapturer->GetParams(getCapturerParams) == AudioTestConstants::SUCCESS) {
+ MEDIA_INFO_LOG("Get Audio format: %{public}d", getCapturerParams.audioSampleFormat);
+ MEDIA_INFO_LOG("Get Audio sampling rate: %{public}d", getCapturerParams.samplingRate);
+ MEDIA_INFO_LOG("Get Audio channels: %{public}d", getCapturerParams.audioChannel);
}
return true;
}
- bool StartRecord(const unique_ptr &audioRecorder, bool isBlocking, FILE *pFile) const
+ bool StartCapture(const unique_ptr &audioCapturer, bool isBlocking, FILE *pFile) const
{
size_t bufferLen;
- if (audioRecorder->GetBufferSize(bufferLen) < 0) {
+ if (audioCapturer->GetBufferSize(bufferLen) < 0) {
MEDIA_ERR_LOG(" GetMinimumBufferSize failed");
return false;
}
- MEDIA_INFO_LOG("Buffer size: %{public}d", bufferLen);
uint32_t frameCount;
- if (audioRecorder->GetFrameCount(frameCount) < 0) {
+ if (audioCapturer->GetFrameCount(frameCount) < 0) {
MEDIA_ERR_LOG(" GetMinimumFrameCount failed");
return false;
}
- MEDIA_INFO_LOG("Frame count: %{public}d", frameCount);
uint8_t* buffer = nullptr;
buffer = (uint8_t *) malloc(bufferLen);
size_t size = 1;
- size_t numBuffersToRecord = 1024;
+ size_t numBuffersToCapture = 1024;
int32_t len = 0;
- while (numBuffersToRecord) {
+ while (numBuffersToCapture) {
size_t bytesRead = 0;
while (bytesRead < bufferLen) {
- len = audioRecorder->Read(*(buffer + bytesRead), bufferLen - bytesRead, isBlocking);
+ len = audioCapturer->Read(*(buffer + bytesRead), bufferLen - bytesRead, isBlocking);
if (len >= 0) {
bytesRead += len;
} else {
- bytesRead = -1;
- MEDIA_INFO_LOG("Bytes read failed");
+ bytesRead = len;
break;
}
}
- MEDIA_INFO_LOG("Bytes read: %{public}d", bytesRead);
if (bytesRead < 0) {
- MEDIA_INFO_LOG("Bytes read less than 0");
+ MEDIA_ERR_LOG("Bytes read failed. error code %{public}d", bytesRead);
break;
- }
- if (bytesRead > 0) {
+ } else if (bytesRead > 0) {
fwrite(buffer, size, bytesRead, pFile);
- numBuffersToRecord--;
- MEDIA_INFO_LOG("Number of buffers to record: %{public}d", numBuffersToRecord);
- if ((numBuffersToRecord == AudioTestConstants::PAUSE_BUFFER_POSITION)
- && (audioRecorder->Stop())) {
- MEDIA_INFO_LOG("Audio record stopped for 2 seconds");
+ numBuffersToCapture--;
+ if ((numBuffersToCapture == AudioTestConstants::PAUSE_BUFFER_POSITION)
+ && (audioCapturer->Stop())) {
+ MEDIA_INFO_LOG("Audio capture stopped for 2 seconds");
sleep(AudioTestConstants::PAUSE_READ_TIME_SECONDS);
- MEDIA_INFO_LOG("Audio record resume");
- if (!audioRecorder->Start()) {
+ MEDIA_INFO_LOG("Audio capture resume");
+ if (!audioCapturer->Start()) {
MEDIA_ERR_LOG("resume stream failed");
- audioRecorder->Release();
+ audioCapturer->Release();
return false;
}
}
@@ -149,49 +143,49 @@ public:
return true;
}
- bool TestRecord(int argc, char *argv[]) const
+ bool TestRecording(int argc, char *argv[]) const
{
MEDIA_INFO_LOG("TestCapture start ");
- unique_ptr audioRecorder = AudioRecorder::Create(AudioStreamType::STREAM_MUSIC);
+ unique_ptr audioCapturer = AudioCapturer::Create(AudioStreamType::STREAM_MUSIC);
CheckSupportedParams();
- AudioRecorderParams recorderParams;
- recorderParams.audioSampleFormat = SAMPLE_S16LE;
- recorderParams.samplingRate = static_cast(atoi(argv[AudioTestConstants::SECOND_ARG_IDX]));
- recorderParams.audioChannel = AudioChannel::STEREO;
- recorderParams.audioEncoding = ENCODING_PCM;
- if (!InitRecord(audioRecorder, recorderParams)) {
- MEDIA_ERR_LOG("Initialize record failed");
+ AudioCapturerParams capturerParams;
+ capturerParams.audioSampleFormat = SAMPLE_S16LE;
+ capturerParams.samplingRate = static_cast(atoi(argv[AudioTestConstants::SECOND_ARG_IDX]));
+ capturerParams.audioChannel = AudioChannel::STEREO;
+ capturerParams.audioEncoding = ENCODING_PCM;
+ if (!InitCapture(audioCapturer, capturerParams)) {
+ MEDIA_ERR_LOG("Initialize capturer failed");
return false;
}
bool isBlocking = (atoi(argv[AudioTestConstants::THIRD_ARG_IDX]) == 1);
MEDIA_INFO_LOG("Is blocking read: %{public}s", isBlocking ? "true" : "false");
FILE *pFile = fopen(argv[AudioTestConstants::SECOND_ARG_IDX - 1], "wb");
- if (!StartRecord(audioRecorder, isBlocking, pFile)) {
- MEDIA_ERR_LOG("Start record failed");
+ if (!StartCapture(audioCapturer, isBlocking, pFile)) {
+ MEDIA_ERR_LOG("Start capturer failed");
return false;
}
Timestamp timestamp;
- if (audioRecorder->GetAudioTime(timestamp, Timestamp::Timestampbase::MONOTONIC)) {
+ if (audioCapturer->GetAudioTime(timestamp, Timestamp::Timestampbase::MONOTONIC)) {
MEDIA_INFO_LOG("Timestamp seconds: %{public}ld", timestamp.time.tv_sec);
MEDIA_INFO_LOG("Timestamp nanoseconds: %{public}ld", timestamp.time.tv_nsec);
}
fflush(pFile);
- if (!audioRecorder->Flush()) {
- MEDIA_ERR_LOG("AudioRecorderTest: flush failed");
+ if (!audioCapturer->Flush()) {
+ MEDIA_ERR_LOG("AudioCapturerTest: flush failed");
}
- if (!audioRecorder->Stop()) {
- MEDIA_ERR_LOG("AudioRecorderTest: Stop failed");
+ if (!audioCapturer->Stop()) {
+ MEDIA_ERR_LOG("AudioCapturerTest: Stop failed");
}
- if (!audioRecorder->Release()) {
- MEDIA_ERR_LOG("AudioRecorderTest: Release failed");
+ if (!audioCapturer->Release()) {
+ MEDIA_ERR_LOG("AudioCapturerTest: Release failed");
}
fclose(pFile);
MEDIA_INFO_LOG("TestCapture end");
@@ -214,8 +208,8 @@ int main(int argc, char *argv[])
MEDIA_INFO_LOG("argv[2]=%{public}s", argv[AudioTestConstants::SECOND_ARG_IDX]);
MEDIA_INFO_LOG("argv[3]=%{public}s", argv[AudioTestConstants::THIRD_ARG_IDX]);
- AudioRecorderTest testObj;
- bool ret = testObj.TestRecord(argc, argv);
+ AudioCapturerTest testObj;
+ bool ret = testObj.TestRecording(argc, argv);
return ret;
}
diff --git a/services/test/record_test.cpp b/services/test/record_test.cpp
index 506b8878a16f6602d35100e953f94f2d1f44a9ae..f6258186ad2909955f085c9ff505f6c5e9f02dab 100644
--- a/services/test/record_test.cpp
+++ b/services/test/record_test.cpp
@@ -25,7 +25,7 @@ constexpr uint8_t DEFAULT_FORMAT = SAMPLE_S16LE;
constexpr uint8_t DEFAULT_CHANNELS = 2;
} // namespace
-class RecordTest : public AudioRecorderCallbacks {
+class RecordTest : public AudioCapturerCallbacks {
public:
void OnSourceDeviceUpdatedCb() const
{
@@ -65,7 +65,7 @@ int main(int argc, char* argv[])
if (client->Initialize(AUDIO_SERVICE_CLIENT_RECORD) < 0)
return -1;
- client->RegisterAudioRecorderCallbacks(customCb);
+ client->RegisterAudioCapturerCallbacks(customCb);
MEDIA_INFO_LOG("Creating Stream");
if (client->CreateStream(audioParams, STREAM_MUSIC) < 0) {
@@ -90,13 +90,13 @@ int main(int argc, char* argv[])
FILE *pFile = fopen(argv[1], "wb");
size_t size = 1;
- size_t numBuffersToRecord = 1024;
+ size_t numBuffersToCapture = 1024;
uint64_t timeStamp;
stream.buffer = buffer;
stream.bufferLen = bufferLen;
int32_t bytesRead = 0;
- while (numBuffersToRecord) {
+ while (numBuffersToCapture) {
bytesRead = client->ReadStream(stream, false);
if (bytesRead < 0) {
break;
@@ -106,7 +106,7 @@ int main(int argc, char* argv[])
fwrite(stream.buffer, size, bytesRead, pFile);
if (client->GetCurrentTimeStamp(timeStamp) >= 0)
MEDIA_DEBUG_LOG("current timestamp: %{public}llu", timeStamp);
- numBuffersToRecord--;
+ numBuffersToCapture--;
}
}