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_CLIENT_H 17 #define SCREEN_CAPTURE_MONITOR_CLIENT_H 18 19 #include "i_screen_capture_monitor_service.h" 20 #include "i_standard_screen_capture_monitor_service.h" 21 #include "screen_capture_monitor_listener_stub.h" 22 23 namespace OHOS { 24 namespace Media { 25 class ScreenCaptureMonitorClient : public IScreenCaptureMonitorService, public NoCopyable { 26 public: 27 static std::shared_ptr<ScreenCaptureMonitorClient> Create( 28 const sptr<IStandardScreenCaptureMonitorService> &ipcProxy); 29 explicit ScreenCaptureMonitorClient(const sptr<IStandardScreenCaptureMonitorService> &ipcProxy); 30 ~ScreenCaptureMonitorClient(); 31 32 int32_t IsScreenCaptureWorking() override; 33 void RegisterScreenCaptureMonitorListener( 34 sptr<ScreenCaptureMonitor::ScreenCaptureMonitorListener> listener) override; 35 void UnregisterScreenCaptureMonitorListener( 36 sptr<ScreenCaptureMonitor::ScreenCaptureMonitorListener> listener) override; 37 void MediaServerDied(); 38 39 private: 40 int32_t CreateListenerObject(); 41 int32_t CloseListenerObject(); 42 sptr<IStandardScreenCaptureMonitorService> screenCaptureMonitorProxy_ = nullptr; 43 sptr<ScreenCaptureMonitorListenerStub> listenerStub_ = nullptr; 44 std::mutex mutex_; 45 bool listenerStubIPCExist_ = false; 46 std::set<sptr<ScreenCaptureMonitor::ScreenCaptureMonitorListener>> screenCaptureMonitorClientCallbacks_; 47 }; 48 } // namespace Media 49 } // namespace OHOS 50 #endif // SCREEN_CAPTURE_MONITOR_CLIENT_H