• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 #ifndef RS_VPE_MANAGER_H
16 #define RS_VPE_MANAGER_H
17 
18 #include <surface.h>
19 
20 #include "command/rs_command.h"
21 #include "detail_enhancer_video.h"
22 
23 namespace OHOS {
24 namespace Rosen {
25 class RSB_EXPORT RSVpeManager {
26 public:
27     RSB_EXPORT static RSVpeManager& GetInstance();
28 
29     RSB_EXPORT sptr<Surface> CheckAndGetSurface(const sptr<Surface>& surface, const RSSurfaceRenderNodeConfig& config);
30     RSB_EXPORT void ReleaseVpeVideo(uint64_t nodeId);
31 
32 private:
33     sptr<Surface> GetVpeVideoSurface(uint32_t type, const sptr<Surface>& RSSurface,
34         const RSSurfaceRenderNodeConfig& config);
35     std::shared_ptr<OHOS::Media::VideoProcessingEngine::VpeVideo> GetVpeVideo(uint32_t type,
36         const RSSurfaceRenderNodeConfig& config);
37     bool SetVpeVideoParameter(std::shared_ptr<OHOS::Media::VideoProcessingEngine::VpeVideo> vpeVideo,
38         uint32_t type, const RSSurfaceRenderNodeConfig& config);
39     mutable std::mutex vpeVideoLock_{};
40     // Guarded by vpeVideoLock_ begin
41     std::unordered_map<uint64_t, std::shared_ptr<OHOS::Media::VideoProcessingEngine::VpeVideo>> allVpeVideo_{};
42     // Guarded by vpeVideoLock_ end
43 };
44 } // namespace Rosen
45 
46 namespace Media {
47 namespace VideoProcessingEngine {
48 class VpeVideoCallbackImpl : public VpeVideoCallback {
49 public:
50     VpeVideoCallbackImpl() = default;
51     ~VpeVideoCallbackImpl() override = default;
VpeVideoCallbackImpl(const std::shared_ptr<VpeVideo> & videoResizeFilter)52     explicit VpeVideoCallbackImpl(const std::shared_ptr<VpeVideo>& videoResizeFilter)
53         : videoFilter_(videoResizeFilter)
54     {
55     }
56     VpeVideoCallbackImpl(const VpeVideoCallbackImpl&) = delete;
57     VpeVideoCallbackImpl& operator=(const VpeVideoCallbackImpl&) = delete;
58     VpeVideoCallbackImpl(VpeVideoCallbackImpl&&) = delete;
59     VpeVideoCallbackImpl& operator=(VpeVideoCallbackImpl&&) = delete;
60 
61     void OnOutputBufferAvailable(uint32_t index, VpeBufferFlag flag) override;
62 
63 private:
64     std::weak_ptr<VpeVideo> videoFilter_;
65 };
66 } // namespace VideoProcessingEngine
67 } // namespace Media
68 } // namespace OHOS
69 
70 #endif