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 <UrlProtocolAsynchronousListener.h> 13 14 15 class FileListener; 16 17 class HTTPMediaIO : public BAdapterIO { 18 public: 19 HTTPMediaIO(BUrl url); 20 virtual ~HTTPMediaIO(); 21 22 virtual void GetFlags(int32* flags) const; 23 24 virtual ssize_t WriteAt(off_t position, 25 const void* buffer, size_t size); 26 27 virtual status_t SetSize(off_t size); 28 29 virtual status_t Open(); 30 31 virtual bool IsRunning() const; 32 33 protected: 34 virtual status_t SeekRequested(off_t position); 35 36 // Other custom stuff 37 38 void UpdateSize(); 39 40 friend class FileListener; 41 private: 42 BPrivate::Network::BUrlRequest* fReq; 43 FileListener* fListener; 44 thread_id fReqThread; 45 46 BUrl fUrl; 47 off_t fTotalSize; 48 bool fIsMutable; 49 }; 50 51 #endif 52