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_STUB_H 17 #define SCREEN_CAPTURE_MONITOR_SERVICE_STUB_H 18 19 #include <map> 20 #include "i_standard_screen_capture_monitor_service.h" 21 #include "i_standard_screen_capture_monitor_listener.h" 22 #include "media_death_recipient.h" 23 #include "screen_capture_monitor_server.h" 24 #include "nocopyable.h" 25 #include "monitor_server_object.h" 26 27 namespace OHOS { 28 namespace Media { 29 class ScreenCaptureMonitorServiceStub : public IRemoteStub<IStandardScreenCaptureMonitorService>, public NoCopyable { 30 public: 31 static sptr<ScreenCaptureMonitorServiceStub> Create(); 32 virtual ~ScreenCaptureMonitorServiceStub(); 33 34 int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; 35 int32_t SetListenerObject(const sptr<IRemoteObject> &object) override; 36 int32_t CloseListenerObject() override; 37 int32_t IsScreenCaptureWorking() override; 38 int32_t DestroyStub() override; 39 40 private: 41 ScreenCaptureMonitorServiceStub(); 42 int32_t Init(); 43 int32_t SetListenerObject(MessageParcel &data, MessageParcel &reply); 44 int32_t CloseListenerObject(MessageParcel &data, MessageParcel &reply); 45 int32_t IsScreenCaptureWorking(MessageParcel &data, MessageParcel &reply); 46 int32_t DestroyStub(MessageParcel &data, MessageParcel &reply); 47 48 std::shared_ptr<ScreenCaptureMonitorServer> screenCaptureMonitorServer_ = nullptr; 49 using screenCaptureMonitorStubFunc = 50 int32_t(ScreenCaptureMonitorServiceStub::*)(MessageParcel &data, MessageParcel &reply); 51 std::map<uint32_t, screenCaptureMonitorStubFunc> screenCaptureMonitorStubFuncs_; 52 std::mutex mutex_; 53 sptr<ScreenCaptureMonitor::ScreenCaptureMonitorListener> screenCaptureMonitorCallback_ = nullptr; 54 }; 55 } // namespace Media 56 } // namespace OHOS 57 #endif // SCREEN_CAPTURE_MONITOR_SERVICE_STUB_H