Main Page | Data Structures | File List | Data Fields | Globals

libdaisy.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2006 by André Lindhjem <belgarat@sdf.lonestar.org>,     *
00003  *                         Kjetil Holien <kjetil.holien@gmail.com>,        *
00004  *                         Terje Risa <terje.risa@gmail.com> &             *
00005  *                         Øyvind Nerbråten <oyvind@nerbraten.com>         *
00006  *                                                                         *
00007  *   This program is free software; you can redistribute it and/or modify  *
00008  *   it under the terms of the GNU General Public License as published by  *
00009  *   the Free Software Foundation; either version 2 of the License, or     *
00010  *   (at your option) any later version.                                   *
00011  *                                                                         *
00012  *   This program is distributed in the hope that it will be useful,       *
00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00015  *   GNU General Public License for more details.                          *
00016  *                                                                         *
00017  *   You should have received a copy of the GNU General Public License     *
00018  *   along with this program; if not, write to the                         *
00019  *   Free Software Foundation, Inc.,                                       *
00020  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00021  ***************************************************************************
00022  *
00023  * \file libdaisy.c
00024  * \author André Lindhjem, Kjetil Holien, Terje Risa & Øyvind Nerbråten
00025  * \date 21.03.2006
00026  * 
00027  * Libdaisy is a toolkit for parsing and playing Daisy Digital Talking Books (DTB).
00028  */
00029
00030
00031 #ifndef LIBDAISY_H_
00032 #define LIBDAISY_H_
00033 
00034 #include <pthread.h>
00035
00036 #ifdef __cplusplus
00037 extern "C" {
00038 #endif
00039 
00040
00041
00042 /* ************************************************ *
00043  *  Global type definitions and datastructures      *
00044  * ************************************************ */
00045
00049 typedef void *daisyplayer_t;
00050
00054 enum daisy_status
00055 {
00056     DAISY_ERROR_UNKNOWN                         = 0x0000,   /* unknown error */
00057
00058     /* parser related errors */
00059
00060
00061     /* audio related errors */
00062     DAISY_ERROR_AUDIO_NOT_INITIALIZED           = 0x0200,   /* audio isn't (properly) initialized */
00063     DAISY_ERROR_AUDIO_CREATE_MMAP               = 0x0201,   /* could not read file into memmory */
00064     DAISY_ERROR_AUDIO_FSTAT                     = 0x0202,   /* could not get file stats */
00065     DAISY_ERROR_AUDIO_OPEN                      = 0x0203,   /* could not open file */
00066     DAISY_ERROR_AUDIO_FREE_MMAP                 = 0x0204,   /* could not free file from memory */
00067     DAISY_ERROR_AUDIO_INITIATE_DATA             = 0x0205,   /* could not initiate data struct */
00068     DAISY_ERROR_AUDIO_NOT_PLAYING               = 0x0206,   /* state is not playing */
00069     DAISY_ERROR_AUDIO_NOT_STOPPED               = 0x0207,   /* state is not stopped */
00070     DAISY_ERROR_AUDIO_DATA_IS_NULL              = 0x0208,   /* data struct seems to be NULL */
00071     DAISY_ERROR_AUDIO_MALLOC                    = 0x0209,   /* failure allocating memmory */
00072     DAISY_ERROR_AUDIO_PAUSED_WHILE_NOT_PLAYING  = 0x0210,   /* paused when not playing */
00073     DAISY_ERROR_AUDIO_STOPPED_WHILE_NOT_PLAYING = 0x0211,   /* stopped when not playing */
00074
00075     /* playback related errors */
00076     DAISY_ERROR_PLAYBACK_NO_TEXT_IN_SEGMENT     = 0x0301,   /* no text in segment */
00077     DAISY_ERROR_PLAYBACK_NO_AUDIO_IN_SEGMENT    = 0x0302,   /* no audio in segment */
00078     DAISY_ERROR_PLAYBACK_NO_DTB_LOADED          = 0x0303,   /* no daisy dtb loaded */
00079     DAISY_ERROR_PLAYBACK_SEEK_FAILED            = 0x0304,   /* seek failed */
00080
00081     /* other errors */
00082     DAISY_ERROR_MISC_INIT_MUTEX                 = 0x0400,   /* could not initialize mutex */
00083
00084     /* playback related status messages */
00085     DAISY_END_OF_BOOK                           = 0x1100    /* we're at the end of the book */
00086 };
00087
00092 enum daisy_seek_option
00093 {
00094     DAISY_SEEK_PREV_CHAPTER = 1,
00095     DAISY_SEEK_PREV_PASSAGE = 2,
00096     DAISY_SEEK_NEXT_CHAPTER = 3,
00097     DAISY_SEEK_NEXT_PASSAGE = 4,
00098     DAISY_SEEK_TO_BEGINNING = 5
00099 };
00100
00105 enum daisy_bookinfo_option
00106 {
00107     DAISY_BOOKINFO_TITLETEXT = 1,
00108     DAISY_BOOKINFO_TITLEIMAGE = 2,
00109     DAISY_BOOKINFO_TOTALTIME = 3
00110 };
00111
00116 enum daisy_chapter_info
00117 {
00118     DAISY_CHAPTER_TITLE = 1,
00119     DAISY_CHAPTER_WEIGHT = 2
00120 };
00121
00130  typedef struct {
00131     int smilpos;
00132     int nodepos;
00133  } daisy_position;
00134
00135
00136
00137 /* ************************************************ *
00138  *          Global function declarations            *
00139  * ************************************************ */
00140
00156 daisyplayer_t daisy_init (void *data,
00157                           void (*l_cb_daisy_audio_done) (void *),           /* (data, progress_ms_t ), */
00158                           void (*l_cb_daisy_audio_next) (void *, unsigned long int),/* (data, void ), */
00159                           void (*l_cb_daisy_text)       (void *, void *),           /* (data, passage ), */
00160                           void (*l_cb_daisy_id)         (void *, void *),           /* (data, id ) */
00161                           void (*l_cb_daisy_error)      (void *, enum daisy_status, const char *daisy_status_msg),
00162                           void (*l_cb_daisy_progress)   (void *, long int)          /* (data, progress_ms) */
00163 );
00164
00170 void daisy_term (daisyplayer_t daisy);
00171
00178 int daisy_load (daisyplayer_t daisy, char *path);
00179
00185 int daisy_play (daisyplayer_t daisy);
00186
00194 int daisy_seek (daisyplayer_t daisy, int seek_option);
00195
00204 daisy_position *daisy_get_position (daisyplayer_t daisy);
00205
00214 int daisy_goto_position (daisyplayer_t daisy, daisy_position *position);
00215
00221 int daisy_stop (daisyplayer_t daisy);
00222
00228 int daisy_pause (daisyplayer_t daisy);
00229
00237 char *daisy_get_info (daisyplayer_t daisy, int value);
00238
00244 int daisy_get_chapter_count (daisyplayer_t daisy);
00245
00256 char *daisy_get_chapter_info (daisyplayer_t daisy, int num, int option);
00257
00258 #ifdef __cplusplus
00259 }
00260 #endif
00261 
00262
00263 #endif /*LIBDAISY_H_*/
00264

Generated on Thu May 18 12:46:33 2006 for libdaisy by  doxygen 1.4.2