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 control.h 00024 * \author André Lindhjem, Kjetil Holien, Terje Risa & Øyvind Nerbråten 00025 * \date 23.02.2006 00026 * 00027 * Datastructure and methods for controlling it. 00028 */ 00029 00030 00031 #ifndef CONTROL_H_ 00032 #define CONTROL_H_ 00033 00034 #include <pthread.h> 00035 #include "libdaisy.h" 00036 #include "audio.h" 00037 00038 00039 00040 /* ************************************************** * 00041 * Global data structures * 00042 * ************************************************** */ 00043 00047 struct DaisyData 00048 { 00049 /* Pointers to head, tail and current position in the linked list containing all the smilfiles 00050 * representing the spine of the loaded daisy DTB (this normally represents all chapters). 00051 */ 00052 struct SmilNode *smilHead, *smilTail, *smilPos; 00053 00054 /* Pointers to head, tail and current position in the linked list containing all passage 00055 * nodes of a parsed smilfile. 00056 */ 00057 struct Node *nodeHead, *nodeTail, *nodePos; 00058 00059 /* Pointer to a struct containing the metadata of the loaded daisy DTB. */ 00060 struct BookInfo *bookInfo; 00061 00062 /* Pointer to head and tail of a linked list containing information off all authors 00063 * of the loaded daisy DTB. 00064 */ 00065 struct AuthorNode *authorHead, *authorTail; 00066 00067 /* Representing the book version format (e.g. 2.02) */ 00068 int format; 00069 00070 /* Used by the smilparsers to define if a smil file is already present */ 00071 int smilAlreadyfound; 00072 00073 /* The path to the directory where the daisy DTB is loaded. */ 00074 char *path; 00075 00076 /* Audio engine thread for the loaded daisy DTB. */ 00077 pthread_t thread_audio; 00078 }; 00079 00083 struct BookInfo 00084 { 00085 char *titleText; /* the title of the book */ 00086 char *titleAudiofilename; /* the source to the audiofile containing the title */ 00087 char *titleAudioStartPos; /* the time offset for where to start playback in the audio file */ 00088 char *titleAudioStopPos; /* the time offset for where to stop playback in the audio file */ 00089 char *titleImage; /* the source to the book image */ 00090 char *totalTime; /* the total time of the book */ 00091 struct AuthorNode *author; /* a linked list containing the authors with their respective text,audiofilename, audiostart/stopos and image */ 00092 }; 00093 00097 struct AuthorNode 00098 { 00099 char *name; /* the title of the book */ 00100 char *audiofilename; /* the source to the audiofile containing the title */ 00101 char *audioStartPos; /* the time offset for where to start playback in the audio file */ 00102 char *audioStopPos; /* the time offset for where to stop playback in the audio file */ 00103 char *image; /* the source to the book image */ 00104 struct AuthorNode *next; /* a pointer to the next authornode in the linked list */ 00105 struct AuthorNode *prev; /* a pointer to the previous authornode in the linked list */ 00106 }; 00107 00112 struct SmilNode 00113 { 00114 int optional; /* marks optional passages */ 00115 char *id; /* id for the SMIL file */ 00116 char *anchor; /* the name of the SMIL file */ 00117 char *header; /* the header of the contens of the smilfile */ 00118 char *fragmentIdentifier; /* identifies a <par> or <text> element in the SMIL file */ 00119 char *textpassage; /* a text corresponding to the smilNode */ 00120 char *audiofilename; /* the filname of the corresponding audio file */ 00121 char *audioStartPos; /* the time offset for where to start playback in the audio file */ 00122 char *audioStopPos; /* the time offset for where to stop playback in the audio file */ 00123 char *image; /* the source to the corresponding image */ 00124 struct SmilNode *next; /* a pointer to the next smilnode in the linked list */ 00125 struct SmilNode *prev; /* a pointer to the previous smilnode in the linked list */ 00126 }; 00127 00132 struct Node 00133 { 00134 /*int skippable; true if the node is auto skippable (normally false) */ 00135 char *audiofilename; /* the filname of the corresponding audio file */ 00136 char *audioStartPos; /* the time offset for where to start playback in the audio file */ 00137 char *audioStopPos; /* the time offset for where to stop playback in the audio file */ 00138 char *textfilename; /* the file_name of the corresponding text file */ 00139 char *fragmentIdentifier; /* identificator for the corresponding passage in the text file */ 00140 char *textPassage; /* the corresponding text passage */ 00141 char *image; /* the source to the corresponding image */ 00142 struct Node *next; /* a pointer to the next node in the lined list */ 00143 struct Node *prev; /* a pointer to the previous node int the linked list */ 00144 }; 00145 00146 00147 00148 /* ************************************************** * 00149 * Global function declarations * 00150 * ************************************************** */ 00151 00156 struct DaisyData *parseInit (void); 00157 00163 void parseTerminate (struct DaisyData *daisydata); 00164 00171 char* removewhitespaces(char* string); 00172 00178 char* tolowercase(const char* string); 00179 00185 char* getTime(char* time); 00186 00191 void addNewAuthor (struct DaisyData *daisydata); 00192 00199 struct SmilNode* addNewSmilNode (struct DaisyData *daisydata); 00200 00207 struct Node* addNewNode (struct DaisyData *daisydata); 00208 00217 int parse (struct DaisyData *daisydata, char* filename); 00218 00226 int seek (struct DaisyData *daisydata, int type); 00227 00233 int getSmilPos (struct DaisyData *daisydata); 00234 00240 int getNodePos (struct DaisyData *daisydata); 00241 00248 int gotoSmilPosition (struct DaisyData *daisydata, int newSmilPos); 00249 00256 int gotoNodePosition (struct DaisyData *daisydata, int newNodePos); 00257 00258 00259 #endif /*CONTROL_H_*/