mediastream.h 18.7 KB
Newer Older
aymeric's avatar
aymeric committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
/*
mediastreamer2 library - modular sound and video processing and streaming
Copyright (C) 2006  Simon MORLAT (simon.morlat@linphone.org)

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/


#ifndef MEDIASTREAM_H
#define MEDIASTREAM_H

Simon Morlat's avatar
Simon Morlat committed
24 25 26 27 28
#include <mediastreamer2/msfilter.h>
#include <mediastreamer2/msticker.h>
#include <mediastreamer2/mssndcard.h>
#include <mediastreamer2/mswebcam.h>
#include <mediastreamer2/msvideo.h>
29 30
#include <mediastreamer2/bitratecontrol.h>
#include <mediastreamer2/qualityindicator.h>
31
#include <mediastreamer2/ice.h>
Simon Morlat's avatar
Simon Morlat committed
32 33
#include <ortp/ortp.h>
#include <ortp/event.h>
Guillaume Beraudo's avatar
Guillaume Beraudo committed
34
#include <ortp/zrtp.h>
35
#include <ortp/ortp_srtp.h>
36

37
#include <ortp/zrtp.h>
aymeric's avatar
aymeric committed
38

Ghislain MARY's avatar
Ghislain MARY committed
39

Simon Morlat's avatar
Simon Morlat committed
40 41 42
#define PAYLOAD_TYPE_FLAG_CAN_RECV	PAYLOAD_TYPE_USER_FLAG_1
#define PAYLOAD_TYPE_FLAG_CAN_SEND	PAYLOAD_TYPE_USER_FLAG_2

Ghislain MARY's avatar
Ghislain MARY committed
43 44 45 46 47

#ifdef __cplusplus
extern "C" {
#endif

48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
/**
 * @addtogroup ring_api
 * @{
**/

struct _RingStream
{
	MSTicker *ticker;
	MSFilter *source;
	MSFilter *gendtmf;
	MSFilter *write_resampler;
	MSFilter *sndwrite;
};

typedef struct _RingStream RingStream;

MS2_PUBLIC RingStream *ring_start (const char * file, int interval, MSSndCard *sndcard);
MS2_PUBLIC RingStream *ring_start_with_cb(const char * file, int interval, MSSndCard *sndcard, MSFilterNotifyFunc func, void * user_data);
MS2_PUBLIC void ring_stop (RingStream * stream);

/**
 * @}
**/


Ghislain MARY's avatar
Ghislain MARY committed
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
typedef enum StreamType {
	AudioStreamType,
	VideoStreamType
} StreamType;

struct _MediaStream {
	StreamType type;
	MSTicker *ticker;
	RtpSession *session;
	OrtpEvQueue *evq;
	MSFilter *rtprecv;
	MSFilter *rtpsend;
	MSFilter *encoder;
	MSFilter *decoder;
	MSFilter *voidsink;
	MSBitrateController *rc;
	IceCheckList *ice_check_list;
	OrtpZrtpContext *zrtp_context;
	srtp_t srtp_session;
	bool_t use_rc;
};

typedef struct _MediaStream MediaStream;

97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
MS2_PUBLIC void media_stream_set_rtcp_information(MediaStream *stream, const char *cname, const char *tool);

MS2_PUBLIC void media_stream_get_local_rtp_stats(MediaStream *stream, rtp_stats_t *stats);

MS2_PUBLIC int media_stream_set_dscp(MediaStream *stream, int dscp);

MS2_PUBLIC void media_stream_enable_adaptive_bitrate_control(MediaStream *stream, bool_t enabled);

MS2_PUBLIC void media_stream_enable_adaptive_jittcomp(MediaStream *stream, bool_t enabled);

MS2_PUBLIC bool_t media_stream_enable_srtp(MediaStream* stream, enum ortp_srtp_crypto_suite_t suite, const char* snd_key, const char* rcv_key);


/**
 * @addtogroup audio_stream_api
 * @{
**/

115 116 117
typedef enum EchoLimiterType{
	ELInactive,
	ELControlMic,
118
	ELControlFull
119 120
} EchoLimiterType;

