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.

770 lines
27 KiB

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