1
/* $Id: splitcomb.h 3553 2011-05-05 06:14:19Z nanang $ */
3
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4
* Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
#ifndef __PJMEDIA_SPLITCOMB_H__
21
#define __PJMEDIA_SPLITCOMB_H__
26
* @brief Media channel splitter/combiner port.
28
#include <pjmedia/port.h>
32
* @addtogroup PJMEDIA_SPLITCOMB Media channel splitter/combiner
33
* @ingroup PJMEDIA_PORT
34
* @brief Split and combine multiple mono-channel media ports into
35
* a single multiple-channels media port
38
* This section describes media port to split and combine media
39
* channels in the stream.
41
* A splitter/combiner splits a single stereo/multichannels audio frame into
42
* multiple audio frames to each channel when put_frame() is called,
43
* and combines mono frames from each channel into a stereo/multichannel
44
* frame when get_frame() is called. A common application for the splitter/
45
* combiner is to split frames from stereo to mono and vise versa.
52
* Create a media splitter/combiner with the specified parameters.
53
* When the splitter/combiner is created, it creates an instance of
54
* pjmedia_port. This media port represents the stereo/multichannel side
55
* of the splitter/combiner. Application needs to supply the splitter/
56
* combiner with a media port for each audio channels.
58
* @param pool Pool to allocate memory to create the splitter/
60
* @param clock_rate Audio clock rate/sampling rate.
61
* @param channel_count Number of channels.
62
* @param samples_per_frame Number of samples per frame.
63
* @param bits_per_sample Bits per sample.
64
* @param options Optional flags.
65
* @param p_splitcomb Pointer to receive the splitter/combiner.
67
* @return PJ_SUCCESS on success, or the appropriate
70
PJ_DECL(pj_status_t) pjmedia_splitcomb_create(pj_pool_t *pool,
72
unsigned channel_count,
73
unsigned samples_per_frame,
74
unsigned bits_per_sample,
76
pjmedia_port **p_splitcomb);
79
* Supply the splitter/combiner with media port for the specified channel
80
* number. The media port will be called at the
81
* same phase as the splitter/combiner; which means that when application
82
* calls get_frame() of the splitter/combiner, it will call get_frame()
83
* for all ports that have the same phase. And similarly for put_frame().
85
* @param splitcomb The splitter/combiner.
86
* @param ch_num Audio channel starting number (zero based).
87
* @param options Must be zero at the moment.
88
* @param port The media port.
90
* @return PJ_SUCCESS on success, or the appropriate error
93
PJ_DECL(pj_status_t) pjmedia_splitcomb_set_channel(pjmedia_port *splitcomb,
99
* Create a reverse phase media port for the specified channel number.
100
* For channels with reversed phase, when application calls put_frame() to
101
* the splitter/combiner, the splitter/combiner will only put the frame to
102
* a buffer. Later on, when application calls get_frame() on the channel's
103
* media port, it will return the frame that are available in the buffer.
104
* The same process happens when application calls put_frame() to the
105
* channel's media port, it will only put the frame to another buffer, which
106
* will be returned when application calls get_frame() to the splitter's
107
* media port. So this effectively reverse the phase of the media port.
109
* @param pool The pool to allocate memory for the port and
111
* @param splitcomb The splitter/combiner.
112
* @param ch_num Audio channel starting number (zero based).
113
* @param options Normally is zero, but the lower 8-bit of the
114
* options can be used to specify the number of
115
* buffers in the circular buffer. If zero, then
116
* default number will be used (default: 8).
117
* @param p_chport The media port created with reverse phase for
118
* the specified audio channel.
120
* @return PJ_SUCCESS on success, or the appropriate error
124
pjmedia_splitcomb_create_rev_channel( pj_pool_t *pool,
125
pjmedia_port *splitcomb,
128
pjmedia_port **p_chport);
138
#endif /* __PJMEDIA_SPLITCOMB_H__ */