2 mediastreamer2 library - modular sound and video processing and streaming
3 Copyright (C) 2006 Simon MORLAT (simon.morlat@linphone.org)
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.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #include "mediastreamer2/msfilter.h"
25 #include "mediastreamer2/msticker.h"
26 #include "mediastreamer2/mssndcard.h"
27 #include "mediastreamer2/mswebcam.h"
28 #include "mediastreamer2/msvideo.h"
29 #include "ortp/ortp.h"
30 #include "ortp/event.h"
33 #if defined(_WIN32_WCE)
34 time_t ms_time (time_t *t);
39 typedef enum EchoLimiterType{
56 MSFilter *ec;/*echo canceler*/
57 MSFilter *volsend,*volrecv; /*MSVolumes*/
58 MSFilter *read_resampler;
59 MSFilter *write_resampler;
61 uint64_t last_packet_count;
62 time_t last_packet_time;
63 EchoLimiterType el_type; /*use echo limiter: two MSVolume, measured input level controlling local output level*/
64 int ec_tail_len; /*milliseconds*/
65 int ec_delay; /*milliseconds*/
66 int ec_framesize; /* number of fft points */
71 bool_t use_ng;/*noise gate*/
78 typedef struct _AudioStream AudioStream;
87 typedef struct _RingStream RingStream;
91 /* start a thread that does sampling->encoding->rtp_sending|rtp_receiving->decoding->playing */
92 AudioStream *audio_stream_start (RtpProfile * prof, int locport, const char *remip,
93 int remport, int payload_type, int jitt_comp, bool_t echo_cancel);
95 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);
97 int audio_stream_start_with_files (AudioStream * stream, RtpProfile * prof,
98 const char *remip, int remport, int rem_rtcp_port,
99 int pt, int jitt_comp,
100 const char * infile, const char * outfile);
102 void audio_stream_play(AudioStream *st, const char *name);
103 void audio_stream_record(AudioStream *st, const char *name);
105 void audio_stream_set_rtcp_information(AudioStream *st, const char *cname, const char *tool);
107 void audio_stream_play_received_dtmfs(AudioStream *st, bool_t yesno);
109 /* those two function do the same as audio_stream_start() but in two steps
110 this is useful to make sure that sockets are open before sending an invite;
111 or to start to stream only after receiving an ack.*/
112 AudioStream *audio_stream_new(int locport, bool_t ipv6);
113 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);
114 void audio_stream_set_relay_session_id(AudioStream *stream, const char *relay_session_id);
115 /*returns true if we are still receiving some data from remote end in the last timeout seconds*/
116 bool_t audio_stream_alive(AudioStream * stream, int timeout);
118 /*enable echo-limiter dispositve: one MSVolume in input branch controls a MSVolume in the output branch*/
119 void audio_stream_enable_echo_limiter(AudioStream *stream, EchoLimiterType type);
121 /*enable gain control, to be done before start() */
122 void audio_stream_enable_gain_control(AudioStream *stream, bool_t val);
124 /*enable automatic gain control, to be done before start() */
125 void audio_stream_enable_automatic_gain_control(AudioStream *stream, bool_t val);
127 /*to be done before start */
128 void audio_stream_set_echo_canceller_params(AudioStream *st, int tail_len_ms, int delay_ms, int framesize);
130 void audio_stream_set_mic_gain(AudioStream *stream, float gain);
132 /*enable noise gate, must be done before start()*/
133 void audio_stream_enable_noise_gate(AudioStream *stream, bool_t val);
135 /*enable parametric equalizer in the stream that goes to the speaker*/
136 void audio_stream_enable_equalizer(AudioStream *stream, bool_t enabled);
138 void audio_stream_equalizer_set_gain(AudioStream *stream, int frequency, float gain, int freq_width);
140 /* stop the audio streaming thread and free everything*/
141 void audio_stream_stop (AudioStream * stream);
143 RingStream *ring_start (const char * file, int interval, MSSndCard *sndcard);
144 RingStream *ring_start_with_cb(const char * file, int interval, MSSndCard *sndcard, MSFilterNotifyFunc func, void * user_data);
145 void ring_stop (RingStream * stream);
149 int audio_stream_send_dtmf (AudioStream * stream, char dtmf);
151 void audio_stream_set_default_card(int cardindex);
173 MSVideoSize sent_vsize;
174 int corner; /*for selfview*/
175 bool_t adapt_bitrate;
178 typedef struct _VideoStream VideoStream;
180 VideoStream *video_stream_new(int locport, bool_t use_ipv6);
181 void video_stream_enable_adaptive_bitrate_control(VideoStream *s, bool_t yesno);
182 int video_stream_start(VideoStream * stream, RtpProfile *profile, const char *remip, int remport, int rem_rtcp_port,
183 int payload, int jitt_comp, MSWebCam *device);
184 void video_stream_set_relay_session_id(VideoStream *stream, const char *relay_session_id);
185 void video_stream_set_rtcp_information(VideoStream *st, const char *cname, const char *tool);
186 /*function to call periodically to handle various events */
187 void video_stream_iterate(VideoStream *stream);
188 void video_stream_send_vfu(VideoStream *stream);
189 void video_stream_stop(VideoStream * stream);
190 void video_stream_set_sent_video_size(VideoStream *stream, MSVideoSize vsize);
191 void video_stream_enable_self_view(VideoStream *stream, bool_t val);
192 unsigned long video_stream_get_native_window_id(VideoStream *stream);
195 VideoStream * video_preview_start(MSWebCam *device, MSVideoSize vsize);
196 void video_preview_stop(VideoStream *stream);
198 int video_stream_recv_only_start(VideoStream * stream, RtpProfile *profile, const char *remip, int remport, int payload, int jitt_comp);
199 int video_stream_send_only_start(VideoStream * stream, RtpProfile *profile, const char *remip, int remport,
200 int rem_rtcp_port, int payload, int jitt_comp, MSWebCam *device);
201 void video_stream_recv_only_stop(VideoStream *stream);
202 void video_stream_send_only_stop(VideoStream *stream);
205 bool_t ms_is_ipv6(const char *address);