diff --git a/services/audio_service/BUILD.gn b/services/audio_service/BUILD.gn index b489dda26c00179481a24557724893c78de0a1ae..f95d14e5c1ea248418f892c7ec24a66e0fe6832f 100644 --- a/services/audio_service/BUILD.gn +++ b/services/audio_service/BUILD.gn @@ -400,6 +400,7 @@ audio_ohos_library("audio_process_service") { "server/src/audio_workgroup_callback.cpp", "server/src/audio_workgroup.cpp", "server/src/audio_resource_service.cpp", + "server/src/audio_injector.cpp", ] if (!audio_framework_feature_new_engine_flag) { diff --git a/services/audio_service/server/include/audio_injector.h b/services/audio_service/server/include/audio_injector.h new file mode 100644 index 0000000000000000000000000000000000000000..7f98f8f7584869abd28e008b83f350744dff34e8 --- /dev/null +++ b/services/audio_service/server/include/audio_injector.h @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 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_INJECTOR_H +#define AUDIO_INJECTOR_H + +#include +#include "audio_module_info.h" + +namespace OHOS { +namespace AudioStandard { +class AudioInjector { +public: + static AudioInjector& GetInstance() + { + static AudioInjector instance; + return instance; + } + int32_t Init(); + int32_t DeInit(); + int32_t UpdateAudioInfo(AudioModuleInfo &info); + int32_t MoveStream(uint32_t renderId, bool flag); + int32_t PeekAudioData(const uint32_t rendererPortIdx, uint8_t *destBuff, const size_t buffSize, AudioStreamInfo &streamInfo); + int32_t GetRendererStreamCount(); + void SetCapturePortIdx(uint32_t idx); + uint32_t GetCapturePortIdx(); + void SetRendererPortIdx(uint32_t idx); + uint32_t GetRendererPortIdx(); + +private: + AudioInjector(); + AudioInjector(const AudioInjector&) = delete; + AudioInjector& operator=(const AudioInjector&) = delete; +private: + AudioModuleInfo moduleInfo_; + uint32_t capturePortIdx_; + uint32_t renderPortIdx_; + bool isConnected_; + std::unordered_map rendererStreamMap_ = {}; +}; +} // namespace AudioStandard +} // namespace OHOS +#endif // AUDIO_INJECTOR_H \ No newline at end of file diff --git a/services/audio_service/server/src/audio_injector.cpp b/services/audio_service/server/src/audio_injector.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fa705301fd86933a71cd4506c6fcc5862ae2ecc9 --- /dev/null +++ b/services/audio_service/server/src/audio_injector.cpp @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2025 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_injector.h" + +namespace OHOS { +namespace AudioStandard { +AudioInjector::AudioInjector() +{ + isConnected_ = false; +} + +int32_t AudioInjector::Init() +{ + return 0; +} + +int32_t AudioInjector::DeInit() +{ + return 0; +} + +int32_t AudioInjector::UpdateAudioInfo(AudioModuleInfo &info) +{ + return 0; +} + +int32_t AudioInjector::MoveStream(uint32_t renderId, bool flag) +{ + return 0; +} + +int32_t AudioInjector::PeekAudioData(const uint32_t rendererPortIdx, uint8_t *destBuff, const size_t buffSize, AudioStreamInfo &streamInfo) +{ + return 0; +} + +// get the number of rendererStream moved in Injector +int32_t AudioInjector::GetRendererStreamCount() +{ + return rendererStreamMap_.size(); +} + +void AudioInjector::SetCapturePortIdx(uint32_t idx) +{ + capturePortIdx_ = idx; +} + +uint32_t AudioInjector::GetCapturePortIdx() +{ + return capturePortIdx_; +} + +void AudioInjector::SetRendererPortIdx(uint32_t idx) +{ + renderPortIdx_ = idx; +} + +uint32_t AudioInjector::GetRendererPortIdx() +{ + return renderPortIdx_; +} +} // namespace AudioStandard +} // namespace OHOS \ No newline at end of file