Main Page   Data Structures   File List   Data Fields   Globals  

libdaisy.h File Reference

#include <pthread.h>

Go to the source code of this file.

Data Structures

struct  daisy_position

Typedefs

typedef void * daisyplayer_t

Enumerations

enum  daisy_status {
  DAISY_ERROR_UNKNOWN = 0x0000, DAISY_ERROR_AUDIO_NOT_INITIALIZED = 0x0200, DAISY_ERROR_AUDIO_CREATE_MMAP = 0x0201, DAISY_ERROR_AUDIO_FSTAT = 0x0202,
  DAISY_ERROR_AUDIO_OPEN = 0x0203, DAISY_ERROR_AUDIO_FREE_MMAP = 0x0204, DAISY_ERROR_AUDIO_INITIATE_DATA = 0x0205, DAISY_ERROR_AUDIO_NOT_PLAYING = 0x0206,
  DAISY_ERROR_AUDIO_NOT_STOPPED = 0x0207, DAISY_ERROR_AUDIO_DATA_IS_NULL = 0x0208, DAISY_ERROR_AUDIO_MALLOC = 0x0209, DAISY_ERROR_AUDIO_PAUSED_WHILE_NOT_PLAYING = 0x0210,
  DAISY_ERROR_AUDIO_STOPPED_WHILE_NOT_PLAYING = 0x0211, DAISY_ERROR_PLAYBACK_NO_TEXT_IN_SEGMENT = 0x0301, DAISY_ERROR_PLAYBACK_NO_AUDIO_IN_SEGMENT = 0x0302, DAISY_ERROR_PLAYBACK_NO_DTB_LOADED = 0x0303,
  DAISY_ERROR_PLAYBACK_SEEK_FAILED = 0x0304, DAISY_ERROR_MISC_INIT_MUTEX = 0x0400, DAISY_END_OF_BOOK = 0x1100
}
enum  daisy_seek_option {
  DAISY_SEEK_PREV_CHAPTER = 1, DAISY_SEEK_PREV_PASSAGE = 2, DAISY_SEEK_NEXT_CHAPTER = 3, DAISY_SEEK_NEXT_PASSAGE = 4,
  DAISY_SEEK_TO_BEGINNING = 5
}
enum  daisy_bookinfo_option { DAISY_BOOKINFO_TITLETEXT = 1, DAISY_BOOKINFO_TITLEIMAGE = 2, DAISY_BOOKINFO_TOTALTIME = 3 }
enum  daisy_chapter_info { DAISY_CHAPTER_TITLE = 1, DAISY_CHAPTER_WEIGHT = 2 }

Functions

daisyplayer_t daisy_init (void *data, void(*l_cb_daisy_audio_done)(void *), void(*l_cb_daisy_audio_next)(void *, unsigned long int), void(*l_cb_daisy_text)(void *, void *), void(*l_cb_daisy_id)(void *, void *), void(*l_cb_daisy_error)(void *, enum daisy_status, const char *daisy_status_msg), void(*l_cb_daisy_progress)(void *, long int))
void daisy_term (daisyplayer_t daisy)
int daisy_load (daisyplayer_t daisy, char *path)
int daisy_play (daisyplayer_t daisy)
int daisy_seek (daisyplayer_t daisy, int seek_option)
daisy_positiondaisy_get_position (daisyplayer_t daisy)
int daisy_goto_position (daisyplayer_t daisy, daisy_position *position)
int daisy_stop (daisyplayer_t daisy)
int daisy_pause (daisyplayer_t daisy)
char * daisy_get_info (daisyplayer_t daisy, int value)
int daisy_get_chapter_count (daisyplayer_t daisy)
char * daisy_get_chapter_info (daisyplayer_t daisy, int num, int option)


Typedef Documentation

typedef void* daisyplayer_t
 

This will need to be initialized and passed along to the daisy functions.

Definition at line 49 of file libdaisy.h.

Referenced by audio_initiate(), audio_thread(), daisy_get_chapter_count(), daisy_get_chapter_info(), daisy_get_info(), daisy_get_position(), daisy_goto_position(), daisy_init(), daisy_load(), daisy_pause(), daisy_play(), daisy_seek(), daisy_stop(), daisy_term(), local_cb_daisy_audio_done(), start_audio(), and stop_audio().


Enumeration Type Documentation

enum daisy_bookinfo_option
 

The different types of book information.

