source: mediastreamer2/include/mediastreamer2/mediastream.h @ 978:c9364a92c2bb

Last change on this file since 978:c9364a92c2bb was 978:c9364a92c2bb, checked in by Simon Morlat <simon.morlat@…>, 3 years ago

RTP statistics retrieval.

File size: 7.4 KB
RevLine 
[856]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#include <time.h>
32
33#if defined(_WIN32_WCE)
34time_t ms_time (time_t *t);
35#else
36#define ms_time time
37#endif
38
39typedef enum EchoLimiterType{
40        ELInactive,
41        ELControlMic,
42        ELControlSpeaker
43} EchoLimiterType;
44
45struct _AudioStream
46{
47        MSTicker *ticker;
48        RtpSession *session;
49        MSFilter *soundread;
50        MSFilter *soundwrite;
51        MSFilter *encoder;
52        MSFilter *decoder;
53        MSFilter *rtprecv;
54        MSFilter *rtpsend;
55        MSFilter *dtmfgen;
56        MSFilter *ec;/*echo canceler*/
57        MSFilter *volsend,*volrecv; /*MSVolumes*/
58        MSFilter *read_resampler;
59        MSFilter *write_resampler;
60        MSFilter *equalizer;
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 */
67        bool_t play_dtmfs;
68        bool_t use_gc;
69        bool_t use_agc;
70        bool_t eq_active;
71        bool_t use_ng;/*noise gate*/
72};
73
74#ifdef __cplusplus
75extern "C" {
76#endif
77
78typedef struct _AudioStream AudioStream;
79
80struct _RingStream
81{
82        MSTicker *ticker;
83        MSFilter *source;
84        MSFilter *sndwrite;
85};
86
87typedef struct _RingStream RingStream;
88
89
90
91/* start a thread that does sampling->encoding->rtp_sending|rtp_receiving->decoding->playing */
92AudioStream *audio_stream_start (RtpProfile * prof, int locport, const char *remip,
93                                 int remport, int payload_type, int jitt_comp, bool_t echo_cancel);
94
95AudioStream *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);
96
97int 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);
101
102void audio_stream_play(AudioStream *st, const char *name);
103void audio_stream_record(AudioStream *st, const char *name);
104
105void audio_stream_set_rtcp_information(AudioStream *st, const char *cname, const char *tool);
106
107void audio_stream_play_received_dtmfs(AudioStream *st, bool_t yesno);
108
109/* those two function do the same as audio_stream_start() but in two steps
110this is useful to make sure that sockets are open before sending an invite;
111or to start to stream only after receiving an ack.*/
112AudioStream *audio_stream_new(int locport, bool_t ipv6);
113int 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);
114void 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*/
116bool_t audio_stream_alive(AudioStream * stream, int timeout);
117
118/*enable echo-limiter dispositve: one MSVolume in input branch controls a MSVolume in the output branch*/
119void audio_stream_enable_echo_limiter(AudioStream *stream, EchoLimiterType type);
120
121/*enable gain control, to be done before start() */
122void audio_stream_enable_gain_control(AudioStream *stream, bool_t val);
123
124/*enable automatic gain control, to be done before start() */
125void audio_stream_enable_automatic_gain_control(AudioStream *stream, bool_t val);
126
127/*to be done before start */
128void audio_stream_set_echo_canceller_params(AudioStream *st, int tail_len_ms, int delay_ms, int framesize);
129
130void audio_stream_set_mic_gain(AudioStream *stream, float gain);
131
132/*enable noise gate, must be done before start()*/
133void audio_stream_enable_noise_gate(AudioStream *stream, bool_t val);
134
135/*enable parametric equalizer in the stream that goes to the speaker*/
136void audio_stream_enable_equalizer(AudioStream *stream, bool_t enabled);
137
138void audio_stream_equalizer_set_gain(AudioStream *stream, int frequency, float gain, int freq_width);
139
140/* stop the audio streaming thread and free everything*/
141void audio_stream_stop (AudioStream * stream);
142
143RingStream *ring_start (const char * file, int interval, MSSndCard *sndcard);
144RingStream *ring_start_with_cb(const char * file, int interval, MSSndCard *sndcard, MSFilterNotifyFunc func, void * user_data);
145void ring_stop (RingStream * stream);
146
147
148/* send a dtmf */
149int audio_stream_send_dtmf (AudioStream * stream, char dtmf);
150
151void audio_stream_set_default_card(int cardindex);
152
[978]153/* retrieve RTP statistics*/
154void audio_stream_get_local_rtp_stats(AudioStream *stream, rtp_stats_t *stats);
155
[856]156
157/*****************
158  Video Support
159 *****************/
160
161
162struct _VideoStream
163{
164        MSTicker *ticker;
165        RtpSession *session;
166        MSFilter *source;
167        MSFilter *pixconv;
168        MSFilter *sizeconv;
169        MSFilter *tee;
170        MSFilter *output;
171        MSFilter *encoder;
172        MSFilter *decoder;
173        MSFilter *rtprecv;
174        MSFilter *rtpsend;
175        OrtpEvQueue *evq;
176        MSVideoSize sent_vsize;
177        int corner; /*for selfview*/
178        bool_t adapt_bitrate;
179};
180
181typedef struct _VideoStream VideoStream;
182
183VideoStream *video_stream_new(int locport, bool_t use_ipv6);
184void video_stream_enable_adaptive_bitrate_control(VideoStream *s, bool_t yesno);
185int video_stream_start(VideoStream * stream, RtpProfile *profile, const char *remip, int remport, int rem_rtcp_port,
186                int payload, int jitt_comp, MSWebCam *device);
187void video_stream_set_relay_session_id(VideoStream *stream, const char *relay_session_id);
188void video_stream_set_rtcp_information(VideoStream *st, const char *cname, const char *tool);
189/*function to call periodically to handle various events */
190void video_stream_iterate(VideoStream *stream);
191void video_stream_send_vfu(VideoStream *stream);
192void video_stream_stop(VideoStream * stream);
193void video_stream_set_sent_video_size(VideoStream *stream, MSVideoSize vsize);
194void video_stream_enable_self_view(VideoStream *stream, bool_t val);
195unsigned long video_stream_get_native_window_id(VideoStream *stream);
196
197
198VideoStream * video_preview_start(MSWebCam *device, MSVideoSize vsize);
199void video_preview_stop(VideoStream *stream);
200
201int video_stream_recv_only_start(VideoStream * stream, RtpProfile *profile, const char *remip, int remport, int payload, int jitt_comp);
202int video_stream_send_only_start(VideoStream * stream, RtpProfile *profile, const char *remip, int remport,
203                int rem_rtcp_port, int payload, int jitt_comp, MSWebCam *device);
204void video_stream_recv_only_stop(VideoStream *stream);
205void video_stream_send_only_stop(VideoStream *stream);
206
207
208bool_t ms_is_ipv6(const char *address);
209
210#ifdef __cplusplus
211}
212#endif
213
214
215#endif
Note: See TracBrowser for help on using the repository browser.