xref: /haiku/src/apps/codycam/VideoConsumer.h (revision d5cd5d63ff0ad395989db6cf4841a64d5b545d1d)
1 //	Copyright (c) 1998-99, Be Incorporated, All Rights Reserved.
2 //	SMS
3 /*	VideoConsumer.h	*/
4 
5 #if !defined(VID_CONSUMER_H)
6 #define VID_CONSUMER_H
7 
8 #include <View.h>
9 #include <Bitmap.h>
10 #include <Window.h>
11 #include <MediaNode.h>
12 #include <TranslationKit.h>
13 #include <BufferConsumer.h>
14 #include <TimedEventQueue.h>
15 #include <MediaEventLooper.h>
16 
17 typedef struct
18 {
19 	port_id					port;
20 	bigtime_t				rate;
21 	uint32					imageFormat;
22 	int32					translator;
23 	bool					passiveFtp;
24 	char					fileNameText[64];
25 	char					serverText[64];
26 	char					loginText[64];
27 	char					passwordText[64];
28 	char					directoryText[64];
29 } ftp_msg_info;
30 
31 #define FTP_INFO			0x60000001
32 
33 class VideoConsumer :
34 	public BMediaEventLooper,
35 	public BBufferConsumer
36 {
37 public:
38 						VideoConsumer(
39 							const char * name,
40 							BView * view,
41 							BStringView	* statusLine,
42 							BMediaAddOn *addon,
43 							const uint32 internal_id);
44 						~VideoConsumer();
45 
46 /*	BMediaNode */
47 public:
48 
49 	virtual	BMediaAddOn	*AddOn(long *cookie) const;
50 
51 protected:
52 
53 	virtual void		Start(bigtime_t performance_time);
54 	virtual void		Stop(bigtime_t performance_time, bool immediate);
55 	virtual void		Seek(bigtime_t media_time, bigtime_t performance_time);
56 	virtual void		TimeWarp(bigtime_t at_real_time, bigtime_t to_performance_time);
57 
58 	virtual void		NodeRegistered();
59 	virtual	status_t 	RequestCompleted(
60 							const media_request_info & info);
61 
62 	virtual	status_t 	HandleMessage(
63 							int32 message,
64 							const void * data,
65 							size_t size);
66 
67 	virtual status_t	DeleteHook(BMediaNode * node);
68 
69 /*  BMediaEventLooper */
70 protected:
71 	virtual void		HandleEvent(
72 							const media_timed_event *event,
73 							bigtime_t lateness,
74 							bool realTimeEvent);
75 /*	BBufferConsumer */
76 public:
77 
78 	virtual	status_t	AcceptFormat(
79 							const media_destination &dest,
80 							media_format * format);
81 	virtual	status_t	GetNextInput(
82 							int32 * cookie,
83 							media_input * out_input);
84 
85 	virtual	void		DisposeInputCookie(
86 							int32 cookie);
87 
88 protected:
89 
90 	virtual	void		BufferReceived(
91 							BBuffer * buffer);
92 
93 private:
94 
95 	virtual	void		ProducerDataStatus(
96 							const media_destination &for_whom,
97 							int32 status,
98 							bigtime_t at_media_time);
99 	virtual	status_t	GetLatencyFor(
100 							const media_destination &for_whom,
101 							bigtime_t * out_latency,
102 							media_node_id * out_id);
103 	virtual	status_t	Connected(
104 							const media_source &producer,
105 							const media_destination &where,
106 							const media_format & with_format,
107 							media_input * out_input);
108 	virtual	void		Disconnected(
109 							const media_source &producer,
110 							const media_destination &where);
111 	virtual	status_t	FormatChanged(
112 							const media_source & producer,
113 							const media_destination & consumer,
114 							int32 from_change_count,
115 							const media_format & format);
116 
117 /*	implementation */
118 
119 public:
120 			status_t	CreateBuffers(
121 							const media_format & with_format);
122 
123 			void		DeleteBuffers();
124 
125 	static	status_t	FtpRun(
126 							void *data);
127 
128 	void				FtpThread(
129 							void);
130 
131 	void				UpdateFtpStatus(
132 							char *status);
133 
134 	status_t			LocalSave(
135 							char *filename,
136 							BBitmap *bitmap);
137 
138 	status_t			FtpSave(
139 							char *filename);
140 
141 private:
142 
143 	BStringView	*		mStatusLine;
144 	uint32				mInternalID;
145 	BMediaAddOn			*mAddOn;
146 
147 	thread_id			mFtpThread;
148 
149 	bool					mConnectionActive;
150 	media_input				mIn;
151 	media_destination		mDestination;
152 	bigtime_t				mMyLatency;
153 
154 	BWindow					*mWindow;
155 	BView					*mView;
156 	BBitmap					*mBitmap[3];
157 	bool					mOurBuffers;
158 	BBufferGroup			*mBuffers;
159 	uint32					mBufferMap[3];
160 
161 	BBitmap					*mFtpBitmap;
162 	volatile bool			mTimeToFtp;
163 	volatile bool			mFtpComplete;
164 
165 	bigtime_t				mRate;
166 	uint32					mImageFormat;
167 	int32					mTranslator;
168 	bool					mPassiveFtp;
169 	char					mFileNameText[64];
170 	char					mServerText[64];
171 	char					mLoginText[64];
172 	char					mPasswordText[64];
173 	char					mDirectoryText[64];
174 };
175 
176 #endif
177