1 /* 2 * Copyright (c) 2023-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 OHOS_PICTURE_IN_PICTURE_MANAGER_H 17 #define OHOS_PICTURE_IN_PICTURE_MANAGER_H 18 19 #include "picture_in_picture_controller.h" 20 #include "window.h" 21 #include "wm_common.h" 22 23 namespace OHOS { 24 namespace Rosen { 25 class PictureInPictureManager { 26 public: 27 PictureInPictureManager(); 28 ~PictureInPictureManager(); 29 static bool ShouldAbortPipStart(); 30 static bool IsSupportPiP(); 31 static void PutPipControllerInfo(int32_t windowId, sptr<PictureInPictureController> pipController); 32 static void RemovePipControllerInfo(int32_t windowId); 33 static void AttachActivePipController(sptr<PictureInPictureController> pipController); 34 static void DetachActivePipController(sptr<PictureInPictureController> pipController); 35 static sptr<PictureInPictureController> GetPipControllerInfo(int32_t windowId); 36 37 static bool HasActiveController(); 38 static bool IsActiveController(wptr<PictureInPictureController> pipController); 39 static void SetActiveController(sptr<PictureInPictureController> pipController); 40 static void RemoveActiveController(wptr<PictureInPictureController> pipController); 41 static void AttachAutoStartController(int32_t handleId, wptr<PictureInPictureController> pipController); 42 static void DetachAutoStartController(int32_t handleId, wptr<PictureInPictureController> pipController); 43 static bool IsAttachedToSameWindow(uint32_t windowId); 44 static sptr<Window> GetCurrentWindow(); 45 46 static void DoPreRestore(); 47 static void DoRestore(); 48 static void DoClose(bool destroyWindow, bool needAnim); 49 static void DoActionClose(); 50 static void DoPrepareSource(); 51 static void DoLocateSource(); 52 static void DoActionEvent(const std::string& actionName, int32_t status); 53 static void DoControlEvent(PiPControlType controlType, PiPControlStatus status); 54 static void AutoStartPipWindow(); 55 static void DoDestroy(); 56 static std::shared_ptr<NativeReference> innerCallbackRef_; 57 58 private: GetActiveController()59 static sptr<PictureInPictureController> GetActiveController() { return activeController_; } 60 61 // controller in use 62 static sptr<PictureInPictureController> activeController_; 63 static wptr<PictureInPictureController> autoStartController_; 64 // controllers enable auto start 65 static std::map<int32_t, wptr<PictureInPictureController>> autoStartControllerMap_; 66 67 static std::map<int32_t, sptr<PictureInPictureController>> windowToControllerMap_; 68 }; 69 } // namespace Rosen 70 } // namespace OHOS 71 #endif // OHOS_PICTURE_IN_PICTURE_MANAGER_H