上次提问还未解决:http://topic.csdn.net/u/20090809/21/fa79ffc2-5b38-4fac-a22d-35bd1ddb06ba.html如题:网页上的用户如何与软件上的用户进行(视频)聊天!
因为以后要扩展成视频语音聊天,所以不能存在数据库里!继续寻找高手。
因为以后要扩展成视频语音聊天,所以不能存在数据库里!继续寻找高手。
解决方案 »
- 请问,下图是什么软件画的
- 遍历dataTable时进行判断,当值为" "||NULL时,不进入IF中,求解
- 很幼稚的问题~~!~!~!~!~!~!~!~!~!~!
- 怎样设置这样的水晶报表?
- [近乎跪求] 编译Infragistics NetAdvantage源码问题 [用过的帮顶! 改过源码并成功使用的请进! 对Asp.net组件开发熟悉的人请进!]
- 请问ASP.NET怎样才能在客户端进行创建,删除,修改目录和文件?
- datalist怎么分页
- TreeView在IE7下不显示,为什么?
- 求助,datagrid的一个简单问题?
- !!!如何将Word文件在IE中打开 !!!
- 怎么让一个DIV固定在网页下面,我的高度和宽度设置的是百分比
- 向高手请教 进来看看这个网站的搜索功能如何实现的?
开发,
找人写一个或找个现成的,如果没有一些经验,是很难写出来的.
或用FMS
或使用NetMeeting
参考
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;
}
}
}