aymeric's avatar
aymeric committed
121 122
struct _AudioStream
{
Ghislain MARY's avatar
Ghislain MARY committed
123
	MediaStream ms;
aymeric's avatar
aymeric committed
124 125 126
	MSFilter *soundread;
	MSFilter *soundwrite;
	MSFilter *dtmfgen;
127
	MSFilter *dtmfgen_rtp;
Yann Diorcet's avatar
Yann Diorcet committed
128
	MSFilter *plc;
aymeric's avatar
aymeric committed
129
	MSFilter *ec;/*echo canceler*/
130
	MSFilter *volsend,*volrecv; /*MSVolumes*/
131 132
	MSFilter *read_resampler;
	MSFilter *write_resampler;
smorlat's avatar
smorlat committed
133
	MSFilter *equalizer;
Simon Morlat's avatar
Simon Morlat committed
134
	MSFilter *dummy;
aymeric's avatar
aymeric committed
135
	uint64_t last_packet_count;
aymeric's avatar
aymeric committed
136
	time_t last_packet_time;
137
	EchoLimiterType el_type; /*use echo limiter: two MSVolume, measured input level controlling local output level*/
138
	MSQualityIndicator *qi;
139
	time_t start_time;
Ghislain MARY's avatar
Ghislain MARY committed
140
	uint32_t features;
smorlat's avatar
smorlat committed
141
	bool_t play_dtmfs;
smorlat's avatar
smorlat committed
142
	bool_t use_gc;
143
	bool_t use_agc;
smorlat's avatar
smorlat committed
144
	bool_t eq_active;
145
	bool_t use_ng;/*noise gate*/
146
	bool_t is_beginning;
aymeric's avatar
aymeric committed
147 148
};

149 150 151
/**
 * The AudioStream holds all resources to create and run typical VoIP audiostream.
**/
aymeric's avatar
aymeric committed
152 153 154 155
typedef struct _AudioStream AudioStream;


/* start a thread that does sampling->encoding->rtp_sending|rtp_receiving->decoding->playing */
Simon Morlat's avatar
Simon Morlat committed
156
MS2_PUBLIC AudioStream *audio_stream_start (RtpProfile * prof, int locport, const char *remip,
aymeric's avatar
aymeric committed
157 158
				 int remport, int payload_type, int jitt_comp, bool_t echo_cancel);

Simon Morlat's avatar
Simon Morlat committed
159
MS2_PUBLIC AudioStream *audio_stream_start_with_sndcards(RtpProfile * prof, int locport, const char *remip4, int remport, int payload_type, int jitt_comp, MSSndCard *playcard, MSSndCard *captcard, bool_t echocancel);
aymeric's avatar
aymeric committed
160

161

Simon Morlat's avatar
Simon Morlat committed
162
MS2_PUBLIC int audio_stream_start_with_files (AudioStream * stream, RtpProfile * prof,
aymeric's avatar
aymeric committed
163 164 165 166
					    const char *remip, int remport, int rem_rtcp_port,
					    int pt, int jitt_comp,
					    const char * infile,  const char * outfile);

167 168 169 170 171 172 173 174 175
/**
 * Starts an audio stream from/to local wav files or soundcards.
 * 
 * This method starts the processing of the audio stream, that is playing from wav file or soundcard, voice processing, encoding,
 * sending through RTP, receiving from RTP, decoding, voice processing and wav file recording or soundcard playback.
 * 
 * 
 * @param stream an AudioStream previously created with audio_stream_new().
 * @param prof a RtpProfile containing all PayloadType possible during the audio session.
176 177 178
 * @param rem_rtp_ip remote IP address where to send the encoded audio.
 * @param rem_rtp_port remote IP port where to send the encoded audio.
 * @param rem_rtcp_ip remote IP address for RTCP.
179 180 181 182 183 184 185 186 187 188
 * @param rem_rtcp_port remote port for RTCP.
 * @param payload_type payload type index to use for the sending stream. This index must point to a valid PayloadType in the RtpProfile.
 * @param jitt_comp Nominal jitter buffer size in milliseconds.
 * @param infile path to wav file to play out (can be NULL)
 * @param outfile path to wav file to record into (can be NULL)
 * @param playcard The soundcard to be used for playback (can be NULL)
 * @param captcard The soundcard to be used for catpure. (can be NULL)
 * @param echo_cancel whether echo cancellation is to be performed.
 * @returns 0 if sucessful, -1 otherwise.
**/
189 190
MS2_PUBLIC int audio_stream_start_full(AudioStream *stream, RtpProfile *profile, const char *rem_rtp_ip,int rem_rtp_port,
	const char *rem_rtcp_ip, int rem_rtcp_port, int payload,int jitt_comp, const char *infile, const char *outfile,
191 192
	MSSndCard *playcard, MSSndCard *captcard, bool_t use_ec);

