1 /*
2 * Copyright (c) 2024 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
16 #include "cj_avsession_manager_ffi.h"
17
18 #include "ability_context.h"
19 #include "avsession_errors.h"
20 #include "cj_avsession_manager_impl.h"
21 #include "cj_avsession_impl.h"
22
23 extern "C" {
FfiMultimediaAVSessionManagerCreateAVSession(void * abilityContext,char ** tag,int32_t * type,int64_t * session,char ** sessionId)24 int32_t FfiMultimediaAVSessionManagerCreateAVSession(void* abilityContext,
25 char** tag, int32_t* type, int64_t* session, char** sessionId)
26 {
27 if (abilityContext == nullptr || type == nullptr || session == nullptr || sessionId == nullptr) {
28 return OHOS::AVSession::ERR_INVALID_PARAM;
29 }
30 auto context = static_cast<OHOS::AbilityRuntime::AbilityContext*>(abilityContext);
31 return CJ_AVSESSION_MANAGER_IMPL->CreateAVSession(*context, std::string(*tag), *type, *session, *sessionId);
32 }
33
FfiMultimediaAVSessionManagerCreateController(int64_t * sessionId)34 int32_t FfiMultimediaAVSessionManagerCreateController(int64_t *sessionId)
35 {
36 if (sessionId == nullptr) { return OHOS::AVSession::ERR_INVALID_PARAM; }
37 return CJ_AVSESSION_MANAGER_IMPL->CreateController(
38 OHOS::FFI::FFIData::GetData<OHOS::AVSession::CJAVSessionImpl>(*sessionId)->GetSessionId());
39 }
40 }