You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

775 lines
27 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #include "addSourceDialog.h"
  2. #include "../controls/VideoSourceChooser.h"
  3. #ifdef __linux__
  4. #include "ui_addSourceDialog.h"
  5. guiAddSourceDialog::guiAddSourceDialog(VideoSourceChooser* pPtr, QWidget* parent) : QDialog((QWidget*)parent), ui(new Ui::guiAddSourceDialog) {
  6. #else
  7. guiAddSourceDialog::guiAddSourceDialog(VideoSourceChooser * pPtr, QWidget * parent) : QDialog((QWidget*)parent){
  8. #endif
  9. m_pParent = pPtr;
  10. m_pSourceManager = mediaVideoSourceManager::getInstance();
  11. m_pSourcePreviewInput = NULL;
  12. m_pOnvifObserver = NULL;
  13. m_nAddSourceDialogStage = 0;
  14. /* Init Temp Data */
  15. m_sTemporarySource.alt = 0;
  16. m_sTemporarySource.bAutoExposure = true;
  17. m_sTemporarySource.bAutoIris = true;
  18. m_sTemporarySource.bAutoWB = true;
  19. m_sTemporarySource.bDZoomEna = false;
  20. m_sTemporarySource.bDigitalZoom = false;
  21. m_sTemporarySource.bMirrored = false;
  22. m_sTemporarySource.bOptixEna = false;
  23. m_sTemporarySource.bOpticZoom = false;
  24. m_sTemporarySource.bPanEna = false;
  25. m_sTemporarySource.bPanReverse = false;
  26. m_sTemporarySource.bPanSpeedDynamic = false;
  27. m_sTemporarySource.bTiltEna = false;
  28. m_sTemporarySource.bTiltReverse = false;
  29. m_sTemporarySource.bTiltSpeedDynamic = false;
  30. m_sTemporarySource.bUpsideDown = false;
  31. m_sTemporarySource.bWDR = false;
  32. m_sTemporarySource.bZoomEna = false;
  33. m_sTemporarySource.bZoomSpeedDynamic = false;
  34. m_sTemporarySource.capturePin = -1;
  35. m_sTemporarySource.fDigitalZoomMax = -1;
  36. m_sTemporarySource.deviceId = 0;
  37. sprintf(m_sTemporarySource.deviceName, "");
  38. sprintf(m_sTemporarySource.devicePath, "");
  39. m_sTemporarySource.fManualExposure = -1;
  40. m_sTemporarySource.fManualFocus = -1;
  41. m_sTemporarySource.fManualIris = -1;
  42. m_sTemporarySource.fManualShutterSpeed = -1;
  43. m_sTemporarySource.fSensorSize = 0.33;
  44. m_sTemporarySource.fZoomSpeedMax = -1;
  45. m_sTemporarySource.fZoomSpeedMin = -1;
  46. m_sTemporarySource.FLMax = 3;
  47. m_sTemporarySource.FLMin = 3;
  48. m_sTemporarySource.frameIsWide = false;
  49. m_sTemporarySource.framerate = -1;
  50. m_sTemporarySource.h_alt = 0;
  51. m_sTemporarySource.h_lat = 0;
  52. m_sTemporarySource.h_lon = 0;
  53. m_sTemporarySource.lat = 0;
  54. m_sTemporarySource.lon = 0;
  55. m_sTemporarySource.protocolId = -1;
  56. m_sTemporarySource.sizeId = 0; // Automatic
  57. m_sTemporarySource.subtype = 0;
  58. m_sTemporarySource.type = 0;
  59. m_iTScaledSizeIndex = 5;
  60. m_bTUseDeviceMenu = false;
  61. m_bTScaled = false;
  62. /* Dialog */
  63. setFixedWidth(600);
  64. setFixedHeight(480);
  65. setWindowTitle("Add Camera Module");
  66. m_pDialogTabWidget = new QTabWidget();
  67. m_pButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
  68. //m_pButtonBox-> setEnabled(false);
  69. connect(m_pButtonBox, &QDialogButtonBox::accepted, this, &guiAddSourceDialog::addSource);
  70. connect(m_pButtonBox, &QDialogButtonBox::rejected, this, &guiAddSourceDialog::cancelDialog);
  71. QVBoxLayout *mainLayout = new QVBoxLayout;
  72. mainLayout->addWidget(m_pDialogTabWidget);
  73. mainLayout->addWidget(m_pButtonBox);
  74. setLayout(mainLayout);
  75. /* Elements */
  76. /* Stage 1 */
  77. m_pDeviceTypeCombo = new QComboBox();
  78. m_pDeviceTypeCombo->addItem(QString("Static Camera"), 0);
  79. m_pDeviceTypeCombo->addItem(QString("Extended Static Camera"), 1);
  80. m_pDeviceTypeCombo->addItem(QString("Extended Static Camera + Zoom"), 2);
  81. #ifndef NO_PTZ_CAMERAS
  82. m_pDeviceTypeCombo->addItem(QString("PTZ Camera"), 3);
  83. #endif
  84. connect(m_pDeviceTypeCombo,
  85. static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
  86. this,
  87. &guiAddSourceDialog::setCameraType);
  88. m_pSourceTypeCombo = new QComboBox();
  89. m_pSourceTypeCombo->addItem(QString("Local Source"), 0);
  90. #ifndef NO_ONVIF_CAMERAS
  91. m_pSourceTypeCombo->addItem(QString("IP Stream"), 1);
  92. #endif
  93. m_pSourceTypeCombo->addItem(QString("File"), 2);
  94. connect(m_pSourceTypeCombo,
  95. static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
  96. this,
  97. &guiAddSourceDialog::setSourceType);
  98. /* Stage 2 */
  99. m_pScalePicture = new QCheckBox();
  100. m_pScalePicture->setText("Strech Output Video");
  101. m_pScalePicture->setChecked(m_bTScaled);
  102. connect(m_pScalePicture,
  103. static_cast<void(QCheckBox::*)(bool)>(&QCheckBox::clicked),
  104. this,
  105. &guiAddSourceDialog::setStrechMode);
  106. m_p16x9resolution = new QRadioButton();
  107. m_p16x9resolution->setText("16x9");
  108. m_p16x9resolution->setChecked(m_sTemporarySource.frameIsWide);
  109. connect(m_p16x9resolution,
  110. static_cast<void(QRadioButton::*)(bool)>(&QRadioButton::clicked),
  111. this,
  112. &guiAddSourceDialog::setProportions16);
  113. m_p4x3resolution = new QRadioButton();
  114. m_p4x3resolution->setText("4x3");
  115. m_p4x3resolution->setChecked(!m_sTemporarySource.frameIsWide);
  116. connect(m_p4x3resolution,
  117. static_cast<void(QRadioButton::*)(bool)>(&QRadioButton::clicked),
  118. this, &guiAddSourceDialog::setProportions4);
  119. m_pScaledResolutionCombo = new QComboBox();
  120. m_pDeviceResolutionCombo = new QComboBox();
  121. for (int i = 0; i < 9; i++){
  122. m_pDeviceResolutionCombo->addItem(QString(m_pSourceManager->getStandardSize(m_sTemporarySource.frameIsWide, i)), i);
  123. m_pScaledResolutionCombo->addItem(QString(m_pSourceManager->getStandardSize(m_sTemporarySource.frameIsWide, i)), i);
  124. };
  125. m_pDeviceResolutionCombo->setCurrentIndex(m_sTemporarySource.sizeId);
  126. m_pScaledResolutionCombo->setCurrentIndex(m_iTScaledSizeIndex);
  127. m_pScaledResolutionCombo->setEnabled(m_bTScaled);
  128. m_pButtonCmdShowDeviceSettings = new QPushButton();
  129. m_pButtonCmdShowDeviceSettings->setText("Show Device Settings");
  130. connect(m_pButtonCmdShowDeviceSettings, &QPushButton::clicked, this, &guiAddSourceDialog::showDeviceSettings);
  131. m_pInputPinCombo = new QComboBox();
  132. m_pInputPinCombo->addItem(QString("Video Tuner"), 0);
  133. m_pInputPinCombo->addItem(QString("Video Composite"), 1);
  134. m_pInputPinCombo->addItem(QString("S-Video"), 2);
  135. m_pInputPinCombo->addItem(QString("Video RGB"), 3);
  136. m_pInputPinCombo->addItem(QString("Video YRYBY"), 4);
  137. m_pInputPinCombo->addItem(QString("Video Serial Digital"), 5);
  138. m_pInputPinCombo->addItem(QString("Video Parallel Digital"), 6);
  139. m_pInputPinCombo->addItem(QString("Video SCSI"), 7);
  140. m_pInputPinCombo->addItem(QString("Video AUX"), 8);
  141. m_pInputPinCombo->addItem(QString("Video 1394"), 9);
  142. m_pInputPinCombo->addItem(QString("Video USB"), 10);
  143. m_pInputPinCombo->addItem(QString("Video Decoder"), 11);
  144. m_pInputPinCombo->addItem(QString("Video Encoder"), 12);
  145. m_pInputPinCombo->setCurrentIndex(m_sTemporarySource.capturePin);
  146. connect(m_pInputPinCombo,
  147. static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
  148. this,
  149. &guiAddSourceDialog::setInputPin);
  150. m_pLocalDevicesCombo = new QComboBox();
  151. for (int i = 0; i < m_pSourceManager->getLocalSourceCount(); i++){
  152. m_pLocalDevicesCombo->addItem(QString(m_pSourceManager->getLocalSourceInfo(i)->FriendlyName), i);
  153. };
  154. m_pLocalDevicesCombo->setCurrentIndex(m_sTemporarySource.deviceId);
  155. connect(m_pLocalDevicesCombo,
  156. static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
  157. this,
  158. &guiAddSourceDialog::setPreviewLocalSource);
  159. connect(m_pDeviceResolutionCombo,
  160. static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
  161. this,
  162. &guiAddSourceDialog::setResolution);
  163. m_pSourcePreview = new VideoThumbWidget();
  164. //setPreviewLocalSource( 0 );
  165. m_pSourcePreview->init();
  166. turnOnVideo();
  167. /*Layouts*/
  168. m_pVerticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
  169. m_pFrame1 = new QFrame();
  170. m_pFrame1->setFrameShape(QFrame::Box);
  171. m_pFrame1->setFrameShadow(QFrame::Sunken);
  172. QSizePolicy sizePolicy1(QSizePolicy::Preferred, QSizePolicy::Fixed);
  173. sizePolicy1.setHorizontalStretch(0);
  174. sizePolicy1.setVerticalStretch(0);
  175. sizePolicy1.setHeightForWidth(m_pFrame1->sizePolicy().hasHeightForWidth());
  176. m_pFrame1->setSizePolicy(sizePolicy1);
  177. m_pFrame1->setMinimumSize(QSize(0, 100));
  178. m_pLabel1 = new QLabel(m_pFrame1);
  179. m_pLabel1->setWordWrap(true);
  180. m_pLabel1->setGeometry(QRect(10, 10, 540, 80));
  181. m_pLabel1->setText(QString("Please choose the camera type\nStatic Camera - simple camera that does not requires any settings or adjustments other then video source\nExtended Static Camera - camera with customized parameters such a lens F-number etc.\nExtended Static Camera + Zoom - same as previous but also must be set control protocol.\nPTZ Camera - full set of parameters avealeble"));
  182. m_pLabel1->setAlignment(Qt::AlignLeading | Qt::AlignLeft | Qt::AlignTop);
  183. m_pLabel1->setMargin(5);
  184. m_pLabel1->setIndent(0);
  185. m_pFrame2 = new QFrame();
  186. m_pFrame2->setFrameShape(QFrame::Box);
  187. m_pFrame2->setFrameShadow(QFrame::Sunken);
  188. QSizePolicy sizePolicy2(QSizePolicy::Preferred, QSizePolicy::Fixed);
  189. sizePolicy2.setHorizontalStretch(0);
  190. sizePolicy2.setVerticalStretch(0);
  191. sizePolicy2.setHeightForWidth(m_pFrame2->sizePolicy().hasHeightForWidth());
  192. m_pFrame2->setSizePolicy(sizePolicy2);
  193. m_pFrame2->setMinimumSize(QSize(0, 100));
  194. m_pLabel2 = new QLabel(m_pFrame2);
  195. m_pLabel2->setWordWrap(true);
  196. m_pLabel2->setGeometry(QRect(10, 10, 540, 80));
  197. m_pLabel2->setText(QString("Please choose the video source type\nLocal Source - Capture Device attached to this system\nIP Stream - Network IP camera stream\nFile - dummy video source for test purposes only"));
  198. m_pLabel2->setAlignment(Qt::AlignLeading | Qt::AlignLeft | Qt::AlignTop);
  199. m_pLabel2->setMargin(5);
  200. m_pLabel2->setIndent(0);
  201. /* Layout 1 */
  202. m_pStage1Layout = new QVBoxLayout();
  203. m_pStage1Layout->addWidget(m_pFrame1);
  204. m_pStage1Layout->addWidget(m_pDeviceTypeCombo);
  205. m_pStage1Layout->addWidget(m_pFrame2);
  206. m_pStage1Layout->addWidget(m_pSourceTypeCombo);
  207. m_pStage1Layout->addItem(m_pVerticalSpacer);
  208. delete ui;
  209. m_pPage1 = new QWidget();
  210. m_pPage1->setLayout(m_pStage1Layout);
  211. m_pDialogTabWidget->addTab(m_pPage1, QString("Camera Type"));
  212. /* Layout 2 */
  213. m_pStage2Layout = new QVBoxLayout();
  214. m_pPage2 = new QWidget();
  215. m_pPage2->setLayout(m_pStage2Layout);
  216. m_pDialogTabWidget->addTab(m_pPage2, QString("Location"));
  217. /* Layout 3 */
  218. m_pStage3Layout = new QVBoxLayout();
  219. verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
  220. horizontalSpacer = new QSpacerItem(20, 40, QSizePolicy::Expanding, QSizePolicy::Minimum);
  221. m_pS2VMLayout = new QVBoxLayout();
  222. m_pS2VMLayout->addWidget(m_pLocalDevicesCombo);
  223. m_pS2VMLayout->addWidget(m_pInputPinCombo);
  224. m_pS2VMLayout->addWidget(m_pButtonCmdShowDeviceSettings);
  225. m_pS2VMLayout->addWidget(m_p16x9resolution);
  226. m_pS2VMLayout->addWidget(m_p4x3resolution);
  227. m_pS2VMLayout->addWidget(m_pDeviceResolutionCombo);
  228. m_pS2VMLayout->addWidget(m_pScalePicture);
  229. m_pS2VMLayout->addWidget(m_pScaledResolutionCombo);
  230. m_pS2HMLayout = new QHBoxLayout();
  231. m_pS2HMLayout->addWidget(m_pSourcePreview);
  232. m_pS2HMLayout->addItem(m_pS2VMLayout);
  233. m_pStage3Layout->addItem(m_pS2HMLayout);
  234. m_pStage3Layout->addItem(verticalSpacer);
  235. m_pPage3 = new QWidget();
  236. m_pPage3->setLayout(m_pStage3Layout);
  237. m_pDialogTabWidget->addTab(m_pPage3, QString("Local Source"));
  238. /* Layout 4 */
  239. m_pStage4Layout = new QVBoxLayout();
  240. #ifndef NO_ONVIF_CAMERAS
  241. m_pButtonCmdStartOnvif = new QPushButton();
  242. m_pButtonCmdStartOnvif->setText("Start ONVIF Observer");
  243. connect(m_pButtonCmdStartOnvif, &QPushButton::clicked, this, &guiAddSourceDialog::showOnvifObserverDialog);
  244. m_pLineText = new QLineEdit(this);
  245. //m_pPlainTextEdit->setObjectName(QString::fromUtf8("plainTextEdit"));
  246. //m_pPlainTextEdit->setGeometry(QRect(40, 50, 301, 27));
  247. m_pLineText->setMinimumSize(QSize(0, 27));
  248. m_pLineText->setMaximumSize(QSize(16777215, 27));
  249. m_pStage4Layout->addWidget(m_pButtonCmdStartOnvif);
  250. m_pStage4Layout->addWidget(m_pLineText);
  251. m_pNetSourcePreview = new VideoThumbWidget();
  252. m_pNetSourcePreview->setError(true, "");
  253. m_pNetSourcePreview->init();
  254. m_pStage4Layout->addWidget(m_pNetSourcePreview);
  255. #endif
  256. QSpacerItem *tSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
  257. m_pStage4Layout->addItem(tSpacer);
  258. m_pPage4 = new QWidget();
  259. m_pPage4->setLayout(m_pStage4Layout);
  260. m_pDialogTabWidget->addTab(m_pPage4, QString("Network Source"));
  261. /* Layout 5 */
  262. m_pPage5 = new QWidget();
  263. //m_pPage5->setLayout(m_pStage3Layout);
  264. m_pDialogTabWidget->addTab(m_pPage5, QString("Lens/Image Settings"));
  265. /* Layout 6 */
  266. m_pPage6 = new QWidget();
  267. m_pStage6Layout = new QFormLayout();
  268. m_pPTZProtocolLabel = new QLabel();
  269. #ifndef NO_PTZ_CAMERAS
  270. m_pPTZProtocolLabel->setText(QString("PTZ Protocol:"));
  271. m_pStage6Layout->setWidget(0, QFormLayout::LabelRole, m_pPTZProtocolLabel);
  272. m_pPTZProtocolCombo = new QComboBox();
  273. m_pPTZProtocolCombo->addItem(QString("SONY VISCA"), 0);
  274. m_pPTZProtocolCombo->addItem(QString("PELCO-D"), 1);
  275. #ifndef NO_ONVIF_CAMERAS
  276. m_pPTZProtocolCombo->addItem(QString("OnVif PTZ"), 2);
  277. #endif
  278. m_sTemporarySource.protocolId = 1;
  279. m_pPTZProtocolCombo->setCurrentIndex( m_sTemporarySource.protocolId - 1 );
  280. connect(m_pPTZProtocolCombo,
  281. static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
  282. this,
  283. &guiAddSourceDialog::setPTZProto);
  284. m_pStage6Layout->setWidget(0, QFormLayout::FieldRole, m_pPTZProtocolCombo);
  285. #endif
  286. m_pPTZComPortLabel = new QLabel();
  287. m_pPTZComPortLabel->setText(QString("Serial Port:"));
  288. m_pStage6Layout->setWidget(1, QFormLayout::LabelRole, m_pPTZComPortLabel);
  289. m_pPTZComPortCombo = new QComboBox();
  290. for (int juju = 0; juju < 26; juju++){
  291. char tbuf[24];
  292. sprintf(tbuf, "COM%d", juju+1);
  293. m_pPTZComPortCombo->addItem(QString(tbuf), juju);
  294. };
  295. sprintf(m_sTemporarySource.comTransportPath,"COM1");
  296. m_sTemporarySource.comTransportPort = 1;
  297. m_pPTZComPortCombo->setCurrentIndex(m_sTemporarySource.comTransportPort-1);
  298. connect(m_pPTZComPortCombo,
  299. static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
  300. this,
  301. &guiAddSourceDialog::setPTZComPort);
  302. m_pStage6Layout->setWidget(1, QFormLayout::FieldRole, m_pPTZComPortCombo);
  303. m_pPTZComSpeedLabel = new QLabel();
  304. m_pPTZComSpeedLabel->setText(QString("Serial Port Speed:"));
  305. m_pStage6Layout->setWidget(2, QFormLayout::LabelRole, m_pPTZComSpeedLabel);
  306. m_pPTZComSpeedBox = new QSpinBox();
  307. m_pPTZComSpeedBox->setMinimum(2400);
  308. m_pPTZComSpeedBox->setSingleStep(2400);
  309. m_pPTZComSpeedBox->setMaximum(115200);
  310. m_sTemporarySource.comTransportSpeed = 9600;
  311. m_pPTZComSpeedBox->setValue(m_sTemporarySource.comTransportSpeed);
  312. m_pStage6Layout->setWidget(2, QFormLayout::FieldRole, m_pPTZComSpeedBox);
  313. m_pPTZCamIDLabel = new QLabel();
  314. m_pPTZCamIDLabel->setText(QString("Protocol Camera ID:"));
  315. m_pStage6Layout->setWidget(3, QFormLayout::LabelRole, m_pPTZCamIDLabel);
  316. m_pPTZCamIDBox = new QSpinBox();
  317. m_pStage6Layout->setWidget(3, QFormLayout::FieldRole, m_pPTZCamIDBox);
  318. m_sTemporarySource.protocolParameter = 1;
  319. m_pPTZPanEna = new QCheckBox();
  320. m_pPTZPanEna->setText("Enable Pan Control");
  321. m_pStage6Layout->setWidget(4, QFormLayout::FieldRole, m_pPTZPanEna);
  322. m_pPTZPanReversed = new QCheckBox();
  323. m_pPTZPanReversed->setText("Reverse Pan Control");
  324. m_sTemporarySource.bPanReverse = false;
  325. m_pPTZPanReversed->setChecked(m_sTemporarySource.bPanReverse);
  326. m_pStage6Layout->setWidget(5, QFormLayout::FieldRole, m_pPTZPanReversed);
  327. m_pPTZPanStartBox = new QDoubleSpinBox();
  328. m_pPTZPanStartBox->setMaximum(360);
  329. m_pPTZPanStartBox->setMinimum(-360);
  330. m_pPTZPanStartBox->setValue(0);
  331. m_pStage6Layout->setWidget(6, QFormLayout::FieldRole, m_pPTZPanStartBox);
  332. m_pPTZPanEndBox = new QDoubleSpinBox();
  333. m_pPTZPanEndBox->setMaximum(360);
  334. m_pPTZPanEndBox->setMinimum(-360);
  335. m_pPTZPanEndBox->setValue(360);
  336. m_pStage6Layout->setWidget(7, QFormLayout::FieldRole, m_pPTZPanEndBox);
  337. m_pPTZTiltEna = new QCheckBox();
  338. m_pPTZTiltEna->setText("Enable Tilt Control");
  339. m_pStage6Layout->setWidget(8, QFormLayout::FieldRole, m_pPTZTiltEna);
  340. m_pPTZTiltReversed = new QCheckBox();
  341. m_pPTZTiltReversed->setText("Reverse Tilt Control");
  342. m_pStage6Layout->setWidget(9, QFormLayout::FieldRole, m_pPTZTiltReversed);
  343. m_pPTZTiltStartBox = new QDoubleSpinBox();
  344. m_pPTZTiltStartBox->setMinimum(-90);
  345. m_pPTZTiltStartBox->setMaximum(90);
  346. m_pPTZTiltStartBox->setValue(0);
  347. m_pStage6Layout->setWidget(10, QFormLayout::FieldRole, m_pPTZTiltStartBox);
  348. m_pPTZTiltEndBox = new QDoubleSpinBox();
  349. m_pPTZTiltEndBox->setMinimum(-90);
  350. m_pPTZTiltEndBox->setMaximum(90);
  351. m_pPTZTiltEndBox->setValue(90);
  352. m_pStage6Layout->setWidget(11, QFormLayout::FieldRole, m_pPTZTiltEndBox);
  353. m_pPTZZoomEna = new QCheckBox();
  354. m_pPTZZoomEna->setText("Enable Zoom Control");
  355. m_pStage6Layout->setWidget(12, QFormLayout::FieldRole, m_pPTZZoomEna);
  356. m_pPTZMaxZoomBox = new QDoubleSpinBox();
  357. m_pPTZMaxZoomBox->setMinimum(1);
  358. m_pPTZMaxZoomBox->setMaximum(64);
  359. m_pStage6Layout->setWidget(13, QFormLayout::FieldRole, m_pPTZMaxZoomBox);
  360. m_pPTZDZoomEna = new QCheckBox();
  361. m_pPTZDZoomEna->setText("Enable Digital Zoom");
  362. m_pStage6Layout->setWidget(14, QFormLayout::FieldRole, m_pPTZDZoomEna);
  363. m_pPTZMaxDZoomBox = new QSpinBox();
  364. m_pPTZMaxDZoomBox->setMinimum(1);
  365. m_pPTZMaxDZoomBox->setMaximum(10);
  366. m_pStage6Layout->setWidget(15, QFormLayout::FieldRole, m_pPTZMaxDZoomBox);
  367. m_pPage6->setLayout(m_pStage6Layout);
  368. m_pDialogTabWidget->addTab(m_pPage6, QString("PTZ Controll"));
  369. /* Business Logic */
  370. m_pDialogTabWidget->setTabEnabled(3, false);
  371. m_pDialogTabWidget->setTabEnabled(4, false);
  372. m_pDialogTabWidget->setTabEnabled(5, false);
  373. m_nAddSourceDialogStage = 0;
  374. };
  375. guiAddSourceDialog::~guiAddSourceDialog(){
  376. if (m_pSourcePreviewInput != NULL){
  377. delete(m_pSourcePreviewInput);
  378. m_pSourcePreviewInput = NULL;
  379. };
  380. if (m_pSourcePreview != NULL){
  381. m_pSourcePreview->setError(true);
  382. delete(m_pSourcePreview);
  383. m_pSourcePreview = NULL;
  384. };
  385. delete ui;
  386. };
  387. #ifndef NO_ONVIF_CAMERAS
  388. void guiAddSourceDialog::showOnvifObserverDialog(void){
  389. if (m_pOnvifObserver == NULL){
  390. m_pOnvifObserver = new OnvifSourceFinderDialog(this);
  391. };
  392. if (m_pOnvifObserver != NULL){
  393. m_pOnvifObserver->show();
  394. };
  395. };
  396. #endif
  397. void guiAddSourceDialog::setDialogStage(uint8_t Stage){
  398. m_nAddSourceDialogStage = Stage;
  399. m_pDialogTabWidget->setCurrentIndex(m_nAddSourceDialogStage);
  400. };
  401. void guiAddSourceDialog::nextDialogStage(void){
  402. switch (m_nAddSourceDialogStage){
  403. case 0:{
  404. m_sTemporarySource.type = m_pDeviceTypeCombo->currentIndex();
  405. m_sTemporarySource.subtype = m_pSourceTypeCombo->currentIndex();
  406. switch (m_sTemporarySource.type){
  407. case 0:setDialogStage(1); break;
  408. case 1:setDialogStage(2); break;
  409. case 2:setDialogStage(0); break;
  410. };
  411. repaint();
  412. break;
  413. };
  414. };
  415. };
  416. void guiAddSourceDialog::turnOnVideo(void){
  417. if (m_pSourcePreviewInput != NULL){
  418. //m_pSourcePreview->setError(true);
  419. delete(m_pSourcePreviewInput);
  420. };
  421. //if (m_pVideoBus == NULL){
  422. // m_pVideoBus = new mediaBus();
  423. //};
  424. #ifdef __linux__
  425. sprintf(m_sTemporarySource.devicePath, "/dev/video0");
  426. #else
  427. sprintf(m_sTemporarySource.devicePath, "video=%s", m_pSourceManager->getLocalSourceInfo(m_sTemporarySource.deviceId)->FriendlyName);
  428. #endif
  429. m_pSourcePreviewInput = new videoAVLIBSource();
  430. if (m_pSourcePreviewInput->_open(m_sTemporarySource.devicePath,
  431. m_bTUseDeviceMenu,
  432. m_sTemporarySource.framerate,
  433. m_sTemporarySource.capturePin,
  434. m_pSourceManager->getStandardWidth(m_sTemporarySource.frameIsWide, m_sTemporarySource.sizeId),
  435. m_pSourceManager->getStandardHeight(m_sTemporarySource.frameIsWide, m_sTemporarySource.sizeId)
  436. )){
  437. m_pSourcePreviewInput->attachDestination(m_pSourcePreview);
  438. m_pSourcePreviewInput->setStreaming(true);
  439. m_pSourcePreview->setError(false);
  440. }
  441. else {
  442. m_pSourcePreview->setError(true, "Problems with parameters");
  443. };
  444. };
  445. void guiAddSourceDialog::setPreviewLocalSource(int index){
  446. m_sTemporarySource.deviceId = index;
  447. turnOnVideo();
  448. };
  449. void guiAddSourceDialog::setResolution(int index){
  450. m_sTemporarySource.sizeId = index;
  451. turnOnVideo();
  452. };
  453. void guiAddSourceDialog::setInputPin(int index){
  454. m_sTemporarySource.capturePin = index;
  455. turnOnVideo();
  456. };
  457. void guiAddSourceDialog::setProportions4(bool ch){
  458. m_sTemporarySource.sizeId = 0;
  459. if (ch){
  460. m_sTemporarySource.frameIsWide = false;
  461. m_pDeviceResolutionCombo->clear();
  462. for (int i = 0; i < 9; i++){
  463. m_pDeviceResolutionCombo->addItem(QString(m_pSourceManager->getStandardSize(m_sTemporarySource.frameIsWide, i)), i);
  464. };
  465. m_pDeviceResolutionCombo->setCurrentIndex(m_sTemporarySource.sizeId);
  466. }
  467. else {
  468. m_sTemporarySource.frameIsWide = true;
  469. m_pDeviceResolutionCombo->clear();
  470. for (int i = 0; i < 9; i++){
  471. m_pDeviceResolutionCombo->addItem(QString(m_pSourceManager->getStandardSize(m_sTemporarySource.frameIsWide, i)), i);
  472. };
  473. m_pDeviceResolutionCombo->setCurrentIndex(m_sTemporarySource.sizeId);
  474. };
  475. turnOnVideo();
  476. };
  477. void guiAddSourceDialog::setProportions16(bool ch){
  478. m_sTemporarySource.sizeId = 0;
  479. if (ch){
  480. m_sTemporarySource.frameIsWide = true;
  481. m_pDeviceResolutionCombo->clear();
  482. for (int i = 0; i < 9; i++){
  483. m_pDeviceResolutionCombo->addItem(QString(m_pSourceManager->getStandardSize(m_sTemporarySource.frameIsWide, i)), i);
  484. };
  485. m_pDeviceResolutionCombo->setCurrentIndex(m_sTemporarySource.sizeId);
  486. }
  487. else {
  488. m_sTemporarySource.frameIsWide = false;
  489. m_pDeviceResolutionCombo->clear();
  490. for (int i = 0; i < 9; i++){
  491. m_pDeviceResolutionCombo->addItem(QString(m_pSourceManager->getStandardSize(m_sTemporarySource.frameIsWide, i)), i);
  492. };
  493. m_pDeviceResolutionCombo->setCurrentIndex(m_sTemporarySource.sizeId);
  494. };
  495. turnOnVideo();
  496. };
  497. void guiAddSourceDialog::showDeviceSettings(void){
  498. m_bTUseDeviceMenu = true;
  499. turnOnVideo();
  500. m_bTUseDeviceMenu = false;
  501. };
  502. /*
  503. m_pDeviceTypeCombo->addItem(QString("Static Camera"), 0);
  504. m_pDeviceTypeCombo->addItem(QString("Extended Static Camera"), 1);
  505. m_pDeviceTypeCombo->addItem(QString("Extended Static Camera + Zoom"), 2);
  506. m_pDeviceTypeCombo->addItem(QString("PTZ Camera"), 3);
  507. */
  508. void guiAddSourceDialog::setSourceType(int index){
  509. m_sTemporarySource.subtype = index;
  510. switch (index){
  511. case 0:{
  512. m_pDialogTabWidget->setTabEnabled(2, true);
  513. m_pDialogTabWidget->setTabEnabled(3, false);
  514. break;
  515. };
  516. case 1:{
  517. m_pDialogTabWidget->setTabEnabled(3, true);
  518. m_pDialogTabWidget->setTabEnabled(2, false);
  519. break;
  520. };
  521. case 2:{
  522. m_pDialogTabWidget->setTabEnabled(2, false);
  523. m_pDialogTabWidget->setTabEnabled(3, false);
  524. break;
  525. };
  526. };
  527. };
  528. void guiAddSourceDialog::setCameraType(int index){
  529. m_sTemporarySource.type = index;
  530. switch (index){
  531. case 0:{
  532. m_pDialogTabWidget->setTabEnabled(4, false);
  533. m_pDialogTabWidget->setTabEnabled(5, false);
  534. m_pPTZProtocolCombo->setEnabled(false);
  535. m_pPTZProtocolLabel->setEnabled(false);
  536. m_pPTZComPortLabel->setEnabled(false);
  537. m_pPTZComSpeedLabel->setEnabled(false);
  538. m_pPTZCamIDLabel->setEnabled(false);
  539. m_pPTZComPortCombo->setEnabled(false);
  540. m_pPTZComSpeedBox->setEnabled(false);
  541. m_pPTZCamIDBox->setEnabled(false);
  542. m_pPTZPanEna->setChecked(false);
  543. m_pPTZPanEna->setEnabled(false);
  544. m_pPTZTiltEna->setChecked(false);
  545. m_pPTZTiltEna->setEnabled(false);
  546. m_pPTZZoomEna->setChecked(false);
  547. m_pPTZZoomEna->setEnabled(false);
  548. m_pPTZDZoomEna->setChecked(false);
  549. m_pPTZDZoomEna->setEnabled(false);
  550. break;
  551. };
  552. case 1:{
  553. m_pDialogTabWidget->setTabEnabled(4, true);
  554. m_pDialogTabWidget->setTabEnabled(5, false);
  555. m_pPTZProtocolCombo->setEnabled(false);
  556. m_pPTZProtocolLabel->setEnabled(false);
  557. m_pPTZComPortLabel->setEnabled(false);
  558. m_pPTZComSpeedLabel->setEnabled(false);
  559. m_pPTZCamIDLabel->setEnabled(false);
  560. m_pPTZComPortCombo->setEnabled(false);
  561. m_pPTZComSpeedBox->setEnabled(false);
  562. m_pPTZCamIDBox->setEnabled(false);
  563. m_pPTZPanEna->setChecked(false);
  564. m_pPTZPanEna->setEnabled(false);
  565. m_pPTZTiltEna->setChecked(false);
  566. m_pPTZTiltEna->setEnabled(false);
  567. m_pPTZZoomEna->setChecked(false);
  568. m_pPTZZoomEna->setEnabled(false);
  569. m_pPTZDZoomEna->setChecked(false);
  570. m_pPTZDZoomEna->setEnabled(false);
  571. break;
  572. };
  573. case 2:{
  574. m_pDialogTabWidget->setTabEnabled(4, true);
  575. m_pDialogTabWidget->setTabEnabled(5, true);
  576. m_pPTZProtocolCombo->setEnabled(true);
  577. m_pPTZProtocolLabel->setEnabled(true);
  578. m_pPTZComPortLabel->setEnabled(true);
  579. m_pPTZComSpeedLabel->setEnabled(true);
  580. m_pPTZCamIDLabel->setEnabled(true);
  581. m_pPTZComPortCombo->setEnabled(true);
  582. m_pPTZComSpeedBox->setEnabled(true);
  583. m_pPTZCamIDBox->setEnabled(true);
  584. m_pPTZPanEna->setChecked(false);
  585. m_pPTZPanEna->setEnabled(false);
  586. m_pPTZTiltEna->setChecked(false);
  587. m_pPTZTiltEna->setEnabled(false);
  588. m_pPTZZoomEna->setChecked(true);
  589. m_pPTZZoomEna->setEnabled(true);
  590. m_pPTZDZoomEna->setChecked(true);
  591. m_pPTZDZoomEna->setEnabled(true);
  592. break;
  593. };
  594. case 3:{
  595. m_pDialogTabWidget->setTabEnabled(4, true);
  596. m_pDialogTabWidget->setTabEnabled(5, true);
  597. m_pPTZProtocolCombo->setEnabled(true);
  598. m_pPTZProtocolLabel->setEnabled(true);
  599. m_pPTZComPortLabel->setEnabled(true);
  600. m_pPTZComSpeedLabel->setEnabled(true);
  601. m_pPTZCamIDLabel->setEnabled(true);
  602. m_pPTZComPortCombo->setEnabled(true);
  603. m_pPTZComSpeedBox->setEnabled(true);
  604. m_pPTZCamIDBox->setEnabled(true);
  605. m_pPTZPanEna->setChecked(true);
  606. m_pPTZPanEna->setEnabled(true);
  607. m_pPTZTiltEna->setChecked(true);
  608. m_pPTZTiltEna->setEnabled(true);
  609. m_pPTZZoomEna->setChecked(true);
  610. m_pPTZZoomEna->setEnabled(true);
  611. m_pPTZDZoomEna->setChecked(true);
  612. m_pPTZDZoomEna->setEnabled(true);
  613. break;
  614. };
  615. };
  616. };
  617. void guiAddSourceDialog::setStrechMode(bool mode){
  618. m_bTScaled = mode;
  619. m_pScaledResolutionCombo->setEnabled(m_bTScaled);
  620. if (m_bTScaled){
  621. } else {
  622. };
  623. };
  624. void guiAddSourceDialog::cancelDialog(void){
  625. hide();
  626. };
  627. void guiAddSourceDialog::addSource(void){
  628. if (m_pSourcePreviewInput != NULL){
  629. delete(m_pSourcePreviewInput);
  630. m_pSourcePreviewInput = NULL;
  631. };
  632. if (m_pSourcePreview != NULL){
  633. m_pSourcePreview->setError(true);
  634. };
  635. m_pParent->createNew( &m_sTemporarySource );
  636. hide();
  637. };
  638. void guiAddSourceDialog::setNetworkSourcePath(CSTR Path, CSTR device, CSTR user, CSTR pass ){
  639. if( device!= NULL ){
  640. sprintf( m_sTemporarySource.onvifDeviceURI, "%s", device );
  641. } else {
  642. memset( m_sTemporarySource.onvifDeviceURI, 0 , MAX_PATH_LEN );
  643. };
  644. if( user!= NULL ){
  645. sprintf( m_sTemporarySource.onvifUser, "%s", user );
  646. } else {
  647. memset( m_sTemporarySource.onvifUser, 0 , MAX_CRED_LEN );
  648. };
  649. if( pass!= NULL ){
  650. sprintf( m_sTemporarySource.onvifPassword, "%s", pass );
  651. } else {
  652. memset( m_sTemporarySource.onvifPassword, 0 , MAX_CRED_LEN );
  653. };
  654. sprintf(m_sTemporarySource.devicePath, "%s", Path);
  655. m_pLineText->setText(m_sTemporarySource.devicePath);
  656. };
  657. void guiAddSourceDialog::setPTZProto(int index){
  658. m_sTemporarySource.protocolId = index+1;
  659. switch (index){
  660. case 0:{
  661. m_pPTZComPortLabel->setEnabled(true);
  662. m_pPTZComSpeedLabel->setEnabled(true);
  663. m_pPTZCamIDLabel->setEnabled(true);
  664. m_pPTZComPortCombo->setEnabled(true);
  665. m_pPTZComSpeedBox->setEnabled(true);
  666. m_pPTZComSpeedBox->setValue(9600);
  667. m_sTemporarySource.comTransportSpeed = 9600;
  668. m_pPTZCamIDBox->setEnabled(true);
  669. m_pPTZCamIDBox->setValue(1);
  670. break;
  671. };
  672. case 1:{
  673. m_pPTZComPortLabel->setEnabled(true);
  674. m_pPTZComSpeedLabel->setEnabled(true);
  675. m_pPTZCamIDLabel->setEnabled(true);
  676. m_pPTZComPortCombo->setEnabled(true);
  677. m_pPTZComSpeedBox->setEnabled(true);
  678. m_pPTZComSpeedBox->setValue(2400);
  679. m_sTemporarySource.comTransportSpeed = 2400;
  680. m_pPTZCamIDBox->setEnabled(true);
  681. m_pPTZCamIDBox->setValue(2);
  682. break;
  683. };
  684. case 2:{
  685. m_pPTZComPortLabel->setEnabled(false);
  686. m_pPTZComSpeedLabel->setEnabled(false);
  687. m_pPTZCamIDLabel->setEnabled(false);
  688. m_pPTZComPortCombo->setEnabled(false);
  689. m_pPTZComSpeedBox->setEnabled(false);
  690. m_pPTZCamIDBox->setEnabled(false);
  691. break;
  692. };
  693. };
  694. };
  695. void guiAddSourceDialog::setPTZComPort(int index){
  696. };
  697. void guiAddSourceDialog::setColorSystem(int){
  698. };