基于wince的网络音视频通信(简单易明版)
本文来自http://blog.****.net/hellogv/
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="ProgId" content="Word.Document"> <meta name="Generator" content="Microsoft Word 11"> <meta name="Originator" content="Microsoft Word 11"> <link rel="File-List" href="file:///G:%5CDOCUME%7E1%5CADMINI%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"> <link rel="Edit-Time-Data" href="file:///G:%5CDOCUME%7E1%5CADMINI%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_editdata.mso"> <!--[if !mso]> <style> v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} </style> <![endif]--><!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:PunctuationKerning/> <w:DrawingGridVerticalSpacing>7.8 磅</w:DrawingGridVerticalSpacing> <w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEvery> <w:DisplayVerticalDrawingGridEvery>2</w:DisplayVerticalDrawingGridEvery> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:Compatibility> <w:SpaceForUL/> <w:BalanceSingleByteDoubleByteWidth/> <w:DoNotLeaveBackslashAlone/> <w:ULTrailSpace/> <w:DoNotExpandShiftReturn/> <w:AdjustLineHeightInTable/> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> <w:DontGrowAutofit/> <w:UseFELayout/> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" LatentStyleCount="156"> </w:LatentStyles> </xml><![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"\@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; line-height:125%; mso-pagination:none; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:宋体; mso-font-kerning:1.0pt;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style> <!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:普通表格; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]--><!--[if gte vml 1]><v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="[email protected]@[email protected]@[email protected]@[email protected]@5xe" filled="f" stroked="f"> <v:stroke joinstyle="miter"/> <v:formulas> <v:f eqn="if lineDrawn pixelLineWidth 0"/> <v:f eqn="sum @0 1 0"/> <v:f eqn="sum 0 0 @1"/> <v:f eqn="prod @2 1 2"/> <v:f eqn="prod @3 21600 pixelWidth"/> <v:f eqn="prod @3 21600 pixelHeight"/> <v:f eqn="sum @0 0 1"/> <v:f eqn="prod @6 1 2"/> <v:f eqn="prod @7 21600 pixelWidth"/> <v:f eqn="sum @8 21600 0"/> <v:f eqn="prod @7 21600 pixelHeight"/> <v:f eqn="sum @10 21600 0"/> </v:formulas> <v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/> <o:lock v:ext="edit" aspectratio="t"/> </v:shapetype><v:shape id="_x0000_i1025" type="#_x0000_t75" style='width:392.25pt; height:314.25pt'> <v:imagedata src="file:///G:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image001.jpg" o:title="IMAGE_00001"/> </v:shape><![endif]--><!--[if !vml]--><!--[endif]-->

