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