• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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_PLAYBACK_STATE_H
17 #define OHOS_NAPI_PLAYBACK_STATE_H
18 
19 #include <vector>
20 #include <map>
21 #include <string>
22 #include "avplayback_state.h"
23 #include "napi/native_api.h"
24 
25 namespace OHOS::AVSession {
26 class NapiPlaybackState {
27 public:
28     static napi_status  ConvertFilter(napi_env env, napi_value filter, AVPlaybackState::PlaybackStateMaskType& mask);
29 
30     static napi_status GetValue(napi_env env, napi_value in, AVPlaybackState& out);
31     static napi_status SetValue(napi_env env, const AVPlaybackState& in, napi_value& out);
32 
33     using GetterType = std::function<napi_status(napi_env, napi_value in, AVPlaybackState& out)>;
34     using SetterType = std::function<napi_status(napi_env env, const AVPlaybackState& in, napi_value& out)>;
35 
36 private:
37     static napi_status GetState(napi_env env, napi_value in, AVPlaybackState& out);
38     static napi_status SetState(napi_env env, const AVPlaybackState& in, napi_value& out);
39 
40     static napi_status GetSpeed(napi_env env, napi_value in, AVPlaybackState& out);
41     static napi_status SetSpeed(napi_env env, const AVPlaybackState& in, napi_value& out);
42 
43     static napi_status GetPosition(napi_env env, napi_value in, AVPlaybackState& out);
44     static napi_status SetPosition(napi_env env, const AVPlaybackState& in, napi_value& out);
45 
46     static napi_status GetBufferedTime(napi_env env, napi_value in, AVPlaybackState& out);
47     static napi_status SetBufferedTime(napi_env env, const AVPlaybackState& in, napi_value& out);
48 
49     static napi_status GetLoopMode(napi_env env, napi_value in, AVPlaybackState& out);
50     static napi_status SetLoopMode(napi_env env, const AVPlaybackState& in, napi_value& out);
51 
52     static napi_status GetIsFavorite(napi_env env, napi_value in, AVPlaybackState& out);
53     static napi_status SetIsFavorite(napi_env env, const AVPlaybackState& in, napi_value& out);
54 
55     static std::map<std::string, GetterType> getterMap_;
56     static std::map<int32_t, SetterType> setterMap_;
57     static std::map<std::string, int32_t> filterMap_;
58 };
59 }
60 #endif // OHOS_NAPI_PLAYBACK_STATE_H