Add support for ICE/STUN/TURN in res_rtp_asterisk and chan_sip.
[asterisk/asterisk.git] / res / pjproject / pjmedia / include / pjmedia-codec / h263_packetizer.h
1 /* $Id$ */
2 /* 
3  * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
18  */
19 #ifndef __PJMEDIA_H263_PACKETIZER_H__
20 #define __PJMEDIA_H263_PACKETIZER_H__
21
22
23 /**
24  * @file h263_packetizer.h
25  * @brief Packetizes/unpacketizes H.263 bitstream into RTP payload.
26  */
27
28 #include <pj/pool.h>
29 #include <pj/types.h>
30
31 PJ_BEGIN_DECL
32
33
34 /**
35  * Opaque declaration for H.263 packetizer.
36  */
37 typedef struct pjmedia_h263_packetizer pjmedia_h263_packetizer;
38
39
40 /**
41  * Enumeration of H.263 packetization modes.
42  */
43 typedef enum
44 {
45     /**
46      * H.263 RTP packetization using RFC 4629.
47      */
48     PJMEDIA_H263_PACKETIZER_MODE_RFC4629,
49
50     /**
51      * H.263 RTP packetization using legacy RFC 2190.
52      * This is currently not supported.
53      */
54     PJMEDIA_H263_PACKETIZER_MODE_RFC2190,
55
56 } pjmedia_h263_packetizer_mode;
57
58
59 /**
60  * H.263 packetizer configuration.
61  */
62 typedef struct pjmedia_h263_packetizer_cfg
63 {
64     /**
65      * Maximum payload length.
66      * Default: PJMEDIA_MAX_MTU
67      */
68     int mtu;
69
70     /**
71      * Packetization mode.
72      * Default: PJMEDIA_H263_PACKETIZER_MODE_RFC4629
73      */
74     pjmedia_h263_packetizer_mode mode;
75
76 } pjmedia_h263_packetizer_cfg;
77
78
79 /**
80  * Create H.263 packetizer.
81  *
82  * @param pool          The memory pool.
83  * @param cfg           Packetizer settings, if NULL, default setting
84  *                      will be used.
85  * @param p_pktz        Pointer to receive the packetizer.
86  *
87  * @return              PJ_SUCCESS on success.
88  */
89 PJ_DECL(pj_status_t) pjmedia_h263_packetizer_create(
90                                     pj_pool_t *pool,
91                                     const pjmedia_h263_packetizer_cfg *cfg,
92                                     pjmedia_h263_packetizer **p_pktz);
93
94
95 /**
96  * Generate an RTP payload from a H.263 picture bitstream. Note that this
97  * function will apply in-place processing, so the bitstream may be modified
98  * during the packetization.
99  *
100  * @param pktz          The packetizer.
101  * @param bits          The picture bitstream to be packetized.
102  * @param bits_len      The length of the bitstream.
103  * @param bits_pos      The bitstream offset to be packetized.
104  * @param payload       The output payload.
105  * @param payload_len   The output payload length.
106  *
107  * @return              PJ_SUCCESS on success.
108  */
109 PJ_DECL(pj_status_t) pjmedia_h263_packetize(pjmedia_h263_packetizer *pktz,
110                                             pj_uint8_t *bits,
111                                             pj_size_t bits_len,
112                                             unsigned *bits_pos,
113                                             const pj_uint8_t **payload,
114                                             pj_size_t *payload_len);
115
116
117 /**
118  * Append an RTP payload to an H.263 picture bitstream. Note that in case of
119  * noticing packet lost, application should keep calling this function with
120  * payload pointer set to NULL, as the packetizer need to update its internal
121  * state.
122  *
123  * @param pktz          The packetizer.
124  * @param payload       The payload to be unpacketized.
125  * @param payload_len   The payload length.
126  * @param bits          The bitstream buffer.
127  * @param bits_size     The bitstream buffer size.
128  * @param bits_pos      The bitstream offset to put the unpacketized payload
129  *                      in the bitstream, upon return, this will be updated
130  *                      to the latest offset as a result of the unpacketized
131  *                      payload.
132  *
133  * @return              PJ_SUCCESS on success.
134  */
135 PJ_DECL(pj_status_t) pjmedia_h263_unpacketize(pjmedia_h263_packetizer *pktz,
136                                               const pj_uint8_t *payload,
137                                               pj_size_t payload_len,
138                                               pj_uint8_t *bits,
139                                               pj_size_t bits_size,
140                                               unsigned *bits_pos);
141
142
143 PJ_END_DECL
144
145
146 #endif  /* __PJMEDIA_H263_PACKETIZER_H__ */