This file is indexed.

/usr/include/pjmedia/sound_port.h is in libpjproject-dev 2.7.2~dfsg-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 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
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
/* $Id: sound_port.h 4982 2015-02-11 05:15:29Z nanang $ */
/* 
 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.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 __PJMEDIA_SOUND_PORT_H__
#define __PJMEDIA_SOUND_PORT_H__

/**
 * @file sound_port.h
 * @brief Media port connection abstraction to sound device.
 */
#include <pjmedia-audiodev/audiodev.h>
#include <pjmedia/clock.h>
#include <pjmedia/port.h>

PJ_BEGIN_DECL

/**
 * @defgroup PJMED_SND_PORT Sound Device Port
 * @ingroup PJMEDIA_PORT_CLOCK
 * @brief Media Port Connection Abstraction to the Sound Device
 @{

 As explained in @ref PJMED_SND, the sound hardware abstraction provides
 some callbacks for its user:
 - it calls <b><tt>rec_cb</tt></b> callback when it has finished capturing
   one media frame, and 
 - it calls <b><tt>play_cb</tt></b> when it needs media frame to be 
   played to the sound playback hardware.

 The @ref PJMED_SND_PORT (the object being explained here) add a
 thin wrapper to the hardware abstraction:
 - it will call downstream port's <tt>put_frame()</tt>
   when <b><tt>rec_cb()</tt></b> is called (i.e. when the sound hardware 
   has finished capturing frame), and 
 - it will call downstream port's <tt>get_frame()</tt> when 
   <b><tt>play_cb()</tt></b> is called (i.e. every time the 
   sound hardware needs more frames to be played to the playback hardware).

 This simple abstraction enables media to flow automatically (and
 in timely manner) from the downstream media port to the sound device.
 In other words, the sound device port supplies media clock to
 the ports. The media clock concept is explained in @ref PJMEDIA_PORT_CLOCK
 section.

 Application registers downstream port to the sound device port by
 calling #pjmedia_snd_port_connect();
 
 */

/**
 * Sound port options.
 */
enum pjmedia_snd_port_option
{
    /** 
     * Don't start the audio device when creating a sound port.
     */    
    PJMEDIA_SND_PORT_NO_AUTO_START = 1
};

/**
 * This structure specifies the parameters to create the sound port.
 * Use pjmedia_snd_port_param_default() to initialize this structure with
 * default values (mostly zeroes)
 */
typedef struct pjmedia_snd_port_param
{
    /**
     * Base structure.
     */
    pjmedia_aud_param base;
    
    /**
     * Sound port creation options.
     */
    unsigned options;

    /**
     * Echo cancellation options/flags.
     */
    unsigned ec_options;

    /**
     * Arbitrary user data for playback and record preview callbacks below.
     */
    void *user_data;

    /**
     * Optional callback for audio frame preview right before queued to
     * the speaker.
     * Notes:
     * - application MUST NOT block or perform long operation in the callback
     *   as the callback may be executed in sound device thread
     * - when using software echo cancellation, application MUST NOT modify
     *   the audio data from within the callback, otherwise the echo canceller
     *   will not work properly.
     * - the return value of the callback will be ignored
     */
    pjmedia_aud_play_cb on_play_frame;

    /**
     * Optional callback for audio frame preview recorded from the microphone
     * before being processed by any media component such as software echo
     * canceller.
     * Notes:
     * - application MUST NOT block or perform long operation in the callback
     *   as the callback may be executed in sound device thread
     * - when using software echo cancellation, application MUST NOT modify
     *   the audio data from within the callback, otherwise the echo canceller
     *   will not work properly.
     * - the return value of the callback will be ignored
     */
    pjmedia_aud_rec_cb on_rec_frame;

} pjmedia_snd_port_param;

/**
 * Initialize pjmedia_snd_port_param with default values.
 *
 * @param prm		    The parameter.
 */
PJ_DECL(void) pjmedia_snd_port_param_default(pjmedia_snd_port_param *prm);

/**
 * This opaque type describes sound device port connection.
 * Sound device port is not a media port, but it is used to connect media
 * port to the sound device.
 */
typedef struct pjmedia_snd_port pjmedia_snd_port;


