xref: /haiku/src/add-ons/media/plugins/http_streamer/HTTPMediaIO.h (revision 21258e2674226d6aa732321b6f8494841895af5f)
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 	BUrlRequest*						fReq;
44 	FileListener*						fListener;
45 	thread_id							fReqThread;
46 
47 	BUrl								fUrl;
48 	off_t								fTotalSize;
49 	bool								fIsMutable;
50 };
51 
52 #endif
53