See also:
daisy_get_info
Enumeration values:
DAISY_BOOKINFO_TITLETEXT 
DAISY_BOOKINFO_TITLEIMAGE 
DAISY_BOOKINFO_TOTALTIME 

Definition at line 105 of file libdaisy.h.

enum daisy_chapter_info
 

The different types of chapter information.

See also:
daisy_get_chapter_info
Enumeration values:
DAISY_CHAPTER_TITLE 
DAISY_CHAPTER_WEIGHT 

Definition at line 116 of file libdaisy.h.

enum daisy_seek_option
 

The different seek operations supported by the engine.

See also:
daisy_seek
Enumeration values:
DAISY_SEEK_PREV_CHAPTER 
DAISY_SEEK_PREV_PASSAGE 
DAISY_SEEK_NEXT_CHAPTER 
DAISY_SEEK_NEXT_PASSAGE 
DAISY_SEEK_TO_BEGINNING 

Definition at line 92 of file libdaisy.h.

enum daisy_status
 

The different sort of status messages libdaisy might return.

Enumeration values:
DAISY_ERROR_UNKNOWN 
DAISY_ERROR_AUDIO_NOT_INITIALIZED 
DAISY_ERROR_AUDIO_CREATE_MMAP 
DAISY_ERROR_AUDIO_FSTAT 
DAISY_ERROR_AUDIO_OPEN 
DAISY_ERROR_AUDIO_FREE_MMAP 
DAISY_ERROR_AUDIO_INITIATE_DATA 
DAISY_ERROR_AUDIO_NOT_PLAYING 
DAISY_ERROR_AUDIO_NOT_STOPPED 
DAISY_ERROR_AUDIO_DATA_IS_NULL 
DAISY_ERROR_AUDIO_MALLOC 
DAISY_ERROR_AUDIO_PAUSED_WHILE_NOT_PLAYING 
DAISY_ERROR_AUDIO_STOPPED_WHILE_NOT_PLAYING 
DAISY_ERROR_PLAYBACK_NO_TEXT_IN_SEGMENT 
DAISY_ERROR_PLAYBACK_NO_AUDIO_IN_SEGMENT 
DAISY_ERROR_PLAYBACK_NO_DTB_LOADED 
DAISY_ERROR_PLAYBACK_SEEK_FAILED 
DAISY_ERROR_MISC_INIT_MUTEX 
DAISY_END_OF_BOOK 

Definition at line 54 of file libdaisy.h.

Referenced by audio_initiate(), audio_stop(), daisy_init(), and start_audio().


Function Documentation

int daisy_get_chapter_count daisyplayer_t    daisy
 

Retrieves the number of chapters in in the loaded Daisy DTB.

Parameters:
daisy  - the daisy struct which must be passed along with all the API functions.
Returns:
the number of chapters, or -1 in case of error.

Definition at line 618 of file libdaisy.c.

References struct_daisyplayer_t::cb_daisy_error, struct_daisyplayer_t::daisy_book_data, DAISY_ERROR_PLAYBACK_NO_DTB_LOADED, daisyplayer_t, struct_daisyplayer_t::data, SmilNode::next, DaisyData::smilHead, and DaisyData::smilTail.

char* daisy_get_chapter_info daisyplayer_t    daisy,
int    num,
int    option
 

Retrieves information about a given chapter.

Parameters:
daisy  - the daisy struct which must be passed along with all the API functions.
num  - the chapter number to retrive information from (use daisy_get_chapter_count to get the number of chapters available).
option  - a daisy_chapter_info which states what information to retrieve.
Returns:
a pointer to a string containing the information, or NULL in case of error.
See also:
daisy_chapter_info , daisy_get_chapter_count

Definition at line 653 of file libdaisy.c.

References struct_daisyplayer_t::cb_daisy_error, struct_daisyplayer_t::daisy_book_data, DAISY_CHAPTER_TITLE, DAISY_CHAPTER_WEIGHT, DAISY_ERROR_PLAYBACK_NO_DTB_LOADED, daisyplayer_t, struct_daisyplayer_t::data, SmilNode::header, SmilNode::next, DaisyData::smilHead, and DaisyData::smilTail.

char* daisy_get_info daisyplayer_t    daisy,
int    value
 

Retrieves book meta information.

Parameters:
daisy  - the daisy struct which must be passed along with all the API functions.
value  - a daisy_bookinfo_option value which states what information to retrieve.
Returns:
the string if found, otherwise NULL. The string must be deallocated by the caller.
See also:
daisy_bookinfo_option

