• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     std::list<int32_t> IsScreenCaptureWorking() override;
38     int32_t DestroyStub() override;
39     bool IsSystemScreenRecorder(int32_t pid) override;
40     bool IsSystemScreenRecorderWorking() override;
41 
42 private:
43     ScreenCaptureMonitorServiceStub();
44     int32_t Init();
45     int32_t SetListenerObject(MessageParcel &data, MessageParcel &reply);
46     int32_t CloseListenerObject(MessageParcel &data, MessageParcel &reply);
47     int32_t IsScreenCaptureWorking(MessageParcel &data, MessageParcel &reply);
48     int32_t DestroyStub(MessageParcel &data, MessageParcel &reply);
49     int32_t IsSystemScreenRecorder(MessageParcel &data, MessageParcel &reply);
50     int32_t IsSystemScreenRecorderWorking(MessageParcel &data, MessageParcel &reply);
51 
52     std::shared_ptr<ScreenCaptureMonitorServer> screenCaptureMonitorServer_ = nullptr;
53     using screenCaptureMonitorStubFunc =
54         int32_t(ScreenCaptureMonitorServiceStub::*)(MessageParcel &data, MessageParcel &reply);
55     std::map<uint32_t, screenCaptureMonitorStubFunc> screenCaptureMonitorStubFuncs_;
56     std::mutex mutex_;
57     sptr<ScreenCaptureMonitor::ScreenCaptureMonitorListener> screenCaptureMonitorCallback_ = nullptr;
58 };
59 } // namespace Media
60 } // namespace OHOS
61 #endif // SCREEN_CAPTURE_MONITOR_SERVICE_STUB_H