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 I_STANDARD_SCREEN_CAPTURE_SERVICE_H
17 #define I_STANDARD_SCREEN_CAPTURE_SERVICE_H
18 
19 #include <memory>
20 #include <atomic>
21 #include "securec.h"
22 #include "ipc_types.h"
23 #include "iremote_broker.h"
24 #include "iremote_proxy.h"
25 #include "iremote_stub.h"
26 #include "i_screen_capture_service.h"
27 
28 namespace OHOS {
29 namespace Media {
30 class IStandardScreenCaptureService : public IRemoteBroker {
31 public:
32     virtual ~IStandardScreenCaptureService() = default;
33     virtual void Release() = 0;
34     virtual int32_t DestroyStub() = 0;
35     virtual int32_t SetCaptureMode(CaptureMode captureMode) = 0;
36     virtual int32_t SetDataType(DataType dataType) = 0;
37     virtual int32_t SetRecorderInfo(RecorderInfo recorderInfo) = 0;
38     virtual int32_t SetOutputFile(int32_t fd) = 0;
39     virtual int32_t InitAudioEncInfo(AudioEncInfo audioEncInfo) = 0;
40     virtual int32_t InitAudioCap(AudioCaptureInfo audioInfo) = 0;
41     virtual int32_t InitVideoEncInfo(VideoEncInfo videoEncInfo) = 0;
42     virtual int32_t InitVideoCap(VideoCaptureInfo videoInfo) = 0;
43     virtual int32_t StartScreenCapture(bool isPrivacyAuthorityEnabled = false) = 0;
44     virtual int32_t StartScreenCaptureWithSurface(sptr<Surface> surface, bool isPrivacyAuthorityEnabled = false) = 0;
45     virtual int32_t StopScreenCapture() = 0;
46     virtual int32_t SetMicrophoneEnabled(bool isMicrophone) = 0;
47     virtual int32_t SetCanvasRotation(bool canvasRotation) = 0;
48     virtual int32_t ResizeCanvas(int32_t width, int32_t height) = 0;
49     virtual int32_t SkipPrivacyMode(std::vector<uint64_t> &windowIDsVec) = 0;
50     virtual int32_t SetMaxVideoFrameRate(int32_t frameRate) = 0;
51     virtual int32_t SetListenerObject(const sptr<IRemoteObject> &object) = 0;
52     virtual int32_t AcquireAudioBuffer(std::shared_ptr<AudioBuffer> &audioBuffer, AudioCaptureSourceType type) = 0;
53     virtual int32_t AcquireVideoBuffer(sptr<OHOS::SurfaceBuffer> &surfaceBuffer, int32_t &fence,
54                                        int64_t &timestamp, OHOS::Rect &damage) = 0;
55     virtual int32_t ReleaseAudioBuffer(AudioCaptureSourceType type) = 0;
56     virtual int32_t ReleaseVideoBuffer() = 0;
57     virtual int32_t ExcludeContent(ScreenCaptureContentFilter &contentFilter) = 0;
58 
59     /**
60      * IPC code ID
61      */
62     enum ScreenCaptureServiceMsg {
63         SET_LISTENER_OBJ = 0,
64         RELEASE = 1,
65         DESTROY = 2,
66         SET_CAPTURE_MODE = 3,
67         SET_DATA_TYPE = 4,
68         SET_RECORDER_INFO = 5,
69         SET_OUTPUT_FILE = 6,
70         INIT_AUDIO_ENC_INFO = 7,
71         INIT_AUDIO_CAP = 8,
72         INIT_VIDEO_ENC_INFO = 9,
73         INIT_VIDEO_CAP = 10,
74         ACQUIRE_AUDIO_BUF = 11,
75         ACQUIRE_VIDEO_BUF = 12,
76         RELEASE_AUDIO_BUF = 13,
77         RELEASE_VIDEO_BUF = 14,
78         SET_MIC_ENABLE = 15,
79         START_SCREEN_CAPTURE = 16,
80         START_SCREEN_CAPTURE_WITH_SURFACE = 17,
81         STOP_SCREEN_CAPTURE = 18,
82         SET_SCREEN_ROTATION = 19,
83         EXCLUDE_CONTENT = 20,
84         RESIZE_CANVAS = 21,
85         SKIP_PRIVACY = 22,
86         SET_MAX_FRAME_RATE = 23,
87     };
88 
89     DECLARE_INTERFACE_DESCRIPTOR(u"IStandardScreenCaptureService");
90 };
91 } // namespace Media
92 } // namespace OHOS
93 #endif // I_STANDARD_SCREEN_CAPTURE_SERVICE_H