1 /*
2 mediastreamer2 library - modular sound and video processing and streaming
3 Copyright (C) 2010  Simon MORLAT (simon.morlat@linphone.org)
4 
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18 */
19 
20 #ifndef msinterfaces_h
21 #define msinterfaces_h
22 
23 #include "mediastreamer2/mscodecutils.h"
24 
25 typedef struct _MSVideoCodecSLI MSVideoCodecSLI;
26 
27 struct _MSVideoCodecSLI {
28 	uint16_t first;
29 	uint16_t number;
30 	uint8_t picture_id;
31 };
32 
33 typedef struct _MSVideoCodecRPSI MSVideoCodecRPSI;
34 
35 struct _MSVideoCodecRPSI {
36 	uint8_t *bit_string;
37 	uint16_t bit_string_len;
38 };
39 
40 typedef struct _MSVideoEncoderPixFmt MSVideoEncoderPixFmt;
41 
42 struct _MSVideoEncoderPixFmt {
43 	uint32_t pixfmt;
44 	bool_t supported;
45 };
46 
47 /**
48  * Interface definition for video display filters.
49 **/
50 
51 typedef struct _MSVideoDisplayDecodingSupport MSVideoDisplayDecodingSupport;
52 
53 struct _MSVideoDisplayDecodingSupport {
54 	const char *mime_type;	/**< Input parameter to asking if the display supports decoding of this mime type */
55 	bool_t supported;	/**< Output telling whether the display supports decoding to the specified mime type */
56 };
57 
58 /** whether the video window should be resized to the stream's resolution*/
59 #define MS_VIDEO_DISPLAY_ENABLE_AUTOFIT \
60 	MS_FILTER_METHOD(MSFilterVideoDisplayInterface,0,int)
61 
62 /**position of the local view */
63 #define MS_VIDEO_DISPLAY_SET_LOCAL_VIEW_MODE \
64 	MS_FILTER_METHOD(MSFilterVideoDisplayInterface,1,int)
65 
66 /**whether the video should be reversed as in mirror */
67 #define MS_VIDEO_DISPLAY_ENABLE_MIRRORING \
68 	MS_FILTER_METHOD(MSFilterVideoDisplayInterface,2,int)
69 
70 /**returns a platform dependant window id where the video is drawn */
71 #define MS_VIDEO_DISPLAY_GET_NATIVE_WINDOW_ID \
72 	MS_FILTER_METHOD(MSFilterVideoDisplayInterface,3,void*)
73 
74 
75 /**Sets an external native window id where the video is to be drawn */
76 #define MS_VIDEO_DISPLAY_SET_NATIVE_WINDOW_ID \
77 	MS_FILTER_METHOD(MSFilterVideoDisplayInterface,4,void*)
78 
79 
80 /**scale factor of the local view */
81 #define MS_VIDEO_DISPLAY_SET_LOCAL_VIEW_SCALEFACTOR \
82 	MS_FILTER_METHOD(MSFilterVideoDisplayInterface,5,float)
83 
84 /**Set the background colour for video window */
85 #define MS_VIDEO_DISPLAY_SET_BACKGROUND_COLOR \
86 	MS_FILTER_METHOD(MSFilterVideoDisplayInterface,8,int[3])
87 
88 /**Show video. Useful to free XV port */
89 #define MS_VIDEO_DISPLAY_SHOW_VIDEO \
90 	MS_FILTER_METHOD(MSFilterVideoDisplayInterface,9,int)
91 
92 #define MS_VIDEO_DISPLAY_ZOOM \
93 	MS_FILTER_METHOD(MSFilterVideoDisplayInterface,10,int[4])
94 
95 /**Specifiy device orientation from portrait */
96 #define MS_VIDEO_DISPLAY_SET_DEVICE_ORIENTATION \
97    MS_FILTER_METHOD(MSFilterVideoDisplayInterface,11,int)
98 
99 /**
100   * Interface definitions for players
101 **/
102 
103 enum _MSPlayerState{
104 	MSPlayerClosed,
105 	MSPlayerPaused,
106 	MSPlayerPlaying
107 };
108 
109 typedef enum _MSPlayerState MSPlayerState;
110 
111 /**open a media file*/
112 #define MS_PLAYER_OPEN \
113 	MS_FILTER_METHOD(MSFilterPlayerInterface,0,const char )
114 
115 #define MS_PLAYER_START \
116 	MS_FILTER_METHOD_NO_ARG(MSFilterPlayerInterface,1)
117 
118 #define MS_PLAYER_PAUSE \
119 	MS_FILTER_METHOD_NO_ARG(MSFilterPlayerInterface,2)
120 
121 #define MS_PLAYER_CLOSE \
122 	MS_FILTER_METHOD_NO_ARG(MSFilterPlayerInterface,3)
123 
124 #define MS_PLAYER_SEEK_MS \
125 	MS_FILTER_METHOD(MSFilterPlayerInterface,4,int)
126 
127 #define MS_PLAYER_GET_STATE \
128 	MS_FILTER_METHOD(MSFilterPlayerInterface,5,MSPlayerState)
129 
130 /**enable loop mode. Argument is a pause interval in milliseconds to be observed between end of play and resuming at start. A value of -1 disables loop mode*/
131 #define MS_PLAYER_SET_LOOP \
132 	MS_FILTER_METHOD(MSFilterPlayerInterface,6,int)
133 
134 #define MS_PLAYER_GET_DURATION \
135 	MS_FILTER_METHOD(MSFilterPlayerInterface,7,int)
136 
137 #define MS_PLAYER_GET_CURRENT_POSITION \
138 	MS_FILTER_METHOD(MSFilterPlayerInterface,8,int64_t)
139 
140 #define MS_PLAYER_EOF \
141 	MS_FILTER_EVENT_NO_ARG(MSFilterPlayerInterface,0)
142 
143 
144 /**
145   * Interface definitions for recorders
146 **/
147 
148 enum _MSRecorderState{
149 	MSRecorderClosed,
150 	MSRecorderPaused,
151 	MSRecorderRunning
152 };
153 
154 typedef enum _MSRecorderState MSRecorderState;
155 
156 /**open a media file for recording*/
157 #define MS_RECORDER_OPEN \
158 	MS_FILTER_METHOD(MSFilterRecorderInterface,0,const char )
159 
160 #define MS_RECORDER_START \
161 	MS_FILTER_METHOD_NO_ARG(MSFilterRecorderInterface,1)
162 
163 #define MS_RECORDER_PAUSE \
164 	MS_FILTER_METHOD_NO_ARG(MSFilterRecorderInterface,2)
165 
166 #define MS_RECORDER_CLOSE \
167 	MS_FILTER_METHOD_NO_ARG(MSFilterRecorderInterface,3)
168 
169 #define MS_RECORDER_GET_STATE \
170 	MS_FILTER_METHOD(MSFilterRecorderInterface,5,MSRecorderState)
171 
172 #define MS_RECORDER_NEEDS_FIR \
173 	MS_FILTER_EVENT_NO_ARG(MSFilterRecorderInterface,0)
174 
175 #define MS_RECORDER_SET_MAX_SIZE \
176 	MS_FILTER_METHOD(MSFilterRecorderInterface,6,int)
177 
178 #define MS_RECORDER_MAX_SIZE_REACHED \
179 	MS_FILTER_EVENT_NO_ARG(MSFilterRecorderInterface,1)
180 
181 
182 /** Interface definitions for echo cancellers */
183 
184 /** sets the echo delay in milliseconds*/
185 #define MS_ECHO_CANCELLER_SET_DELAY \
186 	MS_FILTER_METHOD(MSFilterEchoCancellerInterface,0,int)
187 
188 #define MS_ECHO_CANCELLER_SET_FRAMESIZE \
189 	MS_FILTER_METHOD(MSFilterEchoCancellerInterface,1,int)
190 
191 /** sets tail length in milliseconds */
192 #define MS_ECHO_CANCELLER_SET_TAIL_LENGTH \
193 	MS_FILTER_METHOD(MSFilterEchoCancellerInterface,2,int)
194 
195 /** put filter in bypass mode */
196 #define MS_ECHO_CANCELLER_SET_BYPASS_MODE \
197 	MS_FILTER_METHOD(MSFilterEchoCancellerInterface,3,bool_t)
198 /** get filter bypass mode */
199 #define MS_ECHO_CANCELLER_GET_BYPASS_MODE \
200 	MS_FILTER_METHOD(MSFilterEchoCancellerInterface,4,bool_t)
201 
202 /** retrieve echo canceller internal state, as a base64 encoded string */
203 #define MS_ECHO_CANCELLER_GET_STATE_STRING \
204 	MS_FILTER_METHOD(MSFilterEchoCancellerInterface,5,char *)
205 
206 /** restore a previous state suppling the echo canceller config as base64 encoded string */
207 #define MS_ECHO_CANCELLER_SET_STATE_STRING \
208 	MS_FILTER_METHOD(MSFilterEchoCancellerInterface,6, const char)
209 
210 
211 
212 /** Event definitions for video decoders */
213 #define MS_VIDEO_DECODER_DECODING_ERRORS \
214 	MS_FILTER_EVENT_NO_ARG(MSFilterVideoDecoderInterface,0)
215 #define MS_VIDEO_DECODER_FIRST_IMAGE_DECODED \
216 	MS_FILTER_EVENT_NO_ARG(MSFilterVideoDecoderInterface,1)
217 #define MS_VIDEO_DECODER_SEND_PLI \
218 	MS_FILTER_EVENT_NO_ARG(MSFilterVideoDecoderInterface, 2)
219 #define MS_VIDEO_DECODER_SEND_SLI \
220 	MS_FILTER_EVENT(MSFilterVideoDecoderInterface, 3, MSVideoCodecSLI)
221 #define MS_VIDEO_DECODER_SEND_RPSI \
222 	MS_FILTER_EVENT(MSFilterVideoDecoderInterface, 4, MSVideoCodecRPSI)
223 
224 /** Method definitions for video decoders */
225 #define MS_VIDEO_DECODER_RESET_FIRST_IMAGE_NOTIFICATION \
226 	MS_FILTER_METHOD_NO_ARG(MSFilterVideoDecoderInterface, 5)
227 #define MS_VIDEO_DECODER_ENABLE_AVPF \
228 	MS_FILTER_METHOD(MSFilterVideoDecoderInterface, 6, bool_t)
229 #define MS_VIDEO_DECODER_SUPPORT_RENDERING \
230 	MS_FILTER_METHOD(MSFilterVideoDecoderInterface, 7, MSVideoDisplayDecodingSupport)
231 #define MS_VIDEO_DECODER_FREEZE_ON_ERROR \
232 	MS_FILTER_METHOD(MSFilterVideoDecoderInterface, 8, bool_t)
233 #define MS_VIDEO_DECODER_RECOVERED_FROM_ERRORS \
234 	MS_FILTER_EVENT_NO_ARG(MSFilterVideoDecoderInterface, 9)
235 #define MS_VIDEO_DECODER_RESET \
236 	MS_FILTER_METHOD_NO_ARG(MSFilterVideoDecoderInterface, 10)
237 
238 
239 
240 /** Interface definitions for video capture */
241 #define MS_VIDEO_CAPTURE_SET_DEVICE_ORIENTATION \
242 	MS_FILTER_METHOD(MSFilterVideoCaptureInterface,0,int)
243 #define MS_VIDEO_CAPTURE_GET_CAMERA_SENSOR_ROTATION \
244 	MS_FILTER_METHOD(MSFilterVideoCaptureInterface, 1, int)
245 
246 /** Interface definitions for audio decoder */
247 
248 #define MS_AUDIO_DECODER_HAVE_PLC \
249 	MS_FILTER_METHOD(MSFilterAudioDecoderInterface,0,int)
250 
251 #define MS_DECODER_HAVE_PLC MS_AUDIO_DECODER_HAVE_PLC /*for backward compatibility*/
252 
253 #define MS_AUDIO_DECODER_SET_RTP_PAYLOAD_PICKER \
254 	MS_FILTER_METHOD(MSFilterAudioDecoderInterface,1,MSRtpPayloadPickerContext)
255 
256 #define MS_DECODER_ENABLE_PLC MS_FILTER_METHOD(MSFilterAudioDecoderInterface,2,int)
257 /**
258  * Interface definition for video encoders.
259 **/
260 
261 #define MS_VIDEO_ENCODER_SUPPORTS_PIXFMT \
262 	MS_FILTER_METHOD(MSFilterVideoEncoderInterface, 0, MSVideoEncoderPixFmt)
263 /* request a video-fast-update (=I frame for H263,MP4V-ES) to a video encoder*/
264 #define MS_VIDEO_ENCODER_REQ_VFU \
265 	MS_FILTER_METHOD_NO_ARG(MSFilterVideoEncoderInterface, 1)
266 #define MS_VIDEO_ENCODER_GET_CONFIGURATION_LIST \
267 	MS_FILTER_METHOD(MSFilterVideoEncoderInterface, 2, const MSVideoConfiguration *)
268 #define MS_VIDEO_ENCODER_SET_CONFIGURATION \
269 	MS_FILTER_METHOD(MSFilterVideoEncoderInterface, 3, const MSVideoConfiguration )
270 #define MS_VIDEO_ENCODER_NOTIFY_PLI \
271 	MS_FILTER_METHOD_NO_ARG(MSFilterVideoEncoderInterface, 4)
272 #define MS_VIDEO_ENCODER_NOTIFY_FIR \
273 	MS_FILTER_METHOD(MSFilterVideoEncoderInterface, 5, uint8_t *)
274 #define MS_VIDEO_ENCODER_NOTIFY_SLI \
275 	MS_FILTER_METHOD(MSFilterVideoEncoderInterface, 6, MSVideoCodecSLI)
276 #define MS_VIDEO_ENCODER_NOTIFY_RPSI \
277 	MS_FILTER_METHOD(MSFilterVideoEncoderInterface, 7, MSVideoCodecRPSI)
278 #define MS_VIDEO_ENCODER_ENABLE_AVPF \
279 	MS_FILTER_METHOD(MSFilterVideoEncoderInterface, 8, bool_t)
280 #define MS_VIDEO_ENCODER_SET_CONFIGURATION_LIST \
281 	MS_FILTER_METHOD(MSFilterVideoEncoderInterface, 9, const MSVideoConfiguration *)
282 #define MS_VIDEO_ENCODER_IS_HARDWARE_ACCELERATED \
283 	MS_FILTER_METHOD(MSFilterVideoEncoderInterface, 10, bool_t)
284 
285 /** Interface definitions for audio capture */
286 /* Start numbering from the end for hacks */
287 #define MS_AUDIO_CAPTURE_SET_VOLUME_GAIN \
288 	MS_FILTER_METHOD(MSFilterAudioCaptureInterface, 0, float)
289 #define MS_AUDIO_CAPTURE_GET_VOLUME_GAIN \
290 	MS_FILTER_METHOD(MSFilterAudioCaptureInterface, 1, float)
291 #define MS_AUDIO_CAPTURE_FORCE_SPEAKER_STATE \
292 	MS_FILTER_METHOD(MSFilterAudioCaptureInterface, 255, bool_t)
293 
294 /** Interface definitions for audio playback */
295 enum _MSAudioRoute{
296 	MSAudioRouteEarpiece,
297 	MSAudioRouteSpeaker
298 };
299 typedef enum _MSAudioRoute MSAudioRoute;
300 
301 #define MS_AUDIO_PLAYBACK_SET_VOLUME_GAIN \
302 	MS_FILTER_METHOD(MSFilterAudioPlaybackInterface, 0, float)
303 #define MS_AUDIO_PLAYBACK_GET_VOLUME_GAIN \
304 	MS_FILTER_METHOD(MSFilterAudioPlaybackInterface, 1, float)
305 #define MS_AUDIO_PLAYBACK_SET_ROUTE \
306 	MS_FILTER_METHOD(MSFilterAudioPlaybackInterface, 2, MSAudioRoute)
307 #define MS_AUDIO_PLAYBACK_MUTE \
308 	MS_FILTER_METHOD(MSFilterAudioPlaybackInterface, 3, int)
309 
310 /** Interface definitions for audio encoder */
311 #define MS_AUDIO_ENCODER_SET_PTIME \
312 	MS_FILTER_METHOD(MSFilterAudioEncoderInterface,0,int)
313 
314 #define MS_AUDIO_ENCODER_GET_PTIME \
315 	MS_FILTER_METHOD(MSFilterAudioEncoderInterface,1,int)
316 
317 /* Enable encoder's builtin forward error correction, if available*/
318 #define MS_AUDIO_ENCODER_ENABLE_FEC \
319 	MS_FILTER_METHOD(MSFilterAudioEncoderInterface,2,int)
320 
321 /* Set the packet loss percentage reported, so that encoder may compensate if forward-correction is enabled and implemented.*/
322 #define MS_AUDIO_ENCODER_SET_PACKET_LOSS \
323 	MS_FILTER_METHOD(MSFilterAudioEncoderInterface,3,int)
324 
325 #define MS_AUDIO_ENCODER_CAP_AUTO_PTIME (1)
326 
327 #define MS_AUDIO_ENCODER_GET_CAPABILITIES \
328 	MS_FILTER_METHOD(MSFilterAudioEncoderInterface,4,int)
329 
330 /** Interface definitions for void source/sink */
331 #define MS_VOID_SOURCE_SEND_SILENCE \
332 	MS_FILTER_METHOD(MSFilterVoidInterface, 0, bool_t)
333 
334 #endif
335