• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef LOG_TAG
16 #define LOG_TAG "CoreServiceProviderStub"
17 #endif
18 
19 #include "core_service_provider_stub.h"
20 #include "audio_service_log.h"
21 #include "audio_errors.h"
22 
23 namespace OHOS {
24 namespace AudioStandard {
25 
~CoreServiceProviderWrapper()26 CoreServiceProviderWrapper::~CoreServiceProviderWrapper()
27 {
28     coreServiceWorker_ = nullptr;
29 }
30 
CoreServiceProviderWrapper(ICoreServiceProvider * coreServiceWorker)31 CoreServiceProviderWrapper::CoreServiceProviderWrapper(ICoreServiceProvider *coreServiceWorker)
32     : coreServiceWorker_(coreServiceWorker)
33 {
34 }
35 
UpdateSessionOperation(uint32_t sessionId,uint32_t operation,uint32_t opMsg)36 int32_t CoreServiceProviderWrapper::UpdateSessionOperation(uint32_t sessionId, uint32_t operation, uint32_t opMsg)
37 {
38     CHECK_AND_RETURN_RET_LOG(coreServiceWorker_ != nullptr, AUDIO_INIT_FAIL, "coreServiceWorker_ is null");
39     return coreServiceWorker_->UpdateSessionOperation(sessionId, static_cast<SessionOperation>(operation),
40         static_cast<SessionOperationMsg>(opMsg));
41 }
42 
ReloadCaptureSession(uint32_t sessionId,uint32_t operation)43 int32_t CoreServiceProviderWrapper::ReloadCaptureSession(uint32_t sessionId, uint32_t operation)
44 {
45     CHECK_AND_RETURN_RET_LOG(coreServiceWorker_ != nullptr, AUDIO_INIT_FAIL, "coreServiceWorker_ is null");
46     return coreServiceWorker_->ReloadCaptureSession(sessionId, static_cast<SessionOperation>(operation));
47 }
48 
SetDefaultOutputDevice(int32_t defaultOutputDevice,uint32_t sessionID,int32_t streamUsage,bool isRunning,bool skipForce)49 int32_t CoreServiceProviderWrapper::SetDefaultOutputDevice(int32_t defaultOutputDevice,
50     uint32_t sessionID, int32_t streamUsage, bool isRunning, bool skipForce)
51 {
52     CHECK_AND_RETURN_RET_LOG(coreServiceWorker_ != nullptr, AUDIO_INIT_FAIL, "coreServiceWorker_ is null");
53     return coreServiceWorker_->SetDefaultOutputDevice(static_cast<DeviceType>(defaultOutputDevice), sessionID,
54         static_cast<StreamUsage>(streamUsage), isRunning, skipForce);
55 }
56 
GetAdapterNameBySessionId(uint32_t sessionID,std::string & name)57 int32_t CoreServiceProviderWrapper::GetAdapterNameBySessionId(uint32_t sessionID, std::string& name)
58 {
59     CHECK_AND_RETURN_RET_LOG(coreServiceWorker_ != nullptr, AUDIO_INIT_FAIL, "coreServiceWorker_ is null");
60     name = coreServiceWorker_->GetAdapterNameBySessionId(sessionID);
61     return SUCCESS;
62 }
63 
GetProcessDeviceInfoBySessionId(uint32_t sessionId,AudioDeviceDescriptor & deviceInfo,AudioStreamInfo & streamInfo,bool isReloadProcess)64 int32_t CoreServiceProviderWrapper::GetProcessDeviceInfoBySessionId(uint32_t sessionId,
65     AudioDeviceDescriptor &deviceInfo, AudioStreamInfo &streamInfo, bool isReloadProcess)
66 {
67     CHECK_AND_RETURN_RET_LOG(coreServiceWorker_ != nullptr, AUDIO_INIT_FAIL, "coreServiceWorker_ is null");
68     return coreServiceWorker_->GetProcessDeviceInfoBySessionId(sessionId, deviceInfo, streamInfo, isReloadProcess);
69 }
70 
GenerateSessionId(uint32_t & sessionId)71 int32_t CoreServiceProviderWrapper::GenerateSessionId(uint32_t &sessionId)
72 {
73     CHECK_AND_RETURN_RET_LOG(coreServiceWorker_ != nullptr, 0, "coreServiceWorker_ is null");
74     sessionId = coreServiceWorker_->GenerateSessionId();
75     return SUCCESS;
76 }
77 
SetWakeUpAudioCapturerFromAudioServer(const AudioProcessConfig & config,int32_t & ret)78 int32_t CoreServiceProviderWrapper::SetWakeUpAudioCapturerFromAudioServer(
79     const AudioProcessConfig &config, int32_t &ret)
80 {
81     CHECK_AND_RETURN_RET_LOG(coreServiceWorker_ != nullptr, AUDIO_INIT_FAIL, "coreServiceWorker_ is null");
82     ret = coreServiceWorker_->SetWakeUpAudioCapturerFromAudioServer(config);
83     return SUCCESS;
84 }
85 } // namespace AudioStandard
86 } // namespace OHOS
87