]> git.vomp.tv Git - vompserver.git/blob - mediaprovider.h
Compatibility for VDR 1.7.30, thanks to hondansx, Uwe and MartenR.
[vompserver.git] / mediaprovider.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 MEDIAPROVIDER_H
22 #define MEDIAPROVIDER_H
23
24 #include <stdio.h>
25 #include <string.h>
26 #include <arpa/inet.h>
27 #include "defines.h"
28
29 class Media;
30 class MediaURI;
31 class MediaInfo;
32 class MediaList;
33
34
35 /**
36   this interface has to be implemented by 
37   any provider of media data.
38   In all URIs the provider has to insert providerIds out of its range.
39   threading issues:
40   all operations to one channel are not thread save - so users have to ensure
41   that at most one thread at a time is accesing operations to one channel.
42   Implementers have to ensure that other operations are thread safe.
43   Exception: registering providers is not thread safe (at least at the moment).
44   **/
45
46 //the max number of media channels used in parallel
47 #define NUMCHANNELS 3
48 //name of a media file
49 #define NAMESIZE 255 
50
51 class MediaProvider
52 {
53   public:
54     MediaProvider(){}
55     virtual ~MediaProvider(){}
56
57     /**
58       * get the root media list
59       * the returned list has to be destroyed by the caller
60       * if NULL is returned currently no media is available
61       */
62     virtual MediaList* getRootList()=0;
63
64     /**
65       * get a medialist for a given parent
66       * the returned list has to be destroyed by the caller
67       * NULL if no entries found
68       */
69     virtual MediaList* getMediaList(const MediaURI * parent)=0;
70
71     /**
72       * open a media uri
73       * afterwards getBlock or other functions must be possible
74       * currently only one medium is open at the same time
75       * for a given channel
76       * @param channel: channel id, NUMCHANNELS must be supported
77       * @param xsize,ysize: size of the screen
78       * @param size out: the size of the medium
79       * @return != 0 in case of error
80       * 
81       */
82     virtual int openMedium(ULONG channel, const MediaURI * uri, ULLONG * size, ULONG xsize, ULONG ysize)=0;
83
84     /**
85       * get a block for a channel
86       * @param offset - the offset
87       * @param len - the required len
88       * @param outlen out - the read len if 0 this is EOF
89       * @param buffer out the allocated buffer (must be freed with free!)
90       *        if buffer is set at input the implementation CAN use
91       *        this buffer - it is up to the caller to test if the buffer
92       *        is at the same value when the method returns.
93       *        it is assumed that there is enough room in the buffer if it set
94       *        when calling
95       * @return != 0 in case of error
96       */           
97     virtual int getMediaBlock(ULONG channel, ULLONG offset, ULONG len, ULONG * outlen,
98         unsigned char ** buffer)=0;
99
100     /**
101       * close a media channel
102       */
103     virtual int closeMediaChannel(ULONG channel)=0;
104
105     /**
106       * return the media info for a given channel
107       * return != 0 on error
108       * the caller has to provide a pointer to an existing media info
109       */
110     virtual int getMediaInfo(ULONG channel, MediaInfo * result)=0;
111
112 };
113
114
115 /**
116   * the mediaplayer to register providers at
117   * can be static ctor's
118   */
119 class MediaPlayerRegister {
120   public:
121     virtual void registerMediaProvider(MediaProvider *pi,ULONG id,ULONG range=1)=0;
122     virtual ~MediaPlayerRegister(){}
123     static MediaPlayerRegister* getInstance();
124   protected:
125     static MediaPlayerRegister *instance;
126 };
127
128
129 #endif