193

Simon Morlat's avatar
Simon Morlat committed
194 195
MS2_PUBLIC void audio_stream_play(AudioStream *st, const char *name);
MS2_PUBLIC void audio_stream_record(AudioStream *st, const char *name);
aymeric's avatar
aymeric committed
196

Ghislain MARY's avatar
Ghislain MARY committed
197 198 199
MS2_PUBLIC static inline void audio_stream_set_rtcp_information(AudioStream *st, const char *cname, const char *tool) {
	media_stream_set_rtcp_information(&st->ms, cname, tool);
}
aymeric's avatar
aymeric committed
200

Simon Morlat's avatar
Simon Morlat committed
201
MS2_PUBLIC void audio_stream_play_received_dtmfs(AudioStream *st, bool_t yesno);
smorlat's avatar
smorlat committed
202

203 204
/**
 * Creates an AudioStream object listening on a RTP port.
205 206
 * @param loc_rtp_port the local UDP port to listen for RTP packets.
 * @param loc_rtcp_port the local UDP port to listen for RTCP packets
207 208 209
 * @param ipv6 TRUE if ipv6 must be used.
 * @returns a new AudioStream.
**/
210
MS2_PUBLIC AudioStream *audio_stream_new(int loc_rtp_port, int loc_rtcp_port, bool_t ipv6);
Simon Morlat's avatar
Simon Morlat committed
211

212 213 214 215 216 217 218
#define AUDIO_STREAM_FEATURE_PLC 	(1 << 0)
#define AUDIO_STREAM_FEATURE_EC 	(1 << 1)
#define AUDIO_STREAM_FEATURE_EQUALIZER	(1 << 2)
#define AUDIO_STREAM_FEATURE_VOL_SND 	(1 << 3)
#define AUDIO_STREAM_FEATURE_VOL_RCV 	(1 << 4)
#define AUDIO_STREAM_FEATURE_DTMF	(1 << 5)
#define AUDIO_STREAM_FEATURE_DTMF_ECHO (1 << 6)
Yann Diorcet's avatar
Yann Diorcet committed
219 220 221 222 223 224 225 226 227 228 229 230
#define AUDIO_STREAM_FEATURE_ALL	(\
					AUDIO_STREAM_FEATURE_PLC | \
					AUDIO_STREAM_FEATURE_EC | \
					AUDIO_STREAM_FEATURE_EQUALIZER | \
					AUDIO_STREAM_FEATURE_VOL_SND | \
					AUDIO_STREAM_FEATURE_VOL_RCV | \
					AUDIO_STREAM_FEATURE_DTMF | \
					AUDIO_STREAM_FEATURE_DTMF_ECHO \
					)

MS2_PUBLIC uint32_t audio_stream_get_features(AudioStream *st);
MS2_PUBLIC void audio_stream_set_features(AudioStream *st, uint32_t features);
Simon Morlat's avatar
Simon Morlat committed
231 232 233 234
	
