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_SERVICE_SERVER_H 17 #define SCREEN_CAPTURE_MONITOR_SERVICE_SERVER_H 18 19 #include <chrono> 20 21 #include "i_screen_capture_monitor_service.h" 22 #include "nocopyable.h" 23 #include "task_queue.h" 24 #include "watchdog.h" 25 #include "meta/meta.h" 26 #include <set> 27 28 namespace OHOS { 29 namespace Media { 30 31 class ScreenCaptureMonitorServer : public IScreenCaptureMonitorService, public NoCopyable { 32 public: 33 static std::shared_ptr<ScreenCaptureMonitorServer> GetInstance(); 34 35 ScreenCaptureMonitorServer(); 36 ~ScreenCaptureMonitorServer(); 37 // IScreenCaptureMonitorService override 38 int32_t IsScreenCaptureWorking() override; 39 40 void SetScreenCaptureMonitorCallback(sptr<ScreenCaptureMonitor::ScreenCaptureMonitorListener> listener); 41 void RemoveScreenCaptureMonitorCallback(sptr<ScreenCaptureMonitor::ScreenCaptureMonitorListener> listener); 42 43 void RegisterScreenCaptureMonitorListener( 44 sptr<ScreenCaptureMonitor::ScreenCaptureMonitorListener> listener) override; 45 void UnregisterScreenCaptureMonitorListener( 46 sptr<ScreenCaptureMonitor::ScreenCaptureMonitorListener> listener) override; 47 int32_t CallOnScreenCaptureStarted(int32_t pid); 48 int32_t CallOnScreenCaptureFinished(int32_t pid); 49 int32_t Release(); 50 private: 51 int32_t Init(); 52 std::mutex mutex_; 53 std::mutex mutexCb_; 54 std::set<sptr<ScreenCaptureMonitor::ScreenCaptureMonitorListener>> screenCaptureMonitorCbSet_; 55 }; 56 } // namespace Media 57 } // namespace OHOS 58 #endif // SCREEN_CAPTURE_MONITOR_SERVICE_SERVER_H