• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 NATIVE_AVSCREEN_CAPTURE_H
17 #define NATIVE_AVSCREEN_CAPTURE_H
18 
19 #include <stdint.h>
20 #include <stdio.h>
21 #include "native_avscreen_capture_errors.h"
22 #include "native_avscreen_capture_base.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 /**
29  * @brief Create a screen capture
30  * @syscap SystemCapability.Multimedia.Media.AVScreenCapture
31  * @return Returns a pointer to an OH_AVScreenCapture instance
32  * @since 10
33  * @version 1.0
34  */
35 struct OH_AVScreenCapture *OH_AVScreenCapture_Create(void);
36 
37 /**
38  * @brief To init the screen capture, typically, you need to configure the description information of the audio
39  * and video, which can be extracted from the container. This interface must be called before StartAVScreenCapture
40  * called.
41  * @syscap SystemCapability.Multimedia.Media.AVScreenCapture
42  * @param capture Pointer to an OH_AVScreenCapture instance
43  * @param config Information describing the audio and video config
44  * @return Returns AVSCREEN_CAPTURE_ERR_OK if the execution is successful,
45  * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode}
46  * @since 10
47  * @version 1.0
48  */
49 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_Init(struct OH_AVScreenCapture *capture,
50     OH_AVScreenCaptureConfig config);
51 
52 /**
53  * @brief Start the av screen capture
54  * @syscap SystemCapability.Multimedia.Media.AVScreenCapture
55  * @param capture Pointer to an OH_AVScreenCapture instance
56  * @param type Information describing the data type of the capture
57  * @return Returns AVSCREEN_CAPTURE_ERR_OK if the execution is successful,
58  * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode}
59  * @since 10
60  * @version 1.0
61  */
62 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StartScreenCapture(struct OH_AVScreenCapture *capture);
63 
64 /**
65  * @brief Stop the av screen capture
66  * @syscap SystemCapability.Multimedia.Media.AVScreenCapture
67  * @param capture Pointer to an OH_AVScreenCapture instance
68  * @return Returns AVSCREEN_CAPTURE_ERR_OK if the execution is successful,
69  * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode}
70  * @since 10
71  * @version 1.0
72  */
73 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StopScreenCapture(struct OH_AVScreenCapture *capture);
74 
75 /**
76  * @brief Start av screen record use to start save screen record file.
77  * @syscap SystemCapability.Multimedia.Media.AVScreenCapture
78  * @param capture Pointer to an OH_AVScreenCapture instance
79  * @return Returns AVSCREEN_CAPTURE_ERR_OK if the execution is successful,
80  * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode}
81  * @since 10
82  * @version 1.0
83  */
84 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StartScreenRecording(struct OH_AVScreenCapture *capture);
85 
86 /**
87  * @brief Start av screen record use to stop save screen record file.
88  * @syscap SystemCapability.Multimedia.Media.AVScreenCapture
89  * @param capture Pointer to an OH_AVScreenCapture instance
90  * @return Returns AVSCREEN_CAPTURE_ERR_OK if the execution is successful,
91  * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode}
92  * @since 10
93  * @version 1.0
94  */
95 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_StopScreenRecording(struct OH_AVScreenCapture *capture);
96 
97 /**
98  * @brief Acquire the audio buffer for the av screen capture
99  * @syscap SystemCapability.Multimedia.Media.AVScreenCapture
100  * @param capture Pointer to an OH_AVScreenCapture instance
101  * @param audiobuffer Information describing the audio buffer of the capture
102  * @param type Information describing the audio source type
103  * @return Returns AVSCREEN_CAPTURE_ERR_OK if the execution is successful,
104  * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode}
105  * @since 10
106  * @version 1.0
107  */
108 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_AcquireAudioBuffer(struct OH_AVScreenCapture *capture,
109     OH_AudioBuffer **audiobuffer, OH_AudioCaptureSourceType type);
110 
111 /**
112  * @brief Acquire the video buffer for the av screen capture
113  * @syscap SystemCapability.Multimedia.Media.AVScreenCapture
114  * @param capture Pointer to an OH_AVScreenCapture instance
115  * @param fence A processing state of display buffer
116  * @param timestamp Information about the video buffer
117  * @param region Information about the video buffer
118  * @return Returns a pointer to an OH_NativeBuffer instance
119  * @since 10
120  * @version 1.0
121  */
122 OH_NativeBuffer* OH_AVScreenCapture_AcquireVideoBuffer(struct OH_AVScreenCapture *capture,
123     int32_t *fence, int64_t *timestamp, struct OH_Rect *region);
124 
125 /**
126  * @brief Release the audio buffer for the av screen capture
127  * @syscap SystemCapability.Multimedia.Media.AVScreenCapture
128  * @param capture Pointer to an OH_AVScreenCapture instance
129  * @param type Information describing the audio source type
130  * @return Returns AVSCREEN_CAPTURE_ERR_OK if the execution is successful,
131  * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode}
132  * @since 10
133  * @version 1.0
134  */
135 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ReleaseAudioBuffer(struct OH_AVScreenCapture *capture,
136     OH_AudioCaptureSourceType type);
137 
138 /**
139  * @brief Release the video buffer for the av screen capture
140  * @syscap SystemCapability.Multimedia.Media.AVScreenCapture
141  * @param capture Pointer to an OH_AVScreenCapture instance
142  * @return Returns AVSCREEN_CAPTURE_ERR_OK if the execution is successful,
143  * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode}
144  * @since 10
145  * @version 1.0
146  */
147 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ReleaseVideoBuffer(struct OH_AVScreenCapture *capture);
148 
149 /**
150  * @brief Set the callback function so that your application
151  * can respond to the events generated by the av screen capture. This interface must be called before Init is called.
152  * @syscap SystemCapability.Multimedia.Media.AVScreenCapture
153  * @param capture Pointer to an OH_AVScreenCapture instance
154  * @param callback A collection of all callback functions, see {@link OH_AVScreenCaptureCallback}
155  * @return Returns AVSCREEN_CAPTURE_ERR_OK if the execution is successful,
156  * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode}
157  * @since 10
158  * @version 1.0
159  */
160 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetCallback(struct OH_AVScreenCapture *capture,
161     struct OH_AVScreenCaptureCallback callback);
162 
163 /**
164  * @brief Release the av screen capture
165  * @syscap SystemCapability.Multimedia.Media.AVScreenCapture
166  * @param capture Pointer to an OH_AVScreenCapture instance
167  * @return Returns AVSCREEN_CAPTURE_ERR_OK if the execution is successful,
168  * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode}
169  * @since 10
170  * @version 1.0
171  */
172 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_Release(struct OH_AVScreenCapture *capture);
173 
174 /**
175  * @brief Controls the switch of the microphone, which is turned on by default
176  * @syscap SystemCapability.Multimedia.Media.AVScreenCapture
177  * @param capture Pointer to an OH_AVScreenCapture instance
178  * @param isMicrophone The switch of the microphone
179  * @return Returns AVSCREEN_CAPTURE_ERR_OK if the execution is successful,
180  * otherwise returns a specific error code, refer to {@link OH_AVSCREEN_CAPTURE_ErrCode}
181  * @since 10
182  * @version 1.0
183  */
184 OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetMicrophoneEnabled(struct OH_AVScreenCapture *capture,
185     bool isMicrophone);
186 
187 #ifdef __cplusplus
188 }
189 #endif
190 
191 #endif // NATIVE_AVSCREEN_CAPTURE_H