/* * Copyright (c) 2023 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. */ #define LOG_TAG "VideoNapi" #include "video_napi.h" #include "file_napi.h" #include "unified_record_napi.h" #include "video.h" namespace OHOS { namespace UDMF { napi_value VideoNapi::Constructor(napi_env env) { LOG_DEBUG(UDMF_KITS_NAPI, "VideoNapi"); napi_property_descriptor properties[] = { /* Video extends UnifiedRecord */ DECLARE_NAPI_FUNCTION("getType", UnifiedRecordNapi::GetType), DECLARE_NAPI_FUNCTION("getValue", UnifiedRecordNapi::GetValue), /* Video extends File */ DECLARE_NAPI_GETTER_SETTER("details", FileNapi::GetDetails, FileNapi::SetDetails), DECLARE_NAPI_GETTER_SETTER("uri", FileNapi::GetUri, FileNapi::SetUri), /* Video properties */ DECLARE_NAPI_GETTER_SETTER("videoUri", GetVideoUri, SetVideoUri), }; size_t count = sizeof(properties) / sizeof(properties[0]); return NapiDataUtils::DefineClass(env, "Video", properties, count, VideoNapi::New); } napi_value VideoNapi::New(napi_env env, napi_callback_info info) { LOG_DEBUG(UDMF_KITS_NAPI, "VideoNapi"); auto ctxt = std::make_shared(); ctxt->GetCbInfoSync(env, info); ASSERT_ERR(ctxt->env, ctxt->status == napi_ok, Status::E_ERROR, ctxt->error); auto *video = new (std::nothrow) VideoNapi(); ASSERT_ERR(ctxt->env, video != nullptr, Status::E_ERROR, "no memory for video!"); video->value_ = std::make_shared