Definition at line 566 of file libdaisy.c.

References DaisyData::bookInfo, struct_daisyplayer_t::cb_daisy_error, struct_daisyplayer_t::daisy_book_data, DAISY_BOOKINFO_TITLEIMAGE, DAISY_BOOKINFO_TITLETEXT, DAISY_BOOKINFO_TOTALTIME, DAISY_ERROR_PLAYBACK_NO_DTB_LOADED, daisyplayer_t, struct_daisyplayer_t::data, SmilNode::next, DaisyData::smilHead, DaisyData::smilTail, BookInfo::titleImage, BookInfo::titleText, and BookInfo::totalTime.

daisy_position* daisy_get_position daisyplayer_t    daisy
 

Retrieves the current playback position.

Parameters:
daisy  - the daisy data struct which must be passed along with all the API functions.
Returns:
a pointer to a daisy_position struct containing the chapter and passage positions, or NULL in case of error. The struct must be deallocated by the caller.
See also:
daisy_position , daisy_goto_position

Definition at line 435 of file libdaisy.c.

References struct_daisyplayer_t::cb_daisy_error, struct_daisyplayer_t::daisy_book_data, DAISY_ERROR_PLAYBACK_NO_DTB_LOADED, daisyplayer_t, struct_daisyplayer_t::data, getNodePos(), getSmilPos(), SmilNode::next, daisy_position::nodepos, REP_DEBUG, report(), DaisyData::smilHead, daisy_position::smilpos, and DaisyData::smilTail.

int daisy_goto_position daisyplayer_t    daisy,
daisy_position   position
 

Seeks to a playback position (bookmark) and continue playback from there.

Parameters:
daisy  - the daisy data struct which must be passed along with all the API functions.
position  - a pointer to a daisy_position struct with the chapter and passage position.
Returns:
1 in case of success and -1 in case of error.
See also:
daisy_position , daisy_get_position

Definition at line 473 of file libdaisy.c.

References struct_daisyplayer_t::audio_data, audio_get_state(), AUDIO_STATE_STOP, audio_state_t, audio_stop(), struct_daisyplayer_t::cb_daisy_error, struct_daisyplayer_t::daisy_book_data, DAISY_ERROR_PLAYBACK_NO_DTB_LOADED, struct_daisyplayer_t::daisy_mutex, daisy_play(), daisyplayer_t, struct_daisyplayer_t::data, gotoNodePosition(), gotoSmilPosition(), SmilNode::next, daisy_position::nodepos, REP_DEBUG, report(), DaisyData::smilHead, daisy_position::smilpos, and DaisyData::smilTail.

daisyplayer_t daisy_init void *    data,
void(*    l_cb_daisy_audio_done)(void *),
void(*    l_cb_daisy_audio_next)(void *, unsigned long int),
void(*    l_cb_daisy_text)(void *, void *),
void(*    l_cb_daisy_id)(void *, void *),
void(*    l_cb_daisy_error)(void *, enum daisy_status, const char *daisy_status_msg),
void(*    l_cb_daisy_progress)(void *, long int)
 

Initializes the daisy library. It should be called before any attempt to use the daisy functionality.

Parameters:
data  - a void pointer to any object or datastructure you may need in the callback functions. This data pointer will be available in all callback functions. You can e.g. pass along a GUI object in c++ so that you can output the text from the callbackfunctions in the GUI. Set this parameter to NULL if you don't need it.
l_cb_daisy_audio_done  - a pointer to the function which will be called when an audio segment is done playing.
l_cb_daisy_audio_next  - a pointer to the function which will be called when an new audio segment starts playing, supplying the duration of the segment in ms.
l_cb_daisy_text  - a pointer to the function which will be called when an new audio segment starts playing, supplying the text corresponding to the audio.
l_cb_daisy_id  - a pointer to the function which will be called when an new audio segment starts playing, supplying the id of the text passage in the xml file.
l_cb_daisy_error  - a pointer to the function which will be called when an engine error occures.
l_cb_daisy_progress  - a pointer to the function which will be called during playback, supplying the progress in ms.
Returns:
daisyplayer_t - the daisy data struct which must be passed along with all the API functions.

int daisy_load daisyplayer_t    daisy,
char *    path
 

Loades a new daisy book.