由于这个学期的期末将至,因此期末大作业也要开始做了。这次做的是N个月前就做过的网络音视频通信,不过这次做了不少改进。
在这里,先要感谢一下 MacintoshM 大侠,他的帖子给我提供了最原始的源代码,我现在的代码也是在他代码的基础上做出修改的。
OK,现在进入主题,先来介绍一下这个东东:
http://download.****.net/user/hellogv
网络音视频通信
下面说说关键的源代码:
以下是WINCE部分的代码
以下是PC部分的关键代码
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="ProgId" content="Word.Document"> <meta name="Generator" content="Microsoft Word 11"> <meta name="Originator" content="Microsoft Word 11"> <link rel="File-List" href="file:///G:%5CDOCUME%7E1%5CADMINI%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"> <link rel="Edit-Time-Data" href="file:///G:%5CDOCUME%7E1%5CADMINI%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_editdata.mso"> <!--[if !mso]> <style> v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} </style> <![endif]--><!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:PunctuationKerning/> <w:DrawingGridVerticalSpacing>7.8 磅</w:DrawingGridVerticalSpacing> <w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEvery> <w:DisplayVerticalDrawingGridEvery>2</w:DisplayVerticalDrawingGridEvery> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:Compatibility> <w:SpaceForUL/> <w:BalanceSingleByteDoubleByteWidth/> <w:DoNotLeaveBackslashAlone/> <w:ULTrailSpace/> <w:DoNotExpandShiftReturn/> <w:AdjustLineHeightInTable/> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> <w:DontGrowAutofit/> <w:UseFELayout/> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" LatentStyleCount="156"> </w:LatentStyles> </xml><![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"\@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; line-height:125%; mso-pagination:none; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:宋体; mso-font-kerning:1.0pt;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style> <!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:普通表格; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]--><!--[if gte vml 1]><v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="[email protected]@[email protected]@[email protected]@[email protected]@5xe" filled="f" stroked="f"> <v:stroke joinstyle="miter"/> <v:formulas> <v:f eqn="if lineDrawn pixelLineWidth 0"/> <v:f eqn="sum @0 1 0"/> <v:f eqn="sum 0 0 @1"/> <v:f eqn="prod @2 1 2"/> <v:f eqn="prod @3 21600 pixelWidth"/> <v:f eqn="prod @3 21600 pixelHeight"/> <v:f eqn="sum @0 0 1"/> <v:f eqn="prod @6 1 2"/> <v:f eqn="prod @7 21600 pixelWidth"/> <v:f eqn="sum @8 21600 0"/> <v:f eqn="prod @7 21600 pixelHeight"/> <v:f eqn="sum @10 21600 0"/> </v:formulas> <v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/> <o:lock v:ext="edit" aspectratio="t"/> </v:shapetype><v:shape id="_x0000_i1025" type="#_x0000_t75" style='width:392.25pt; height:314.25pt'> <v:imagedata src="file:///G:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image001.jpg" o:title="IMAGE_00001"/> </v:shape><![endif]--><!--[if !vml]--><!--[endif]-->
由于这个学期的期末将至,因此期末大作业也要开始做了。这次做的是N个月前就做过的网络音视频通信,不过这次做了不少改进。
在这里,先要感谢一下 MacintoshM 大侠,他的帖子给我提供了最原始的源代码,我现在的代码也是在他代码的基础上做出修改的。
OK,现在进入主题,先来介绍一下这个东东:
- 下位机为 mini2440 ,其操作系统是WINCE 5.0,需要在下位机上插入USB摄像头(中星微301,驱动为15分钟限制版),以及插入麦克风耳机;
- 上位机为普通的PC,需要插入麦克风耳机;
- 上位机和下位机的开发环境为Visual Studio 2005。
- 网络视频传输,首先把mini2440与USB摄像头连接在一起,通过USB摄像头捕捉图像(320 x 240,15fps),然后通过UDP协议发送至PC端,在PC屏幕上以15fps的速度显示。
- 网络音频传输,首先在mini2440和PC上都插入麦克风耳机,两者都同时录音,并以G.726编码,然后把压缩包通过UDP协议发送至对方,而在录音的同时,也对来自对方的压缩包用G.726解码,然后再在耳机播放音频。
- 把以前的RTP改为UDP,实践证明,在这个系统中,用UDP的效率会比RTP好,毕竟不需要用到RTP的流量监测等高级功能,仅仅能通信就行了;
- 以前版本基于100M网卡,现在支持10M网卡了,在100M网卡的机器上,可以直接把JPEG图片发过去,但是,在10M的网卡是,每次数据包最大为1440比特,因此要兼容10M网卡,就需要把图像分割成多个1440大小的数据包,分别发送了。
http://download.****.net/user/hellogv
网络音视频通信
下面说说关键的源代码:
以下是WINCE部分的代码
- #pragmaonce
- #include"winsock2.h"
- //RTP支持
- #include"..\UDP\UDP.h"
- //音频支持
- #include"WaveIn.h"
- #include"WaveOut.h"
- //G726支持
- #include"g726.h"
- //摄像头支持
- #include".\video\\zc030xlib.h"
- #defineVideo_Width320//视频宽度
- #defineVideo_Height240//视频长度
- #defineAudioData_Size960//每块音频数据包的大小
- #defineCompr_AudioData_Size120//压缩后音频块的大小
- //音频输入输出变量
- CWaveIn*g_pIn;
- CWaveOut*g_pOut;
- charpin[AudioData_Size],pout[Compr_AudioData_Size];
- charwaveout[AudioData_Size];
- //摄像头输入变量
- DWORDdwSize;
- DWORDdwJpg;
- DWORDdwRtnSize[2];/*0-forbmp,1-forjpeg*/
- LPBYTElpFrameBuffer;
- LPBYTElpJpgBuffer;
- //控制变量
- boolisCameraEnabled;
- //UDP
- CUDP_CEm_CEUdp;
- classAVClass
- {
- public:
- //=====================================================================
- //语法格式:voidInitAV(CWnd*p)
- //实现功能:初始化音频和视频,用于录音、播放音频,以及播放视频
- //参数:p为窗口类指针
- //返回值:无
- //=====================================================================
- voidInitAV(CWnd*p,intlocal_port,CStringremote_ip,intremote_port)
- {
- //-----------------------初始化UDP-----------------------//
- m_CEUdp.m_OnUdpRecv=OnUdpCERecv;
- DWORDnResult=m_CEUdp.Open(p,local_port,remote_ip,remote_port);
- if(nResult<=0)
- {
- AfxMessageBox(_T("打开端口失败"));
- return;
- }
- //------------------------控制变量-----------------------//
- isCameraEnabled=false;
- //-------------------------视频--------------------------//
- inti=capInitCamera();
- dwSize=320*240*3;
- dwJpg=40960;
- lpFrameBuffer=(LPBYTE)malloc(dwSize);
- lpJpgBuffer=(LPBYTE)malloc(dwJpg);
- if(i<=0)
- {
- //::MessageBox(NULL,L"Initcameraerror",L"Notice",0);
- gotovideo_error;//出错,释放空间
- }
- if(0!=capSetVideoFormat(0,VIDEO_PALETTE_RGB24,VIDEO_SIZE_SIF))
- {
- //::MessageBox(NULL,L"SetVideoFormaterror",L"Notice",0);
- gotovideo_error;//出错,释放空间
- }
- if(capStartCamera(0)!=0)
- {
- //::MessageBox(NULL,L"StartCameraerror",L"Notice",0);
- capStopCamera(0);
- gotovideo_error;//出错,释放空间
- }
- //没出错,进行视频(控制状态)、音频设置
- isCameraEnabled=true;
- gotoaudio;
- video_error:
- free(lpFrameBuffer);
- lpFrameBuffer=NULL;
- free(lpJpgBuffer);
- lpJpgBuffer=NULL;
- //-------------------------音频--------------------------//
- audio:
- g_pOut=newCWaveOut();
- g_pIn=newCWaveIn();
- g_pOut->StartPlay();
- g_pIn->StartRec(OnRecCapAndSend,(DWORD)p);
- }
- //=====================================================================
- //语法格式:voidFreeAV()
- //实现功能:释放音频、视频
- //参数:无
- //返回值:无
- //=====================================================================
- voidFreeAV()
- {
- //-------------------------视频--------------------------//
- if(isCameraEnabled)
- capStopCamera(0);
- //-------------------------音频--------------------------//
- g_pOut->StopPlay();
- g_pIn->StopRec();
- deleteg_pOut;
- deleteg_pIn;
- //------------------------UDP------------------------//
- m_CEUdp.Close();
- }
- //=====================================================================
- //语法格式:voidRecAndPlay(WPARAMwParam,LPARAMlParam)
- //实现功能:接收网络传来的音频,以及播放
- //参数:wParam,表示数据;lParam,表示数据长度
- //返回值:无
- //=====================================================================
- staticvoidCALLBACKOnUdpCERecv(CWnd*pWnd,char*buf,intnLen,sockaddr*addr)
- {
- g726_Decode(buf,(unsignedchar*)waveout);
- g_pOut->Play(waveout,AudioData_Size);
- }
- //=====================================================================
- //语法格式:staticvoidOnRecCapAndSend(char*data,intlength,DWORDuserdata)
- //实现功能:录音,摄像并且发送
- //参数:data表示数据,length表示数据长度,userdata暂时没用
- //返回值:无
- //=====================================f================================
- staticvoidOnRecCapAndSend(char*data,intlength,DWORDuserdata)
- {
- //-------------------------音频--------------------------//
- memcpy(pin,g_pIn->buffer,AudioData_Size);
- g726_Encode((unsignedchar*)pin,pout);
- m_CEUdp.SendData(pout,Compr_AudioData_Size);
- //-------------------------视频--------------------------//
- if(isCameraEnabled==false)//如果程序不能用摄像头
- return;
- Sleep(15);
- intindex=0;
- memset(lpFrameBuffer,0,dwSize);
- memset(lpJpgBuffer,0,dwJpg);
- dwRtnSize[0]=dwRtnSize[1]=0;
- if(capGetPicture(index,lpFrameBuffer,dwSize,lpJpgBuffer,dwJpg,dwRtnSize)==0)
- {
- ///m_CEUdp.SendData((constchar*)lpJpgBuffer,dwRtnSize[1]);
- chartmp[1440];
- inttmp_i=0;
- for(inti=0;i<dwRtnSize[1];i++)
- {
- tmp[tmp_i]=lpJpgBuffer[i];
- tmp_i++;
- if(tmp_i==1440)
- {
- m_CEUdp.SendData(tmp,1440);
- tmp_i=0;
- }
- elseif(i==dwRtnSize[1]-1)
- {
- m_CEUdp.SendData(tmp,dwRtnSize[1]-(dwRtnSize[1]/1440)*1440);
- tmp_i=0;
- }
- }
- }
- }
- };
- #pragmaonce
- #include"winsock2.h"
- //UDP支持
- #include"..\UDP\UDP.h"
- //音频支持
- #include"WaveIn.h"
- #include"waveout.h"
- //G726支持
- #include"g726.h"
- //视频支持
- #include"Gdiplus.h"
- usingnamespaceGdiplus;
- #defineVideoData_Size1440//每块视频数据包的大小
- #defineVideo_Width320//视频宽度
- #defineVideo_Height240//视频长度
- #defineAudioData_Size960//每块音频数据包的大小
- #defineCompr_AudioData_Size120//压缩后音频块的大小
- //音频输入输出变量
- CWaveIn*g_pIn;
- CWaveOut*g_pOut;
- charpin[AudioData_Size],pout[Compr_AudioData_Size];
- charwave_data[AudioData_Size];
- //UDP变量
- CUDP_CEm_CEUdp;
- //视频输入变量
- GdiplusStartupInputm_gdiPlusInPut;
- ULONG_PTRm_gdiPlusToken;
- charvideo_data[Video_Width*Video_Height];
- intindex;//视频数据当前索引
- classAVClass
- {
- private:
- public:
- //=====================================================================
- //语法格式:voidInitAV(CWnd*p)
- //实现功能:初始化音频和视频,用于录音、播放音频,以及播放视频
- //参数:p为窗口类指针
- //返回值:无
- //=====================================================================
- voidInitAV(CWnd*p,intlocal_port,CStringremote_ip,intremote_port)
- {
- //-------------------------UDP连接--------------------------//
- m_CEUdp.m_OnUdpRecv=OnUdpCERecv;
- DWORDnResult=m_CEUdp.Open(p,local_port,remote_ip,remote_port);
- if(nResult<=0)
- {
- AfxMessageBox(_T("打开端口失败"));
- return;
- }
- //-------------------------音频--------------------------//
- g_pOut=newCWaveOut();
- g_pIn=newCWaveIn();
- g_pOut->StartPlay();
- g_pIn->StartRec(OnRecording,(DWORD)p);
- //-------------------------视频--------------------------//
- GdiplusStartup(&m_gdiPlusToken,&m_gdiPlusInPut,NULL);//初始化GDI+
- memset(video_data,0,Video_Width*Video_Height);
- index=0;
- }
- //=====================================================================
- //语法格式:voidFreeAV()
- //实现功能:释放音频、视频
- //参数:无
- //返回值:无
- //=====================================================================
- voidFreeAV()
- {
- //-------------------------音频--------------------------//
- g_pOut->StopPlay();
- g_pIn->StopRec();
- deleteg_pOut;
- deleteg_pIn;
- //-------------------------视频--------------------------//
- GdiplusShutdown(m_gdiPlusToken);//销毁GDI+
- //------------------------UDP--------------------------//
- m_CEUdp.Close();
- }
- //=====================================================================
- //语法格式:voidRecAndPlay(WPARAMwParam,LPARAMlParam,HWNDhwnd)
- //实现功能:接收网络传来的音频,以及播放
- //参数:wParam,表示数据;lParam,表示数据长度;hwnd,表示显示视频的窗口句柄
- //返回值:无
- //=====================================================================
- staticvoidCALLBACKOnUdpCERecv(CWnd*pWnd,char*buf,intnLen,sockaddr*addr)
- {
- /*测试收到的数据大小
- CStringtmp;
- tmp.Format(L"%d",nLen);
- MessageBox(0,tmp,0,0);
- return;*/
- //-------------------------如果是音频数据--------------------------//
- if(nLen==Compr_AudioData_Size)
- {
- g726_Decode(buf,(unsignedchar*)wave_data);
- g_pOut->Play(wave_data,AudioData_Size);
- return;
- }
- //-------------------------如果是视频数据--------------------------//
- if(nLen==VideoData_Size)//完整的视频数据块
- {
- for(inti=0;i<nLen;i++)
- {
- video_data[index]=buf[i];
- index++;
- }
- return;
- }
- //视频数据块的最后一块
- for(inti=0;i<nLen;i++)
- {
- video_data[index]=buf[i];
- index++;
- }
- //如果JPEG图像特别大,则肯定是出错,则抛弃
- if(index>Video_Width*Video_Height)
- {
- //MessageBox(0,"缓冲区出错","错误信息",0);
- return;
- }
- try{
- IPicture*pPic;
- IStream*pStm;
- //分配全局存储空间
- HGLOBALhGlobal=GlobalAlloc(GMEM_MOVEABLE,index);
- LPVOIDpvData=NULL;
- //锁定分配内存块
- pvData=GlobalLock(hGlobal);
- //复制数据包video_data到pvData
- memcpy(pvData,video_data,index);
- GlobalUnlock(hGlobal);
- CreateStreamOnHGlobal(hGlobal,TRUE,&pStm);
- ULARGE_INTEGERpSeek;
- LARGE_INTEGERdlibMove={0};
- pStm->Seek(dlibMove,STREAM_SEEK_SET,&pSeek);
- //Sleep(15);
- //装入图形文件
- if(FAILED(OleLoadPicture(pStm,index,TRUE,IID_IPicture,(LPVOID*)&pPic)))
- {//附:如果video_data这个数组包含的图像有错,则OleLoadPicture容易产生读写内存错误
- //pPic->Release();
- //pStm->Release();
- return;
- }
- Imageimg(pStm,0);
- GraphicsmGraphics(GetDC(pWnd->m_hWnd));
- mGraphics.DrawImage(&img,0,0,Video_Width,Video_Height);
- img.~Image();//会出错
- mGraphics.~Graphics();
- pPic->Release();
- pStm->Release();
- }
- catch(CException*e)
- {}
- memset(video_data,0,Video_Width*Video_Height);
- index=0;
- }
- //=====================================================================
- //语法格式:staticvoidOnRecording(char*data,intlength,DWORDuserdata)
- //实现功能:释放音频
- //参数:data表示数据,length表示数据长度,userdata暂时没用
- //返回值:无
- //=====================================================================
- staticvoidOnRecording(char*data,intlength,DWORDuserdata)
- {
- memcpy(pin,g_pIn->buffer,AudioData_Size);
- g726_Encode((unsignedchar*)pin,pout);
- m_CEUdp.SendData(pout,Compr_AudioData_Size);
- }
- };