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.

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