xref: /haiku/src/add-ons/media/plugins/http_streamer/HTTPMediaIO.h (revision 79d6f0870e70cb72a2bbd7910e05cb531335e9b7)
1 /*
2  * Copyright 2016, Dario Casalinuovo
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _HTTP_MEDIA_IO_H
6 #define _HTTP_MEDIA_IO_H
7 
8 
9 #include <AdapterIO.h>
10 #include <FileRequest.h>
11 #include <Url.h>
12 #include <UrlContext.h>
13 #include <UrlProtocolAsynchronousListener.h>
14 
15 
16 class FileListener;
17 
18 class HTTPMediaIO : public BAdapterIO {
19 public:
20 										HTTPMediaIO(BUrl url);
21 	virtual								~HTTPMediaIO();
22 
23 	virtual void						GetFlags(int32* flags) const;
24 
25 	virtual	ssize_t						WriteAt(off_t position,
26 											const void* buffer, size_t size);
27 
28 	virtual status_t					SetSize(off_t size);
29 
30 	virtual status_t					Open();
31 
32 	virtual bool						IsRunning() const;
33 
34 protected:
35 	virtual	status_t					SeekRequested(off_t position);
36 
37 	// Other custom stuff
38 
39 			void						UpdateSize();
40 
41 	friend class FileListener;
42 private:
43 	BUrlContext*						fContext;
44 	BUrlRequest*						fReq;
45 	FileListener*						fListener;
46 	thread_id							fReqThread;
47 
48 	BUrl								fUrl;
49 	off_t								fTotalSize;
50 	bool								fIsMutable;
51 };
52 
53 #endif
54