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.

758 lines
28 KiB

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