2 Copyright 2004-2006 Chris Tallon, Andreas Vogel
\r
4 This file is part of VOMP.
\r
6 VOMP is free software; you can redistribute it and/or modify
\r
7 it under the terms of the GNU General Public License as published by
\r
8 the Free Software Foundation; either version 2 of the License, or
\r
9 (at your option) any later version.
\r
11 VOMP is distributed in the hope that it will be useful,
\r
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 GNU General Public License for more details.
\r
16 You should have received a copy of the GNU General Public License
\r
17 along with VOMP; if not, write to the Free Software
\r
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
\r
21 #ifndef IMAGEREADER_H
\r
22 #define IMAGEREADER_H
\r
27 #include <sys/time.h>
\r
31 #include "callback.h"
\r
34 #include "threadsystem.h"
\r
38 class MediaProvider;
\r
42 class ImageReader : public Thread_TYPE, public Callback
\r
46 //create an image reader for a media channel
\r
47 //the channel must already been opened
\r
48 ImageReader(int channel,MediaProvider *p);
\r
49 //call shutdown before destroying the reader!
\r
50 virtual ~ImageReader();
\r
51 //request the next image block
\r
52 //will return the current block (if already read) and request the next from the server
\r
53 //rsize will return the received len: 0 on EOF, -1 on error
\r
54 //the returned buffer has to be freed outside (really use free!)
\r
55 //if the buffer is not filled it will wait until the chunk is received!
\r
56 int getImageChunk(ULLONG offset,UINT len, UINT * rsize,UCHAR **buffer);
\r
58 //is the reader still running?
\r
59 bool isReaderRunning();
\r
63 //stop the reader (waits until the reader thread does not access anything)
\r
67 virtual void call(void * caller);
\r
71 void threadMethod();
\r
72 void threadPostStopCleanup();
\r
75 MediaProvider * provider;
\r
77 static const int MAXCHUNKS=2;
\r
78 //start the player thread
\r
84 void waitTimed(int ms);
\r
96 UCHAR * buffer; //receive buffer (to be deallocated with free)
\r
97 ULLONG offset; //offset within stream/file
\r
98 UINT reqlen; //requested len
\r
99 ULONG len; //received len
\r
100 rstate state; //current state
\r
110 //setting state in this array requires the thread lock
\r
111 Chunk data[MAXCHUNKS];
\r