Hello to all, i need to develop an application that does VOIP call. In the same time, i need to send video capture from web cam to the callee.

I using pjlib for VOIP and QT for GUI.

http://nashruddin.com/Streaming_Open...k#introduction

I have this resources.

Do we need another thread for web cam frame grabber and one thread for voip calling ?

My task is to discover the callee IP using SIP URI register to public server. Then, i send the web cam to the calless' address.
How to discover IP after VOIP call of caller and callee ?

This is my final year project.

Please suggest the tool to use or idea to start.
I wonder does anyone do this before.
I plan to do this in Qt using QThread and QTcpSocket. Is this possible ? If yes, how to code ?

Qt Code:
  1. class InteractiveMultiTouchCommunicationSystem : public QMainWindow
  2. {
  3. private:
  4. Q_OBJECT
  5.  
  6. public:
  7. InteractiveMultiTouchCommunicationSystem(QWidget *parent = 0, Qt::WFlags flags = 0);
  8. ~InteractiveMultiTouchCommunicationSystem();
  9.  
  10. protected:
  11.  
  12. // Show Context Menu created by createStandardContextMenu();
  13. // Event paramenet used to identify where mouse position event generated
  14. // Implement KeyBoard shortcut Event
  15. void contextMenuEvent(QContextMenuEvent* );
  16.  
  17. //private SIGNAL:
  18.  
  19. //
  20.  
  21. // SLOT
  22. private slots:
  23.  
  24. // Main Slot
  25. void VOIPLogSlot();
  26. void VOIPCallRedialSlot();
  27. void VOIPCallRecordSlot();
  28. void VOIPCallRecordValidateSlot();
  29. void VOIPCallHoldSlot();
  30. void VOIPCallReInvite();
  31. void VOIPCallTransferSlot();
  32.  
  33. void VOIPConfigSlot();
  34.  
  35. void AddContactSlot();
  36. void DeleteContactSlot();
  37. void ManageContactSlot();
  38.  
  39. void VOIPHistorySlot();
  40.  
  41. void AboutSlot();
  42. void AboutQTSlot();
  43.  
  44.  
  45. // Slot for Child Widget
  46.  
  47.  
  48. // VOIP Widget Slot
  49. void VOIPCallSlot();
  50. void VOIPHUSlot();
  51. void DialPadSlot();
  52.  
  53.  
  54. // VOIP Config Dialog Slot
  55. // First Tab
  56. void SIPSaveSlot();
  57. void SIPAddSlot();
  58. void SIPEditSlot();
  59. void SIPRemoveSlot();
  60.  
  61. // Second Tab
  62. void NetworkSettingsSaveSlot();
  63. void NetworkSettingsDefaultSlot();
  64.  
  65. // Third Tab
  66.  
  67.  
  68. // Add Contact Dialog Slot
  69. void AddContactDlgSlot();
  70.  
  71. // Delete Contact Dialog Slot
  72. void DeleteContactDlgSlot();
  73.  
  74. private:
  75.  
  76. Ui::InteractiveMultiTouchCommunicationSystemClass ui;
  77.  
  78. // ToolBar
  79. QToolBar* myTB;
  80.  
  81. // Menu
  82. QMenu* VOIPMenu;
  83. QMenu* ConfigurationMenu;
  84. QMenu* HistoryMenu, *NestedVOIPMenu;
  85. QMenu *ContactsMenu, *HelpMenu, *ExitMenu;
  86.  
  87. // Action
  88. QAction* VOIPInfoAct, *VOIPRedialAct,
  89. *VOIPRecordAct, *VOIPHoldAct,
  90. *VOIPReinviteAct, *VOIPTransferAct;
  91.  
  92. QAction* VOIPConfigAct;
  93. QAction* IncomingVOIPHistoryAct,
  94. *OutgoingVOIPHistoryAct, *MissedVOIPHistoryAct,
  95. *ReceivedVOIPHistoryAct;
  96.  
  97. QAction* AddContactAct, *DeleteContactAct,
  98. *ManageContactAct;
  99.  
  100. QAction* AboutAct, *AboutQTAct;
  101. QAction* ExitAct;
  102.  
  103.  
  104. // Child Widget Component
  105. // Selection Widget/Dialog/GO
  106. QWidget* VOIPWgt, *IMWgt, *SMSWgt;
  107. QDialog* VOIPConfigDlg, *AddContactDlg,
  108. *DeleteContactDlg, *ManageContactDlg;
  109.  
  110. // VOIP Widget Component
  111. QLineEdit* display;
  112. QPushButton* call, *hangup, *One, *Two, *Three,
  113. *Four, *Five, *Six, *Seven, *Eight, *Nine,
  114. *DotSign, *Zero, *Hash;
  115. QErrorMessage* errorMsg;
  116.  
  117. // VOIP Log Dialog Component
  118. QDialog* VOIPDebugDlg;
  119. QTextEdit* logText;
  120.  
  121. // VOIP Call Record Widget Componenet
  122. QDialog* CallRecordFileNameDlg;
  123. QLabel* fileName;
  124. QLineEdit* fileNameLE;
  125. QPushButton* confirm;
  126. QMessageBox* msgBox;
  127.  
  128. // VOIP Configuration Dialog Component
  129. QLabel* UserInfo, *Username, *SIPAdd,
  130. *SIPAccount, *Ports, *SIPPort, *audioVideoPort,
  131. *NAT, *StunServer;
  132. QLineEdit* usernameLE, *SIPAddLE, *StunServerLE;
  133. QPushButton* Save, *AddSIPAcc, *EditSIPAcc,
  134. *RemoveSIPAcc, *SaveBtn, *DefaultBtn;
  135. QSpinBox* PortSB, *audioVideoSB ;
  136. QRadioButton* DirectConn, *RouterConn;
  137.  
  138. // Third Tab
  139. QLabel* SIPContacts, *SIPAddress, *SIPContactList;
  140. QLineEdit* SIPURIAddLE;
  141. QPushButton* saveContact, *EditSIPAdd,
  142. *RemoveSIPAdd;
  143.  
  144.  
  145. // Add Contact Dialog Component
  146. QLabel* contactInfo, *Instruction,
  147. *myEmail;
  148. QLineEdit* myEmailLE;
  149. QPushButton* OK, *Cancel;
  150.  
  151. // Delete Contact Dialog Component
  152. QLabel* theContactInfo, *theInstruction,
  153. *theEmail;
  154. QComboBox* myEmailCB;
  155. QPushButton* Delete, *Reset;
  156.  
  157.  
  158.  
  159. // Private Function
  160. void Init();
  161.  
  162. void createAction();
  163. void createMenu();
  164. void createToolBar();
  165.  
  166. void createVOIPWidget();
  167.  
  168. void createVOIPConfigDlg();
  169.  
  170. void createAddContactDlg();
  171. void createDeleteContactDlg();
  172. void createManageContactDlg();
  173.  
  174.  
  175. // Utility Function
  176. bool ValidateSIP(const std::string&, bool&, int&) const;
  177.  
  178.  
  179.  
  180.  
  181. // =================== VOIP ====================
  182. public:
  183.  
  184. typedef boost::shared_ptr<VOIP> VOIPPtr;
  185.  
  186. private:
  187.  
  188. VOIPPtr obj;
  189.  
  190. };
