xref: /haiku/src/apps/codycam/CodyCam.h (revision 323b65468e5836bb27a5e373b14027d902349437)
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 
88 class CodyCam : public BApplication {
89 public:
90 							CodyCam();
91 	virtual					~CodyCam();
92 
93 			void			ReadyToRun();
94 	virtual	bool			QuitRequested();
95 	virtual	void			MessageReceived(BMessage* message);
96 
97 private:
98 			status_t		_SetUpNodes();
99 			void			_TearDownNodes();
100 
101 			BMediaRoster*	fMediaRoster;
102 			media_node		fTimeSourceNode;
103 			media_node		fProducerNode;
104 			VideoConsumer*	fVideoConsumer;
105 			media_output	fProducerOut;
106 			media_input		fConsumerIn;
107 			BWindow*		fWindow;
108 			port_id			fPort;
109 			BWindow*		fVideoControlWindow;
110 };
111 
112 
113 class VideoWindow : public BWindow {
114 public:
115 							VideoWindow(BRect frame, const char* title,
116 								window_type type, uint32 flags,
117 								port_id* consumerport);
118 							~VideoWindow();
119 
120 	virtual	bool			QuitRequested();
121 	virtual	void			MessageReceived(BMessage* message);
122 
123 			void			ApplyControls();
124 
125 			BView*			VideoView();
126 			BStringView*	StatusLine();
127 
128 private:
129 			void			_BuildCaptureControls();
130 
131 			void			_SetUpSettings(const char* filename,
132 								const char* dirname);
133 			void			_UploadClientChanged();
134 			void			_QuitSettings();
135 
136 private:
137 			media_node*		fProducer;
138 			port_id*		fPortPtr;
139 
140 			BView*			fVideoView;
141 
142 			BTextControl*	fFileName;
143 			BBox*			fCaptureSetupBox;
144 			BMenu*			fCaptureRateMenu;
145 			BMenuField*		fCaptureRateSelector;
146 			BMenu*			fImageFormatMenu;
147 			BMenuField*		fImageFormatSelector;
148 			BMenu*			fUploadClientMenu;
149 			BMenuField*		fUploadClientSelector;
150 			BBox*			fFtpSetupBox;
151 			BTextControl*	fServerName;
152 			BTextControl*	fLoginId;
153 			BTextControl*	fPassword;
154 			BTextControl*	fDirectory;
155 			BCheckBox*		fPassiveFtp;
156 			BBox*			fStatusBox;
157 			BStringView*	fStatusLine;
158 
159 			ftp_msg_info	fFtpInfo;
160 
161 			Settings*		fSettings;
162 
163 			StringValueSetting*		fServerSetting;
164 			StringValueSetting*		fLoginSetting;
165 			StringValueSetting*		fPasswordSetting;
166 			StringValueSetting*		fDirectorySetting;
167 			BooleanValueSetting*	fPassiveFtpSetting;
168 			StringValueSetting*		fFilenameSetting;
169 			StringValueSetting*		fImageFormatSettings;
170 
171 			EnumeratedStringValueSetting*	fUploadClientSetting;
172 			EnumeratedStringValueSetting*	fCaptureRateSetting;
173 };
174 
175 
176 class ControlWindow : public BWindow {
177 public:
178 							ControlWindow(const BRect& frame, BView* controls,
179 								media_node node);
180 			void			MessageReceived(BMessage* message);
181 			bool			QuitRequested();
182 
183 private:
184 			BView*			fView;
185 			media_node		fNode;
186 };
187 
188 #endif	// CODYCAM_H
189 
190