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_CLIENT_H 17 #define SCREEN_CAPTURE_CLIENT_H 18 19 #include "i_screen_capture_service.h" 20 #include "i_standard_screen_capture_service.h" 21 #include "screen_capture_listener_stub.h" 22 23 namespace OHOS { 24 namespace Media { 25 class ScreenCaptureClient : public IScreenCaptureService, public NoCopyable { 26 public: 27 static std::shared_ptr<ScreenCaptureClient> Create(const sptr<IStandardScreenCaptureService> &ipcProxy); 28 explicit ScreenCaptureClient(const sptr<IStandardScreenCaptureService> &ipcProxy); 29 ~ScreenCaptureClient(); 30 int32_t CreateListenerObject(); 31 32 // ScreenCaptureClient 33 void MediaServerDied(); 34 int32_t SetCaptureMode(CaptureMode captureMode) override; 35 int32_t SetDataType(DataType dataType) override; 36 int32_t SetRecorderInfo(RecorderInfo recorderInfo) override; 37 int32_t SetOutputFile(int32_t fd) override; 38 int32_t InitAudioEncInfo(AudioEncInfo audioEncInfo) override; 39 int32_t InitAudioCap(AudioCaptureInfo audioInfo) override; 40 int32_t InitVideoEncInfo(VideoEncInfo videoEncInfo) override; 41 int32_t InitVideoCap(VideoCaptureInfo videoInfo) override; 42 int32_t StartScreenCapture(bool isPrivacyAuthorityEnabled) override; 43 int32_t StartScreenCaptureWithSurface(sptr<Surface> surface, bool isPrivacyAuthorityEnabled) override; 44 int32_t StopScreenCapture() override; 45 int32_t AcquireAudioBuffer(std::shared_ptr<AudioBuffer> &audioBuffer, AudioCaptureSourceType type) override; 46 int32_t AcquireVideoBuffer(sptr<OHOS::SurfaceBuffer> &surfaceBuffer, int32_t &fence, 47 int64_t ×tamp, OHOS::Rect &damage) override; 48 int32_t ReleaseAudioBuffer(AudioCaptureSourceType type) override; 49 int32_t ReleaseVideoBuffer() override; 50 int32_t SetMicrophoneEnabled(bool isMicrophone) override; 51 int32_t SetCanvasRotation(bool canvasRotation) override; 52 int32_t ResizeCanvas(int32_t width, int32_t height) override; 53 int32_t SkipPrivacyMode(std::vector<uint64_t> &windowIDsVec) override; 54 int32_t SetMaxVideoFrameRate(int32_t frameRate) override; 55 int32_t SetScreenCaptureCallback(const std::shared_ptr<ScreenCaptureCallBack> &callback) override; 56 void Release() override; 57 int32_t ExcludeContent(ScreenCaptureContentFilter &contentFilter) override; 58 59 private: 60 sptr<IStandardScreenCaptureService> screenCaptureProxy_ = nullptr; 61 sptr<ScreenCaptureListenerStub> listenerStub_ = nullptr; 62 std::shared_ptr<ScreenCaptureCallBack> callback_ = nullptr; 63 std::mutex mutex_; 64 }; 65 } // namespace Media 66 } // namespace OHOS 67 #endif // SCREEN_CAPTURE_CLIENT_H