]> git.vomp.tv Git - vompserver.git/blob - mediaplayer.h
15 years that line of code has been waiting to crash
[vompserver.git] / mediaplayer.h
1 /*
2     Copyright 2004-2005 Chris Tallon, Andreas Vogel
3
4     This file is part of VOMP.
5
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.
10
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.
15
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
19 */
20
21 #ifndef MEDIAPLAYER
22 #define MEDIAPLAYER
23
24 using namespace std;
25 #include <vector>
26 #include <stdio.h>
27 #include <string.h>
28 #include "mediaprovider.h"
29
30 class MediaProviderHolder;
31
32
33 class MediaPlayer : public MediaPlayerRegister, public MediaProvider
34 {
35   public:
36     MediaPlayer();
37     virtual ~MediaPlayer();
38
39     /**
40       * get the root media list
41       * the returned list has to be destroyed by the caller
42       * if NULL is returned currently no media is available
43       */
44     virtual MediaList* getRootList();
45
46     /**
47       * get a medialist for a given parent
48       * the returned list has to be destroyed by the caller
49       * NULL if no entries found
50       */
51     virtual MediaList* getMediaList(const MediaURI * parent);
52
53     /**
54       * open a media uri
55       * afterwards getBlock or other functions must be possible
56       * currently only one medium is open at the same time
57       * for a given channel
58       * @param channel: channel id, NUMCHANNELS must be supported
59       * @param xsize,ysize: size of the screen
60       * @param size out: the size of the medium
61       * @return != 0 in case of error
62       * 
63       */
64     virtual int openMedium(ULONG channel, const MediaURI * uri, ULLONG * size, ULONG xsize, ULONG ysize);
65
66     /**
67       * get a block for a channel
68       * @param offset - the offset
69       * @param len - the required len
70       * @param outlen out - the read len if 0 this is EOF
71       * @param buffer out the allocated buffer (must be freed with free!)
72       * @return != 0 in case of error
73       */           
74     virtual int getMediaBlock(ULONG channel, ULLONG offset, ULONG len, ULONG * outlen,
75         unsigned char ** buffer);
76
77     /**
78       * close a media channel
79       */
80     virtual int closeMediaChannel(ULONG channel);
81
82     /**
83       * return the media info for a given channel
84       * return != 0 on error
85       * the caller has to provide a pointer to an existing media info
86       */
87     virtual int getMediaInfo(ULONG channel, struct MediaInfo * result);
88     
89     /**
90       * from MediaPlayerRegister
91       */
92     virtual void registerMediaProvider(MediaProvider *p,ULONG providerID,ULONG range);
93
94     /**
95       * the instance
96       */
97     static MediaPlayer * getInstance();
98
99   private:
100     MediaProvider * providerById(ULONG id);
101     typedef vector<MediaProviderHolder *> Tplist;
102     Tplist plist;
103     struct channelInfo {
104       ULONG providerId;
105       MediaProvider *provider;
106       channelInfo() {
107         provider=NULL;
108         providerId=0;
109       }
110       };
111     struct channelInfo info[NUMCHANNELS];
112
113 };
114
115
116 #endif