Update httpstream
[vuplus_dvbapp] / lib / base / httpstream.h
1 #ifndef __lib_base_httpstream_h
2 #define __lib_base_httpstream_h
3
4 #include <string>
5 #include <lib/base/ebase.h>
6 #include <lib/base/itssource.h>
7 #include <lib/base/socketbase.h>
8 #include <lib/base/thread.h>
9
10 class eHttpStream: public iTsSource, public eSocketBase, public Object, public eThread
11 {
12         DECLARE_REF(eHttpStream);
13
14         int streamSocket;
15         enum { BUSY, CONNECTED, FAILED } connectionStatus;
16         bool isChunked;
17         size_t currentChunkSize;
18         std::string streamUrl;
19         std::string authorizationData;
20         char partialPkt[192];
21         size_t partialPktSz;
22         char* tmpBuf;
23         size_t tmpBufSize;
24         int packetSize;
25
26         int openUrl(const std::string &url, std::string &newurl);
27         void thread();
28         ssize_t httpChunkedRead(void *buf, size_t count);
29         ssize_t syncNextRead(void *buf, ssize_t length);
30
31         /* iTsSource */
32         off_t lseek(off_t offset, int whence);
33         ssize_t read(off_t offset, void *buf, size_t count);
34         off_t length();
35         int valid();
36         bool isStream() { return true; }
37 public:
38         eHttpStream();
39         ~eHttpStream();
40         int open(const char *url);
41         int close();
42 };
43
44 #endif