2 Copyright 2004-2005 Chris Tallon, Andreas Vogel
4 This file is part of VOMP.
6 VOMP is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 VOMP is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with VOMP; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #include "serialize.h"
31 /* media types form a bitmask
32 so you can add them to have > 1*/
33 #define MEDIA_TYPE_DIR 1
34 #define MEDIA_TYPE_AUDIO 2
35 #define MEDIA_TYPE_VIDEO 4
36 #define MEDIA_TYPE_PICTURE 8
37 #define MEDIA_TYPE_UNKNOWN 0
39 #define MEDIA_TYPE_ALL (1+2+4+8)
42 * MediaURI - a data holder for the complete path to a media
43 * depending on the provider there is an internal name and a display name
44 * by providing own MediaList implementations the provider can control
45 * how URIs are concatenated
47 class MediaURI : public Serializable{
48 //to be able to access private members
49 friend class MediaList;
60 _allowedTypes=MEDIA_TYPE_ALL;
62 //constructor copying params
63 MediaURI(ULONG provider, const char * name, const char * display);
65 if (_name) delete _name;
66 if (_display) delete _display;
68 MediaURI(const MediaURI *cp) ;
69 const char * getName() const { return _name;}
70 const char * getDisplayName() const {
71 if (_display) return _display;
74 ULONG getProvider() const {
77 void setProvider(ULONG pid) {
80 ULONG getAllowedTypes() const {
83 void setAllowedTypes(ULONG allowedTypes) {
84 _allowedTypes=allowedTypes;
86 bool hasDisplayName() const {
87 return _display!=NULL;
91 //get the #of bytes needed to serialize
92 virtual int getSerializedLenImpl();
94 //advance buffer, check if >= end
96 virtual int serializeImpl(SerializeBuffer *b);
98 //advance buffer, check if >= end
100 virtual int deserializeImpl(SerializeBuffer *b);
105 * a class providing additional info for a medium
107 class MediaInfo : public Serializable{
111 ULONG type; //a media type
112 ULONG subtype; //TODO
114 * return any info item contained within this info
116 virtual const char * getInfo(ULONG infoId) { return NULL;}
117 virtual ULLONG getIntegerInfo(ULONG infoId) { return 0;}
118 virtual const char * getInfoName(ULONG infoId) { return NULL;}
119 virtual bool hasInfo(ULONG infoId) { return false;}
123 type=MEDIA_TYPE_UNKNOWN;
126 virtual ~MediaInfo(){};
127 //serialize functions
128 //get the #of bytes needed to serialize
129 virtual int getSerializedLenImpl();
131 //advance buffer, check if >= end
133 virtual int serializeImpl(SerializeBuffer *b);
135 //advance buffer, check if >= end
137 virtual int deserializeImpl(SerializeBuffer *b);
142 * the Media class - a data holder describing a single media
143 * WITHOUT the complete path
144 * to retrieve an URI you need the list where this media is contained
145 * this has the root URI and can construct the URI for this media
146 * optional the media can contain an UIR by itself - then this is used
149 class Media : public Serializable
151 friend class MediaList;
154 Media(const Media *m);
157 void setTime(ULONG mtimeTime);
158 void setDisplayName(const char* displayName);
159 void setFileName(const char* fileName);
160 void setMediaType(ULONG mtype);
162 ULONG getTime() const;
163 const char* getDisplayName() const;
164 const char* getFileName() const;
165 //return the time as a string
166 //if the user provides a buffer, this one is used, if NULL
167 //is given a new buffer is allocated
168 //caller must delete the buffer after usage!
169 char * getTimeString(char *buffer) const;
170 //length for the time display buffer
171 const static int TIMEBUFLEN=100;
173 ULONG getMediaType() const;
174 bool hasDisplayName() const;
175 //optionally the media can contain an URI
176 //in this case the filename is not considered
177 //but the data from the URI is taken
178 //this enables having another providerId set in the media...
179 //returns URI without copy
180 const MediaURI * getURI() const;
181 void setURI(const MediaURI *uri);
183 //serialize functions
184 //get the #of bytes needed to serialize
185 virtual int getSerializedLenImpl();
187 //advance buffer, check if >= end
189 virtual int serializeImpl(SerializeBuffer *b);
191 //advance buffer, check if >= end
193 virtual int deserializeImpl(SerializeBuffer *b);
206 typedef vector<Media*> MediaListI;
209 * the MediaList - containing a root URI and
210 * all the Media entries
211 * providers can provide derived classes to overwrite the URI-Methods
213 class MediaList : public MediaListI , public Serializable{
219 MediaList(const MediaURI *root); //root is copied
220 virtual ~MediaList();
222 virtual MediaURI * getRoot() {return _root;}
223 //all methods return a copy of the URI
224 //so the caller has to destroy this
225 virtual MediaURI * getRootURI();
226 virtual MediaURI * getParent(MediaURI *c) ;
227 virtual MediaURI * getURI(Media *m);
228 virtual ULONG getProvider();
229 virtual void setOwning(bool owning);
230 //serialize functions
231 //get the #of bytes needed to serialize
232 virtual int getSerializedLenImpl();
234 //advance buffer, check if >= end
236 virtual int serializeImpl(SerializeBuffer *b);
238 //advance buffer, check if >= end
240 virtual int deserializeImpl(SerializeBuffer *b);