大家一起来,就快完工了.视频网络传送(vc++------>>delphi)1000分. (300分)

  • 主题发起人 主题发起人 BlackDragon
  • 开始时间 开始时间
厉害,咱也学学。
 
修正了几处错误,翻译了大部分,明天再贴.
 
http://www.delphi-jedi.org/
上面有你需要的工具和资料。。。。[:)]
 
嘿嘿,那些早看过了,快完工了.
 
??
http://delphi.mychangshu.com
这个网站怎么上不去了,好象是什么开发在线,以前都可以上的嘛,怎么回事呀,谁能回答我呀
 
好长时间不混分了,来混10分
 
大家一起修改啊,怎么都这么懒啊,我没学c,大家快来啊。[:(!]
 
视频广播的东东那些高手都当宝贝似的,都不公开,让大家一起来,都不来,斑竹帮我删了吧.
 
强烈观注
 
BlackDragon:
我很有兴趣啊. 什么时候一起交流一下吧.? 不过现在我还没有时间
 
xwings:
老哥,什么时候有时间啊,你要好好辅导一下我啊,你要烦了是小狗[:D][:D]
 
xwings:
再留下你的qq,我的是15448929
 
我也只是关注。不要骂我。
 
我有源程序,有些看不懂(delphi)的,哪个要?
xwings:我也在搞这个东西,象你学习。
BlackDragon, :我为了写这个东西,有去学习VC
 
To hurryman:
老哥,送俺一个 zhaohai9@163.net
 
unit mainclient;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ScktComp, StdCtrls, Mask,vfw, Buttons;
type
SERVER_CTRL_MSG = record
strCommand:array [0..100] of char;
nContentUsedByte:dword;
strContent:array [0..1000] of char;
end;
type
video_data = record
bKeyFrame:boolean;
nSampleNum:dword;
nUsedSize:dword;
Buf:array [0..8180] of byte;
end;
type
TForm1 = class(TForm)
ClientSocket1: TClientSocket;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
procedure FormCreate(Sender: TObject);
procedure ClientSocket1Read(Sender: TObject;
Socket: TCustomWinSocket);
procedure BitBtn1Click(Sender: TObject);
private
m_InInfo:BITMAPINFO;
m_CV:TCOMPVARS;
procedure InitNetWork();
procedure UnInitDecompressor();
procedure ExcuteServerCommand(msg:SERVER_CTRL_MSG);
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
implementation
{$R *.dfm}
{ TForm1 }
procedure TForm1.ExcuteServerCommand(msg: SERVER_CTRL_MSG);
var
palbg:TICDRAWbegin
;
pal:HPALETTE;
begin
if strcomp(msg.strCommand,'Set Bitmap Info')=0 then
movememory(@msg.strContent,@m_InInfo,sizeof(BITMAPINFO));
if (strcomp(msg.strCommand,'Set COMPVARS')=0) then
begin
movememory(@msg.strContent,@m_CV,sizeof(TCOMPVARS));
m_CV.hic:=ICOpen(m_CV.fccType,m_CV.fccHandler,ICMODE_DRAW);
if(m_CV.hic=NULL) then
showmessage('please install the proper decompressor!')
else
begin
ICDrawbegin
(m_CV.hic,ICDRAW_CONTINUE or ICDRAW_HDC,self.GetPalette,Self.Canvas.Handle,Self.Handle,0,0,200,200,@m_InInfo.bmiHeader,0,0,m_InInfo.bmiHeader.biWidth,m_InInfo.bmiHeader.biHeight,m_CV.lDataRate,(m_CV.lDataRate div m_CV.lKey));
end;
end;
end;
procedure TForm1.InitNetWork;
begin
clientsocket1.Address:='127.0.0.1';
clientsocket1.Port:=2002;
end;

procedure TForm1.UnInitDecompressor;
begin
if (m_CV.hic <> NULL) then
begin
ICDrawEnd(m_CV.hic);
ICClose(m_CV.hic);
end;

end;

procedure TForm1.FormCreate(Sender: TObject);
begin
InitNetWork();
end;

procedure TForm1.ClientSocket1Read(Sender: TObject;
Socket: TCustomWinSocket);
var
msg:SERVER_CTRL_MSG;
VideoData:VIDEO_DATA;
begin
fillmemory(@msg,sizeof(SERVER_CTRL_MSG),0);
clientsocket1.Socket.ReceiveBuf(msg,sizeof(SERVER_CTRL_MSG));
ExcuteServerCommand(msg);
fillmemory(@VideoData,sizeof(VIDEO_DATA),0);
clientsocket1.Socket.ReceiveBuf(VideoData,sizeof(VIDEO_DATA));
ICDraw(m_CV.hic,0,@m_InInfo.bmiHeader,@VideoData.Buf,VideoData.nUsedSize,VideoData.nSampleNum);
end;

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
clientsocket1.Active:=true;
if clientsocket1.Active = true then
showmessage('ok');
end;

end.
 
unit main;
interface
uses
Windows, Messages,variants, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, ScktComp,vfw, StdCtrls;
type
SERVER_CTRL_MSG = record
strCommand:array [0..100] of char;
nContentUsedByte:dword;
strContent:array [0..1000] of char;
end;
type
video_data = record
bKeyFrame:boolean;
nSampleNum:dword;
nUsedSize:dword;
Buf:array [0..8180] of byte;
end;

type
TForm1 = class(TForm)
ServerSocket1: TServerSocket;
Label1: TLabel;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure ServerSocket1ClientConnect(Sender: TObject;
Socket: TCustomWinSocket);
procedure FormDestroy(Sender: TObject);
procedure ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
private
procedure InitVideoCard();
//function FrameCallBack(HhWND:hwnd;lpVHdr:PVIDEOHDR):DWORD;stdcall;
procedure InitNetWork();
procedure InitCompressor();
procedure UnInitCompressor();
procedure UnInitVideoCard();
procedure FillBitmapStruct();
procedure CompressFrame(lpVHdr:PVIDEOHDR);
{ Private declarations }
public
{ Public declarations }

end;
function FrameCallBack(hWnd: HWND;
lpVHdr: PVIDEOHDR): DWORD;
stdcall;
var
ii:integer;
Form1: TForm1;
m_bConnect:boolean;
m_SampleNum:dword;
m_hWndCapture:hwnd;
m_OutFormatSize,m_OutBufferSize:DWord;
m_OutActSize:Longint;
m_InInfo,m_OutInfo:BITMAPINFO;
m_CV:TCOMPVARS;
implementation
{$R *.dfm}
procedure TForm1.CompressFrame(lpVHdr: PVIDEOHDR);
var
bKeyFrame:boolean;
VideoData:VIDEO_DATA;
Buf:char;
begin
m_OutActSize:=m_InInfo.bmiHeader.biSizeImage;
buf:=char(ICSeqCompressFrame(@m_CV,0,lpVHdr.lpData,@bKeyFrame,@m_OutActSize));
if (m_bConnect = true) and (m_OutActSize<8180) then
begin
FillMemory(@VideoData,sizeof(VIDEO_DATA),0);
VideoData.bKeyFrame:=bKeyFrame;
movememory(@Buf,@VideoData.Buf,m_OutActSize);
VideoData.nSampleNum:=m_SampleNum;
VideoData.nUsedSize:=m_OutActSize;
serversocket1.Socket.SendBuf(videodata,sizeof(VIDEO_DATA));
m_SampleNum:=m_SampleNum+1;
end;
end;

procedure TForm1.FillBitmapStruct;
begin
m_InInfo.bmiHeader.biBitCount:=24;
m_InInfo.bmiHeader.biClrUsed:=0;
m_InInfo.bmiHeader.biClrImportant:=m_InInfo.bmiHeader.biClrUsed;
m_InInfo.bmiHeader.biCompression:=BI_RGB;
m_InInfo.bmiHeader.biHeight:=240;
m_InInfo.bmiHeader.biPlanes:=1;
m_InInfo.bmiHeader.biSize:=sizeof(BITMAPINFOHEADER);
m_InInfo.bmiHeader.biSizeImage:=0;
m_InInfo.bmiHeader.biWidth:=320;
m_InInfo.bmiHeader.biYPelsPerMeter:=0;
m_InInfo.bmiHeader.biXPelsPerMeter:=m_InInfo.bmiHeader.biYPelsPerMeter;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
ii:=0;
m_bConnect:=FALSE;
m_SampleNum:=0;
FillBitmapStruct();
InitVideoCard();
InitCompressor();
InitNetWork();
end;

function FrameCallBack(hWnd: HWND;
lpVHdr: PVIDEOHDR): dword;stdcall;
begin
if (m_bConnect=TRUE) then
form1.CompressFrame(lpVHdr);
end;

procedure TForm1.InitCompressor;
begin
FillMemory(@m_CV,sizeof(TCOMPVARS),0);
m_CV.dwFlags:=ICMF_COMPVARS_VALID;
m_CV.cbSize:=sizeof(m_CV);
m_CV.cbSize:=0;
m_CV.fccHandler:=mmioFOURCC('d','i','v','x');
m_CV.fccType:=ICTYPE_VIDEO;
m_CV.hic:=ICOpen(ICTYPE_VIDEO,mmioFOURCC('d','i','v','x'),ICMODE_COMPRESS);
m_CV.lDataRate:=780;
m_CV.lFrame:=0;
m_CV.lKey:=15;
m_CV.lKeyCount:=0;
m_CV.lpbiIn:=Nil;
m_CV.lpBitsOut:=Nil;
m_CV.lpState:=Nil;
m_CV.lpBitsPrev:=Nil;
m_CV.lQ:=ICQUALITY_DEFAULT;
if (m_CV.hic<>0) then
begin
m_OutFormatSize:=ICCompressGetFormatSize(m_CV.hic,@m_InInfo);
//getmem(@m_pOutInfo,m_OutFormatSize);
//m_pOutInfo:=(BITMAPINFO *)new BYTE[m_OutFormatSize];
//ICCompressGetFormat(m_CV.hic,@m_InInfo,m_pOutInfo);
ICCompressGetFormat(m_CV.hic,@m_InInfo,@m_OutInfo);
m_OutBufferSize:=ICCompressGetSize(m_CV.hic,@m_InInfo,@m_OutInfo);
ICSeqCompressFrameStart(@m_CV,@m_InInfo);
end;
end;

procedure TForm1.InitNetWork;
begin
serversocket1.Active:=true;
end;

procedure TForm1.InitVideoCard;
var aa:THandle;
begin
m_hWndCapture:=capCreateCaptureWindow('Capture Window',WS_VISIBLE or WS_CHILD,0,0,320,240,form1.Handle,1);
capDriverConnect(m_hWndCapture,0);
//set the video format
capSetVideoFormat(m_hWndCapture,@m_InInfo,sizeof(BITMAPINFO));
capPreviewRate(m_hWndCapture,40);
// capDlgVideoFormat(this->m_hWndCapture);
capPreview(m_hWndCapture,TRUE);
capSetCallbackOnFrame(m_hWndCapture,FrameCallBack);
end;

procedure TForm1.UnInitCompressor;
begin
if (m_CV.hic <> NULL) then
begin
zeromemory(@m_OutInfo,0);
ICSeqCompressFrameEnd(@m_CV);
ICCompressorFree(@m_CV);
ICClose(m_CV.hic);
end;
end;

procedure TForm1.UnInitVideoCard;
begin
capSetCallbackOnFrame(m_hWndCapture,FrameCallBack);
capDriverDisconnect(m_hWndCapture);
end;

procedure TForm1.ServerSocket1ClientConnect(Sender: TObject;
Socket: TCustomWinSocket);
begin
ii:=ii+1;
label1.Caption:='User Connected,begin
transporting video image!'+inttostr(ii);
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
UnInitCompressor();
UnInitVideoCard();
end;

procedure TForm1.ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
var
msg:SERVER_CTRL_MSG;
begin
FillMemory(@msg,sizeof(SERVER_CTRL_MSG),0);
strpcopy(msg.strCommand,'Set Bitmap Info');
//memcpy(msg.strContent,pDlg->m_pOutInfo,sizeof(BITMAPINFO));
//
movememory(@m_OutInfo,@msg.strContent,sizeof(BITMAPINFO));
//这个翻译的好像不对头
msg.nContentUsedByte:=sizeof(BITMAPINFO);
serversocket1.Socket.SendBuf(msg,sizeof(SERVER_CTRL_MSG));
FillMemory(@msg,sizeof(SERVER_CTRL_MSG),0);
strpcopy(msg.strCommand,'Set COMPVARS');
msg.nContentUsedByte:=sizeof(TCOMPVARS);
//memcpy(msg.strContent,&amp;pDlg->m_CV,sizeof(COMPVARS));
serversocket1.Socket.SendBuf(msg,sizeof(SERVER_CTRL_MSG));
//afxDump<<pDlg->m_CV.fccType<<"/n";
//这个不懂
m_bConnect:=TRUE;
end;

end.


大家继续改,继续翻译。
 
基本上是完了,这些再整理一下.大家一起来.[:)]
 

Similar threads

D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
后退
顶部