MS2_PUBLIC void audio_stream_prepare_sound(AudioStream *st, MSSndCard *playcard, MSSndCard *captcard);
MS2_PUBLIC void audio_stream_unprepare_sound(AudioStream *st);
MS2_PUBLIC bool_t audio_stream_started(AudioStream *stream);
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251
/**
 * Starts an audio stream from local soundcards.
 * 
 * This method starts the processing of the audio stream, that is capture from soundcard, voice processing, encoding,
 * sending through RTP, receiving from RTP, decoding, voice processing and soundcard playback.
 * 
 * @param stream an AudioStream previously created with audio_stream_new().
 * @param prof a RtpProfile containing all PayloadType possible during the audio session.
 * @param remip remote IP address where to send the encoded audio.
 * @param remport remote IP port where to send the encoded audio
 * @param rem_rtcp_port remote port for RTCP.
 * @param payload_type payload type index to use for the sending stream. This index must point to a valid PayloadType in the RtpProfile.
 * @param jitt_comp Nominal jitter buffer size in milliseconds.
 * @param playcard The soundcard to be used for playback
 * @param captcard The soundcard to be used for catpure.
 * @param echo_cancel whether echo cancellation is to be performed.
**/
Simon Morlat's avatar
Simon Morlat committed
252 253
MS2_PUBLIC int audio_stream_start_now(AudioStream * stream, RtpProfile * prof,  const char *remip, int remport, int rem_rtcp_port, int payload_type, int jitt_comp,MSSndCard *playcard, MSSndCard *captcard, bool_t echo_cancel);
MS2_PUBLIC void audio_stream_set_relay_session_id(AudioStream *stream, const char *relay_session_id);
aymeric's avatar
aymeric committed
254
/*returns true if we are still receiving some data from remote end in the last timeout seconds*/
Simon Morlat's avatar
Simon Morlat committed
255
MS2_PUBLIC bool_t audio_stream_alive(AudioStream * stream, int timeout);
aymeric's avatar
aymeric committed
256

257 258 259 260
/**
 * Executes background low priority tasks related to audio processing (RTP statistics analysis).
 * It should be called periodically, for example with an interval of 100 ms or so.
 */
261 262
MS2_PUBLIC void audio_stream_iterate(AudioStream *stream);

smorlat's avatar
smorlat committed
263
/*enable echo-limiter dispositve: one MSVolume in input branch controls a MSVolume in the output branch*/
Simon Morlat's avatar
Simon Morlat committed
264
MS2_PUBLIC void audio_stream_enable_echo_limiter(AudioStream *stream, EchoLimiterType type);
265

smorlat's avatar
smorlat committed
266
/*enable gain control, to be done before start() */
Simon Morlat's avatar
Simon Morlat committed
267
MS2_PUBLIC void audio_stream_enable_gain_control(AudioStream *stream, bool_t val);
smorlat's avatar
smorlat committed
268

269
/*enable automatic gain control, to be done before start() */
Simon Morlat's avatar
Simon Morlat committed
270
MS2_PUBLIC void audio_stream_enable_automatic_gain_control(AudioStream *stream, bool_t val);
271

272
/*to be done before start */
Simon Morlat's avatar
Simon Morlat committed
273
MS2_PUBLIC void audio_stream_set_echo_canceller_params(AudioStream *st, int tail_len_ms, int delay_ms, int framesize);
274

275
/*enable adaptive rate control */
Ghislain MARY's avatar
Ghislain MARY committed
276 277 278
MS2_PUBLIC static inline void audio_stream_enable_adaptive_bitrate_control(AudioStream *stream, bool_t enabled) {
	media_stream_enable_adaptive_bitrate_control(&stream->ms, enabled);
}
279

280
/* Enable adaptive jitter compensation */
Ghislain MARY's avatar
Ghislain MARY committed
281 282 283
MS2_PUBLIC static inline void audio_stream_enable_adaptive_jittcomp(AudioStream *stream, bool_t enabled) {
	media_stream_enable_adaptive_jittcomp(&stream->ms, enabled);
}
284

Simon Morlat's avatar
Simon Morlat committed
285
MS2_PUBLIC void audio_stream_set_mic_gain(AudioStream *stream, float gain);
smorlat's avatar
smorlat committed
286

287
/* enable/disable rtp stream */
Simon Morlat's avatar
Simon Morlat committed
288
MS2_PUBLIC void audio_stream_mute_rtp(AudioStream *stream, bool_t val);
Simon Morlat's avatar
Simon Morlat committed
289

290
/*enable noise gate, must be done before start()*/
Simon Morlat's avatar
Simon Morlat committed
291
MS2_PUBLIC void audio_stream_enable_noise_gate(AudioStream *stream, bool_t val);
292

smorlat's avatar
smorlat committed
293
/*enable parametric equalizer in the stream that goes to the speaker*/
Simon Morlat's avatar
Simon Morlat committed
294
MS2_PUBLIC void audio_stream_enable_equalizer(AudioStream *stream, bool_t enabled);
smorlat's avatar
smorlat committed
295

Simon Morlat's avatar
Simon Morlat committed
296
MS2_PUBLIC void audio_stream_equalizer_set_gain(AudioStream *stream, int frequency, float gain, int freq_width);
smorlat's avatar
smorlat committed
297

