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 InitAudioCap(AudioCaptureInfo audioInfo) override; 34 int32_t InitVideoCap(VideoCaptureInfo videoInfo) override; 35 int32_t StartScreenCapture() override; 36 int32_t StopScreenCapture() override; 37 int32_t AcquireAudioBuffer(std::shared_ptr<AudioBuffer> &audioBuffer, AudioCaptureSourceType type) override; 38 int32_t AcquireVideoBuffer(sptr<OHOS::SurfaceBuffer> &surfaceBuffer, int32_t &fence, 39 int64_t ×tamp, OHOS::Rect &damage) override; 40 int32_t ReleaseAudioBuffer(AudioCaptureSourceType type) override; 41 int32_t ReleaseVideoBuffer() override; 42 int32_t SetMicrophoneEnabled(bool isMicrophone) override; 43 int32_t SetListenerObject(const sptr<IRemoteObject> &object) override; 44 int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; 45 46 private: 47 ScreenCaptureServiceStub(); 48 int32_t Init(); 49 int32_t SetCaptureMode(MessageParcel &data, MessageParcel &reply); 50 int32_t InitAudioCap(MessageParcel &data, MessageParcel &reply); 51 int32_t InitVideoCap(MessageParcel &data, MessageParcel &reply); 52 int32_t StartScreenCapture(MessageParcel &data, MessageParcel &reply); 53 int32_t StopScreenCapture(MessageParcel &data, MessageParcel &reply); 54 int32_t SetListenerObject(MessageParcel &data, MessageParcel &reply); 55 int32_t AcquireAudioBuffer(MessageParcel &data, MessageParcel &reply); 56 int32_t AcquireVideoBuffer(MessageParcel &data, MessageParcel &reply); 57 int32_t ReleaseAudioBuffer(MessageParcel &data, MessageParcel &reply); 58 int32_t ReleaseVideoBuffer(MessageParcel &data, MessageParcel &reply); 59 int32_t SetMicrophoneEnabled(MessageParcel &data, MessageParcel &reply); 60 61 int32_t Release(MessageParcel &data, MessageParcel &reply); 62 int32_t DestroyStub(MessageParcel &data, MessageParcel &reply); 63 64 std::mutex mutex_; 65 std::shared_ptr<IScreenCaptureService> screenCaptureServer_ = nullptr; 66 using screenCaptureStubFuncs = int32_t(ScreenCaptureServiceStub::*)(MessageParcel &data, MessageParcel &reply); 67 std::map<uint32_t, screenCaptureStubFuncs> screenCaptureStubFuncs_; 68 }; 69 } // namespace Media 70 } // namespace OHOS 71 #endif // SCREEN_CAPTURE_SERVICE_STUB_H