source: mediastreamer2/include/mediastreamer2/mediastream.h @ 1438:88b94b2fe138

Last change on this file since 1438:88b94b2fe138 was 1438:88b94b2fe138, checked in by laurent <laurent@…>, 17 months ago

verona video

File size: 10.8 KB
Line 
1/*
2mediastreamer2 library - modular sound and video processing and streaming
3Copyright (C) 2006  Simon MORLAT (simon.morlat@linphone.org)
4
5This program is free software; you can redistribute it and/or
6modify it under the terms of the GNU General Public License
7as published by the Free Software Foundation; either version 2
8of the License, or (at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program; if not, write to the Free Software
17Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18*/
19
20
21#ifndef MEDIASTREAM_H
22#define MEDIASTREAM_H
23
24#include <mediastreamer2/msfilter.h>
25#include <mediastreamer2/msticker.h>
26#include <mediastreamer2/mssndcard.h>
27#ifdef VIDEO_ENABLED
28#include <mediastreamer2/mswebcam.h>
29#include <mediastreamer2/msvideo.h>
30#endif
31#include <ortp/ortp.h>
32#include <ortp/event.h>
33
34
35typedef enum EchoLimiterType{
36        ELInactive,
37        ELControlMic,
38        ELControlFull
39} EchoLimiterType;
40
41struct _AudioStream
42{
43        MSTicker *ticker;
44        RtpSession *session;
45        MSFilter *soundread;
46        MSFilter *soundwrite;
47        MSFilter *encoder;
48        MSFilter *decoder;
49        MSFilter *rtprecv;
50        MSFilter *rtpsend;
51        MSFilter *dtmfgen;
52        MSFilter *dtmfgen_rtp;
53        MSFilter *ec;/*echo canceler*/
54        MSFilter *volsend,*volrecv; /*MSVolumes*/
55        MSFilter *read_resampler;
56        MSFilter *write_resampler;
57        MSFilter *equalizer;
58        uint64_t last_packet_count;
59        time_t last_packet_time;
60        EchoLimiterType el_type; /*use echo limiter: two MSVolume, measured input level controlling local output level*/
61        OrtpEvQueue *evq;
62        bool_t play_dtmfs;
63        bool_t use_gc;
64        bool_t use_agc;
65        bool_t eq_active;
66        bool_t use_ng;/*noise gate*/
67};
68
69#ifdef __cplusplus
70extern "C" {
71#endif
72
73typedef struct _AudioStream AudioStream;
74
75struct _RingStream
76{
77        MSTicker *ticker;
78        MSFilter *source;
79        MSFilter *gendtmf;
80        MSFilter *write_resampler;
81        MSFilter *sndwrite;
82        MSFilter *volume;
83};
84
85typedef struct _RingStream RingStream;
86
87
88
89/* start a thread that does sampling->encoding->rtp_sending|rtp_receiving->decoding->playing */
90MS2_PUBLIC AudioStream *audio_stream_start (RtpProfile * prof, int locport, const char *remip,
91                                 int remport, int payload_type, int jitt_comp, bool_t echo_cancel);
92
93MS2_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);
94
95MS2_PUBLIC int audio_stream_start_with_files (AudioStream * stream, RtpProfile * prof,
96                                            const char *remip, int remport, int rem_rtcp_port,
97                                            int pt, int jitt_comp,
98                                            const char * infile,  const char * outfile);
99
100MS2_PUBLIC int audio_stream_start_full(AudioStream *stream, RtpProfile *profile, const char *remip,int remport,
101        int rem_rtcp_port, int payload,int jitt_comp, const char *infile, const char *outfile,
102        MSSndCard *playcard, MSSndCard *captcard, bool_t use_ec);
103
104MS2_PUBLIC void audio_stream_play(AudioStream *st, const char *name);
105MS2_PUBLIC void audio_stream_record(AudioStream *st, const char *name);
106
107MS2_PUBLIC void audio_stream_set_rtcp_information(AudioStream *st, const char *cname, const char *tool);
108
109MS2_PUBLIC void audio_stream_play_received_dtmfs(AudioStream *st, bool_t yesno);
110
111/* those two function do the same as audio_stream_start() but in two steps
112this is useful to make sure that sockets are open before sending an invite;
113or to start to stream only after receiving an ack.*/
114MS2_PUBLIC AudioStream *audio_stream_new(int locport, bool_t ipv6);
115MS2_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);
116MS2_PUBLIC void audio_stream_set_relay_session_id(AudioStream *stream, const char *relay_session_id);
117/*returns true if we are still receiving some data from remote end in the last timeout seconds*/
118MS2_PUBLIC bool_t audio_stream_alive(AudioStream * stream, int timeout);
119
120/*enable echo-limiter dispositve: one MSVolume in input branch controls a MSVolume in the output branch*/
121MS2_PUBLIC void audio_stream_enable_echo_limiter(AudioStream *stream, EchoLimiterType type);
122
123/*enable gain control, to be done before start() */
124MS2_PUBLIC void audio_stream_enable_gain_control(AudioStream *stream, bool_t val);
125
126/*enable automatic gain control, to be done before start() */
127MS2_PUBLIC void audio_stream_enable_automatic_gain_control(AudioStream *stream, bool_t val);
128
129/*to be done before start */
130MS2_PUBLIC void audio_stream_set_echo_canceller_params(AudioStream *st, int tail_len_ms, int delay_ms, int framesize);
131
132MS2_PUBLIC void audio_stream_set_mic_gain(AudioStream *stream, float gain);
133
134/* enable/disable rtp stream */ 
135MS2_PUBLIC void audio_stream_mute_rtp(AudioStream *stream, bool_t val);
136
137/*enable noise gate, must be done before start()*/
138MS2_PUBLIC void audio_stream_enable_noise_gate(AudioStream *stream, bool_t val);
139
140/*enable parametric equalizer in the stream that goes to the speaker*/
141MS2_PUBLIC void audio_stream_enable_equalizer(AudioStream *stream, bool_t enabled);
142
143MS2_PUBLIC void audio_stream_equalizer_set_gain(AudioStream *stream, int frequency, float gain, int freq_width);
144
145/* stop the audio streaming thread and free everything*/
146MS2_PUBLIC void audio_stream_stop (AudioStream * stream);
147
148MS2_PUBLIC RingStream *ring_start (const char * file, int interval, MSSndCard *sndcard);
149MS2_PUBLIC RingStream *ring_start_with_cb(const char * file, int interval, MSSndCard *sndcard, MSFilterNotifyFunc func, void * user_data);
150MS2_PUBLIC void ring_stop (RingStream * stream);
151
152
153/* send a dtmf */
154MS2_PUBLIC int audio_stream_send_dtmf (AudioStream * stream, char dtmf);
155
156MS2_PUBLIC void audio_stream_set_default_card(int cardindex);
157
158/* retrieve RTP statistics*/
159MS2_PUBLIC void audio_stream_get_local_rtp_stats(AudioStream *stream, rtp_stats_t *stats);
160
161MS2_PUBLIC void audio_stream_change_decoder(AudioStream *stream, int payload);
162
163MS2_PUBLIC void audio_stream_free(AudioStream *stream);
164
165#ifdef VIDEO_ENABLED
166/*****************
167  Video Support
168 *****************/
169
170typedef void (*VideoStreamRenderCallback)(void *user_pointer, const MSPicture *local_view, const MSPicture *remote_view);
171typedef void (*VideoStreamEventCallback)(void *user_pointer, const MSFilter *f, const unsigned int event_id, const void *args);
172
173
174
175typedef enum _VideoStreamDir{
176        VideoStreamSendRecv,
177        VideoStreamSendOnly,
178        VideoStreamRecvOnly
179}VideoStreamDir;
180
181struct _VideoStream
182{
183        MSTicker *ticker;
184        RtpSession *session;
185        MSFilter *source;
186        MSFilter *pixconv;
187        MSFilter *sizeconv;
188        MSFilter *tee;
189        MSFilter *output;
190        MSFilter *encoder;
191        MSFilter *decoder;
192        MSFilter *rtprecv;
193        MSFilter *rtpsend;
194        MSFilter *tee2;
195        MSFilter *jpegwriter;
196        MSFilter *output2;
197        OrtpEvQueue *evq;
198        MSVideoSize sent_vsize;
199        int corner; /*for selfview*/
200        VideoStreamRenderCallback rendercb;
201        void *render_pointer;
202        VideoStreamEventCallback eventcb;
203        void *event_pointer;
204        char *display_name;
205        unsigned long window_id;
206        unsigned long preview_window_id;
207        VideoStreamDir dir;
208        MSWebCam *cam;
209        bool_t use_preview_window;
210        bool_t adapt_bitrate;
211};
212
213typedef struct _VideoStream VideoStream;
214
215
216
217MS2_PUBLIC VideoStream *video_stream_new(int locport, bool_t use_ipv6);
218MS2_PUBLIC void video_stream_set_direction(VideoStream *vs, VideoStreamDir dir);
219MS2_PUBLIC void video_stream_enable_adaptive_bitrate_control(VideoStream *s, bool_t yesno);
220MS2_PUBLIC void video_stream_set_render_callback(VideoStream *s, VideoStreamRenderCallback cb, void *user_pointer);
221MS2_PUBLIC void video_stream_set_event_callback(VideoStream *s, VideoStreamEventCallback cb, void *user_pointer);
222MS2_PUBLIC void video_stream_set_display_filter_name(VideoStream *s, const char *fname);
223MS2_PUBLIC int video_stream_start(VideoStream * stream, RtpProfile *profile, const char *remip, int remport, int rem_rtcp_port,
224                int payload, int jitt_comp, MSWebCam *device);
225
226
227MS2_PUBLIC void video_stream_set_relay_session_id(VideoStream *stream, const char *relay_session_id);
228MS2_PUBLIC void video_stream_set_rtcp_information(VideoStream *st, const char *cname, const char *tool);
229MS2_PUBLIC void video_stream_change_camera(VideoStream *stream, MSWebCam *cam);
230/* Calling video_stream_set_sent_video_size() or changing the bitrate value in the used PayloadType during a stream is running does nothing.
231The following function allows to take into account new parameters by redrawing the sending graph*/
232MS2_PUBLIC void video_stream_update_video_params(VideoStream *stream);
233/*function to call periodically to handle various events */
234MS2_PUBLIC void video_stream_iterate(VideoStream *stream);
235MS2_PUBLIC void video_stream_send_vfu(VideoStream *stream);
236MS2_PUBLIC void video_stream_stop(VideoStream * stream);
237MS2_PUBLIC void video_stream_set_sent_video_size(VideoStream *stream, MSVideoSize vsize);
238MS2_PUBLIC void video_stream_enable_self_view(VideoStream *stream, bool_t val);
239MS2_PUBLIC unsigned long video_stream_get_native_window_id(VideoStream *stream);
240MS2_PUBLIC void video_stream_set_native_window_id(VideoStream *stream, unsigned long id);
241MS2_PUBLIC void video_stream_set_native_preview_window_id(VideoStream *stream, unsigned long id);
242MS2_PUBLIC unsigned long video_stream_get_native_preview_window_id(VideoStream *stream);
243MS2_PUBLIC void video_stream_use_preview_video_window(VideoStream *stream, bool_t yesno);
244
245/*provided for compatibility, use video_stream_set_direction() instead */
246MS2_PUBLIC int video_stream_recv_only_start(VideoStream *videostream, RtpProfile *profile, const char *addr, int port, int used_pt, int jitt_comp);
247MS2_PUBLIC int video_stream_send_only_start(VideoStream *videostream,
248                                RtpProfile *profile, const char *addr, int port, int rtcp_port, 
249                                int used_pt, int  jitt_comp, MSWebCam *device);
250MS2_PUBLIC void video_stream_recv_only_stop(VideoStream *vs);
251MS2_PUBLIC void video_stream_send_only_stop(VideoStream *vs);
252
253
254/**
255 * Small API to display a local preview window.
256**/
257
258typedef VideoStream VideoPreview;
259
260MS2_PUBLIC VideoPreview * video_preview_new();
261#define video_preview_set_size(p,s)                                                     video_stream_set_sent_video_size(p,s)
262#define video_preview_set_display_filter_name(p,dt)     video_stream_set_display_filter_name(p,dt)
263#define video_preview_set_native_window_id(p,id)                video_stream_set_native_preview_window_id (p,id)
264#define video_preview_get_native_window_id(p)                   video_stream_get_native_preview_window_id (p)
265MS2_PUBLIC void video_preview_start(VideoPreview *stream, MSWebCam *device);
266MS2_PUBLIC void video_preview_stop(VideoPreview *stream);
267
268MS2_PUBLIC void video_stream_change_decoder(VideoStream *stream, int payload);
269
270#endif /* VIDEO_ENABLED */
271
272MS2_PUBLIC bool_t ms_is_ipv6(const char *address);
273
274#ifdef __cplusplus
275}
276#endif
277
278
279#endif
Note: See TracBrowser for help on using the repository browser.