xref: /haiku/src/apps/codycam/CodyCam.h (revision 7ebabb8644d955041e7b4cb9a51629cb5a6071ca)
1 /* CodyCam.h */
2 
3 #ifndef CODYCAM_H
4 #define CODYCAM_H
5 
6 #include <Box.h>
7 #include <Menu.h>
8 #include <string.h>
9 #include <Window.h>
10 #include <CheckBox.h>
11 #include <MenuField.h>
12 #include <StringView.h>
13 #include <Application.h>
14 #include <TextControl.h>
15 
16 #include "Settings.h"
17 #include"VideoConsumer.h"
18 
19 
20 class BMediaRoster;
21 
22 
23 enum {
24 	msg_filename	= 'file',
25 
26 	msg_rate_15s	= 'r15s',
27 	msg_rate_30s	= 'r30s',
28 	msg_rate_1m		= 'r1m ',
29 	msg_rate_5m		= 'r5m ',
30 	msg_rate_10m	= 'r10m',
31 	msg_rate_15m	= 'r15m',
32 	msg_rate_30m	= 'r30m',
33 	msg_rate_1h		= 'r1h ',
34 	msg_rate_2h		= 'r2h ',
35 	msg_rate_4h		= 'r4h ',
36 	msg_rate_8h		= 'r8h ',
37 	msg_rate_24h	= 'r24h',
38 	msg_rate_never	= 'nevr',
39 
40 	msg_translate	= 'tran',
41 
42 	msg_server		= 'srvr',
43 	msg_login		= 'lgin',
44 	msg_password	= 'pswd',
45 	msg_directory	= 'drct',
46 	msg_passiveftp	= 'pasv',
47 	msg_pswrd_text	= 'pstx',
48 
49 	msg_start		= 'strt',
50 	msg_stop		= 'stop',
51 
52 	msg_about		= 'abut',
53 	msg_setup		= 'setp',
54 	msg_video		= 'vdeo',
55 
56 	msg_control_win = 'ctlw'
57 };
58 
59 const char *kCaptureRate[] = {
60 	"Every 15 seconds",
61 	"Every 30 seconds",
62 	"Every minute",
63 	"Every 5 minutes",
64 	"Every 10 minutes",
65 	"Every 15 minutes",
66 	"Every 30 minutes",
67 	"Every hour",
68 	"Every 2 hours",
69 	"Every 4 hours",
70 	"Every 8 hours",
71 	"Every 24 hours",
72 	"Never",
73 	0
74 };
75 
76 class CodyCam : public BApplication {
77 	public:
78 							CodyCam();
79 		virtual				~CodyCam();
80 
81 		void				ReadyToRun();
82 		virtual bool		QuitRequested();
83 		virtual void		MessageReceived(
84 								BMessage *message);
85 
86 	private:
87 		status_t			SetUpNodes();
88 		void				TearDownNodes();
89 
90 		BMediaRoster *		fMediaRoster;
91 
92 		media_node			fTimeSourceNode;
93 		media_node			fProducerNode;
94 
95 		VideoConsumer *		fVideoConsumer;
96 
97 		media_output		fProducerOut;
98 		media_input			fConsumerIn;
99 
100 		BWindow *			fWindow;
101 
102 		port_id				fPort;
103 
104 		BWindow 			*mVideoControlWindow;
105 };
106 
107 class VideoWindow : public BWindow
108 {
109 public:
110 						VideoWindow (
111 							BRect frame,
112 							const char * title,
113 							window_type type,
114 							uint32 flags,
115 							port_id * consumerport);
116 						~VideoWindow();
117 
118 	virtual	bool		QuitRequested();
119 	virtual void		MessageReceived(
120 							BMessage *message);
121 
122 	void 				ApplyControls();
123 
124 	BView *				VideoView();
125 	BStringView *		StatusLine();
126 
127 private:
128 	void				BuildCaptureControls(
129 							BView *theView);
130 
131 	void				SetUpSettings(
132 							const char *filename,
133 							const char *dirname);
134 	void				QuitSettings();
135 
136 
137 private:
138 		media_node *		fProducer;
139 		port_id	*			fPortPtr;
140 
141 
142 		BView *				fView;
143 		BView *				fVideoView;
144 
145 		BTextControl *		fFileName;
146 		BBox *				fCaptureSetupBox;
147 		BMenu *				fCaptureRateMenu;
148 		BMenuField *		fCaptureRateSelector;
149 		BMenu *				fImageFormatMenu;
150 		BMenuField *		fImageFormatSelector;
151 		BBox *				fFtpSetupBox;
152 		BTextControl *		fServerName;
153 		BTextControl *		fLoginId;
154 		BTextControl *		fPassword;
155 		BTextControl *		fDirectory;
156 		BCheckBox *			fPassiveFtp;
157 		BBox *				fStatusBox;
158 		BStringView	*		fStatusLine;
159 
160 		ftp_msg_info		fFtpInfo;
161 
162 
163 		Settings *				fSettings;
164 		StringValueSetting *	fServerSetting;
165 		StringValueSetting *	fLoginSetting;
166 		StringValueSetting *	fPasswordSetting;
167 		StringValueSetting *	fDirectorySetting;
168 		BooleanValueSetting *	fPassiveFtpSetting;
169 		StringValueSetting *	fFilenameSetting;
170 		EnumeratedStringValueSetting *fCaptureRateSetting;
171 };
172 
173 class ControlWindow : public BWindow {
174 
175 public:
176 		ControlWindow(const BRect & frame, BView * controls, media_node node);
177 		void MessageReceived(BMessage * message);
178 		bool QuitRequested();
179 
180 private:
181 		BView *				fView;
182 		media_node			fNode;
183 };
184 
185 #endif
186