To copy to clipboard, switch view to plain text mode 

And this is my openCV Video streaming code.

Qt Code:
  1. class OpenCVQT : public QWidget
  2. {
  3. Q_OBJECT
  4.  
  5. public:
  6. typedef unsigned char uchar;
  7.  
  8. public:
  9. OpenCVQT(QWidget *parent = 0, Qt::WFlags flags = 0);
  10. ~OpenCVQT();
  11.  
  12. void operator()();
  13.  
  14. void StreamCamera();
  15.  
  16. void InitCam();
  17. void ConvertImage();
  18. void CreateQImage();
  19. void SetDisplayImage();
  20.  
  21. private:
  22. Ui::OpenCVQTClass ui;
  23. QLabel* myLabel;
  24. QVBoxLayout* mainLayout;
  25.  
  26. private:
  27. CvCapture* myCaptureHandler;
  28. IplImage* myOriginalIplImage, *myRGBIplImage;
  29. QImage myQImage;
  30. uchar* ImageData;
  31.  
  32. void CreateImage();
  33. };
  34.  
  35. OpenCVQT::OpenCVQT(QWidget *parent, Qt::WFlags flags)
  36. : QWidget(parent, flags),
  37. myCaptureHandler(),
  38. myOriginalIplImage(&IplImage() ),
  39. myRGBIplImage(&IplImage() ),
  40. myQImage(QImage()),
  41. ImageData()
  42. {
  43. ui.setupUi(this);
  44. myLabel = new QLabel;
  45. mainLayout = new QVBoxLayout;
  46.  
  47. mainLayout->addWidget(myLabel);
  48. this->setLayout(mainLayout);
  49.  
  50. myCaptureHandler = cvCreateCameraCapture(0);
  51. myOriginalIplImage = cvCreateImage(cvSize(320, 480),
  52. IPL_DEPTH_8U, 3);
  53. myRGBIplImage = cvCloneImage(myOriginalIplImage);
  54.  
  55. }
  56. // =============================================
  57. OpenCVQT::~OpenCVQT()
  58. {
  59. }
  60. // =============================================
  61. void OpenCVQT::StreamCamera()
  62. {
  63. //InitCam();
  64.  
  65. //while (1)
  66. {
  67. myRGBIplImage = cvQueryFrame(myCaptureHandler);
  68. //cvNamedWindow("OpenCV");
  69. //cvShowImage("OpenCV", myRGBIplImage);
  70. ConvertImage();
  71. CreateQImage();
  72. //SetDisplayImage();
  73. myLabel->setPixmap(QPixmap::fromImage(myQImage) );
  74.  
  75. }
  76. }
  77. // =============================================
  78. void OpenCVQT::InitCam()
  79. {
  80. myCaptureHandler = cvCreateCameraCapture(0);
  81.  
  82. if (!myCaptureHandler)
  83. {
  84. errMsg->showMessage("No Web Cam Plugin");
  85. }
  86.  
  87. }
  88. // =============================================
  89. void OpenCVQT::ConvertImage()
  90. {
  91. cvCvtColor(myRGBIplImage,
  92. myRGBIplImage, CV_BGR2RGB);
  93.  
  94. if (!myRGBIplImage)
  95. {
  96. errMsg->showMessage("Error Convert Image");
  97. }
  98. else
  99. {
  100. ImageData = (uchar*) myRGBIplImage->imageData;
  101. }
  102. }
  103. // =============================================
  104. void OpenCVQT::CreateQImage()
  105. {
  106. myQImage = QImage(ImageData,
  107. myRGBIplImage->width, myRGBIplImage->height,
  108. myRGBIplImage->widthStep,
  109. QImage::Format_RGB888);
  110. }
  111. // =============================================
  112. void OpenCVQT::SetDisplayImage()
  113. {
  114. QPainter* myPainter = new QPainter(this);
  115. myPainter->drawImage(myQImage.rect(), myQImage);
  116. resize(myRGBIplImage->width, myRGBIplImage->height);
  117. }
  118. // =============================================
  119. void OpenCVQT::CreateImage()
  120. {
  121. myOriginalIplImage = cvCreateImage(
  122. cvSize(myOriginalIplImage->width,
  123. myOriginalIplImage->height), IPL_DEPTH_8U, 3);
  124.  
  125. ImageData = (uchar*)myOriginalIplImage->imageData;
  126.  
  127. myQImage = QImage(ImageData,
  128. myOriginalIplImage->width,
  129. myOriginalIplImage->height, myOriginalIplImage->widthStep,
  130. QImage::Format_RGB888);
  131.  
  132. }
  133.  
  134. int main(int argc, char *argv[])
  135. {
  136. QApplication a(argc, argv);
  137. OpenCVQT w;
  138.  
  139. w.show();
  140. w.StreamCamera();
  141.  
  142. return a.exec();
  143. }
To copy to clipboard, switch view to plain text mode 

It just display a single image rather than sequence of live frame.
Please comment my code.

Please provide some guide to start.

Please help.

Thanks.