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