Changeset 531 for pjproject/trunk/pjmedia/src/pjmedia/wav_writer.c
- Timestamp:
- Jun 20, 2006 3:39:07 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/wav_writer.c
r411 r531 29 29 30 30 #define THIS_FILE "wav_writer.c" 31 #define SIGNATURE ('F'<<24|'W'<<16|'R'<<8|'T')31 #define SIGNATURE PJMEDIA_PORT_SIGNATURE('F', 'W', 'R', 'T') 32 32 #define BYTES_PER_SAMPLE 2 33 33 … … 39 39 char *buf; 40 40 char *writepos; 41 pj_size_t total; 41 42 42 43 pj_oshandle_t fd; 44 45 pj_size_t cb_size; 46 pj_status_t (*cb)(pjmedia_port*, void*); 43 47 }; 44 48 … … 178 182 179 183 184 185 /* 186 * Get current writing position. 187 */ 188 PJ_DEF(pj_ssize_t) pjmedia_wav_writer_port_get_pos( pjmedia_port *port ) 189 { 190 struct file_port *fport; 191 192 /* Sanity check */ 193 PJ_ASSERT_RETURN(port, -PJ_EINVAL); 194 195 /* Check that this is really a writer port */ 196 PJ_ASSERT_RETURN(port->info.signature == SIGNATURE, -PJ_EINVALIDOP); 197 198 fport = (struct file_port*) port; 199 200 return fport->total; 201 } 202 203 204 /* 205 * Register callback. 206 */ 207 PJ_DEF(pj_status_t) 208 pjmedia_wav_writer_port_set_cb( pjmedia_port *port, 209 pj_size_t pos, 210 void *user_data, 211 pj_status_t (*cb)(pjmedia_port *port, 212 void *usr_data)) 213 { 214 struct file_port *fport; 215 216 /* Sanity check */ 217 PJ_ASSERT_RETURN(port && cb, PJ_EINVAL); 218 219 /* Check that this is really a writer port */ 220 PJ_ASSERT_RETURN(port->info.signature == SIGNATURE, PJ_EINVALIDOP); 221 222 fport = (struct file_port*) port; 223 224 fport->cb_size = pos; 225 fport->base.user_data = user_data; 226 fport->cb = cb; 227 228 return PJ_SUCCESS; 229 } 230 231 180 232 #if defined(PJ_IS_BIG_ENDIAN) && PJ_IS_BIG_ENDIAN!=0 181 233 static void swap_samples(pj_int16_t *samples, unsigned count) … … 235 287 fport->writepos += frame->size; 236 288 289 /* Increment total written, and check if we need to call callback */ 290 fport->total += frame->size; 291 if (fport->cb && fport->total >= fport->cb_size) { 292 pj_status_t (*cb)(pjmedia_port*, void*); 293 pj_status_t status; 294 295 cb = fport->cb; 296 fport->cb = NULL; 297 298 status = (*cb)(this_port, this_port->user_data); 299 return status; 300 } 301 237 302 return PJ_SUCCESS; 238 303 }
Note: See TracChangeset
for help on using the changeset viewer.