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_about = 'abut', 44 msg_setup = 'setp', 45 msg_video = 'vdeo', 46 47 msg_control_win = 'ctlw' 48 }; 49 50 51 struct capture_rate { 52 const char* name; 53 time_t seconds; 54 }; 55 56 57 // NOTE: These are translated once the app catalog is loaded. 58 capture_rate kCaptureRates[] = { 59 {"Every 15 seconds", 15 }, 60 {"Every 30 seconds", 30 }, 61 {"Every minute", 60 }, 62 {"Every 5 minutes", 5 * 60 }, 63 {"Every 10 minutes", 10 * 60 }, 64 {"Every 15 minutes", 15 * 60 }, 65 {"Every 30 minutes", 30 * 60 }, 66 {"Every hour", 60 * 60 }, 67 {"Every 2 hours", 2 * 60 * 60 }, 68 {"Every 4 hours", 4 * 60 * 60 }, 69 {"Every 8 hours", 8 * 60 * 60 }, 70 {"Every 24 hours", 24 * 60 * 60 }, 71 {"Never", 0 } 72 }; 73 74 75 const int32 kCaptureRatesCount = sizeof(kCaptureRates) / sizeof(capture_rate); 76 77 78 const char* kUploadClients[] = { 79 // NOTE: These are translated once the app catalog is loaded. 80 "FTP", 81 "SFTP", 82 "Local" 83 }; 84 85 86 const int32 kUploadClientsCount = sizeof(kUploadClients) / sizeof(char*); 87 88 89 class CodyCam : public BApplication { 90 public: 91 CodyCam(); 92 virtual ~CodyCam(); 93 94 void ReadyToRun(); 95 virtual bool QuitRequested(); 96 virtual void MessageReceived(BMessage* message); 97 98 private: 99 status_t _SetUpNodes(); 100 void _TearDownNodes(); 101 102 BMediaRoster* fMediaRoster; 103 media_node fTimeSourceNode; 104 media_node fProducerNode; 105 VideoConsumer* fVideoConsumer; 106 media_output fProducerOut; 107 media_input fConsumerIn; 108 BWindow* fWindow; 109 port_id fPort; 110 BWindow* fVideoControlWindow; 111 }; 112 113 114 class VideoWindow : public BWindow { 115 public: 116 VideoWindow(BRect frame, const char* title, 117 window_type type, uint32 flags, 118 port_id* consumerport); 119 ~VideoWindow(); 120 121 virtual bool QuitRequested(); 122 virtual void MessageReceived(BMessage* message); 123 124 void ApplyControls(); 125 126 BView* VideoView(); 127 BStringView* StatusLine(); 128 129 private: 130 void _BuildCaptureControls(); 131 132 void _SetUpSettings(const char* filename, 133 const char* dirname); 134 void _UploadClientChanged(); 135 void _QuitSettings(); 136 137 private: 138 media_node* fProducer; 139 port_id* fPortPtr; 140 141 BView* fVideoView; 142 143 BTextControl* fFileName; 144 BBox* fCaptureSetupBox; 145 BMenu* fCaptureRateMenu; 146 BMenuField* fCaptureRateSelector; 147 BMenu* fImageFormatMenu; 148 BMenuField* fImageFormatSelector; 149 BMenu* fUploadClientMenu; 150 BMenuField* fUploadClientSelector; 151 BBox* fFtpSetupBox; 152 BTextControl* fServerName; 153 BTextControl* fLoginId; 154 BTextControl* fPassword; 155 BTextControl* fDirectory; 156 BCheckBox* fPassiveFtp; 157 BBox* fStatusBox; 158 BStringView* fStatusLine; 159 160 ftp_msg_info fFtpInfo; 161 162 Settings* fSettings; 163 164 StringValueSetting* fServerSetting; 165 StringValueSetting* fLoginSetting; 166 StringValueSetting* fPasswordSetting; 167 StringValueSetting* fDirectorySetting; 168 BooleanValueSetting* fPassiveFtpSetting; 169 StringValueSetting* fFilenameSetting; 170 StringValueSetting* fImageFormatSettings; 171 172 EnumeratedStringValueSetting* fUploadClientSetting; 173 EnumeratedStringValueSetting* fCaptureRateSetting; 174 }; 175 176 177 class ControlWindow : public BWindow { 178 public: 179 ControlWindow(const BRect& frame, BView* controls, 180 media_node node); 181 void MessageReceived(BMessage* message); 182 bool QuitRequested(); 183 184 private: 185 BView* fView; 186 media_node fNode; 187 }; 188 189 #endif // CODYCAM_H 190 191