1 /* 2 * Copyright (C) 2024 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 SCREEN_CAPTURE_MONITOR_H 17 #define SCREEN_CAPTURE_MONITOR_H 18 #include <cstdint> 19 #include <refbase.h> 20 #include <list> 21 22 namespace OHOS { 23 namespace Media { 24 25 enum ScreenCaptureMonitorErrorType : int32_t { 26 SCREEN_CAPTURE_MONITOR_ERROR_INTERNAL, 27 }; 28 29 enum ScreenCaptureMonitorEvent : int32_t { 30 SCREENCAPTURE_STARTED = 0, 31 SCREENCAPTURE_STOPPED = 1 32 }; 33 34 class ScreenCaptureMonitor { 35 public: 36 #ifdef UNSUPPORT_SCREEN_CAPTURE GetInstance()37 static ScreenCaptureMonitor *GetInstance() 38 { 39 return nullptr; 40 } 41 class ScreenCaptureMonitorListener : public virtual RefBase { 42 public: 43 virtual void OnScreenCaptureStarted(int32_t pid) = 0; 44 virtual void OnScreenCaptureFinished(int32_t pid) = 0; 45 }; 46 IsScreenCaptureWorking()47 std::list<int32_t> IsScreenCaptureWorking() 48 { 49 return {}; 50 } RegisterScreenCaptureMonitorListener(sptr<ScreenCaptureMonitorListener> listener)51 void RegisterScreenCaptureMonitorListener(sptr<ScreenCaptureMonitorListener> listener) {} UnregisterScreenCaptureMonitorListener(sptr<ScreenCaptureMonitorListener> listener)52 void UnregisterScreenCaptureMonitorListener(sptr<ScreenCaptureMonitorListener> listener) {} IsSystemScreenRecorder(int32_t pid)53 bool IsSystemScreenRecorder(int32_t pid) 54 { 55 return false; 56 } IsSystemScreenRecorderWorking()57 bool IsSystemScreenRecorderWorking() 58 { 59 return false; 60 } 61 #else 62 static ScreenCaptureMonitor *GetInstance(); 63 class ScreenCaptureMonitorListener : public virtual RefBase { 64 public: 65 /** 66 * @brief Notify when screen capture started. 67 * @param pid Indicates the screen capture instance pid. 68 * @since 1.0 69 * @version 1.0 70 */ 71 virtual void OnScreenCaptureStarted(int32_t pid) = 0; 72 /** 73 * @brief Notify when screen capture finished. 74 * @param pid Indicates the screen capture instance pid. 75 * @since 1.0 76 * @version 1.0 77 */ 78 virtual void OnScreenCaptureFinished(int32_t pid) = 0; 79 }; 80 81 std::list<int32_t> IsScreenCaptureWorking(); 82 void RegisterScreenCaptureMonitorListener(sptr<ScreenCaptureMonitorListener> listener); 83 void UnregisterScreenCaptureMonitorListener(sptr<ScreenCaptureMonitorListener> listener); 84 bool IsSystemScreenRecorder(int32_t pid); 85 bool IsSystemScreenRecorderWorking(); 86 virtual ~ScreenCaptureMonitor() = default; 87 #endif 88 }; 89 } // namespace Media 90 } // namespace OHOS 91 #endif // SCREEN_CAPTURE_MONITOR_H