2 Copyright 2004-2006 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.
34 #include "threadsystem.h"
42 class ImageReader : public Thread_TYPE, public Callback
46 //create an image reader for a media channel
47 //the channel must already been opened
48 ImageReader(int channel,MediaProvider *p);
49 //call shutdown before destroying the reader!
50 virtual ~ImageReader();
51 //request the next image block
52 //will return the current block (if already read) and request the next from the server
53 //rsize will return the received len: 0 on EOF, -1 on error
54 //the returned buffer has to be freed outside (really use free!)
55 //if the buffer is not filled it will wait until the chunk is received!
56 int getImageChunk(ULLONG offset,UINT len, UINT * rsize,UCHAR **buffer);
58 //is the reader still running?
59 bool isReaderRunning();
63 //stop the reader (waits until the reader thread does not access anything)
67 virtual void call(void * caller);
74 MediaProvider * provider;
76 static const int MAXCHUNKS=2;
77 //start the player thread
83 void waitTimed(int ms);
95 UCHAR * buffer; //receive buffer (to be deallocated with free)
96 ULLONG offset; //offset within stream/file
97 UINT reqlen; //requested len
98 ULONG len; //received len
99 rstate state; //current state
109 //setting state in this array requires the thread lock
110 Chunk data[MAXCHUNKS];