1/* 2 * Copyright 2016, Dario Casalinuovo. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5#ifndef _RTSP_MEDIA_IO_H 6#define _RTSP_MEDIA_IO_H 7 8 9#include <AdapterIO.h> 10#include <Url.h> 11 12#include "rtsp.h" 13 14 15class HaikuRTSPClient; 16 17 18class RTSPMediaIO : public BAdapterIO 19{ 20public: 21 RTSPMediaIO(BUrl ourUrl); 22 virtual ~RTSPMediaIO(); 23 24 virtual ssize_t WriteAt(off_t position, 25 const void* buffer, 26 size_t size); 27 28 virtual status_t SetSize(off_t size); 29 30 virtual status_t Open(); 31 32 void LoopThread(); 33 void ShutdownLoop(); 34private: 35 static int32 _LoopThread(void* data); 36 37 BUrl fUrl; 38 39 HaikuRTSPClient* fClient; 40 UsageEnvironment* fEnv; 41 TaskScheduler* fScheduler; 42 43 char fLoopWatchVariable; 44 thread_id fLoopThread; 45}; 46 47 48class HaikuRTSPClient : public RTSPClient 49{ 50public: 51 HaikuRTSPClient(UsageEnvironment& env, 52 char const* rtspURL, 53 portNumBits tunnelOverHTTPPortNum, 54 RTSPMediaIO* fInputAdapter); 55 56 void Close(); 57 58 BInputAdapter* GetInputAdapter() const; 59 60 status_t WaitForInit(bigtime_t timeout); 61 62 void NotifyError(); 63 void NotifySucces(); 64 65protected: 66 67 virtual ~HaikuRTSPClient(); 68public: 69 MediaSubsessionIterator* iter; 70 MediaSession* session; 71 MediaSubsession* subsession; 72 TaskToken streamTimerTask; 73 double duration; 74 75private: 76 RTSPMediaIO* fInterface; 77 78 port_id fInitPort; 79}; 80 81#endif 82