1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
/*
* Copyright 2004 Timo Hirvonen
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#ifndef _NOMAD_H
#define _NOMAD_H
#include <mad.h>
#include <sys/types.h>
#define INPUT_BUFFER_SIZE (5 * 8192)
/* default callbacks use read, lseek, close */
struct nomad_callbacks {
ssize_t (*read)(void *datasource, void *buffer, size_t count);
off_t (*lseek)(void *datasource, off_t offset, int whence);
int (*close)(void *datasource);
};
/* always 16-bit signed little-endian */
struct nomad_info {
double duration;
int sample_rate;
int channels;
int nr_frames;
int layer;
/* -1 if fast = 1 */
int vbr;
/* -1 if fast = 1 */
int avg_bitrate;
/* -1 if file not seekable */
int filesize;
unsigned int joint_stereo : 1;
unsigned int dual_channel : 1;
};
enum {
NOMAD_ERROR_SUCCESS,
NOMAD_ERROR_ERRNO,
NOMAD_ERROR_FILE_FORMAT
};
struct nomad;
/* -NOMAD_ERROR_ERRNO -NOMAD_ERROR_FILE_FORMAT */
int nomad_open(struct nomad **nomadp, int fd, int fast);
int nomad_open_callbacks(struct nomad **nomadp, void *datasource, int fast,
struct nomad_callbacks *cbs);
void nomad_close(struct nomad *nomad);
void nomad_info(struct nomad *nomad, struct nomad_info *info);
/* -NOMAD_ERROR_ERRNO */
int nomad_read(struct nomad *nomad, char *buffer, int count);
/* -NOMAD_ERROR_ERRNO */
int nomad_time_seek(struct nomad *nomad, double pos);
double nomad_time_tell(struct nomad *nomad);
double nomad_time_total(struct nomad *nomad);
#endif
|