1 /* 2 * Copyright (C) 2023 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_SERVICE_STUB_H 17 #define SCREEN_CAPTURE_SERVICE_STUB_H 18 19 #include <map> 20 #include "i_standard_screen_capture_service.h" 21 #include "screen_capture_server.h" 22 #include "media_death_recipient.h" 23 24 namespace OHOS { 25 namespace Media { 26 class ScreenCaptureServiceStub : public IRemoteStub<IStandardScreenCaptureService>, public NoCopyable { 27 public: 28 static sptr<ScreenCaptureServiceStub> Create(); 29 virtual ~ScreenCaptureServiceStub(); 30 void Release() override; 31 int32_t DestroyStub() override; 32 int32_t SetCaptureMode(CaptureMode captureMode) override; 33 int32_t SetDataType(DataType dataType) override; 34 int32_t SetRecorderInfo(RecorderInfo recorderInfo) override; 35 int32_t SetOutputFile(int32_t fd) override; 36 int32_t InitAudioEncInfo(AudioEncInfo audioEncInfo) override; 37 int32_t InitAudioCap(AudioCaptureInfo audioInfo) override; 38 int32_t InitVideoEncInfo(VideoEncInfo videoEncInfo) override; 39 int32_t InitVideoCap(VideoCaptureInfo videoInfo) override; 40 int32_t StartScreenCapture(bool isPrivacyAuthorityEnabled) override; 41 int32_t StartScreenCaptureWithSurface(sptr<Surface> surface, bool isPrivacyAuthorityEnabled) override; 42 int32_t StopScreenCapture() override; 43 int32_t AcquireAudioBuffer(std::shared_ptr<AudioBuffer> &audioBuffer, AudioCaptureSourceType type) override; 44 int32_t AcquireVideoBuffer(sptr<OHOS::SurfaceBuffer> &surfaceBuffer, int32_t &fence, 45 int64_t ×tamp, OHOS::Rect &damage) override; 46 int32_t ReleaseAudioBuffer(AudioCaptureSourceType type) override; 47 int32_t ReleaseVideoBuffer() override; 48 int32_t SetMicrophoneEnabled(bool isMicrophone) override; 49 int32_t SetCanvasRotation(bool canvasRotation) override; 50 int32_t ResizeCanvas(int32_t width, int32_t height) override; 51 int32_t SkipPrivacyMode(std::vector<uint64_t> &windowIDsVec) override; 52 int32_t SetMaxVideoFrameRate(int32_t frameRate) override; 53 int32_t SetListenerObject(const sptr<IRemoteObject> &object) override; 54 int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; 55 int32_t ExcludeContent(ScreenCaptureContentFilter &contentFilter) override; 56 57 private: 58 ScreenCaptureServiceStub(); 59 int32_t Init(); 60 int32_t SetCaptureMode(MessageParcel &data, MessageParcel &reply); 61 int32_t SetDataType(MessageParcel &data, MessageParcel &reply); 62 int32_t SetRecorderInfo(MessageParcel &data, MessageParcel &reply); 63 int32_t SetOutputFile(MessageParcel &data, MessageParcel &reply); 64 int32_t InitAudioEncInfo(MessageParcel &data, MessageParcel &reply); 65 int32_t InitAudioCap(MessageParcel &data, MessageParcel &reply); 66 int32_t InitVideoEncInfo(MessageParcel &data, MessageParcel &reply); 67 int32_t InitVideoCap(MessageParcel &data, MessageParcel &reply); 68 int32_t StartScreenCapture(MessageParcel &data, MessageParcel &reply); 69 int32_t StartScreenCaptureWithSurface(MessageParcel &data, MessageParcel &reply); 70 int32_t StopScreenCapture(MessageParcel &data, MessageParcel &reply); 71 int32_t SetListenerObject(MessageParcel &data, MessageParcel &reply); 72 int32_t AcquireAudioBuffer(MessageParcel &data, MessageParcel &reply); 73 int32_t AcquireVideoBuffer(MessageParcel &data, MessageParcel &reply); 74 int32_t ReleaseAudioBuffer(MessageParcel &data, MessageParcel &reply); 75 int32_t ReleaseVideoBuffer(MessageParcel &data, MessageParcel &reply); 76 int32_t SetMicrophoneEnabled(MessageParcel &data, MessageParcel &reply); 77 int32_t SetCanvasRotation(MessageParcel &data, MessageParcel &reply); 78 int32_t ResizeCanvas(MessageParcel &data, MessageParcel &reply); 79 int32_t SkipPrivacyMode(MessageParcel &data, MessageParcel &reply); 80 int32_t SetMaxVideoFrameRate(MessageParcel &data, MessageParcel &reply); 81 int32_t ExcludeContent(MessageParcel &data, MessageParcel &reply); 82 83 int32_t Release(MessageParcel &data, MessageParcel &reply); 84 int32_t DestroyStub(MessageParcel &data, MessageParcel &reply); 85 86 std::mutex mutex_; 87 std::shared_ptr<IScreenCaptureService> screenCaptureServer_ = nullptr; 88 using screenCaptureStubFuncs = int32_t(ScreenCaptureServiceStub::*)(MessageParcel &data, MessageParcel &reply); 89 std::map<uint32_t, screenCaptureStubFuncs> screenCaptureStubFuncs_; 90 }; 91 } // namespace Media 92 } // namespace OHOS 93 #endif // SCREEN_CAPTURE_SERVICE_STUB_H