1e0dac50fSopenharmony_ci/*
2e0dac50fSopenharmony_ci * Copyright (c) 2023-2023 Huawei Device Co., Ltd.
3e0dac50fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4e0dac50fSopenharmony_ci * you may not use this file except in compliance with the License.
5e0dac50fSopenharmony_ci * You may obtain a copy of the License at
6e0dac50fSopenharmony_ci *
7e0dac50fSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8e0dac50fSopenharmony_ci *
9e0dac50fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10e0dac50fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11e0dac50fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12e0dac50fSopenharmony_ci * See the License for the specific language governing permissions and
13e0dac50fSopenharmony_ci * limitations under the License.
14e0dac50fSopenharmony_ci */
15e0dac50fSopenharmony_ci
16e0dac50fSopenharmony_ci#ifndef OHOS_PICTURE_IN_PICTURE_MANAGER_H
17e0dac50fSopenharmony_ci#define OHOS_PICTURE_IN_PICTURE_MANAGER_H
18e0dac50fSopenharmony_ci
19e0dac50fSopenharmony_ci#include <refbase.h>
20e0dac50fSopenharmony_ci#include "picture_in_picture_controller.h"
21e0dac50fSopenharmony_ci#include "window.h"
22e0dac50fSopenharmony_ci#include "wm_common.h"
23e0dac50fSopenharmony_ci
24e0dac50fSopenharmony_cinamespace OHOS {
25e0dac50fSopenharmony_cinamespace Rosen {
26e0dac50fSopenharmony_ciclass PictureInPictureManager {
27e0dac50fSopenharmony_cipublic:
28e0dac50fSopenharmony_ci    PictureInPictureManager();
29e0dac50fSopenharmony_ci    ~PictureInPictureManager();
30e0dac50fSopenharmony_ci    static bool ShouldAbortPipStart();
31e0dac50fSopenharmony_ci    static bool IsSupportPiP();
32e0dac50fSopenharmony_ci    static void PutPipControllerInfo(int32_t windowId, sptr<PictureInPictureController> pipController);
33e0dac50fSopenharmony_ci    static void RemovePipControllerInfo(int32_t windowId);
34e0dac50fSopenharmony_ci    static void AttachActivePipController(sptr<PictureInPictureController> pipController);
35e0dac50fSopenharmony_ci    static void DetachActivePipController(sptr<PictureInPictureController> pipController);
36e0dac50fSopenharmony_ci    static sptr<PictureInPictureController> GetPipControllerInfo(int32_t windowId);
37e0dac50fSopenharmony_ci
38e0dac50fSopenharmony_ci    static bool HasActiveController();
39e0dac50fSopenharmony_ci    static bool IsActiveController(wptr<PictureInPictureController> pipController);
40e0dac50fSopenharmony_ci    static void SetActiveController(sptr<PictureInPictureController> pipController);
41e0dac50fSopenharmony_ci    static void RemoveActiveController(wptr<PictureInPictureController> pipController);
42e0dac50fSopenharmony_ci    static void AttachAutoStartController(int32_t handleId, wptr<PictureInPictureController> pipController);
43e0dac50fSopenharmony_ci    static void DetachAutoStartController(int32_t handleId, wptr<PictureInPictureController> pipController);
44e0dac50fSopenharmony_ci    static bool IsAttachedToSameWindow(uint32_t windowId);
45e0dac50fSopenharmony_ci    static sptr<Window> GetCurrentWindow();
46e0dac50fSopenharmony_ci
47e0dac50fSopenharmony_ci    static void DoPreRestore();
48e0dac50fSopenharmony_ci    static void DoRestore();
49e0dac50fSopenharmony_ci    static void DoClose(bool destroyWindow, bool needAnim);
50e0dac50fSopenharmony_ci    static void DoActionClose();
51e0dac50fSopenharmony_ci    static void DoPrepareSource();
52e0dac50fSopenharmony_ci    static void DoLocateSource();
53e0dac50fSopenharmony_ci    static void DoActionEvent(const std::string& actionName, int32_t status);
54e0dac50fSopenharmony_ci    static void DoControlEvent(PiPControlType controlType, PiPControlStatus status);
55e0dac50fSopenharmony_ci    static void AutoStartPipWindow();
56e0dac50fSopenharmony_ci    static void DoDestroy();
57e0dac50fSopenharmony_ci    static std::shared_ptr<NativeReference> innerCallbackRef_;
58e0dac50fSopenharmony_ciprivate:
59e0dac50fSopenharmony_ci    // controller in use
60e0dac50fSopenharmony_ci    static sptr<PictureInPictureController> activeController_;
61e0dac50fSopenharmony_ci    static wptr<PictureInPictureController> autoStartController_;
62e0dac50fSopenharmony_ci    // controllers enable auto start
63e0dac50fSopenharmony_ci    static std::map<int32_t, wptr<PictureInPictureController>> autoStartControllerMap_;
64e0dac50fSopenharmony_ci
65e0dac50fSopenharmony_ci    static std::map<int32_t, sptr<PictureInPictureController>> windowToControllerMap_;
66e0dac50fSopenharmony_ci};
67e0dac50fSopenharmony_ci} // namespace Rosen
68e0dac50fSopenharmony_ci} // namespace OHOS
69e0dac50fSopenharmony_ci#endif // OHOS_PICTURE_IN_PICTURE_MANAGER_H