xref: /haiku/src/apps/codycam/CodyCam.h (revision 204dee708a999d5a71d0cb9497650ee7cef85d0a)
1 #ifndef CODYCAM_H
2 #define CODYCAM_H
3 
4 
5 #include "Settings.h"
6 #include "VideoConsumer.h"
7 
8 #include <string.h>
9 
10 #include <Application.h>
11 #include <Box.h>
12 #include <Catalog.h>
13 #include <CheckBox.h>
14 #include <Locale.h>
15 #include <Menu.h>
16 #include <MenuField.h>
17 #include <StringView.h>
18 #include <TextControl.h>
19 #include <Window.h>
20 
21 
22 class BMediaRoster;
23 
24 
25 enum {
26 	msg_filename	= 'file',
27 
28 	msg_rate_changed = 'rate',
29 
30 	msg_translate	= 'tran',
31 
32 	msg_upl_client	= 'ucli',
33 	msg_server		= 'srvr',
34 	msg_login		= 'lgin',
35 	msg_password	= 'pswd',
36 	msg_directory	= 'drct',
37 	msg_passiveftp	= 'pasv',
38 	msg_pswrd_text	= 'pstx',
39 
40 	msg_start		= 'strt',
41 	msg_stop		= 'stop',
42 
43 	msg_setup		= 'setp',
44 	msg_video		= 'vdeo',
45 
46 	msg_control_win = 'ctlw'
47 };
48 
49 
50 struct capture_rate {
51 	const char* name;
52 	time_t		seconds;
53 };
54 
55 
56 // NOTE: These are translated once the app catalog is loaded.
57 capture_rate kCaptureRates[] = {
58 	{"Every 15 seconds", 15 },
59 	{"Every 30 seconds", 30 },
60 	{"Every minute", 60 },
61 	{"Every 5 minutes", 5 * 60 },
62 	{"Every 10 minutes", 10 * 60 },
63 	{"Every 15 minutes", 15 * 60 },
64 	{"Every 30 minutes", 30 * 60 },
65 	{"Every hour", 60 * 60 },
66 	{"Every 2 hours", 2 * 60 * 60 },
67 	{"Every 4 hours", 4 * 60 * 60 },
68 	{"Every 8 hours", 8 * 60 * 60 },
69 	{"Every 24 hours", 24 * 60 * 60 },
70 	{"Never", 0 }
71 };
72 
73 
74 const int32 kCaptureRatesCount = sizeof(kCaptureRates) / sizeof(capture_rate);
75 
76 
77 const char* kUploadClients[] = {
78 	// NOTE: These are translated once the app catalog is loaded.
79 	"FTP",
80 	"SFTP",
81 	"Local"
82 };
83 
84 
85 const int32 kUploadClientsCount = sizeof(kUploadClients) / sizeof(char*);
86 
87 class VideoWindow;
88 class ControlWindow;
89 
90 class CodyCam : public BApplication {
91 public:
92 							CodyCam();
93 	virtual					~CodyCam();
94 
95 			void			ReadyToRun();
96 	virtual	bool			QuitRequested();
97 	virtual	void			MessageReceived(BMessage* message);
98 
99 private:
100 			status_t		_SetUpNodes();
101 			void			_TearDownNodes();
102 
103 			BMediaRoster*	fMediaRoster;
104 			media_node		fTimeSourceNode;
105 			media_node		fProducerNode;
106 			VideoConsumer*	fVideoConsumer;
107 			media_output	fProducerOut;
108 			media_input		fConsumerIn;
109 			VideoWindow*	fWindow;
110 			port_id			fPort;
111 			ControlWindow*	fVideoControlWindow;
112 };
113 
114 
115 class VideoWindow : public BWindow {
116 public:
117 							VideoWindow(BRect frame, const char* title,
118 								window_type type, uint32 flags,
119 								port_id* consumerport);
120 							~VideoWindow();
121 
122 	virtual	bool			QuitRequested();
123 	virtual	void			MessageReceived(BMessage* message);
124 
125 			void			ApplyControls();
126 
127 			BView*			VideoView();
128 			BStringView*	StatusLine();
129 			void			ToggleMenuOnOff();
130 
131 private:
132 			void			_BuildCaptureControls();
133 
134 			void			_SetUpSettings(const char* filename,
135 								const char* dirname);
136 			void			_UploadClientChanged();
137 			void			_QuitSettings();
138 
139 private:
140 			media_node*		fProducer;
141 			port_id*		fPortPtr;
142 
143 			BView*			fVideoView;
144 
145 			BTextControl*	fFileName;
146 			BBox*			fCaptureSetupBox;
147 			BMenu*			fCaptureRateMenu;
148 			BMenuField*		fCaptureRateSelector;
149 			BMenu*			fImageFormatMenu;
150 			BMenuField*		fImageFormatSelector;
151 			BMenu*			fUploadClientMenu;
152 			BMenuField*		fUploadClientSelector;
153 			BBox*			fFtpSetupBox;
154 			BTextControl*	fServerName;
155 			BTextControl*	fLoginId;
156 			BTextControl*	fPassword;
157 			BTextControl*	fDirectory;
158 			BCheckBox*		fPassiveFtp;
159 			BBox*			fStatusBox;
160 			BStringView*	fStatusLine;
161 
162 			ftp_msg_info	fFtpInfo;
163 
164 			Settings*		fSettings;
165 
166 			BMenu* 			fMenu;
167 
168 			StringValueSetting*		fServerSetting;
169 			StringValueSetting*		fLoginSetting;
170 			StringValueSetting*		fPasswordSetting;
171 			StringValueSetting*		fDirectorySetting;
172 			BooleanValueSetting*	fPassiveFtpSetting;
173 			StringValueSetting*		fFilenameSetting;
174 			StringValueSetting*		fImageFormatSettings;
175 
176 			EnumeratedStringValueSetting*	fUploadClientSetting;
177 			EnumeratedStringValueSetting*	fCaptureRateSetting;
178 };
179 
180 
181 class ControlWindow : public BWindow {
182 public:
183 							ControlWindow(const BRect& frame, BView* controls,
184 								media_node node);
185 			void			MessageReceived(BMessage* message);
186 			bool			QuitRequested();
187 
188 private:
189 			BView*			fView;
190 			media_node		fNode;
191 };
192 
193 #endif	// CODYCAM_H
194 
195