• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 #ifndef OHOS_NAPI_AVCALL_META_DATA_H
17 #define OHOS_NAPI_AVCALL_META_DATA_H
18 
19 #include "avcall_meta_data.h"
20 #include "napi/native_api.h"
21 
22 namespace OHOS::AVSession {
23 class NapiAVCallMetaData {
24 public:
25     static napi_status ConvertFilter(napi_env env, napi_value filter, AVCallMetaData::AVCallMetaMaskType& mask);
26 
27     static napi_status GetValue(napi_env env, napi_value in, AVCallMetaData& out);
28     static napi_status SetValue(napi_env env, const AVCallMetaData& in, napi_value& out);
29 
30     using GetterType = std::function<napi_status(napi_env, napi_value in, AVCallMetaData& out)>;
31     using SetterType = std::function<napi_status(napi_env env, const AVCallMetaData& in, napi_value& out)>;
32 
33 private:
34     static napi_status SetUndefinedMeta(napi_env env, napi_value& meta);
35 
36     static napi_status GetName(napi_env env, napi_value in, AVCallMetaData& out);
37     static napi_status SetName(napi_env env, const AVCallMetaData& in, napi_value& out);
38 
39     static napi_status GetPhoneNumber(napi_env env, napi_value in, AVCallMetaData& out);
40     static napi_status SetPhoneNumber(napi_env env, const AVCallMetaData& in, napi_value& out);
41 
42     static napi_status GetMediaImage(napi_env env, napi_value in, AVCallMetaData& out);
43     static napi_status SetMediaImage(napi_env env, const AVCallMetaData& in, napi_value& out);
44     static napi_status SetMediaImageUri(napi_env env, const AVCallMetaData& in, napi_value& out);
45 
46     static std::map<std::string, GetterType> getterMap_;
47     static std::map<int32_t, SetterType> setterMap_;
48     static std::pair<std::string, int32_t> filterMap_[AVCallMetaData::AVCALL_META_KEY_MAX];
49 
50     static constexpr int GETTER_INDEX = 0;
51     static constexpr int SETTER_INDEX = 1;
52     static constexpr int ENUM_INDEX = 2;
53 };
54 }
55 #endif // OHOS_NAPI_AVCALL_META_DATA_H
56