上次提问还未解决:http://topic.csdn.net/u/20090809/21/fa79ffc2-5b38-4fac-a22d-35bd1ddb06ba.html如题:网页上的用户如何与软件上的用户进行(视频)聊天!
因为以后要扩展成视频语音聊天,所以不能存在数据库里!继续寻找高手。

解决方案 »

  1.   

    视频,必须用Activex控件了,同一个控件,winform, webform都可以用,利用vc+directshow
    开发,
      

  2.   

    得做ACTIVEX控件,就跟网页上的播放器一样。
      

  3.   

    考虑到没办法使用P2P模式,WEB-》》server 是没办法是用UDP通信协议的。我写个sample试试
      

  4.   

    晕啦,我还不会ACTIVEX =======>
    找人写一个或找个现成的,如果没有一些经验,是很难写出来的.
      

  5.   

    FLASH,COM,asp.net实现在线视频聊天 
    或用FMS
    或使用NetMeeting
    参考
      

  6.   


    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Runtime.InteropServices;
    using System.Drawing.Imaging;
    using System.Net;
    using System.Net.Sockets;
    using System.Threading;
    using System.IO;namespace VideoConference.Chat
    {
        public partial class Form1 : Form
        {
            TcpClient myclient;
            MemoryStream ms;
            NetworkStream myns;
            BinaryWriter mysw;
            Thread myth;
            TcpListener mytcpl;
            Socket mysocket;
            NetworkStream ns;        #region WebCam API
            const short WM_CAP = 1024;
            const int WM_CAP_DRIVER_CONNECT = WM_CAP + 10;
            const int WM_CAP_DRIVER_DISCONNECT = WM_CAP + 11;
            const int WM_CAP_EDIT_COPY = WM_CAP + 30;
            const int WM_CAP_SET_PREVIEW = WM_CAP + 50;
            const int WM_CAP_SET_PREVIEWRATE = WM_CAP + 52;
            const int WM_CAP_SET_SCALE = WM_CAP + 53;
            const int WS_CHILD = 1073741824;
            const int WS_VISIBLE = 268435456;
            const short SWP_NOMOVE = 2;
            const short SWP_NOSIZE = 1;
            const short SWP_NOZORDER = 4;
            const short HWND_BOTTOM = 1;
            int iDevice = 0;
            int hHwnd;
            [System.Runtime.InteropServices.DllImport("user32", EntryPoint = "SendMessageA")]
            static extern int SendMessage(int hwnd, int wMsg, int wParam, [MarshalAs(UnmanagedType.AsAny)] 
    object lParam);
            [System.Runtime.InteropServices.DllImport("user32", EntryPoint = "SetWindowPos")]
            static extern int SetWindowPos(int hwnd, int hWndInsertAfter, int x, int y, int cx, int cy, int wFlags);
            [System.Runtime.InteropServices.DllImport("user32")]
            static extern bool DestroyWindow(int hndw);
            [System.Runtime.InteropServices.DllImport("avicap32.dll")]
            static extern int capCreateCaptureWindowA(string lpszWindowName, int dwStyle, int x, int y, int nWidth, short nHeight, int hWndParent, int nID);
            [System.Runtime.InteropServices.DllImport("avicap32.dll")]
            static extern bool capGetDriverDescriptionA(short wDriver, string lpszName, int cbName, string lpszVer, int cbVer);
            private void OpenPreviewWindow()
            {
                int iHeight = 320;
                int iWidth = 200;
                // 
                //  Open Preview window in picturebox
                // 
                hHwnd = capCreateCaptureWindowA(iDevice.ToString(), (WS_VISIBLE | WS_CHILD), 0, 0, 640, 480, picCapture.Handle.ToInt32(), 0);
                // 
                //  Connect to device
                // 
                if (SendMessage(hHwnd, WM_CAP_DRIVER_CONNECT, iDevice, 0) == 1)
                {
                    // 
                    // 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 | SWP_NOZORDER));
                }
                else
                {
                    // 
                    //  Error connecting to device close window
                    //  
                    DestroyWindow(hHwnd);
                }
            }
            private void ClosePreviewWindow()
            {
                // 
                //  Disconnect from device
                // 
                SendMessage(hHwnd, WM_CAP_DRIVER_DISCONNECT, iDevice, 0);
                // 
                //  close window
                // 
                DestroyWindow(hHwnd);
            }
            #endregion        public Form1()
            {
                InitializeComponent();
            }        private void Start_Receiving_Video_Conference()
            {
                try
                {
                    mytcpl = new TcpListener(5000);
                    mytcpl.Start();
                    mysocket = mytcpl.AcceptSocket();
                    ns = new NetworkStream(mysocket);                 picture_comming.Image = Image.FromStream(ns);
                    mytcpl.Stop();                 if (mysocket.Connected == true)
                    {
                        while (true)
                        {
                            Start_Receiving_Video_Conference();
                        }
                    }
                    myns.Flush();            }
                catch (Exception) { button1.Enabled = true; myth.Abort(); }
            }        private void Start_Sending_Video_Conference(string remote_IP, int port_number)
            {
                try
                {                ms = new MemoryStream();
                    IDataObject data;
                    Image bmap;                SendMessage(hHwnd, WM_CAP_EDIT_COPY, 0, 0);                data = Clipboard.GetDataObject();                if (data.GetDataPresent(typeof(System.Drawing.Bitmap)))
                    {
                        bmap = ((Image)(data.GetData(typeof(System.Drawing.Bitmap))));
                        bmap.Save(ms, ImageFormat.Bmp);
                    }
                    //picCapture.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                    byte[] arrImage = ms.GetBuffer();
                    myclient = new TcpClient(remote_IP, port_number);
                    myns = myclient.GetStream();
                    mysw = new BinaryWriter(myns);
                    mysw.Write(arrImage);
                    ms.Flush();
                    mysw.Flush();
                    myns.Flush();
                    ms.Close();
                    mysw.Close();
                    myns.Close();
                    myclient.Close();
                }
                catch (Exception ex)
                {
                    //MessageBox.Show(ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            private void btnStart_Click(object sender, System.EventArgs e)
            {
                iDevice = int.Parse(device_number_textBox.Text);
                OpenPreviewWindow();
            }
            private void btnStop_Click(object sender, System.EventArgs e)
            {
                ClosePreviewWindow();        }
            private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
            {
                if (btnStop.Enabled)
                {
                    ClosePreviewWindow();
                }        }        private void button1_Click(object sender, EventArgs e)
            {
                button1.Enabled = false;
                myth = new Thread(new System.Threading.ThreadStart(Start_Receiving_Video_Conference));
                myth.Start(); 
            }        private void timer1_Tick(object sender, EventArgs e)
            {
                Start_Sending_Video_Conference(IP_textBox.Text, 6000);
            }        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
            {
                try
                {
                    mytcpl.Stop();
                    myth.Abort();
                }
                catch (Exception) { }
            }        private void button2_Click(object sender, EventArgs e)
            {
                timer1.Enabled = true;
            }
        }
    }
      

  7.   

    我也想知道webform与winform怎么连!
      

  8.   

    API获取流-》C/S端显示并产生TCP通信-》发送流-》服务器接收并找到链接对象-》发送流-》FLASH接收并显示