blob: b80faf8472b7d1329402bf641301b038500d7c1b [file] [log] [blame]
Benny Prijonoc45d9512010-12-10 11:04:30 +00001/* $Id$ */
2/*
3 * Copyright (C) 2008-2009 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
Nanang Izzuddind91af572011-03-31 17:29:54 +000025 * @brief Packetizes/unpacketizes H.263 bitstream into RTP payload.
Benny Prijonoc45d9512010-12-10 11:04:30 +000026 */
27
Nanang Izzuddind91af572011-03-31 17:29:54 +000028#include <pj/pool.h>
29#include <pj/types.h>
Benny Prijonoc45d9512010-12-10 11:04:30 +000030
31PJ_BEGIN_DECL
32
Benny Prijonoc45d9512010-12-10 11:04:30 +000033
34/**
Nanang Izzuddind91af572011-03-31 17:29:54 +000035 * Opaque declaration for H.263 packetizer.
Benny Prijonoc45d9512010-12-10 11:04:30 +000036 */
Nanang Izzuddind91af572011-03-31 17:29:54 +000037typedef struct pjmedia_h263_packetizer pjmedia_h263_packetizer;
38
39
40/**
41 * Enumeration of H.263 packetization modes.
42 */
43typedef enum
Benny Prijonoc45d9512010-12-10 11:04:30 +000044{
Nanang Izzuddind91af572011-03-31 17:29:54 +000045 /**
46 * H.263 RTP packetization using RFC 4629.
Benny Prijonoc45d9512010-12-10 11:04:30 +000047 */
Nanang Izzuddind91af572011-03-31 17:29:54 +000048 PJMEDIA_H263_PACKETIZER_MODE_RFC4629,
Benny Prijonoc45d9512010-12-10 11:04:30 +000049
Nanang Izzuddind91af572011-03-31 17:29:54 +000050 /**
51 * H.263 RTP packetization using legacy RFC 2190.
52 * This is currently not supported.
53 */
54 PJMEDIA_H263_PACKETIZER_MODE_RFC2190,
Benny Prijonoc45d9512010-12-10 11:04:30 +000055
Nanang Izzuddind91af572011-03-31 17:29:54 +000056} pjmedia_h263_packetizer_mode;
57
Benny Prijonoc45d9512010-12-10 11:04:30 +000058
59/**
Nanang Izzuddind91af572011-03-31 17:29:54 +000060 * H.263 packetizer configuration.
Benny Prijonoc45d9512010-12-10 11:04:30 +000061 */
Nanang Izzuddind91af572011-03-31 17:29:54 +000062typedef struct pjmedia_h263_packetizer_cfg
Benny Prijonoc45d9512010-12-10 11:04:30 +000063{
Nanang Izzuddind91af572011-03-31 17:29:54 +000064 /**
65 * Maximum payload length.
66 * Default: PJMEDIA_MAX_MTU
67 */
68 int mtu;
Benny Prijonoc45d9512010-12-10 11:04:30 +000069
Nanang Izzuddind91af572011-03-31 17:29:54 +000070 /**
71 * Packetization mode.
72 * Default: PJMEDIA_H263_PACKETIZER_MODE_RFC4629
73 */
74 pjmedia_h263_packetizer_mode mode;
Benny Prijonoc45d9512010-12-10 11:04:30 +000075
Nanang Izzuddind91af572011-03-31 17:29:54 +000076} pjmedia_h263_packetizer_cfg;
Benny Prijonoc45d9512010-12-10 11:04:30 +000077
Benny Prijonoc45d9512010-12-10 11:04:30 +000078
Nanang Izzuddind91af572011-03-31 17:29:54 +000079/**
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 */
89PJ_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);
Benny Prijonoc45d9512010-12-10 11:04:30 +000093
Benny Prijonoc45d9512010-12-10 11:04:30 +000094
Nanang Izzuddind91af572011-03-31 17:29:54 +000095/**
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 */
109PJ_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);
Benny Prijonoc45d9512010-12-10 11:04:30 +0000115
Nanang Izzuddind91af572011-03-31 17:29:54 +0000116
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 */
135PJ_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);
Benny Prijonoc45d9512010-12-10 11:04:30 +0000141
142
143PJ_END_DECL
144
145
146#endif /* __PJMEDIA_H263_PACKETIZER_H__ */