• 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 #include "video_param.h"
16 
17 #include "dscreen_constants.h"
18 #include "dscreen_errcode.h"
19 
20 using json = nlohmann::json;
21 
22 namespace OHOS {
23 namespace DistributedHardware {
SetScreenWidth(uint32_t screenWidth)24 void VideoParam::SetScreenWidth(uint32_t screenWidth)
25 {
26     screenWidth_ = screenWidth;
27 }
28 
GetScreenWidth() const29 uint32_t VideoParam::GetScreenWidth() const
30 {
31     return screenWidth_;
32 }
33 
SetScreenHeight(uint32_t screenHeight)34 void VideoParam::SetScreenHeight(uint32_t screenHeight)
35 {
36     screenHeight_ = screenHeight;
37 }
38 
GetScreenHeight() const39 uint32_t VideoParam::GetScreenHeight() const
40 {
41     return screenHeight_;
42 }
43 
SetVideoWidth(uint32_t videoWidth)44 void VideoParam::SetVideoWidth(uint32_t videoWidth)
45 {
46     videoWidth_ = videoWidth;
47 }
48 
GetVideoWidth() const49 uint32_t VideoParam::GetVideoWidth() const
50 {
51     return videoWidth_;
52 }
53 
SetVideoHeight(uint32_t videoHeight)54 void VideoParam::SetVideoHeight(uint32_t videoHeight)
55 {
56     videoHeight_ = videoHeight;
57 }
58 
GetVideoHeight() const59 uint32_t VideoParam::GetVideoHeight() const
60 {
61     return videoHeight_;
62 }
63 
SetFps(uint32_t fps)64 void VideoParam::SetFps(uint32_t fps)
65 {
66     fps_ = fps;
67 }
68 
GetFps() const69 uint32_t VideoParam::GetFps() const
70 {
71     return fps_;
72 }
73 
SetCodecType(uint8_t codecType)74 void VideoParam::SetCodecType(uint8_t codecType)
75 {
76     codecType_ = codecType;
77 }
78 
GetCodecType() const79 uint8_t VideoParam::GetCodecType() const
80 {
81     return codecType_;
82 }
83 
SetVideoFormat(uint8_t videoFormat)84 void VideoParam::SetVideoFormat(uint8_t videoFormat)
85 {
86     videoFormat_ = videoFormat;
87 }
88 
GetVideoFormat() const89 uint8_t VideoParam::GetVideoFormat() const
90 {
91     return videoFormat_;
92 }
93 
to_json(json & j,const DistributedHardware::VideoParam & videoParam)94 void to_json(json &j, const DistributedHardware::VideoParam &videoParam)
95 {
96     j = json {
97         {KEY_SCREEN_WIDTH, videoParam.screenWidth_},
98         {KEY_SCREEN_HEIGHT, videoParam.screenHeight_},
99         {KEY_VIDEO_WIDTH, videoParam.videoWidth_},
100         {KEY_VIDEO_HEIGHT, videoParam.videoHeight_},
101         {KEY_FPS, videoParam.fps_},
102         {KEY_CODECTYPE, videoParam.codecType_}
103     };
104 }
105 
from_json(const json & j,DistributedHardware::VideoParam & videoParam)106 void from_json(const json &j, DistributedHardware::VideoParam &videoParam)
107 {
108     j.at(KEY_SCREEN_WIDTH).get_to(videoParam.screenWidth_);
109     j.at(KEY_SCREEN_HEIGHT).get_to(videoParam.screenHeight_);
110     j.at(KEY_VIDEO_WIDTH).get_to(videoParam.videoWidth_);
111     j.at(KEY_VIDEO_HEIGHT).get_to(videoParam.videoHeight_);
112     j.at(KEY_FPS).get_to(videoParam.fps_);
113     j.at(KEY_CODECTYPE).get_to(videoParam.codecType_);
114 }
115 } // namespace DistributedHardware
116 } // namespace OHOS
117