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.

774 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. m_pPage1 = new QWidget();
  209. m_pPage1->setLayout(m_pStage1Layout);
  210. m_pDialogTabWidget->addTab(m_pPage1, QString("Camera Type"));
  211. /* Layout 2 */
  212. m_pStage2Layout = new QVBoxLayout();
  213. m_pPage2 = new QWidget();
  214. m_pPage2->setLayout(m_pStage2Layout);
  215. m_pDialogTabWidget->addTab(m_pPage2, QString("Location"));
  216. /* Layout 3 */
  217. m_pStage3Layout = new QVBoxLayout();
  218. verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
  219. horizontalSpacer = new QSpacerItem(20, 40, QSizePolicy::Expanding, QSizePolicy::Minimum);
  220. m_pS2VMLayout = new QVBoxLayout();
  221. m_pS2VMLayout->addWidget(m_pLocalDevicesCombo);
  222. m_pS2VMLayout->addWidget(m_pInputPinCombo);
  223. m_pS2VMLayout->addWidget(m_pButtonCmdShowDeviceSettings);
  224. m_pS2VMLayout->addWidget(m_p16x9resolution);
  225. m_pS2VMLayout->addWidget(m_p4x3resolution);
  226. m_pS2VMLayout->addWidget(m_pDeviceResolutionCombo);
  227. m_pS2VMLayout->addWidget(m_pScalePicture);
  228. m_pS2VMLayout->addWidget(m_pScaledResolutionCombo);
  229. m_pS2HMLayout = new QHBoxLayout();
  230. m_pS2HMLayout->addWidget(m_pSourcePreview);
  231. m_pS2HMLayout->addItem(m_pS2VMLayout);
  232. m_pStage3Layout->addItem(m_pS2HMLayout);
  233. m_pStage3Layout->addItem(verticalSpacer);
  234. m_pPage3 = new QWidget();
  235. m_pPage3->setLayout(m_pStage3Layout);
  236. m_pDialogTabWidget->addTab(m_pPage3, QString("Local Source"));
  237. /* Layout 4 */
  238. m_pStage4Layout = new QVBoxLayout();
  239. #ifndef NO_ONVIF_CAMERAS
  240. m_pButtonCmdStartOnvif = new QPushButton();
  241. m_pButtonCmdStartOnvif->setText("Start ONVIF Observer");
  242. connect(m_pButtonCmdStartOnvif, &QPushButton::clicked, this, &guiAddSourceDialog::showOnvifObserverDialog);
  243. m_pLineText = new QLineEdit(this);
  244. //m_pPlainTextEdit->setObjectName(QString::fromUtf8("plainTextEdit"));
  245. //m_pPlainTextEdit->setGeometry(QRect(40, 50, 301, 27));
  246. m_pLineText->setMinimumSize(QSize(0, 27));
  247. m_pLineText->setMaximumSize(QSize(16777215, 27));
  248. m_pStage4Layout->addWidget(m_pButtonCmdStartOnvif);
  249. m_pStage4Layout->addWidget(m_pLineText);
  250. //m_pNetSourcePreview = new VideoThumbWidget();
  251. //m_pNetSourcePreview->setError(true, "");
  252. //m_pNetSourcePreview->init();
  253. //m_pStage4Layout->addWidget(m_pNetSourcePreview);
  254. #endif
  255. QSpacerItem *tSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
  256. m_pStage4Layout->addItem(tSpacer);
  257. m_pPage4 = new QWidget();
  258. m_pPage4->setLayout(m_pStage4Layout);
  259. m_pDialogTabWidget->addTab(m_pPage4, QString("Network Source"));
  260. /* Layout 5 */
  261. m_pPage5 = new QWidget();
  262. //m_pPage5->setLayout(m_pStage3Layout);
  263. m_pDialogTabWidget->addTab(m_pPage5, QString("Lens/Image Settings"));
  264. /* Layout 6 */
  265. m_pPage6 = new QWidget();
  266. m_pStage6Layout = new QFormLayout();
  267. m_pPTZProtocolLabel = new QLabel();
  268. #ifndef NO_PTZ_CAMERAS
  269. m_pPTZProtocolLabel->setText(QString("PTZ Protocol:"));
  270. m_pStage6Layout->setWidget(0, QFormLayout::LabelRole, m_pPTZProtocolLabel);
  271. m_pPTZProtocolCombo = new QComboBox();
  272. m_pPTZProtocolCombo->addItem(QString("SONY VISCA"), 0);
  273. m_pPTZProtocolCombo->addItem(QString("PELCO-D"), 1);
  274. #ifndef NO_ONVIF_CAMERAS
  275. m_pPTZProtocolCombo->addItem(QString("OnVif PTZ"), 2);
  276. #endif
  277. m_sTemporarySource.protocolId = 1;
  278. m_pPTZProtocolCombo->setCurrentIndex( m_sTemporarySource.protocolId - 1 );
  279. connect(m_pPTZProtocolCombo,
  280. static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
  281. this,
  282. &guiAddSourceDialog::setPTZProto);
  283. m_pStage6Layout->setWidget(0, QFormLayout::FieldRole, m_pPTZProtocolCombo);
  284. #endif
  285. m_pPTZComPortLabel = new QLabel();
  286. m_pPTZComPortLabel->setText(QString("Serial Port:"));
  287. m_pStage6Layout->setWidget(1, QFormLayout::LabelRole, m_pPTZComPortLabel);
  288. m_pPTZComPortCombo = new QComboBox();
  289. for (int juju = 0; juju < 26; juju++){
  290. char tbuf[24];
  291. sprintf(tbuf, "COM%d", juju+1);
  292. m_pPTZComPortCombo->addItem(QString(tbuf), juju);
  293. };
  294. sprintf(m_sTemporarySource.comTransportPath,"COM1");
  295. m_sTemporarySource.comTransportPort = 1;
  296. m_pPTZComPortCombo->setCurrentIndex(m_sTemporarySource.comTransportPort-1);
  297. connect(m_pPTZComPortCombo,
  298. static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
  299. this,
  300. &guiAddSourceDialog::setPTZComPort);
  301. m_pStage6Layout->setWidget(1, QFormLayout::FieldRole, m_pPTZComPortCombo);
  302. m_pPTZComSpeedLabel = new QLabel();
  303. m_pPTZComSpeedLabel->setText(QString("Serial Port Speed:"));
  304. m_pStage6Layout->setWidget(2, QFormLayout::LabelRole, m_pPTZComSpeedLabel);
  305. m_pPTZComSpeedBox = new QSpinBox();
  306. m_pPTZComSpeedBox->setMinimum(2400);
  307. m_pPTZComSpeedBox->setSingleStep(2400);
  308. m_pPTZComSpeedBox->setMaximum(115200);
  309. m_sTemporarySource.comTransportSpeed = 9600;
  310. m_pPTZComSpeedBox->setValue(m_sTemporarySource.comTransportSpeed);
  311. m_pStage6Layout->setWidget(2, QFormLayout::FieldRole, m_pPTZComSpeedBox);
  312. m_pPTZCamIDLabel = new QLabel();
  313. m_pPTZCamIDLabel->setText(QString("Protocol Camera ID:"));
  314. m_pStage6Layout->setWidget(3, QFormLayout::LabelRole, m_pPTZCamIDLabel);
  315. m_pPTZCamIDBox = new QSpinBox();
  316. m_pStage6Layout->setWidget(3, QFormLayout::FieldRole, m_pPTZCamIDBox);
  317. m_sTemporarySource.protocolParameter = 1;
  318. m_pPTZPanEna = new QCheckBox();
  319. m_pPTZPanEna->setText("Enable Pan Control");
  320. m_pStage6Layout->setWidget(4, QFormLayout::FieldRole, m_pPTZPanEna);
  321. m_pPTZPanReversed = new QCheckBox();
  322. m_pPTZPanReversed->setText("Reverse Pan Control");
  323. m_sTemporarySource.bPanReverse = false;
  324. m_pPTZPanReversed->setChecked(m_sTemporarySource.bPanReverse);
  325. m_pStage6Layout->setWidget(5, QFormLayout::FieldRole, m_pPTZPanReversed);
  326. m_pPTZPanStartBox = new QDoubleSpinBox();
  327. m_pPTZPanStartBox->setMaximum(360);
  328. m_pPTZPanStartBox->setMinimum(-360);
  329. m_pPTZPanStartBox->setValue(0);
  330. m_pStage6Layout->setWidget(6, QFormLayout::FieldRole, m_pPTZPanStartBox);
  331. m_pPTZPanEndBox = new QDoubleSpinBox();
  332. m_pPTZPanEndBox->setMaximum(360);
  333. m_pPTZPanEndBox->setMinimum(-360);
  334. m_pPTZPanEndBox->setValue(360);
  335. m_pStage6Layout->setWidget(7, QFormLayout::FieldRole, m_pPTZPanEndBox);
  336. m_pPTZTiltEna = new QCheckBox();
  337. m_pPTZTiltEna->setText("Enable Tilt Control");
  338. m_pStage6Layout->setWidget(8, QFormLayout::FieldRole, m_pPTZTiltEna);
  339. m_pPTZTiltReversed = new QCheckBox();
  340. m_pPTZTiltReversed->setText("Reverse Tilt Control");
  341. m_pStage6Layout->setWidget(9, QFormLayout::FieldRole, m_pPTZTiltReversed);
  342. m_pPTZTiltStartBox = new QDoubleSpinBox();
  343. m_pPTZTiltStartBox->setMinimum(-90);
  344. m_pPTZTiltStartBox->setMaximum(90);
  345. m_pPTZTiltStartBox->setValue(0);
  346. m_pStage6Layout->setWidget(10, QFormLayout::FieldRole, m_pPTZTiltStartBox);
  347. m_pPTZTiltEndBox = new QDoubleSpinBox();
  348. m_pPTZTiltEndBox->setMinimum(-90);
  349. m_pPTZTiltEndBox->setMaximum(90);
  350. m_pPTZTiltEndBox->setValue(90);
  351. m_pStage6Layout->setWidget(11, QFormLayout::FieldRole, m_pPTZTiltEndBox);
  352. m_pPTZZoomEna = new QCheckBox();
  353. m_pPTZZoomEna->setText("Enable Zoom Control");
  354. m_pStage6Layout->setWidget(12, QFormLayout::FieldRole, m_pPTZZoomEna);
  355. m_pPTZMaxZoomBox = new QDoubleSpinBox();
  356. m_pPTZMaxZoomBox->setMinimum(1);
  357. m_pPTZMaxZoomBox->setMaximum(64);
  358. m_pStage6Layout->setWidget(13, QFormLayout::FieldRole, m_pPTZMaxZoomBox);
  359. m_pPTZDZoomEna = new QCheckBox();
  360. m_pPTZDZoomEna->setText("Enable Digital Zoom");
  361. m_pStage6Layout->setWidget(14, QFormLayout::FieldRole, m_pPTZDZoomEna);
  362. m_pPTZMaxDZoomBox = new QSpinBox();
  363. m_pPTZMaxDZoomBox->setMinimum(1);
  364. m_pPTZMaxDZoomBox->setMaximum(10);
  365. m_pStage6Layout->setWidget(15, QFormLayout::FieldRole, m_pPTZMaxDZoomBox);
  366. m_pPage6->setLayout(m_pStage6Layout);
  367. m_pDialogTabWidget->addTab(m_pPage6, QString("PTZ Controll"));
  368. /* Business Logic */
  369. m_pDialogTabWidget->setTabEnabled(3, false);
  370. m_pDialogTabWidget->setTabEnabled(4, false);
  371. m_pDialogTabWidget->setTabEnabled(5, false);
  372. m_nAddSourceDialogStage = 0;
  373. };
  374. guiAddSourceDialog::~guiAddSourceDialog(){
  375. if (m_pSourcePreviewInput != NULL){
  376. delete(m_pSourcePreviewInput);
  377. m_pSourcePreviewInput = NULL;
  378. };
  379. if (m_pSourcePreview != NULL){
  380. m_pSourcePreview->setError(true);
  381. delete(m_pSourcePreview);
  382. m_pSourcePreview = NULL;
  383. };
  384. delete ui;
  385. };
  386. #ifndef NO_ONVIF_CAMERAS
  387. void guiAddSourceDialog::showOnvifObserverDialog(void){
  388. if (m_pOnvifObserver == NULL){
  389. m_pOnvifObserver = new OnvifSourceFinderDialog(this);
  390. };
  391. if (m_pOnvifObserver != NULL){
  392. m_pOnvifObserver->show();
  393. };
  394. };
  395. #endif
  396. void guiAddSourceDialog::setDialogStage(uint8_t Stage){
  397. m_nAddSourceDialogStage = Stage;
  398. m_pDialogTabWidget->setCurrentIndex(m_nAddSourceDialogStage);
  399. };
  400. void guiAddSourceDialog::nextDialogStage(void){
  401. switch (m_nAddSourceDialogStage){
  402. case 0:{
  403. m_sTemporarySource.type = m_pDeviceTypeCombo->currentIndex();
  404. m_sTemporarySource.subtype = m_pSourceTypeCombo->currentIndex();
  405. switch (m_sTemporarySource.type){
  406. case 0:setDialogStage(1); break;
  407. case 1:setDialogStage(2); break;
  408. case 2:setDialogStage(0); break;
  409. };
  410. repaint();
  411. break;
  412. };
  413. };
  414. };
  415. void guiAddSourceDialog::turnOnVideo(void){
  416. if (m_pSourcePreviewInput != NULL){
  417. //m_pSourcePreview->setError(true);
  418. delete(m_pSourcePreviewInput);
  419. };
  420. //if (m_pVideoBus == NULL){
  421. // m_pVideoBus = new mediaBus();
  422. //};
  423. #ifdef __linux__
  424. sprintf(m_sTemporarySource.devicePath, "/dev/video0");
  425. #else
  426. sprintf(m_sTemporarySource.devicePath, "video=%s", m_pSourceManager->getLocalSourceInfo(m_sTemporarySource.deviceId)->FriendlyName);
  427. #endif
  428. m_pSourcePreviewInput = new videoAVLIBSource();
  429. if (m_pSourcePreviewInput->_open(m_sTemporarySource.devicePath,
  430. m_bTUseDeviceMenu,
  431. m_sTemporarySource.framerate,
  432. m_sTemporarySource.capturePin,
  433. m_pSourceManager->getStandardWidth(m_sTemporarySource.frameIsWide, m_sTemporarySource.sizeId),
  434. m_pSourceManager->getStandardHeight(m_sTemporarySource.frameIsWide, m_sTemporarySource.sizeId)
  435. )){
  436. m_pSourcePreviewInput->attachDestination(m_pSourcePreview);
  437. m_pSourcePreviewInput->setStreaming(true);
  438. m_pSourcePreview->setError(false);
  439. }
  440. else {
  441. m_pSourcePreview->setError(true, "Problems with parameters");
  442. };
  443. };
  444. void guiAddSourceDialog::setPreviewLocalSource(int index){
  445. m_sTemporarySource.deviceId = index;
  446. turnOnVideo();
  447. };
  448. void guiAddSourceDialog::setResolution(int index){
  449. m_sTemporarySource.sizeId = index;
  450. turnOnVideo();
  451. };
  452. void guiAddSourceDialog::setInputPin(int index){
  453. m_sTemporarySource.capturePin = index;
  454. turnOnVideo();
  455. };
  456. void guiAddSourceDialog::setProportions4(bool ch){
  457. m_sTemporarySource.sizeId = 0;
  458. if (ch){
  459. m_sTemporarySource.frameIsWide = false;
  460. m_pDeviceResolutionCombo->clear();
  461. for (int i = 0; i < 9; i++){
  462. m_pDeviceResolutionCombo->addItem(QString(m_pSourceManager->getStandardSize(m_sTemporarySource.frameIsWide, i)), i);
  463. };
  464. m_pDeviceResolutionCombo->setCurrentIndex(m_sTemporarySource.sizeId);
  465. }
  466. else {
  467. m_sTemporarySource.frameIsWide = true;
  468. m_pDeviceResolutionCombo->clear();
  469. for (int i = 0; i < 9; i++){
  470. m_pDeviceResolutionCombo->addItem(QString(m_pSourceManager->getStandardSize(m_sTemporarySource.frameIsWide, i)), i);
  471. };
  472. m_pDeviceResolutionCombo->setCurrentIndex(m_sTemporarySource.sizeId);
  473. };
  474. turnOnVideo();
  475. };
  476. void guiAddSourceDialog::setProportions16(bool ch){
  477. m_sTemporarySource.sizeId = 0;
  478. if (ch){
  479. m_sTemporarySource.frameIsWide = true;
  480. m_pDeviceResolutionCombo->clear();
  481. for (int i = 0; i < 9; i++){
  482. m_pDeviceResolutionCombo->addItem(QString(m_pSourceManager->getStandardSize(m_sTemporarySource.frameIsWide, i)), i);
  483. };
  484. m_pDeviceResolutionCombo->setCurrentIndex(m_sTemporarySource.sizeId);
  485. }
  486. else {
  487. m_sTemporarySource.frameIsWide = false;
  488. m_pDeviceResolutionCombo->clear();
  489. for (int i = 0; i < 9; i++){
  490. m_pDeviceResolutionCombo->addItem(QString(m_pSourceManager->getStandardSize(m_sTemporarySource.frameIsWide, i)), i);
  491. };
  492. m_pDeviceResolutionCombo->setCurrentIndex(m_sTemporarySource.sizeId);
  493. };
  494. turnOnVideo();
  495. };
  496. void guiAddSourceDialog::showDeviceSettings(void){
  497. m_bTUseDeviceMenu = true;
  498. turnOnVideo();
  499. m_bTUseDeviceMenu = false;
  500. };
  501. /*
  502. m_pDeviceTypeCombo->addItem(QString("Static Camera"), 0);
  503. m_pDeviceTypeCombo->addItem(QString("Extended Static Camera"), 1);
  504. m_pDeviceTypeCombo->addItem(QString("Extended Static Camera + Zoom"), 2);
  505. m_pDeviceTypeCombo->addItem(QString("PTZ Camera"), 3);
  506. */
  507. void guiAddSourceDialog::setSourceType(int index){
  508. m_sTemporarySource.subtype = index;
  509. switch (index){
  510. case 0:{
  511. m_pDialogTabWidget->setTabEnabled(2, true);
  512. m_pDialogTabWidget->setTabEnabled(3, false);
  513. break;
  514. };
  515. case 1:{
  516. m_pDialogTabWidget->setTabEnabled(3, true);
  517. m_pDialogTabWidget->setTabEnabled(2, false);
  518. break;
  519. };
  520. case 2:{
  521. m_pDialogTabWidget->setTabEnabled(2, false);
  522. m_pDialogTabWidget->setTabEnabled(3, false);
  523. break;
  524. };
  525. };
  526. };
  527. void guiAddSourceDialog::setCameraType(int index){
  528. m_sTemporarySource.type = index;
  529. switch (index){
  530. case 0:{
  531. m_pDialogTabWidget->setTabEnabled(4, false);
  532. m_pDialogTabWidget->setTabEnabled(5, false);
  533. m_pPTZProtocolCombo->setEnabled(false);
  534. m_pPTZProtocolLabel->setEnabled(false);
  535. m_pPTZComPortLabel->setEnabled(false);
  536. m_pPTZComSpeedLabel->setEnabled(false);
  537. m_pPTZCamIDLabel->setEnabled(false);
  538. m_pPTZComPortCombo->setEnabled(false);
  539. m_pPTZComSpeedBox->setEnabled(false);
  540. m_pPTZCamIDBox->setEnabled(false);
  541. m_pPTZPanEna->setChecked(false);
  542. m_pPTZPanEna->setEnabled(false);
  543. m_pPTZTiltEna->setChecked(false);
  544. m_pPTZTiltEna->setEnabled(false);
  545. m_pPTZZoomEna->setChecked(false);
  546. m_pPTZZoomEna->setEnabled(false);
  547. m_pPTZDZoomEna->setChecked(false);
  548. m_pPTZDZoomEna->setEnabled(false);
  549. break;
  550. };
  551. case 1:{
  552. m_pDialogTabWidget->setTabEnabled(4, true);
  553. m_pDialogTabWidget->setTabEnabled(5, false);
  554. m_pPTZProtocolCombo->setEnabled(false);
  555. m_pPTZProtocolLabel->setEnabled(false);
  556. m_pPTZComPortLabel->setEnabled(false);
  557. m_pPTZComSpeedLabel->setEnabled(false);
  558. m_pPTZCamIDLabel->setEnabled(false);
  559. m_pPTZComPortCombo->setEnabled(false);
  560. m_pPTZComSpeedBox->setEnabled(false);
  561. m_pPTZCamIDBox->setEnabled(false);
  562. m_pPTZPanEna->setChecked(false);
  563. m_pPTZPanEna->setEnabled(false);
  564. m_pPTZTiltEna->setChecked(false);
  565. m_pPTZTiltEna->setEnabled(false);
  566. m_pPTZZoomEna->setChecked(false);
  567. m_pPTZZoomEna->setEnabled(false);
  568. m_pPTZDZoomEna->setChecked(false);
  569. m_pPTZDZoomEna->setEnabled(false);
  570. break;
  571. };
  572. case 2:{
  573. m_pDialogTabWidget->setTabEnabled(4, true);
  574. m_pDialogTabWidget->setTabEnabled(5, true);
  575. m_pPTZProtocolCombo->setEnabled(true);
  576. m_pPTZProtocolLabel->setEnabled(true);
  577. m_pPTZComPortLabel->setEnabled(true);
  578. m_pPTZComSpeedLabel->setEnabled(true);
  579. m_pPTZCamIDLabel->setEnabled(true);
  580. m_pPTZComPortCombo->setEnabled(true);
  581. m_pPTZComSpeedBox->setEnabled(true);
  582. m_pPTZCamIDBox->setEnabled(true);
  583. m_pPTZPanEna->setChecked(false);
  584. m_pPTZPanEna->setEnabled(false);
  585. m_pPTZTiltEna->setChecked(false);
  586. m_pPTZTiltEna->setEnabled(false);
  587. m_pPTZZoomEna->setChecked(true);
  588. m_pPTZZoomEna->setEnabled(true);
  589. m_pPTZDZoomEna->setChecked(true);
  590. m_pPTZDZoomEna->setEnabled(true);
  591. break;
  592. };
  593. case 3:{
  594. m_pDialogTabWidget->setTabEnabled(4, true);
  595. m_pDialogTabWidget->setTabEnabled(5, true);
  596. m_pPTZProtocolCombo->setEnabled(true);
  597. m_pPTZProtocolLabel->setEnabled(true);
  598. m_pPTZComPortLabel->setEnabled(true);
  599. m_pPTZComSpeedLabel->setEnabled(true);
  600. m_pPTZCamIDLabel->setEnabled(true);
  601. m_pPTZComPortCombo->setEnabled(true);
  602. m_pPTZComSpeedBox->setEnabled(true);
  603. m_pPTZCamIDBox->setEnabled(true);
  604. m_pPTZPanEna->setChecked(true);
  605. m_pPTZPanEna->setEnabled(true);
  606. m_pPTZTiltEna->setChecked(true);
  607. m_pPTZTiltEna->setEnabled(true);
  608. m_pPTZZoomEna->setChecked(true);
  609. m_pPTZZoomEna->setEnabled(true);
  610. m_pPTZDZoomEna->setChecked(true);
  611. m_pPTZDZoomEna->setEnabled(true);
  612. break;
  613. };
  614. };
  615. };
  616. void guiAddSourceDialog::setStrechMode(bool mode){
  617. m_bTScaled = mode;
  618. m_pScaledResolutionCombo->setEnabled(m_bTScaled);
  619. if (m_bTScaled){
  620. } else {
  621. };
  622. };
  623. void guiAddSourceDialog::cancelDialog(void){
  624. hide();
  625. };
  626. void guiAddSourceDialog::addSource(void){
  627. if (m_pSourcePreviewInput != NULL){
  628. delete(m_pSourcePreviewInput);
  629. m_pSourcePreviewInput = NULL;
  630. };
  631. if (m_pSourcePreview != NULL){
  632. m_pSourcePreview->setError(true);
  633. };
  634. m_pParent->createNew( &m_sTemporarySource );
  635. hide();
  636. };
  637. void guiAddSourceDialog::setNetworkSourcePath(CSTR Path, CSTR device, CSTR user, CSTR pass ){
  638. if( device!= NULL ){
  639. sprintf( m_sTemporarySource.onvifDeviceURI, "%s", device );
  640. } else {
  641. memset( m_sTemporarySource.onvifDeviceURI, 0 , MAX_PATH_LEN );
  642. };
  643. if( user!= NULL ){
  644. sprintf( m_sTemporarySource.onvifUser, "%s", user );
  645. } else {
  646. memset( m_sTemporarySource.onvifUser, 0 , MAX_CRED_LEN );
  647. };
  648. if( pass!= NULL ){
  649. sprintf( m_sTemporarySource.onvifPassword, "%s", pass );
  650. } else {
  651. memset( m_sTemporarySource.onvifPassword, 0 , MAX_CRED_LEN );
  652. };
  653. sprintf(m_sTemporarySource.devicePath, "%s", Path);
  654. m_pLineText->setText(m_sTemporarySource.devicePath);
  655. };
  656. void guiAddSourceDialog::setPTZProto(int index){
  657. m_sTemporarySource.protocolId = index+1;
  658. switch (index){
  659. case 0:{
  660. m_pPTZComPortLabel->setEnabled(true);
  661. m_pPTZComSpeedLabel->setEnabled(true);
  662. m_pPTZCamIDLabel->setEnabled(true);
  663. m_pPTZComPortCombo->setEnabled(true);
  664. m_pPTZComSpeedBox->setEnabled(true);
  665. m_pPTZComSpeedBox->setValue(9600);
  666. m_sTemporarySource.comTransportSpeed = 9600;
  667. m_pPTZCamIDBox->setEnabled(true);
  668. m_pPTZCamIDBox->setValue(1);
  669. break;
  670. };
  671. case 1:{
  672. m_pPTZComPortLabel->setEnabled(true);
  673. m_pPTZComSpeedLabel->setEnabled(true);
  674. m_pPTZCamIDLabel->setEnabled(true);
  675. m_pPTZComPortCombo->setEnabled(true);
  676. m_pPTZComSpeedBox->setEnabled(true);
  677. m_pPTZComSpeedBox->setValue(2400);
  678. m_sTemporarySource.comTransportSpeed = 2400;
  679. m_pPTZCamIDBox->setEnabled(true);
  680. m_pPTZCamIDBox->setValue(2);
  681. break;
  682. };
  683. case 2:{
  684. m_pPTZComPortLabel->setEnabled(false);
  685. m_pPTZComSpeedLabel->setEnabled(false);
  686. m_pPTZCamIDLabel->setEnabled(false);
  687. m_pPTZComPortCombo->setEnabled(false);
  688. m_pPTZComSpeedBox->setEnabled(false);
  689. m_pPTZCamIDBox->setEnabled(false);
  690. break;
  691. };
  692. };
  693. };
  694. void guiAddSourceDialog::setPTZComPort(int index){
  695. };
  696. void guiAddSourceDialog::setColorSystem(int){
  697. };