smorlat's avatar
smorlat committed
298
/* stop the audio streaming thread and free everything*/
Simon Morlat's avatar
Simon Morlat committed
299
MS2_PUBLIC void audio_stream_stop (AudioStream * stream);
aymeric's avatar
aymeric committed
300 301

/* send a dtmf */
Simon Morlat's avatar
Simon Morlat committed
302
MS2_PUBLIC int audio_stream_send_dtmf (AudioStream * stream, char dtmf);
aymeric's avatar
aymeric committed
303

Simon Morlat's avatar
Simon Morlat committed
304
MS2_PUBLIC void audio_stream_set_default_card(int cardindex);
aymeric's avatar
aymeric committed
305

Simon Morlat's avatar
Simon Morlat committed
306
/* retrieve RTP statistics*/
Ghislain MARY's avatar
Ghislain MARY committed
307 308 309
MS2_PUBLIC static inline void audio_stream_get_local_rtp_stats(AudioStream *stream, rtp_stats_t *stats) {
	media_stream_get_local_rtp_stats(&stream->ms, stats);
}
Simon Morlat's avatar
Simon Morlat committed
310

311
/* returns a realtime indicator of the stream quality between 0 and 5 */
312 313
MS2_PUBLIC float audio_stream_get_quality_rating(AudioStream *stream);

314 315
/* returns the quality rating as an average since the start of the streaming session.*/
MS2_PUBLIC float audio_stream_get_average_quality_rating(AudioStream *stream);
aymeric's avatar
aymeric committed
316

Guillaume Beraudo's avatar
Guillaume Beraudo committed
317 318 319
/* enable ZRTP on the audio stream */
MS2_PUBLIC void audio_stream_enable_zrtp(AudioStream *stream, OrtpZrtpParams *params);

320
/* enable SRTP on the audio stream */
Ghislain MARY's avatar
Ghislain MARY committed
321 322 323
MS2_PUBLIC static inline bool_t audio_stream_enable_srtp(AudioStream* stream, enum ortp_srtp_crypto_suite_t suite, const char* snd_key, const char* rcv_key) {
	return media_stream_enable_srtp(&stream->ms, suite, snd_key, rcv_key);
}
Guillaume Beraudo's avatar
Guillaume Beraudo committed
324

Ghislain MARY's avatar
Ghislain MARY committed
325 326 327
MS2_PUBLIC static inline int audio_stream_set_dscp(AudioStream *stream, int dscp) {
	return media_stream_set_dscp(&stream->ms, dscp);
}
Simon Morlat's avatar
Simon Morlat committed
328

329 330 331 332 333 334 335 336 337
/**
 * @}
**/


/**
 * @addtogroup video_stream_api
 * @{
**/
aymeric's avatar
aymeric committed
338

339
typedef void (*VideoStreamRenderCallback)(void *user_pointer, const MSPicture *local_view, const MSPicture *remote_view);
340 341 342
typedef void (*VideoStreamEventCallback)(void *user_pointer, const MSFilter *f, const unsigned int event_id, const void *args);


343 344 345 346 347 348
typedef enum _VideoStreamDir{
	VideoStreamSendRecv,
	VideoStreamSendOnly,
	VideoStreamRecvOnly
}VideoStreamDir;

aymeric's avatar
aymeric committed
349 350
struct _VideoStream
{
Ghislain MARY's avatar
Ghislain MARY committed
351
	MediaStream ms;
aymeric's avatar
aymeric committed
352 353
	MSFilter *source;
	MSFilter *pixconv;
354
	MSFilter *sizeconv;
aymeric's avatar
aymeric committed
355 356
	MSFilter *tee;
	MSFilter *output;
357 358
	MSFilter *tee2;
	MSFilter *jpegwriter;
359
	MSFilter *output2;
smorlat's avatar
smorlat committed
360
	MSVideoSize sent_vsize;
smorlat's avatar
smorlat committed
361
	int corner; /*for selfview*/
362 363
	VideoStreamRenderCallback rendercb;
	void *render_pointer;
364 365
	VideoStreamEventCallback eventcb;
	void *event_pointer;
366
	char *display_name;
367 368
	unsigned long window_id;
	unsigned long preview_window_id;
369
	VideoStreamDir dir;
370
	MSWebCam *cam;
371
	int device_orientation; /* warning: meaning of this variable depends on the platform (Android, iOS, ...) */
Ghislain MARY's avatar
Ghislain MARY committed
372 373
	bool_t use_preview_window;
	bool_t display_filter_auto_rotate_enabled;
374
	bool_t prepare_ongoing;
aymeric's avatar
aymeric committed
375 376 377
};