/**
 * Create bidirectional sound port for both capturing and playback of
 * audio samples.
 *
 * @param pool		    Pool to allocate sound port structure.
 * @param rec_id	    Device index for recorder/capture stream, or
 *			    -1 to use the first capable device.
 * @param play_id	    Device index for playback stream, or -1 to use 
 *			    the first capable device.
 * @param clock_rate	    Sound device's clock rate to set.
 * @param channel_count	    Set number of channels, 1 for mono, or 2 for
 *			    stereo. The channel count determines the format
 *			    of the frame.
 * @param samples_per_frame Number of samples per frame.
 * @param bits_per_sample   Set the number of bits per sample. The normal 
 *			    value for this parameter is 16 bits per sample.
 * @param options	    Options flag.
 * @param p_port	    Pointer to receive the sound device port instance.
 *
 * @return		    PJ_SUCCESS on success, or the appropriate error
 *			    code.
 */
PJ_DECL(pj_status_t) pjmedia_snd_port_create( pj_pool_t *pool,
					      int rec_id,
					      int play_id,
					      unsigned clock_rate,
					      unsigned channel_count,
					      unsigned samples_per_frame,
					      unsigned bits_per_sample,
					      unsigned options,
					      pjmedia_snd_port **p_port);

/**
 * Create unidirectional sound device port for capturing audio streams from 
 * the sound device with the specified parameters.
 *
 * @param pool		    Pool to allocate sound port structure.
 * @param index		    Device index, or -1 to let the library choose the 
 *			    first available device.
 * @param clock_rate	    Sound device's clock rate to set.
 * @param channel_count	    Set number of channels, 1 for mono, or 2 for
 *			    stereo. The channel count determines the format
 *			    of the frame.
 * @param samples_per_frame Number of samples per frame.
 * @param bits_per_sample   Set the number of bits per sample. The normal 
 *			    value for this parameter is 16 bits per sample.
 * @param options	    Options flag.
 * @param p_port	    Pointer to receive the sound device port instance.
 *
 * @return		    PJ_SUCCESS on success, or the appropriate error
 *			    code.
 */
PJ_DECL(pj_status_t) pjmedia_snd_port_create_rec(pj_pool_t *pool,
						 int index,
						 unsigned clock_rate,
						 unsigned channel_count,
						 unsigned samples_per_frame,
						 unsigned bits_per_sample,
						 unsigned options,
						 pjmedia_snd_port **p_port);
					      
/**
 * Create unidirectional sound device port for playing audio streams with the 
 * specified parameters.
 *
 * @param pool		    Pool to allocate sound port structure.
 * @param index		    Device index, or -1 to let the library choose the 
 *			    first available device.
 * @param clock_rate	    Sound device's clock rate to set.
 * @param channel_count	    Set number of channels, 1 for mono, or 2 for
 *			    stereo. The channel count determines the format
 *			    of the frame.
 * @param samples_per_frame Number of samples per frame.
 * @param bits_per_sample   Set the number of bits per sample. The normal 
 *			    value for this parameter is 16 bits per sample.
 * @param options	    Options flag.
 * @param p_port	    Pointer to receive the sound device port instance.
 *
 * @return		    PJ_SUCCESS on success, or the appropriate error
 *			    code.
 */
PJ_DECL(pj_status_t) pjmedia_snd_port_create_player(pj_pool_t *pool,
						    int index,
						    unsigned clock_rate,
						    unsigned channel_count,
						    unsigned samples_per_frame,
						    unsigned bits_per_sample,
						    unsigned options,
						    pjmedia_snd_port **p_port);


/**
 * Create sound device port according to the specified parameters.
 *
 * @param pool		    Pool to allocate sound port structure.
 * @param prm		    Sound port parameter.
 * @param p_port	    Pointer to receive the sound device port instance.
 *
 * @return		    PJ_SUCCESS on success, or the appropriate error
 *			    code.
 */
PJ_DECL(pj_status_t) pjmedia_snd_port_create2(pj_pool_t *pool,
					      const pjmedia_snd_port_param *prm,
					      pjmedia_snd_port **p_port);


