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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30 #include "serialize.h"
32 /* media types form a bitmask
33 so you can add them to have > 1*/
34 #define MEDIA_TYPE_DIR 1
35 #define MEDIA_TYPE_AUDIO 2
36 #define MEDIA_TYPE_VIDEO 4
37 #define MEDIA_TYPE_PICTURE 8
38 #define MEDIA_TYPE_UNKNOWN 0
40 #define MEDIA_TYPE_ALL (1+2+4+8)
43 * MediaURI - a data holder for the complete path to a media
44 * depending on the provider there is an internal name and a display name
45 * by providing own MediaList implementations the provider can control
46 * how URIs are concatenated
48 class MediaURI : public Serializable{
49 //to be able to access private members
50 friend class MediaList;
61 _allowedTypes=MEDIA_TYPE_ALL;
63 //constructor copying params
64 MediaURI(ULONG provider, const char * name, const char * display);
66 if (_name) delete _name;
67 if (_display) delete _display;
69 MediaURI(const MediaURI *cp) ;
70 const char * getName() const { return _name;}
71 const char * getDisplayName() const {
72 if (_display) return _display;
75 ULONG getProvider() const {
78 void setProvider(ULONG pid) {
81 ULONG getAllowedTypes() const {
84 void setAllowedTypes(ULONG allowedTypes) {
85 _allowedTypes=allowedTypes;
87 bool hasDisplayName() const {
88 return _display!=NULL;
92 //get the #of bytes needed to serialize
93 virtual int getSerializedLenImpl();
95 //advance buffer, check if >= end
97 virtual int serializeImpl(SerializeBuffer *b);
99 //advance buffer, check if >= end
101 virtual int deserializeImpl(SerializeBuffer *b);
106 * a class providing additional info for a medium
108 class MediaInfo : public Serializable{
112 ULONG type; //a media type
113 ULONG subtype; //TODO
115 * return any info item contained within this info
117 virtual const char * getInfo(ULONG infoId) { return NULL;}
118 virtual ULLONG getIntegerInfo(ULONG infoId) { return 0;}
119 virtual const char * getInfoName(ULONG infoId) { return NULL;}
120 virtual bool hasInfo(ULONG infoId) { return false;}
124 type=MEDIA_TYPE_UNKNOWN;
127 virtual ~MediaInfo(){};
128 //serialize functions
129 //get the #of bytes needed to serialize
130 virtual int getSerializedLenImpl();
132 //advance buffer, check if >= end
134 virtual int serializeImpl(SerializeBuffer *b);
136 //advance buffer, check if >= end
138 virtual int deserializeImpl(SerializeBuffer *b);
143 * the Media class - a data holder describing a single media
144 * WITHOUT the complete path
145 * to retrieve an URI you need the list where this media is contained
146 * this has the root URI and can construct the URI for this media
147 * optional the media can contain an UIR by itself - then this is used
150 class Media : public Serializable
152 friend class MediaList;
155 Media(const Media *m);
158 void setTime(ULONG mtimeTime);
159 void setDisplayName(const char* displayName);
160 void setFileName(const char* fileName);
161 void setMediaType(ULONG mtype);
163 ULONG getTime() const;
164 const char* getDisplayName() const;
165 const char* getFileName() const;
166 //return the time as a string
167 //if the user provides a buffer, this one is used, if NULL
168 //is given a new buffer is allocated
169 //caller must delete the buffer after usage!
170 char * getTimeString(char *buffer) const;
171 //length for the time display buffer
172 const static int TIMEBUFLEN=100;
174 ULONG getMediaType() const;
175 bool hasDisplayName() const;
176 //optionally the media can contain an URI
177 //in this case the filename is not considered
178 //but the data from the URI is taken
179 //this enables having another providerId set in the media...
180 //returns URI without copy
181 const MediaURI * getURI() const;
182 void setURI(const MediaURI *uri);
184 //serialize functions
185 //get the #of bytes needed to serialize
186 virtual int getSerializedLenImpl();
188 //advance buffer, check if >= end
190 virtual int serializeImpl(SerializeBuffer *b);
192 //advance buffer, check if >= end
194 virtual int deserializeImpl(SerializeBuffer *b);
207 typedef vector<Media*> MediaListI;
210 * the MediaList - containing a root URI and
211 * all the Media entries
212 * providers can provide derived classes to overwrite the URI-Methods
214 class MediaList : public MediaListI , public Serializable{
220 MediaList(const MediaURI *root); //root is copied
221 virtual ~MediaList();
223 virtual MediaURI * getRoot() {return _root;}
224 //all methods return a copy of the URI
225 //so the caller has to destroy this
226 virtual MediaURI * getRootURI();
227 virtual MediaURI * getParent(MediaURI *c) ;
228 virtual MediaURI * getURI(Media *m);
229 virtual ULONG getProvider();
230 virtual void setOwning(bool owning);
231 //serialize functions
232 //get the #of bytes needed to serialize
233 virtual int getSerializedLenImpl();
235 //advance buffer, check if >= end
237 virtual int serializeImpl(SerializeBuffer *b);
239 //advance buffer, check if >= end
241 virtual int deserializeImpl(SerializeBuffer *b);