typedef struct _VideoStream VideoStream;
smorlat's avatar
smorlat committed
378

379

380
MS2_PUBLIC VideoStream *video_stream_new(int loc_rtp_port, int loc_rtcp_port, bool_t use_ipv6);
Simon Morlat's avatar
Simon Morlat committed
381
MS2_PUBLIC void video_stream_set_direction(VideoStream *vs, VideoStreamDir dir);
Ghislain MARY's avatar
Ghislain MARY committed
382 383 384 385 386 387
MS2_PUBLIC static inline void video_stream_enable_adaptive_bitrate_control(VideoStream *stream, bool_t enabled) {
	media_stream_enable_adaptive_bitrate_control(&stream->ms, enabled);
}
MS2_PUBLIC static inline void video_stream_enable_adaptive_jittcomp(VideoStream *stream, bool_t enabled) {
	media_stream_enable_adaptive_jittcomp(&stream->ms, enabled);
}
Simon Morlat's avatar
Simon Morlat committed
388 389 390
MS2_PUBLIC void video_stream_set_render_callback(VideoStream *s, VideoStreamRenderCallback cb, void *user_pointer);
MS2_PUBLIC void video_stream_set_event_callback(VideoStream *s, VideoStreamEventCallback cb, void *user_pointer);
MS2_PUBLIC void video_stream_set_display_filter_name(VideoStream *s, const char *fname);
391
MS2_PUBLIC int video_stream_start(VideoStream * stream, RtpProfile *profile, const char *rem_rtp_ip, int rem_rtp_port, const char *rem_rtcp_ip, int rem_rtcp_port,
aymeric's avatar
aymeric committed
392
		int payload, int jitt_comp, MSWebCam *device);
393 394
MS2_PUBLIC void video_stream_prepare_video(VideoStream *stream);
MS2_PUBLIC void video_stream_unprepare_video(VideoStream *stream);
395 396


Simon Morlat's avatar
Simon Morlat committed
397
MS2_PUBLIC void video_stream_set_relay_session_id(VideoStream *stream, const char *relay_session_id);
Ghislain MARY's avatar
Ghislain MARY committed
398 399 400
MS2_PUBLIC static inline void video_stream_set_rtcp_information(VideoStream *st, const char *cname, const char *tool) {
	media_stream_set_rtcp_information(&st->ms, cname, tool);
}
Simon Morlat's avatar
Simon Morlat committed
401
MS2_PUBLIC void video_stream_change_camera(VideoStream *stream, MSWebCam *cam);
402 403
/* Calling video_stream_set_sent_video_size() or changing the bitrate value in the used PayloadType during a stream is running does nothing.
The following function allows to take into account new parameters by redrawing the sending graph*/
Simon Morlat's avatar
Simon Morlat committed
404
MS2_PUBLIC void video_stream_update_video_params(VideoStream *stream);
aymeric's avatar
aymeric committed
405
/*function to call periodically to handle various events */
Simon Morlat's avatar
Simon Morlat committed
406 407 408 409 410 411 412 413 414 415
MS2_PUBLIC void video_stream_iterate(VideoStream *stream);
MS2_PUBLIC void video_stream_send_vfu(VideoStream *stream);
MS2_PUBLIC void video_stream_stop(VideoStream * stream);
MS2_PUBLIC void video_stream_set_sent_video_size(VideoStream *stream, MSVideoSize vsize);
MS2_PUBLIC void video_stream_enable_self_view(VideoStream *stream, bool_t val);
MS2_PUBLIC unsigned long video_stream_get_native_window_id(VideoStream *stream);
MS2_PUBLIC void video_stream_set_native_window_id(VideoStream *stream, unsigned long id);
MS2_PUBLIC void video_stream_set_native_preview_window_id(VideoStream *stream, unsigned long id);
MS2_PUBLIC unsigned long video_stream_get_native_preview_window_id(VideoStream *stream);
MS2_PUBLIC void video_stream_use_preview_video_window(VideoStream *stream, bool_t yesno);
416
MS2_PUBLIC void video_stream_set_device_rotation(VideoStream *stream, int orientation);
417
MS2_PUBLIC void video_stream_show_video(VideoStream *stream, bool_t show);
418

