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 AUDIO_RENDERER_INFO_NAPI_H
17 #define AUDIO_RENDERER_INFO_NAPI_H
18 
19 #include "audio_info.h"
20 #include "napi/native_api.h"
21 #include "napi/native_node_api.h"
22 
23 namespace OHOS {
24 namespace Media {
25 static const std::string AUDIO_RENDERER_INFO_NAPI_CLASS_NAME = "AudioRendererInfo";
26 
27 class AudioRendererInfoNapi {
28 public:
29     AudioRendererInfoNapi();
30     ~AudioRendererInfoNapi();
31 
32     static napi_value Init(napi_env env, napi_value exports);
33     static napi_value CreateAudioRendererInfoWrapper(napi_env env,
34         std::unique_ptr<AudioStandard::AudioRendererInfo> &audioRendererInfo);
35 
36 private:
37     static void Destructor(napi_env env, void *nativeObject, void *finalize_hint);
38     static napi_value Construct(napi_env env, napi_callback_info info);
39     static napi_value GetContentType(napi_env env, napi_callback_info info);
40     static napi_value SetContentType(napi_env env, napi_callback_info info);
41     static napi_value GetStreamUsage(napi_env env, napi_callback_info info);
42     static napi_value SetStreamUsage(napi_env env, napi_callback_info info);
43     static napi_value GetRendererFlags(napi_env env, napi_callback_info info);
44     static napi_value SetRendererFlags(napi_env env, napi_callback_info info);
45 
46     static thread_local napi_ref sConstructor_;
47 
48     static std::unique_ptr<AudioStandard::AudioRendererInfo> sAudioRendererInfo_;
49 
50     std::unique_ptr<AudioStandard::AudioRendererInfo> audioRendererInfo_;
51     napi_env env_;
52 };
53 } // namespace media
54 } // namespace OHOS
55 #endif // AUDIO_RENDERER_INFO_NAPI_H