video conferencing


  • Hi,

    I'm trying to create a video conferencing application using visual studio 2008 and programming language Can anyone help me by providing me details and examples on how to do it. Thanks in advance.
    Thursday, July 09, 2009 7:02 AM


All replies

  • There are a lot of things your program would need.... so where would you want to start?

    You need to figure out all you want your app to achieve, and also what it NEEDS to do, how you want it to look, etc.
    ....then start building it.

    Have you built anything before in VB.NET?
    Thursday, July 09, 2009 8:06 AM
  • Here's the code for my application that i had tried however, i couldn't get it working. My picturebox doesn't show anything that my webcam captures.

    Imports System
    Imports System.Drawing
    Imports System.Collections
    Imports System.ComponentModel
    Imports System.Windows.Forms
    Imports System.Data
    Imports System.Runtime.InteropServices
    Imports System.Drawing.Imaging
    Imports System.Net
    Imports System.Net.Sockets
    Imports System.Threading
    Imports System.IO

    Public Class Form1

        Private myclient As TcpClient
        Private ms As MemoryStream
        Private myns As NetworkStream
        Private mysw As BinaryWriter
        Private myth As Thread
        Private mytcpl As TcpListener
        Private mysocket As Socket
        Private ns As NetworkStream

        Const WM_CAP As Short = 1024
        Const WM_CAP_DRIVER_CONNECT As Integer = WM_CAP + 10
        Const WM_CAP_DRIVER_DISCONNECT As Integer = WM_CAP + 11
        Const WM_CAP_EDIT_COPY As Integer = WM_CAP + 30
        Const WM_CAP_SET_PREVIEW As Integer = WM_CAP + 50
        Const WM_CAP_SET_PREVIEWRATE As Integer = WM_CAP + 52
        Const WM_CAP_SET_SCALE As Integer = WM_CAP + 53
        Const WS_CHILD As Integer = 1073741824
        Const WS_VISIBLE As Integer = 268435456
        Const SWP_NOMOVE As Short = 2
        Const SWP_NOSIZE As Short = 1
        Const SWP_NOZORDER As Short = 4
        Const HWND_BOTTOM As Short = 1
        Dim iDevice As Integer = 0
        Dim hHwnd As Integer

        <System.Runtime.InteropServices.DllImport("user32", EntryPoint:="SendMessageA")> _
         Private Shared Function SendMessage(ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, <MarshalAs(UnmanagedType.AsAny)> ByVal lParam As Object) As Integer
        End Function
        <System.Runtime.InteropServices.DllImport("user32", EntryPoint:="SetWindowPos")> _
         Private Shared Function SetWindowPos(ByVal hwnd As Integer, ByVal hWndInsertAfter As Integer, ByVal x As Integer, ByVal y As Integer, ByVal cx As Integer, ByVal cy As Integer, _
        ByVal wFlags As Integer) As Integer
        End Function
        <System.Runtime.InteropServices.DllImport("user32")> _
    Private Shared Function DestroyWindow(ByVal hndw As Integer) As Boolean
        End Function
        <System.Runtime.InteropServices.DllImport("avicap32.dll")> _
     Private Shared Function capCreateCaptureWindowA(ByVal lpszWindowName As String, ByVal dwStyle As Integer, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Short, _
      ByVal hWndParent As Integer, ByVal nID As Integer) As Integer
        End Function
        <System.Runtime.InteropServices.DllImport("avicap32.dll")> _
      Private Shared Function capGetDriverDescriptionA(ByVal wDriver As Short, ByVal lpszName As String, ByVal cbName As Integer, ByVal lpszVer As String, ByVal cbVer As Integer) As Boolean
        End Function

        Public Sub New()
            ' Required for Windows Form Designer support

            ' TODO: Add any constructor code after InitializeComponent call
        End Sub

        ''' Clean up any resources being used.

        Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
            If disposing Then
                If components IsNot Nothing Then
                End If
            End If
        End Sub

        ''' The main entry point for the application.
        <STAThread()> _
        Private Shared Sub Main()
            Application.Run(New Form1())
        End Sub

        Private Sub OpenPreviewWindow()
            Dim iHeight As Integer = 320
            Dim iWidth As Integer = 200
            ' Open Preview window in picturebox
            hHwnd = capCreateCaptureWindowA(iDevice.ToString(), (WS_VISIBLE Or WS_CHILD), 0, 0, 640, 480, _
           picCapture.Handle.ToInt32(), 0)
            ' Connect to device
            If SendMessage(hHwnd, WM_CAP_DRIVER_CONNECT, iDevice, 0) = 1 Then
                ' Set the preview scale
                SendMessage(hHwnd, WM_CAP_SET_SCALE, 1, 0)
                ' Set the preview rate in milliseconds
                SendMessage(hHwnd, WM_CAP_SET_PREVIEWRATE, 66, 0)
                ' Start previewing the image from the camera
                SendMessage(hHwnd, WM_CAP_SET_PREVIEW, 1, 0)
                ' Resize window to fit in picturebox
                SetWindowPos(hHwnd, HWND_BOTTOM, 0, 0, iWidth, iHeight, _
                (SWP_NOMOVE Or SWP_NOZORDER))
                ' Error connecting to device close window
            End If
        End Sub

        Private Sub ClosePreviewWindow()
            ' Disconnect from device
            SendMessage(hHwnd, WM_CAP_DRIVER_DISCONNECT, iDevice, 0)
            ' close window
        End Sub

        Private Sub Start_Sending_Video_Conference(ByVal remote_IP As String, ByVal port_number As Integer)

                ms = New MemoryStream()
                ' Store it in Binary Array as Stream

                Dim data As IDataObject
                Dim bmap As Image

                ' Copy image to clipboard
                SendMessage(hHwnd, WM_CAP_EDIT_COPY, 0, 0)

                ' Get image from clipboard and convert it to a bitmap
                data = Clipboard.GetDataObject()

                If data.GetDataPresent(GetType(System.Drawing.Bitmap)) Then
                    bmap = DirectCast((data.GetData(GetType(System.Drawing.Bitmap))), Image)
                    bmap.Save(ms, ImageFormat.Bmp)
                End If

                picCapture.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg)
                Dim arrImage As Byte() = ms.GetBuffer()
                myclient = New TcpClient(remote_IP, port_number)
                'Connecting with server
                myns = myclient.GetStream()
                mysw = New BinaryWriter(myns)
                'send the stream to above address
            Catch ex As Exception
                MessageBox.Show(ex.Message, "Video Conference Error Message", MessageBoxButtons.OK, MessageBoxIcon.[Error])
            End Try
        End Sub

        Private Sub Start_Receiving_Video_Conference()

                ' Open The Port
                mytcpl = New TcpListener(5000)
                ' Start Listening on That Port
                mysocket = mytcpl.AcceptSocket()
                ' Accept Any Request From Client and Start a Session
                ns = New NetworkStream(mysocket)
                ' Receives The Binary Data From Port
                picture_comming.Image = Image.FromStream(ns)
                ' Close TCP Session
                If mysocket.Connected = True Then
                    ' Looping While Connected to Receive Another Message
                    While (True)
                        ' Back to First Method
                    End While
                End If

            Catch generatedExceptionName As Exception
                Button4.Enabled = True
            End Try
        End Sub

        Private Sub btnStart_Click(ByVal sender As Object, ByVal e As System.EventArgs)
            iDevice = Integer.Parse("0")
        End Sub
        Private Sub btnStop_Click(ByVal sender As Object, ByVal e As System.EventArgs)

        End Sub
        Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs)
            If btnStop.Enabled Then

            End If
        End Sub

        Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
            Button4.Enabled = False
            myth = New Thread(New System.Threading.ThreadStart(AddressOf Start_Receiving_Video_Conference))
            'myth = New Thread(New System.Threading.ThreadStart(Start_Receiving_Video_Conference))
            ' Start Thread Session
            ' Start Receiveing Camera
        End Sub

        Private Sub timer1_Tick(ByVal sender As Object, ByVal e As EventArgs)
            Start_Sending_Video_Conference(IP_textBox.Text, 6000)
        End Sub

        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        End Sub

        Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As FormClosingEventArgs)
            Catch generatedExceptionName As Exception
            End Try
        End Sub

        Private Sub button2_Click(ByVal sender As Object, ByVal e As EventArgs)
            timer1.Enabled = True
        End Sub
    End Class

    Thursday, July 09, 2009 8:59 AM
  • Here's a thread from this forum that deals with your same question:


    SEARCH ... then ask
    • Marked as answer by Xingwei Hu Monday, July 13, 2009 2:13 AM
    Thursday, July 09, 2009 10:27 AM