419
/*provided for compatibility, use video_stream_set_direction() instead */
Simon Morlat's avatar
Simon Morlat committed
420 421
MS2_PUBLIC int video_stream_recv_only_start(VideoStream *videostream, RtpProfile *profile, const char *addr, int port, int used_pt, int jitt_comp);
MS2_PUBLIC int video_stream_send_only_start(VideoStream *videostream,
422
				RtpProfile *profile, const char *addr, int port, int rtcp_port,
423
				int used_pt, int  jitt_comp, MSWebCam *device);
Simon Morlat's avatar
Simon Morlat committed
424 425
MS2_PUBLIC void video_stream_recv_only_stop(VideoStream *vs);
MS2_PUBLIC void video_stream_send_only_stop(VideoStream *vs);
aymeric's avatar
aymeric committed
426

Guillaume Beraudo's avatar
Guillaume Beraudo committed
427 428
/* enable ZRTP on the video stream using information from the audio stream */
MS2_PUBLIC void video_stream_enable_zrtp(VideoStream *vstream, AudioStream *astream, OrtpZrtpParams *param);
429

430
/* enable SRTP on the video stream */
Ghislain MARY's avatar
Ghislain MARY committed
431 432 433 434
MS2_PUBLIC static inline bool_t video_stream_enable_strp(VideoStream* stream, enum ortp_srtp_crypto_suite_t suite, const char* snd_key, const char* rcv_key) {
	return media_stream_enable_srtp(&stream->ms, suite, snd_key, rcv_key);
}

435 436
/* if enabled, the display filter will internaly rotate the video, according to the device orientation */
MS2_PUBLIC void video_stream_enable_display_filter_auto_rotate(VideoStream* stream, bool_t enable);
437

438
/* retrieve RTP statistics*/
Ghislain MARY's avatar
Ghislain MARY committed
439 440 441
MS2_PUBLIC static inline void video_stream_get_local_rtp_stats(VideoStream *stream, rtp_stats_t *stats) {
	media_stream_get_local_rtp_stats(&stream->ms, stats);
}
442

Ghislain MARY's avatar
Ghislain MARY committed
443 444 445
MS2_PUBLIC static inline int video_stream_set_dscp(VideoStream *stream, int dscp) {
	return media_stream_set_dscp(&stream->ms, dscp);
}
Simon Morlat's avatar
Simon Morlat committed
446

447 448 449 450
/**
 * Small API to display a local preview window.
**/

Simon Morlat's avatar
Simon Morlat committed
451 452
typedef VideoStream VideoPreview;

Simon Morlat's avatar
Simon Morlat committed
453
MS2_PUBLIC VideoPreview * video_preview_new();
Simon Morlat's avatar
Simon Morlat committed
454 455 456 457
#define video_preview_set_size(p,s) 							video_stream_set_sent_video_size(p,s)
#define video_preview_set_display_filter_name(p,dt)	video_stream_set_display_filter_name(p,dt)
#define video_preview_set_native_window_id(p,id)		video_stream_set_native_preview_window_id (p,id)
#define video_preview_get_native_window_id(p)			video_stream_get_native_preview_window_id (p)
Simon Morlat's avatar
Simon Morlat committed
458 459
MS2_PUBLIC void video_preview_start(VideoPreview *stream, MSWebCam *device);
MS2_PUBLIC void video_preview_stop(VideoPreview *stream);
aymeric's avatar
aymeric committed
460

461 462 463 464
/**
 * @}
**/

Simon Morlat's avatar
Simon Morlat committed
465
MS2_PUBLIC bool_t ms_is_ipv6(const char *address);
aymeric's avatar
aymeric committed
466

Guillaume Beraudo's avatar
Guillaume Beraudo committed
467

aymeric's avatar
aymeric committed
468 469 470 471 472
#ifdef __cplusplus
}
#endif

#endif