📄 点对点视频会议程序videonet开发例解-太平洋电脑网pconline-[vc-mfc].htm
字号:
else{
demo.scrollTop++
}
}
var MyMar=setInterval(Marquee,speed)
demo.onmouseover=function() {clearInterval(MyMar)}
demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}</SCRIPT>
</TD></TR></TBODY></TABLE></DIV>
<P> <A
href="http://www.pconline.com.cn/pcedu/empolder/gj/vc/0508/acc/VideoNet_src.zip">下载源代码</A>。</P>
<P><IFRAME id=ad_top name=ad_top align=left marginWidth=0
marginHeight=0
src="点对点视频会议程序VideoNet开发例解-太平洋电脑网Pconline-[VC-MFC].files/show"
frameBorder=0 width=320 scrolling=no
height=280></IFRAME> 该程序可以用于两个人在LAN/Intranet(或者Internet)上进行视频会议。现在有许多视频会议程序,每个都有各自的性能提升技术。主要的问题是视频会议视频帧的尺寸对于传输来说太大。因此,性能依赖于对帧的编解码。我使用快速h263编码库来达到更好的压缩率提高速度。该程序做些小改动也可以在Internet上使用。</P>
<P><STRONG>音频的录制与播放</STRONG></P>
<P> 我在以前的语音会议程序中使用了RecordSound和PlaySound类,这里我将提供摘要说明RecordSound和PlaySound类的使用。</P>
<P>// Create and Start Recorder Thread<BR>
record=new RecordSound(this);<BR>
record->CreateThread();<BR><BR><BR>// Create and Start
Player Thread<BR> play=new
PlaySound1(this);<BR>
play->CreateThread();<BR><BR><BR>// Start
Recording<BR>
record->PostThreadMessage(WM_RECORDSOUND_STARTRECORDING,0,0);<BR><BR><BR>//
Start Playing<BR>
play->PostThreadMessage(WM_PLAYSOUND_STARTPLAYING,0,0);<BR><BR><BR>//
During audio recording, data will be available in the
OnSoundData<BR>// callback function of the RecordSound class.
Here, you can place<BR>// your code to send the data to remote
host...<BR><BR><BR>// To play the data received from the
remote host<BR>
play->PostThreadMessage(WM_PLAYSOUND_PLAYBLOCK,size,(LPARAM)data);<BR><BR><BR>//
Stop Recording<BR>
record->PostThreadMessage(WM_RECORDSOUND_STOPRECORDING,0,0);<BR><BR><BR>//
Stop Playing<BR>
play->PostThreadMessage(WM_PLAYSOUND_STOPPLAYING,0,0);<BR><BR><BR>//
At last, to Stop the Recording Thread<BR>
record->PostThreadMessage(WM_RECORDSOUND_ENDTHREAD,0,0);<BR><BR><BR>//
To stop playing thread...<BR>
play->PostThreadMessage(WM_PLAYSOUND_ENDTHREAD,0,0);</P>
<P><STRONG>视频捕获</STRONG></P>
<P> 使用VFW(Video For
Windows)API进行视频捕获,它提供了通过webcam进行视频捕获。VideoCapture.h
和VideoCapture.cpp包含了处理视频捕获的代码。<BR><BR> 如下代码说明了如何使用该类:</P><PRE>// Create instance of Class<BR> vidcap=new VideoCapture();</PRE><PRE><BR>// This is later used to call display function of the main<BR>// dialog class when the frame is captured...<BR> vidcap->SetDialog(this);</PRE><PRE><BR>// This does lot of work, including connecting to the driver<BR>// and setting the desired video format. Returns TRUE if<BR>// successfully connected to videocapture device.<BR> vidcap->Initialize();</PRE><PRE><BR>// If successfully connected, you can get the BITMAPINFO<BR>// structure associated with the video format. This is later<BR>// used to display the captured frame...<BR> this->m_bmpinfo=&vidcap->m_bmpinfo;</PRE><PRE><BR>// Now you can start the capture....<BR> vidcap->StartCapture();</PRE><PRE><BR>// Once capture is started, frames will arrive in the "OnCaptureVideo"<BR>// callback function of the VideoCapture class. Here you call the<BR>// display function to display the frame.</PRE><PRE><BR>// To stop the capture<BR> vidcap->StopCapture();</PRE><PRE><BR>// If your job is over....just destroy it..<BR> vidcap->Destroy();</PRE>
<P> 要使以上代码通过编译,你应该链接适当的库:</P>
<P>#pragma comment(lib,"vfw32")<BR>#pragma
comment(lib,"winmm")</P>
<P><STRONG>显示捕获的视频帧</STRONG><BR><BR> 有许多方法和API可以显示捕获的视频。你可以使用SetDIBitsToDevice()方法直接显示,但给予GDI的函数非常的慢。更好的方法是使用DrawDib
API
显示。DrawDib函数为设备无关位图(DIBs)提供了高性能的图形绘制能力。DrawDib函数直接写入视频内存,因此性能更好。<BR><BR> 以下代码摘要演示了使用DrawDib
API显示视频帧。</P><PRE>// Initialize DIB for drawing...<BR> HDRAWDIB hdib=::DrawDibOpen();</PRE><PRE><BR>// Then call this function with suitable parameters....<BR> ::DrawDibBegin(hdib,...);</PRE><PRE><BR>// Now, if you are ready with the frame data, just invoke this<BR>// function to display the frame<BR> ::DrawDibDraw(hdib,...);</PRE><PRE><BR>// Finally, termination...<BR> ::DrawDibEnd(hdib);<BR> ::DrawDibClose(hdib);</PRE>
<P><STRONG>编解码库<BR></STRONG><BR> 编码器: </P>
<P> 我使用快速h.263编码库进行编码。该库是使其实时编码更快的 Tmndecoder
修改版。我已经将该库从C转换到C++,这样可以很容易用于任何Windows应用程序。我移除了快速h263编码库中一些不必要的代码与文件,并在.h和.cpp文件中移除了一些定义与申明。<BR>以下是H263编码库的使用方法:</P><PRE>// Initialize the compressor<BR> CParam cparams;<BR> cparams.format = CPARAM_QCIF;<BR> InitH263Encoder(&cparams);</PRE><PRE> </PRE><PRE>//If you need conversion from RGB24 to YUV420, call this<BR> InitLookupTable();</PRE><PRE> </PRE><PRE>// Set up the callback function<BR>// OwnWriteFunction is the global function called during<BR>// encoding to return the encoded data...<BR> WriteByteFunction = OwnWriteFunction;</PRE><PRE> </PRE><PRE>// For compression, data must be in the YUV420 format...<BR>// Hence, before compression, invoke this method<BR> ConvertRGB2YUV(IMAGE_WIDTH,IMAGE_HEIGHT,data,yuv);</PRE><PRE><BR>// Compress the frame.....<BR> cparams.format = CPARAM_QCIF;<BR> cparams.inter = CPARAM_INTRA;<BR> cparams.Q_intra = 8;<BR> cparams.data=yuv; // Data in YUV format...<BR> CompressFrame(&cparams, &bits);</PRE><PRE><BR>// You can get the compressed data from the callback function<BR>// that you have registerd at the begining...</PRE><PRE><BR>// Finally, terminate the encoder<BR>// ExitH263Encoder();</PRE><STRONG>解码器:</STRONG><BR><BR> 这是tmndecoder(H.263解码器)的修改版。使用ANSI
C编写,我将它转换到C++使其方便在Windows应用程序中使用。我移除了一些用于显示和文件处理的文件,移除了不必要的代码并增加了一些新文件。<BR><BR> 原始的库中一些文件不适合于实时的解码。我已经做了修改使其适合实时的解码处理。现在,可以使用该库来解码H263帧,该库非常快,性能不错。<BR><BR> 解码的使用方法:<PRE>//Initialize the decoder<BR> InitH263Decoder();</PRE><PRE><BR>// Decompress the frame....<BR>// > rgbdata must be large enough to hold the output data...<BR>// > decoder produces the image data in YUV420 format. After<BR>// decoding, it is converted into RGB24 format...<BR> DecompressFrame(data,size,rgbdata,buffersize);</PRE><PRE><BR>// Finaly, terminate the decoder<BR> ExitH263Decoder();</PRE>
<P><STRONG>如何运行程序</STRONG></P>
<P><STRONG> </STRONG>拷贝可执行文件到局域网上两台不同的机器中:A和B,运行他们。在机器A(或B)中选择connect菜单条,在弹出的对话框中输入机器B的名字或IP地址然后按connect按钮,在另外一台机器(B)显示出accept/reject对话框,按accept按钮。在机器A将显示一个通知对话框,按OK后开始会议。<BR><BR>That's
it....Enjoy......!!! <BR><BR><STRONG>致谢:</STRONG><BR><BR> 我感谢
Paul Cheffers
提供了他的音频录制播放类。因为有了开源人士奉献的开源库才有你所看到的videonet程序,我感激Tmndecoder的开发者Karl
Lillevold和h.263快速编码库的开发者Roalt Aalmoes
免费提供这些开发库。<BR><BR> 如果你有任何问题或建议,可以发邮件给我
nsry2002@yahoo.co.in</P><BR clear=all>
<DIV class=article align=center><A
href="http://www.pconline.com.cn/pcedu/carton/"
target=_blank><FONT
color=#ff0000>Flash剧场全新改版,精品Flash让你看够玩够!</FONT></A></DIV><BR
clear=all><BR>
<TABLE cellSpacing=0 cellPadding=3 width="96%" align=center
border=0>
<TBODY>
<TR>
<TD class=article align=right></TD></TR></TBODY></TABLE><BR>
<DIV class=article align=center>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD height=10></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width=428 align=center
bgColor=#f0f4f7 border=0>
<FORM name=s action=http://ks.pconline.com.cn/index.jsp
method=get target=_blank>
<TBODY>
<TR>
<TD align=middle width=73><IMG
src="点对点视频会议程序VideoNet开发例解-太平洋电脑网Pconline-[VC-MFC].files/quick_art_4.gif"></TD>
<TD align=middle width=240><INPUT class=pt9 id=q
style="BORDER-RIGHT: #8e9fb0 1px solid; BORDER-TOP: #8e9fb0 1px solid; BORDER-LEFT: #8e9fb0 1px solid; BORDER-BOTTOM: #8e9fb0 1px solid"
maxLength=40 size=40 name=q></TD>
<TD align=middle width=108><INPUT type=image height=18
width=82
src="点对点视频会议程序VideoNet开发例解-太平洋电脑网Pconline-[VC-MFC].files/quick_art_8.gif"></TD></TR></FORM></TBODY></TABLE>
<TABLE cellSpacing=3 cellPadding=0 width=430 border=0>
<TBODY>
<TR>
<TD>更多相关搜索: <A class=font_line
href="http://ks.pconline.com.cn/index.jsp?q=vc"
target=_BLANK>vc..</A> <A class=font_line
href="http://ks.pconline.com.cn/index.jsp?q=视频"
target=_BLANK>视频..</A> <A class=font_line
href="http://ks.pconline.com.cn/index.jsp?q=视频会议"
target=_BLANK>视频会议..</A> <A class=font_line
href="http://ks.pconline.com.cn/index.jsp?q=视频聊天"
target=_BLANK>视频聊天..</A> <A class=font_line
href="http://ks.pconline.com.cn/index.jsp?q=VideoNet"
target=_BLANK>VideoNet..</A></TD></TR>
<TR>
<TD height=8></TD></TR></TBODY></TABLE>
<DIV align=center>
<SCRIPT language=javascript
src="点对点视频会议程序VideoNet开发例解-太平洋电脑网Pconline-[VC-MFC].files/ad_dell.js"></SCRIPT>
<SCRIPT language=javascript
src="点对点视频会议程序VideoNet开发例解-太平洋电脑网Pconline-[VC-MFC].files/ad_text_pcauto.js"></SCRIPT>
</DIV></DIV>
<TABLE style="CLEAR: both" cellSpacing=0 cellPadding=0
width="96%" align=center border=0>
<TBODY>
<TR>
<TD align=middle><A name=_comment_tag_>正在加载评论,请稍候…</A>
</TD></TR></TBODY></TABLE>
<DIV id=ad_xl align=center><BR>
<SCRIPT
src="J:\点对点视频会议程序VideoNet开发例解-太平洋电脑网Pconline-[VC-MFC].files\show(3).1]"></SCRIPT>
</DIV>
<DIV align=center>
<TABLE
style="BORDER-RIGHT: #cccccc 1px solid; BORDER-TOP: #cccccc 1px solid; BORDER-LEFT: #cccccc 1px solid; BORDER-BOTTOM: #cccccc 1px solid"
cellSpacing=0 width=414 bgColor=#f7f8f9 border=0>
<TBODY>
<TR>
<TD>
<DIV id=demoo
style="OVERFLOW: hidden; WIDTH: 380px; HEIGHT: 20px">
<DIV id=demoo1>
<TABLE cellSpacing=0 cellPadding=0 border=0>
<TBODY>
<TR>
<TD width=201 height=18>·<A
href="http://itbbs.pconline.com.cn/traditional/article.jsp?topic=1124838&forum=5"
target=_blank>6800SLI系统登场</A></TD>
<TD width=183 height=18>·<A
href="http://itbbs.pconline.com.cn/traditional/article.jsp?topic=1126046"
target=_blank>疯狂,6600_AGP标准版小测</A></TD></TR>
<TR>
<TD height=18>·<A
href="http://itbbs.pconline.com.cn/traditional/article.jsp?topic=1098824"
target=_blank>家文:升技NF8主板测试报告!</A></TD>
<TD height=18>·<A
href="http://itbbs.pconline.com.cn/traditional/article.jsp?topic=1124236&forum=4"
target=_blank>6600GT AGP扔入珠江? </A></TD></TR>
<TR>
<TD height=18>·<A
href="http://itbbs.pconline.com.cn/traditional/article.jsp?topic=1122532&forum=5"
target=_blank>看图猜哪颗CPU超频极限最强!</A></TD>
<TD height=18>·<A
href="http://itbbs.pconline.com.cn/traditional/article.jsp?topic=1063634"
target=_blank>无法访问网上邻居解决方案集</A></TD></TR></TBODY></TABLE></DIV>
<DIV id=demoo2></DIV></DIV>
<SCRIPT>
var speed=100
demoo2.innerHTML=demoo1.innerHTML
function Marquee(){
if(demoo2.offsetTop-demoo.scrollTop<=0)
demoo.scrollTop-=demoo1.offsetHeight
else{
demoo.scrollTop++
}
}
var MyMar=setInterval(Marquee,speed)
demoo.onmouseover=function() {clearInterval(MyMar)}
demoo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}</SCRIPT>
</TD></TR></TBODY></TABLE></DIV>
<TABLE
style="BORDER-TOP: #303880 1px solid; BORDER-BOTTOM: #303880 1px solid"
height=30 cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR align=middle>
<TD width="9%"></TD>
<TD noWrap width="15%"><IMG height=17
src="点对点视频会议程序VideoNet开发例解-太平洋电脑网Pconline-[VC-MFC].files/commend.gif"
width=17 align=absMiddle> <A
href="http://www.pconline.com.cn/script/email.html?点对点视频会议程序VideoNet开发例解&http://www.pconline.com.cn/pcedu/empolder/gj/vc/0508/679721.html"
target=_blank>发给好友 </A></TD>
<TD noWrap width="18%"><IMG height=17
src="点对点视频会议程序VideoNet开发例解-太平洋电脑网Pconline-[VC-MFC].files/commend6.gif"
width=17 align=absMiddle nowrap> <A
href="http://guide.pconline.com.cn/suggest/post.jsp">我要报错</A></TD>
<TD noWrap width="19%"><IMG height=17
src="点对点视频会议程序VideoNet开发例解-太平洋电脑网Pconline-[VC-MFC].files/commend1.gif"
width=17 align=absMiddle nowrap> <A
href="http://ittg.pc.com.cn/contribute_pconline/contribute.jsp">投稿给我们</A></TD>
<TD noWrap width="14%"><IMG height=17
src="点对点视频会议程序VideoNet开发例解-太平洋电脑网Pconline-[VC-MFC].files/commend4.gif"
width=17 align=absMiddle nowrap> <A
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -