16a739773SCodeforEvolution/*
26a739773SCodeforEvolution * Copyright 1998-1999 Be, Inc. All Rights Reserved.
36a739773SCodeforEvolution * Copyright 2003-2019 Haiku, Inc. All rights reserved.
46a739773SCodeforEvolution * Distributed under the terms of the MIT License.
56a739773SCodeforEvolution */
6dba5824bSPhil Greenway#ifndef CODYCAM_H
7dba5824bSPhil Greenway#define CODYCAM_H
8dba5824bSPhil Greenway
99d3f15c6SIngo Weinhold
10dba5824bSPhil Greenway#include <string.h>
119d3f15c6SIngo Weinhold
129d3f15c6SIngo Weinhold#include <Application.h>
139d3f15c6SIngo Weinhold#include <Box.h>
14c4f9b1d1SStephan Aßmus#include <Catalog.h>
15dba5824bSPhil Greenway#include <CheckBox.h>
16c4f9b1d1SStephan Aßmus#include <Locale.h>
179d3f15c6SIngo Weinhold#include <Menu.h>
18dba5824bSPhil Greenway#include <MenuField.h>
19dba5824bSPhil Greenway#include <StringView.h>
20dba5824bSPhil Greenway#include <TextControl.h>
219d3f15c6SIngo Weinhold#include <Window.h>
22dba5824bSPhil Greenway
236a739773SCodeforEvolution#include "Settings.h"
246a739773SCodeforEvolution#include "VideoConsumer.h"
256a739773SCodeforEvolution
26dba5824bSPhil Greenway
277ebabb86SJérôme Duvalclass BMediaRoster;
287ebabb86SJérôme Duval
297ebabb86SJérôme Duval
30dba5824bSPhil Greenwayenum {
31dba5824bSPhil Greenway	msg_filename	= 'file',
32dba5824bSPhil Greenway
338ceeae63SAlex Wilson	msg_rate_changed = 'rate',
34dba5824bSPhil Greenway
35dba5824bSPhil Greenway	msg_translate	= 'tran',
36dba5824bSPhil Greenway
37e3145a8dSFrançois Revol	msg_upl_client	= 'ucli',
38dba5824bSPhil Greenway	msg_server		= 'srvr',
39dba5824bSPhil Greenway	msg_login		= 'lgin',
40dba5824bSPhil Greenway	msg_password	= 'pswd',
41dba5824bSPhil Greenway	msg_directory	= 'drct',
42dba5824bSPhil Greenway	msg_passiveftp	= 'pasv',
43dba5824bSPhil Greenway	msg_pswrd_text	= 'pstx',
44476fad7fSMatt Madia
45dba5824bSPhil Greenway	msg_start		= 'strt',
46dba5824bSPhil Greenway	msg_stop		= 'stop',
47dba5824bSPhil Greenway
48dba5824bSPhil Greenway	msg_setup		= 'setp',
49dba5824bSPhil Greenway	msg_video		= 'vdeo',
50476fad7fSMatt Madia
51dba5824bSPhil Greenway	msg_control_win = 'ctlw'
52dba5824bSPhil Greenway};
53dba5824bSPhil Greenway
549d3f15c6SIngo Weinhold
558ceeae63SAlex Wilsonstruct capture_rate {
568ceeae63SAlex Wilson	const char* name;
578ceeae63SAlex Wilson	time_t		seconds;
588ceeae63SAlex Wilson};
598ceeae63SAlex Wilson
608ceeae63SAlex Wilson
618ceeae63SAlex Wilson// NOTE: These are translated once the app catalog is loaded.
628ceeae63SAlex Wilsoncapture_rate kCaptureRates[] = {
638ceeae63SAlex Wilson	{"Every 15 seconds", 15 },
648ceeae63SAlex Wilson	{"Every 30 seconds", 30 },
658ceeae63SAlex Wilson	{"Every minute", 60 },
668ceeae63SAlex Wilson	{"Every 5 minutes", 5 * 60 },
678ceeae63SAlex Wilson	{"Every 10 minutes", 10 * 60 },
688ceeae63SAlex Wilson	{"Every 15 minutes", 15 * 60 },
698ceeae63SAlex Wilson	{"Every 30 minutes", 30 * 60 },
708ceeae63SAlex Wilson	{"Every hour", 60 * 60 },
718ceeae63SAlex Wilson	{"Every 2 hours", 2 * 60 * 60 },
728ceeae63SAlex Wilson	{"Every 4 hours", 4 * 60 * 60 },
738ceeae63SAlex Wilson	{"Every 8 hours", 8 * 60 * 60 },
748ceeae63SAlex Wilson	{"Every 24 hours", 24 * 60 * 60 },
758ceeae63SAlex Wilson	{"Never", 0 }
76dba5824bSPhil Greenway};
77dba5824bSPhil Greenway
789d3f15c6SIngo Weinhold
798ceeae63SAlex Wilsonconst int32 kCaptureRatesCount = sizeof(kCaptureRates) / sizeof(capture_rate);
808ceeae63SAlex Wilson
818ceeae63SAlex Wilson
828ceeae63SAlex Wilsonconst char* kUploadClients[] = {
83c4f9b1d1SStephan Aßmus	// NOTE: These are translated once the app catalog is loaded.
84e3145a8dSFrançois Revol	"FTP",
85e3145a8dSFrançois Revol	"SFTP",
868ceeae63SAlex Wilson	"Local"
87e3145a8dSFrançois Revol};
88e3145a8dSFrançois Revol
89e3145a8dSFrançois Revol
908ceeae63SAlex Wilsonconst int32 kUploadClientsCount = sizeof(kUploadClients) / sizeof(char*);
918ceeae63SAlex Wilson
921615cec9SFredrik Modéenclass VideoWindow;
931615cec9SFredrik Modéenclass ControlWindow;
948ceeae63SAlex Wilson
95dba5824bSPhil Greenwayclass CodyCam : public BApplication {
9618ba9ea5SJonas Sundströmpublic:
9718ba9ea5SJonas Sundström							CodyCam();
9818ba9ea5SJonas Sundström	virtual					~CodyCam();
9918ba9ea5SJonas Sundström
10018ba9ea5SJonas Sundström			void			ReadyToRun();
10118ba9ea5SJonas Sundström	virtual	bool			QuitRequested();
10218ba9ea5SJonas Sundström	virtual	void			MessageReceived(BMessage* message);
10318ba9ea5SJonas Sundström
10418ba9ea5SJonas Sundströmprivate:
10518ba9ea5SJonas Sundström			status_t		_SetUpNodes();
10618ba9ea5SJonas Sundström			void			_TearDownNodes();
10718ba9ea5SJonas Sundström
10818ba9ea5SJonas Sundström			BMediaRoster*	fMediaRoster;
10918ba9ea5SJonas Sundström			media_node		fTimeSourceNode;
11018ba9ea5SJonas Sundström			media_node		fProducerNode;
11118ba9ea5SJonas Sundström			VideoConsumer*	fVideoConsumer;
11218ba9ea5SJonas Sundström			media_output	fProducerOut;
11318ba9ea5SJonas Sundström			media_input		fConsumerIn;
1141615cec9SFredrik Modéen			VideoWindow*	fWindow;
11518ba9ea5SJonas Sundström			port_id			fPort;
1161615cec9SFredrik Modéen			ControlWindow*	fVideoControlWindow;
117dba5824bSPhil Greenway};
118dba5824bSPhil Greenway
119dba5824bSPhil Greenway
1209d3f15c6SIngo Weinholdclass VideoWindow : public BWindow {
12118ba9ea5SJonas Sundströmpublic:
1223c5208e4SHumdinger							VideoWindow(const char* title,
12318ba9ea5SJonas Sundström								window_type type, uint32 flags,
12418ba9ea5SJonas Sundström								port_id* consumerport);
12518ba9ea5SJonas Sundström							~VideoWindow();
12618ba9ea5SJonas Sundström
12718ba9ea5SJonas Sundström	virtual	bool			QuitRequested();
12818ba9ea5SJonas Sundström	virtual	void			MessageReceived(BMessage* message);
12918ba9ea5SJonas Sundström
13018ba9ea5SJonas Sundström			void			ApplyControls();
13118ba9ea5SJonas Sundström
13218ba9ea5SJonas Sundström			BView*			VideoView();
13318ba9ea5SJonas Sundström			BStringView*	StatusLine();
1341615cec9SFredrik Modéen			void			ToggleMenuOnOff();
13518ba9ea5SJonas Sundström
136b3b96925SAdrien Destugues			void			ErrorAlert(const char*, status_t);
137b3b96925SAdrien Destugues
13818ba9ea5SJonas Sundströmprivate:
1398ceeae63SAlex Wilson			void			_BuildCaptureControls();
14018ba9ea5SJonas Sundström
14118ba9ea5SJonas Sundström			void			_SetUpSettings(const char* filename,
14218ba9ea5SJonas Sundström								const char* dirname);
143f5e3b474SStephan Aßmus			void			_UploadClientChanged();
14418ba9ea5SJonas Sundström			void			_QuitSettings();
14518ba9ea5SJonas Sundström
14618ba9ea5SJonas Sundströmprivate:
14718ba9ea5SJonas Sundström			media_node*		fProducer;
14818ba9ea5SJonas Sundström			port_id*		fPortPtr;
14918ba9ea5SJonas Sundström
150070c8b72SAdrien Destugues			BView*			fVideoView;
1516a739773SCodeforEvolution			BTextView*		fErrorView;
15218ba9ea5SJonas Sundström
15318ba9ea5SJonas Sundström			BTextControl*	fFileName;
15418ba9ea5SJonas Sundström			BBox*			fCaptureSetupBox;
15518ba9ea5SJonas Sundström			BMenu*			fCaptureRateMenu;
15618ba9ea5SJonas Sundström			BMenuField*		fCaptureRateSelector;
15718ba9ea5SJonas Sundström			BMenu*			fImageFormatMenu;
15818ba9ea5SJonas Sundström			BMenuField*		fImageFormatSelector;
15918ba9ea5SJonas Sundström			BMenu*			fUploadClientMenu;
16018ba9ea5SJonas Sundström			BMenuField*		fUploadClientSelector;
16118ba9ea5SJonas Sundström			BBox*			fFtpSetupBox;
16218ba9ea5SJonas Sundström			BTextControl*	fServerName;
16318ba9ea5SJonas Sundström			BTextControl*	fLoginId;
16418ba9ea5SJonas Sundström			BTextControl*	fPassword;
16518ba9ea5SJonas Sundström			BTextControl*	fDirectory;
16618ba9ea5SJonas Sundström			BCheckBox*		fPassiveFtp;
16718ba9ea5SJonas Sundström			BBox*			fStatusBox;
16818ba9ea5SJonas Sundström			BStringView*	fStatusLine;
16918ba9ea5SJonas Sundström
17018ba9ea5SJonas Sundström			ftp_msg_info	fFtpInfo;
17118ba9ea5SJonas Sundström
17218ba9ea5SJonas Sundström			Settings*		fSettings;
1733c5208e4SHumdinger
1741615cec9SFredrik Modéen			BMenu* 			fMenu;
17518ba9ea5SJonas Sundström
17618ba9ea5SJonas Sundström			StringValueSetting*		fServerSetting;
17718ba9ea5SJonas Sundström			StringValueSetting*		fLoginSetting;
17818ba9ea5SJonas Sundström			StringValueSetting*		fPasswordSetting;
17918ba9ea5SJonas Sundström			StringValueSetting*		fDirectorySetting;
18018ba9ea5SJonas Sundström			BooleanValueSetting*	fPassiveFtpSetting;
18118ba9ea5SJonas Sundström			StringValueSetting*		fFilenameSetting;
18218ba9ea5SJonas Sundström			StringValueSetting*		fImageFormatSettings;
18318ba9ea5SJonas Sundström
18418ba9ea5SJonas Sundström			EnumeratedStringValueSetting*	fUploadClientSetting;
18518ba9ea5SJonas Sundström			EnumeratedStringValueSetting*	fCaptureRateSetting;
186dba5824bSPhil Greenway};
187dba5824bSPhil Greenway
188dba5824bSPhil Greenway
1899d3f15c6SIngo Weinholdclass ControlWindow : public BWindow {
19018ba9ea5SJonas Sundströmpublic:
1913c5208e4SHumdinger							ControlWindow(BView* controls,
19218ba9ea5SJonas Sundström								media_node node);
19318ba9ea5SJonas Sundström			void			MessageReceived(BMessage* message);
19418ba9ea5SJonas Sundström			bool			QuitRequested();
19518ba9ea5SJonas Sundström
19618ba9ea5SJonas Sundströmprivate:
19718ba9ea5SJonas Sundström			BView*			fView;
19818ba9ea5SJonas Sundström			media_node		fNode;
199dba5824bSPhil Greenway};
200dba5824bSPhil Greenway
2019d3f15c6SIngo Weinhold#endif	// CODYCAM_H
202