Debian Codegraph @

Xpjproject/third_party/mp3/mp3_port.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2003-2007 Benny Prijono <[email protected]>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19 /*
20 * Contributed by:
21 * Toni < buldozer at aufbix dot org >
22 */
23
24 #ifndef __PJMEDIA_MP3_PORT_H__
25 #define __PJMEDIA_MP3_PORT_H__
26
27
28 /**
29 * @file mp3_port.h
30 * @brief MP3 writer
31 */
32 #include <pjmedia/port.h>
33
34 /**
35 * @defgroup PJMEDIA_MP3_FILE_REC MP3 Audio File Writer (Recorder)
36 * @ingroup PJMEDIA_PORT
37 * @brief MP3 Audio File Writer (Recorder)
38 * @{
39 *
40 * This section describes MP3 file writer. Currently it only works on Windows
41 * using BladeEncDLL of the LAME MP3 encoder. <b>Note that the LAME_ENC.DLL
42 * file must exist in the PATH so that the encoder can work properly.</b>
43 *
44 * The MP3 file writer is created with #pjmedia_mp3_writer_port_create() which
45 * among other things specifies the desired file name and audio properties.
46 * It then takes PCM input when #pjmedia_port_put_frame() is called and encode
47 * the PCM input into MP3 streams before writing it to the .mp3 file.
48 */
49
50
51 PJ_BEGIN_DECL
52
53
54 /**
55 * This structure contains encoding options that can be specified during
56 * MP3 writer port creation. Application should always zero the structure
57 * before setting some value to make sure that default options will be used.
58 */
59 typedef struct pjmedia_mp3_encoder_option
60 {
61 /** Specify whether variable bit rate should be used. Variable bitrate
62 * would normally produce better quality at the expense of probably
63 * larger file.
64 */
65 pj_bool_t vbr;
66
67 /** Target bitrate, in bps. If VBR is enabled, this settings specifies
68 * the average bit-rate requested, and will make the encoder ignore
69 * the quality setting. For CBR, this specifies the actual bitrate,
70 * and if this option is zero, it will be set to the sampling rate
71 * multiplied by number of channels.
72 */
73 unsigned bit_rate;
74
75 /** Encoding quality, 0-9, with 0 is the highest quality. For VBR, the
76 * quality setting will only take effect when bit_rate setting is zero.
77 */
78 unsigned quality;
79
80 } pjmedia_mp3_encoder_option;
81
82
83 /**
84 * Create a media port to record PCM media to a MP3 file. After the port
85 * is created, application can call #pjmedia_port_put_frame() to feed the
86 * port with PCM frames. The port then will encode the PCM frame into MP3
87 * stream, and store it to MP3 file specified in the argument.
88 *
89 * When application has finished with writing MP3 file, it must destroy the
90 * media port with #pjmedia_port_destroy() so that the MP3 file can be
91 * closed properly.
92 *
93 * @param pool Pool to create memory buffers for this port.
94 * @param filename File name.
95 * @param clock_rate The sampling rate.
96 * @param channel_count Number of channels.
97 * @param samples_per_frame Number of samples per frame.
98 * @param bits_per_sample Number of bits per sample (eg 16).
99 * @param option Optional option to set encoding parameters.
100 * @param p_port Pointer to receive the file port instance.
101 *
102 * @return PJ_SUCCESS on success.
103 */
104 PJ_DECL(pj_status_t)
105 pjmedia_mp3_writer_port_create(pj_pool_t *pool,
106 const char *filename,
107 unsigned clock_rate,
108 unsigned channel_count,
109 unsigned samples_per_frame,
110 unsigned bits_per_sample,
111 const pjmedia_mp3_encoder_option *option,
112 pjmedia_port **p_port );
113
114
115 #if !DEPRECATED_FOR_TICKET_2251
116 /**
117 * Register the callback to be called when the file writing has reached
118 * certain size. Application can use this callback, for example, to limit
119 * the size of the output file.
120 *
121 * @param port The file writer port.
122 * @param pos The file position on which the callback will be called.
123 * @param user_data User data to be specified in the callback, and will be
124 * given on the callback.
125 * @param cb Callback to be called. If the callback returns non-
126 * PJ_SUCCESS, the writing will stop. Note that if
127 * application destroys the port in the callback, it must
128 * return non-PJ_SUCCESS here.
129 *
130 * @return PJ_SUCCESS on success.
131 */
132 PJ_DECL(pj_status_t)
133 pjmedia_mp3_writer_port_set_cb( pjmedia_port *port,
134 pj_size_t pos,
135 void *user_data,
136 pj_status_t (*cb)(pjmedia_port *port,
137 void *usr_data));
138 #endif
139
140
141 /**
142 * Register the callback to be called when the file writing has reached
143 * certain size. Application can use this callback, for example, to limit
144 * the size of the output file.
145 *
146 * @param port The file writer port.
147 * @param pos The file position on which the callback will be called.
148 * @param user_data User data to be specified in the callback, and will be
149 * given on the callback.
150 * @param cb Callback to be called. Note that if
151 * application wishes to stop the playback, it
152 * can disconnect the port in the callback, and
153 * only after all connections have been removed
154 * could the application safely destroy the port.
155 *
156 * @return PJ_SUCCESS on success.
157 */
158 PJ_DECL(pj_status_t)
159 pjmedia_mp3_writer_port_set_cb2(pjmedia_port *port,
160 pj_size_t pos,
161 void *user_data,
162 void (*cb)(pjmedia_port *port,
163 void *usr_data));
164
165
166 /**
167 * @}
168 */
169
170
171 PJ_END_DECL
172
173 #endif /* __PJMEDIA_MP3_PORT_H__ */
174