source: mediastreamer2/include/mediastreamer2/mediastream.h @ 1344:10d074197822

Last change on this file since 1344:10d074197822 was 1344:10d074197822, checked in by Simon Morlat <simon.morlat@…>, 2 years ago

i18n of mediastreamer2

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