xref: /haiku/src/add-ons/media/plugins/rtsp_streamer/RTSPMediaIO.h (revision fce4895d1884da5ae6fb299d23c735c598e690b1)
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 
15 class HaikuRTSPClient;
16 
17 
18 class RTSPMediaIO : public BAdapterIO
19 {
20 public:
21 										RTSPMediaIO(BUrl* ourUrl);
22 	virtual								~RTSPMediaIO();
23 
24 			status_t					InitCheck() const;
25 
26 	virtual	ssize_t						WriteAt(off_t position,
27 											const void* buffer,
28 											size_t size);
29 
30 			void						LoopThread();
31 			void						ShutdownLoop();
32 private:
33 			static int32				_LoopThread(void* data);
34 
35 			BUrl*						fUrl;
36 			BInputAdapter*				fInputAdapter;
37 
38 
39 			HaikuRTSPClient*			fClient;
40 			UsageEnvironment*			fEnv;
41 			TaskScheduler*				fScheduler;
42 
43 			char						fLoopWatchVariable;
44 			thread_id					fLoopThread;
45 
46 			status_t					fInitErr;
47 };
48 
49 
50 class HaikuRTSPClient : public RTSPClient
51 {
52 public:
53 										HaikuRTSPClient(UsageEnvironment& env,
54 											char const* rtspURL,
55 											portNumBits tunnelOverHTTPPortNum,
56 											RTSPMediaIO* fInputAdapter);
57 
58 			void						Close();
59 
60 			BInputAdapter*				GetInputAdapter() const;
61 
62 			status_t					WaitForInit(bigtime_t timeout);
63 
64 			void						NotifyError();
65 			void						NotifySucces();
66 
67 protected:
68 
69 	virtual 							~HaikuRTSPClient();
70 public:
71 			MediaSubsessionIterator* 	iter;
72 			MediaSession*				session;
73 			MediaSubsession*			subsession;
74 			TaskToken					streamTimerTask;
75 			double						duration;
76 
77 private:
78 			RTSPMediaIO*				fInterface;
79 
80 			port_id						fInitPort;
81 };
82 
83 #endif
84