Parameters:
daisy  - the daisy data struct which must be passed along with all the API functions.
path  - a full path to the daisy dtb (ncc.* | *.ncx) to open.
Returns:
1 in case of success and -1 in case of error.

Definition at line 279 of file libdaisy.c.

References struct_daisyplayer_t::audio_data, struct_daisyplayer_t::cb_daisy_error, struct_daisyplayer_t::cb_daisy_progress, struct_daisyplayer_t::daisy_book_data, DAISY_SEEK_NEXT_PASSAGE, daisyplayer_t, local_cb_daisy_audio_done(), parse(), REP_DEBUG, report(), seek(), start_audio(), and stop_audio().

int daisy_pause daisyplayer_t    daisy
 

Toggle pause. Pauses playback if state is playing and continues playing of state is paused.

Parameters:
daisy  - the daisy data struct which must be passed along with all the API functions.
Returns:
1 in case of success and -1 in case of error.

Definition at line 552 of file libdaisy.c.

References struct_daisyplayer_t::audio_data, audio_pause(), daisyplayer_t, REP_DEBUG, and report().

int daisy_play daisyplayer_t    daisy
 

Starts playback if a book i loaded.

Parameters:
daisy  - the daisy data struct which must be passed along with all the API functions.
Returns:
1 in case of success and -1 in case of error.

Definition at line 301 of file libdaisy.c.

References struct_daisyplayer_t::audio_data, audio_play(), Node::audiofilename, Node::audioStartPos, Node::audioStopPos, struct_daisyplayer_t::cb_daisy_audio_next, struct_daisyplayer_t::cb_daisy_error, struct_daisyplayer_t::cb_daisy_id, struct_daisyplayer_t::cb_daisy_text, struct_daisyplayer_t::daisy_book_data, DAISY_ERROR_PLAYBACK_NO_AUDIO_IN_SEGMENT, DAISY_ERROR_PLAYBACK_NO_DTB_LOADED, DAISY_ERROR_PLAYBACK_NO_TEXT_IN_SEGMENT, daisyplayer_t, struct_daisyplayer_t::data, Node::fragmentIdentifier, SmilNode::next, DaisyData::nodePos, DaisyData::path, REP_DEBUG, report(), DaisyData::smilHead, DaisyData::smilTail, STRLEN, and Node::textPassage.

Referenced by daisy_goto_position(), and daisy_seek().

int daisy_seek daisyplayer_t    daisy,
int    seek_option
 

Seek operations which can be performed when a book is loaded.

Parameters:
daisy  - the daisy data struct which must be passed along with all the API functions.
seek_option  - a daisy_seek_option.
Returns:
0 if end_of_book, 1 in case of success and -1 in case of error.
See also:
daisy_seek_option

Definition at line 351 of file libdaisy.c.

References struct_daisyplayer_t::audio_data, audio_get_state(), AUDIO_STATE_STOP, audio_state_t, audio_stop(), struct_daisyplayer_t::cb_daisy_error, struct_daisyplayer_t::daisy_book_data, DAISY_ERROR_PLAYBACK_NO_DTB_LOADED, struct_daisyplayer_t::daisy_mutex, daisy_play(), daisyplayer_t, struct_daisyplayer_t::data, SmilNode::next, REP_DEBUG, report(), seek(), DaisyData::smilHead, and DaisyData::smilTail.

Referenced by local_cb_daisy_audio_done().

int daisy_stop daisyplayer_t    daisy
 

Stops playback.

Parameters:
daisy  - the daisy data struct which must be passed along with all the API functions.
Returns:
1 in case of success. Has no other return values at this point.

Definition at line 535 of file libdaisy.c.

References struct_daisyplayer_t::audio_data, audio_stop(), struct_daisyplayer_t::daisy_mutex, daisyplayer_t, REP_DEBUG, and report().

void daisy_term daisyplayer_t    daisy
 

Terminates the daisy library and frees memory used by it. It should be called when daisy are no longer needed.

Parameters:
daisy  - the daisy data struct which must be passed along with all the API functions.

Definition at line 259 of file libdaisy.c.

References struct_daisyplayer_t::audio_data, struct_daisyplayer_t::daisy_book_data, daisyplayer_t, struct_daisyplayer_t::magic, parseTerminate(), REP_DEBUG, report(), and stop_audio().


Generated on Tue Sep 5 12:14:08 2006 for libdaisy by doxygen1.2.15