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