/**
 * Destroy sound device port.
 *
 * @param snd_port	    The sound device port.
 *
 * @return		    PJ_SUCCESS on success, or the appropriate error
 *			    code.
 */
PJ_DECL(pj_status_t) pjmedia_snd_port_destroy(pjmedia_snd_port *snd_port);


/**
 * Retrieve the sound stream associated by this sound device port.
 *
 * @param snd_port	    The sound device port.
 *
 * @return		    The sound stream instance.
 */
PJ_DECL(pjmedia_aud_stream*) pjmedia_snd_port_get_snd_stream(
						pjmedia_snd_port *snd_port);


/**
 * Change the echo cancellation settings. The echo cancellation settings 
 * should have been specified when this sound port was created, by setting
 * the appropriate fields in the pjmedia_aud_param, because not all sound
 * device implementation supports changing the EC setting once the device
 * has been opened.
 *
 * The behavior of this function depends on whether device or software AEC
 * is being used. If the device supports AEC, this function will forward
 * the change request to the device and it will be up to the device whether
 * to support the request. If software AEC is being used (the software EC
 * will be used if the device does not support AEC), this function will
 * change the software EC settings.
 *
 * @param snd_port	    The sound device port.
 * @param pool		    Pool to re-create the echo canceller if necessary.
 * @param tail_ms	    Maximum echo tail length to be supported, in
 *			    miliseconds. If zero is specified, the EC would
 *			    be disabled.
 * @param options	    The options to be passed to #pjmedia_echo_create().
 *			    This is only used if software EC is being used.
 *
 * @return		    PJ_SUCCESS on success.
 */
PJ_DECL(pj_status_t) pjmedia_snd_port_set_ec( pjmedia_snd_port *snd_port,
					      pj_pool_t *pool,
					      unsigned tail_ms,
					      unsigned options);


/**
 * Get current echo canceller tail length, in miliseconds. The tail length 
 * will be zero if EC is not enabled.
 *
 * @param snd_port	    The sound device port.
 * @param p_length	    Pointer to receive the tail length.
 *
 * @return		    PJ_SUCCESS on success.
 */
PJ_DECL(pj_status_t) pjmedia_snd_port_get_ec_tail(pjmedia_snd_port *snd_port,
						  unsigned *p_length);


/**
 * Get a clock source from the sound port.
 *
 * @param snd_port  The sound port.
 * @param dir       Sound port's direction.
 *
 * @return	    The clock source.
 */
PJ_DECL(pjmedia_clock_src *)
pjmedia_snd_port_get_clock_src( pjmedia_snd_port *snd_port,
                                pjmedia_dir dir );


/**
 * Connect a port to the sound device port. If the sound device port has a
 * sound recorder device, then this will start periodic function call to
 * the port's put_frame() function. If the sound device has a sound player
 * device, then this will start periodic function call to the port's
 * get_frame() function.
 *
 * For this version of PJMEDIA, the media port MUST have the same audio
 * settings as the sound device port, or otherwise the connection will
 * fail. This means the port MUST have the same clock_rate, channel count,
 * samples per frame, and bits per sample as the sound device port.
 *
 * @param snd_port	    The sound device port.
 * @param port		    The media port to be connected.
 *
 * @return		    PJ_SUCCESS on success, or the appropriate error
 *			    code.
 */
PJ_DECL(pj_status_t) pjmedia_snd_port_connect(pjmedia_snd_port *snd_port,
					      pjmedia_port *port);


/**
 * Retrieve the port instance currently attached to the sound port, if any.
 *
 * @param snd_port	    The sound device port.
 *
 * @return		    The port instance currently attached to the 
 *			    sound device port, or NULL if there is no port
 *			    currently attached to the sound device port.
 */
PJ_DECL(pjmedia_port*) pjmedia_snd_port_get_port(pjmedia_snd_port *snd_port);


/**
 * Disconnect currently attached port from the sound device port.
 *
 * @param snd_port	    The sound device port.
 *
 * @return		    PJ_SUCCESS on success.
 */
PJ_DECL(pj_status_t) pjmedia_snd_port_disconnect(pjmedia_snd_port *snd_port);


/**
 * @}
 */

PJ_END_DECL


#endif	/* __PJMEDIA_SOUND_PORT_H__ */