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_15s = 'r15s', 29 msg_rate_30s = 'r30s', 30 msg_rate_1m = 'r1m ', 31 msg_rate_5m = 'r5m ', 32 msg_rate_10m = 'r10m', 33 msg_rate_15m = 'r15m', 34 msg_rate_30m = 'r30m', 35 msg_rate_1h = 'r1h ', 36 msg_rate_2h = 'r2h ', 37 msg_rate_4h = 'r4h ', 38 msg_rate_8h = 'r8h ', 39 msg_rate_24h = 'r24h', 40 msg_rate_never = 'nevr', 41 42 msg_translate = 'tran', 43 44 msg_upl_client = 'ucli', 45 msg_server = 'srvr', 46 msg_login = 'lgin', 47 msg_password = 'pswd', 48 msg_directory = 'drct', 49 msg_passiveftp = 'pasv', 50 msg_pswrd_text = 'pstx', 51 52 msg_start = 'strt', 53 msg_stop = 'stop', 54 55 msg_about = 'abut', 56 msg_setup = 'setp', 57 msg_video = 'vdeo', 58 59 msg_control_win = 'ctlw' 60 }; 61 62 63 const char* kCaptureRate[] = { 64 // NOTE: These are translated once the app catalog is loaded. 65 "Every 15 seconds", 66 "Every 30 seconds", 67 "Every minute", 68 "Every 5 minutes", 69 "Every 10 minutes", 70 "Every 15 minutes", 71 "Every 30 minutes", 72 "Every hour", 73 "Every 2 hours", 74 "Every 4 hours", 75 "Every 8 hours", 76 "Every 24 hours", 77 "Never", 78 0 79 }; 80 81 82 const char* kUploadClient[] = { 83 // NOTE: These are translated once the app catalog is loaded. 84 "FTP", 85 "SFTP", 86 "Local", 87 0 88 }; 89 90 91 class CodyCam : public BApplication { 92 public: 93 CodyCam(); 94 virtual ~CodyCam(); 95 96 void ReadyToRun(); 97 virtual bool QuitRequested(); 98 virtual void MessageReceived(BMessage* message); 99 100 private: 101 status_t _SetUpNodes(); 102 void _TearDownNodes(); 103 104 BMediaRoster* fMediaRoster; 105 media_node fTimeSourceNode; 106 media_node fProducerNode; 107 VideoConsumer* fVideoConsumer; 108 media_output fProducerOut; 109 media_input fConsumerIn; 110 BWindow* fWindow; 111 port_id fPort; 112 BWindow* fVideoControlWindow; 113 BCatalog fAppCatalog; 114 }; 115 116 117 class VideoWindow : public BWindow { 118 public: 119 VideoWindow(BRect frame, const char* title, 120 window_type type, uint32 flags, 121 port_id* consumerport); 122 ~VideoWindow(); 123 124 virtual bool QuitRequested(); 125 virtual void MessageReceived(BMessage* message); 126 127 void ApplyControls(); 128 129 BView* VideoView(); 130 BStringView* StatusLine(); 131 132 private: 133 void _BuildCaptureControls(BView* theView); 134 135 void _SetUpSettings(const char* filename, 136 const char* dirname); 137 void _UploadClientChanged(); 138 void _QuitSettings(); 139 140 private: 141 media_node* fProducer; 142 port_id* fPortPtr; 143 144 BView* fView; 145 BView* 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 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