summaryrefslogtreecommitdiff
path: root/pjmedia/include/pjmedia/plc.h
blob: 01d77b29339cad341d4cc3645eb3aae300430e61 (plain)
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
/* $Id$ */
/* 
 * Copyright (C) 2003-2007 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_PLC_H__
#define __PJMEDIA_PLC_H__


/**
 * @file plc.h
 * @brief Packet Lost Concealment (PLC) API.
 */
#include <pjmedia/types.h>

/**
 * @defgroup PJMED_PLC Packet Lost Concealment (PLC)
 * @ingroup PJMEDIA_FRAME_OP
 * @{
 * This section describes PJMEDIA's implementation of Packet Lost
 * Concealment algorithm. This algorithm is used to implement PLC for
 * codecs that do not have built-in support for one (e.g. G.711 or GSM codecs).
 *
 * The PLC algorithm (either built-in or external) is embedded in
 * PJMEDIA codec instance, and application can conceal lost frames
 * by calling <b><tt>recover()</tt></b> member of the codec's member
 * operation (#pjmedia_codec_op).
 *
 * See also @ref plc_codec for more info.
 */


PJ_BEGIN_DECL


/**
 * Opaque declaration for PLC.
 */
typedef struct pjmedia_plc pjmedia_plc;



/**
 * Create PLC session. This function will select the PLC algorithm to
 * use based on the arguments.
 *
 * @param pool		    Pool to allocate memory for the PLC.
 * @param clock_rate	    Media sampling rate.
 * @param samples_per_frame Number of samples per frame.
 * @param options	    Must be zero for now.
 * @param p_plc		    Pointer to receive the PLC instance.
 *
 * @return		    PJ_SUCCESS on success.
 */
PJ_DECL(pj_status_t) pjmedia_plc_create( pj_pool_t *pool,
					 unsigned clock_rate,
					 unsigned samples_per_frame,
					 unsigned options,
					 pjmedia_plc **p_plc);


/**
 * Save a good frame to PLC.
 *
 * @param plc		    The PLC session.
 * @param frame		    The good frame to be stored to PLC. This frame
 *			    must have the same length as the configured
 *			    samples per frame.
 *
 * @return		    PJ_SUCCESS on success.
 */
PJ_DECL(pj_status_t) pjmedia_plc_save( pjmedia_plc *plc,
				       pj_int16_t *frame );


/**
 * Generate a replacement for lost frame.
 *
 * @param plc		    The PLC session.
 * @param frame		    Buffer to receive the generated frame. This buffer
 *			    must be able to store the frame.
 *
 * @return		    PJ_SUCCESS on success.
 */
PJ_DECL(pj_status_t) pjmedia_plc_generate( pjmedia_plc *plc,
					   pj_int16_t *frame );




PJ_END_DECL

/**
 * @}
 */

#endif	/* __PJMEDIA_PLC_H__ */