- 浏览: 150446 次
- 性别:
- 来自: 广州
最新评论
-
yinren13:
说的便捷的视频会议,我们公司的遥控器一按就能开始的视频会议tu ...
便捷视频会议 -
xujinquan19:
...
可视通讯与移植、跨平台开发 -
xujinquan19:
...
Android 平台下的即时通讯 -
xujinquan19:
...
Android 平台下的即时通讯 -
xujinquan19:
...
Android 平台下的即时通讯
1. BRAnyChatSDKDemoDlg.cpp : implementation file
2. //
3.
4. #include "stdafx.h"
5. #include <WINSOCK2.H>
6. #include "BRAnyChatSDKDemo.h"
7. #include "BRAnyChatSDKDemoDlg.h"
8.
9.
10. #ifdef _DEBUG
11. #define new DEBUG_NEW
12. #undef THIS_FILE
13. static char THIS_FILE[] = __FILE__;
14. #endif
15.
16.
17. #define REFRESH_TRANSTASK_STATUS_TIMER 1 ///< 刷新传输任务状态定时器
18. #define REFRESH_SPEAKVOLUME_TIMER 2 ///< 更新用户说话音量定时器
19. #define REFRESH_RECORDSTATE_TIMER 3 ///< 更新录像状态定时器
20.
21. class CAboutDlg : public CDialog
22. {
23. public:
24. CAboutDlg();
25.
26. // Dialog Data
27. //{{AFX_DATA(CAboutDlg)
28. enum { IDD = IDD_ABOUTBOX };
29. //}}AFX_DATA
30.
31. // ClassWizard generated virtual function overrides
32. //{{AFX_VIRTUAL(CAboutDlg)
33. protected:
34. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
35. //}}AFX_VIRTUAL
36.
37. // Implementation
38. protected:
39. //{{AFX_MSG(CAboutDlg)
40. //}}AFX_MSG
41. DECLARE_MESSAGE_MAP()
42. };
43.
44. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
45. {
46. //{{AFX_DATA_INIT(CAboutDlg)
47. //}}AFX_DATA_INIT
48. }
49.
50. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
51. {
52. CDialog::DoDataExchange(pDX);
53. //{{AFX_DATA_MAP(CAboutDlg)
54. //}}AFX_DATA_MAP
55. }
56.
57. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
58. //{{AFX_MSG_MAP(CAboutDlg)
59. // No message handlers
60. //}}AFX_MSG_MAP
61. END_MESSAGE_MAP()
62.
63. /////////////////////////////////////////////////////////////////////////////
64. // CBRAnyChatSDKDemoDlg dialog
65.
66. CBRAnyChatSDKDemoDlg::CBRAnyChatSDKDemoDlg(CWnd* pParent )
67. : CDialog(CBRAnyChatSDKDemoDlg::IDD, pParent)
68. {
69. //{{AFX_DATA_INIT(CBRAnyChatSDKDemoDlg)
70. m_bEnableAGC = TRUE;
71. m_bEnableEcho = TRUE;
72. m_bEnableNS = TRUE;
73. m_bEnableVAD = TRUE;
74. m_iPort = 8906;
75. m_iRoomId = 1;
76. //}}AFX_DATA_INIT
77. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
78. }
79.
80. void CBRAnyChatSDKDemoDlg::DoDataExchange(CDataExchange* pDX)
81. {
82. CDialog::DoDataExchange(pDX);
83. //{{AFX_DATA_MAP(CBRAnyChatSDKDemoDlg)
84. DDX_Control(pDX, IDC_PROGRESS_SPEAKVOLUME0, m_ctrlSpeakVolume0);
85. DDX_Control(pDX, IDC_PROGRESS_SPEAKVOLUME1, m_ctrlSpeakVolume1);
86. DDX_Control(pDX, IDC_PROGRESS_SPEAKVOLUME2, m_ctrlSpeakVolume2);
87. DDX_Control(pDX, IDC_PROGRESS_SPEAKVOLUME3, m_ctrlSpeakVolume3);
88. DDX_Control(pDX, IDC_SLIDER_OUTVOLUME, m_ctrlOutVolume);
89. DDX_Control(pDX, IDC_SLIDER_INVOLUME, m_ctrlInVolume);
90. DDX_Control(pDX, IDC_COMBO_VCAPTURE, m_cbVideoCapture);
91. DDX_Control(pDX, IDC_COMBO_ACAPTURE, m_cbAudioCapture);
92. DDX_Control(pDX, IDC_EDIT_LOG, m_ctrlEditLog);
93. DDX_Check(pDX, IDC_CHECK_AGC, m_bEnableAGC);
94. DDX_Check(pDX, IDC_CHECK_ECHO, m_bEnableEcho);
95. DDX_Check(pDX, IDC_CHECK_NS, m_bEnableNS);
96. DDX_Check(pDX, IDC_CHECK_VAD, m_bEnableVAD);
97. DDX_Text(pDX, IDC_EDIT_PORT, m_iPort);
98. DDX_Text(pDX, IDC_EDIT_ROOMID, m_iRoomId);
99. //}}AFX_DATA_MAP
100. }
101.
102. BEGIN_MESSAGE_MAP(CBRAnyChatSDKDemoDlg, CDialog)
103. //{{AFX_MSG_MAP(CBRAnyChatSDKDemoDlg)
104. ON_WM_SYSCOMMAND()
105. ON_WM_PAINT()
106. ON_WM_QUERYDRAGICON()
107. ON_WM_DESTROY()
108. ON_BN_CLICKED(IDC_BUTTON_INIT, OnButtonInit)
109. ON_MESSAGE(WM_GV_CONNECT,OnGVClientConnect)
110. ON_MESSAGE(WM_GV_LOGINSYSTEM,OnGVClientLogin)
111. ON_MESSAGE(WM_GV_ENTERROOM,OnGVClientEnterRoom)
112. ON_MESSAGE(WM_GV_ONLINEUSER,OnGVClientOnlineUser)
113. ON_MESSAGE(WM_GV_USERATROOM,OnGVClientUserAtRoom)
114. ON_MESSAGE(WM_GV_MICSTATECHANGE,OnGVClientMicStateChange)
115. ON_MESSAGE(WM_GV_LINKCLOSE,OnGVClientLinkClose)
116. ON_MESSAGE(WM_GV_CHATMODECHG,OnGVClientChatModeChange)
117. ON_BN_CLICKED(IDC_BUTTON_ENTERROOM, OnButtonEnterRoom)
118. ON_BN_CLICKED(IDC_BUTTON_LEAVEROOM, OnButtonLeaveRoom)
119. ON_BN_CLICKED(IDC_BUTTON_VIDEOPROPERTY, OnButtonVideoproperty)
120. ON_BN_CLICKED(IDC_BUTTON_REFRESHCAPTURE, OnButtonRefreshCapture)
121. ON_CBN_SELCHANGE(IDC_COMBO_VCAPTURE, OnSelchangeComboVideoCapture)
122. ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDER_OUTVOLUME, OnSliderOutVolumeChange)
123. ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDER_INVOLUME, OnOnSliderInVolumeChange)
124. ON_CBN_SELCHANGE(IDC_COMBO_ACAPTURE, OnSelChangeComboAudioCapture)
125. ON_WM_TIMER()
126. ON_BN_CLICKED(IDC_BUTTON_SENDFILE, OnButtonSendFile)
127. ON_BN_CLICKED(IDC_CHECK_VAD, OnCheckVad)
128. ON_BN_CLICKED(IDC_CHECK_AGC, OnCheckAgc)
129. ON_BN_CLICKED(IDC_CHECK_ECHO, OnCheckEcho)
130. ON_BN_CLICKED(IDC_CHECK_NS, OnCheckNs)
131. ON_BN_CLICKED(IDC_BUTTON_TRANSBUF, OnButtonTransbuf)
132. ON_BN_CLICKED(IDC_BUTTON_RELEASE, OnButtonRelease)
133. ON_BN_CLICKED(IDC_BUTTON_VIDEOCTRL0, OnButtonVideoctrl0)
134. ON_BN_CLICKED(IDC_BUTTON_VIDEOCTRL1, OnButtonVideoctrl1)
135. ON_BN_CLICKED(IDC_BUTTON_VIDEOCTRL2, OnButtonVideoctrl2)
136. ON_BN_CLICKED(IDC_BUTTON_VIDEOCTRL3, OnButtonVideoctrl3)
137. ON_BN_CLICKED(IDC_BUTTON_AUDIOCTRL0, OnButtonAudioctrl0)
138. ON_BN_CLICKED(IDC_BUTTON_AUDIOCTRL1, OnButtonAudioctrl1)
139. ON_BN_CLICKED(IDC_BUTTON_AUDIOCTRL2, OnButtonAudioctrl2)
140. ON_BN_CLICKED(IDC_BUTTON_AUDIOCTRL3, OnButtonAudioctrl3)
141. ON_BN_CLICKED(IDC_BUTTON_RECORDCTRL0, OnButtonRecordctrl0)
142. ON_BN_CLICKED(IDC_BUTTON_RECORDCTRL1, OnButtonRecordctrl1)
143. ON_BN_CLICKED(IDC_BUTTON_RECORDCTRL2, OnButtonRecordctrl2)
144. ON_BN_CLICKED(IDC_BUTTON_RECORDCTRL3, OnButtonRecordctrl3)
145. ON_BN_CLICKED(IDC_BUTTON_SNAPSHOTCTRL0, OnButtonSnapshotctrl0)
146. ON_BN_CLICKED(IDC_BUTTON_SNAPSHOTCTRL1, OnButtonSnapshotctrl1)
147. ON_BN_CLICKED(IDC_BUTTON_SNAPSHOTCTRL2, OnButtonSnapshotctrl2)
148. ON_BN_CLICKED(IDC_BUTTON_SNAPSHOTCTRL3, OnButtonSnapshotctrl3)
149. ON_BN_CLICKED(IDC_BUTTON_LOGIN, OnButtonLogin)
150. ON_BN_CLICKED(IDC_BUTTON_LOGOUT, OnButtonLogout)
151. //}}AFX_MSG_MAP
152. END_MESSAGE_MAP()
153.
154.
155. void CALLBACK VideoData_CallBack(DWORD dwUserid, LPVOID lpBuf, DWORD dwLen, BITMAPINFOHEADER bmiHeader, LPVOID lpUserValue)
156. {
157. CBRAnyChatSDKDemoDlg* pDemoDlg = (CBRAnyChatSDKDemoDlg*)lpUserValue;
158. if(pDemoDlg)
159. pDemoDlg->DrawUserVideo(dwUserid,lpBuf,dwLen,bmiHeader);
160. }
161.
162. void CALLBACK AudioData_CallBack(DWORD dwUserid, LPVOID lpBuf, DWORD dwLen, WAVEFORMATEX waveFormatEx, LPVOID lpUserValue)
163. {
164. CBRAnyChatSDKDemoDlg* pDemoDlg = (CBRAnyChatSDKDemoDlg*)lpUserValue;
165. if(pDemoDlg)
166. {
167. // do something ...
168. }
169. }
170.
171.
172. void CALLBACK VolumeChange_CallBack(BRAC_AudioDevice device, DWORD dwCurrentVolume, LPVOID lpUserValue)
173. {
174. CBRAnyChatSDKDemoDlg* pDemoDlg = (CBRAnyChatSDKDemoDlg*)lpUserValue;
175. if(pDemoDlg)
176. {
177. if(device == BRAC_AD_WAVEIN)
178. pDemoDlg->OnWaveInVolumeChange(dwCurrentVolume);
179. else
180. pDemoDlg->OnWaveOutVolumeChange(dwCurrentVolume);
181. }
182. }
183. // 透明通道数据回调函数定义
184. void CALLBACK TransBuffer_CallBack(DWORD dwUserid, LPBYTE lpBuf, DWORD dwLen, LPVOID lpUserValue)
185. {
186. CBRAnyChatSDKDemoDlg* pDemoDlg = (CBRAnyChatSDKDemoDlg*)lpUserValue;
187. if(pDemoDlg)
188. {
189. CString strNotify;
190. strNotify.Format("TransBuffer_CallBack:dwUserid-%d, bufSize-%d",dwUserid,dwLen);
191. pDemoDlg->AppendLogString(strNotify);
192. }
193. }
194.
195. // 透明通道数据扩展回调函数定义
196. void CALLBACK TransBufferEx_CallBack(DWORD dwUserid, LPBYTE lpBuf, DWORD dwLen, DWORD wParam, DWORD lParam, DWORD dwTaskId, LPVOID lpUserValue)
197. {
198. CBRAnyChatSDKDemoDlg* pDemoDlg = (CBRAnyChatSDKDemoDlg*)lpUserValue;
199. if(pDemoDlg)
200. {
201. BOOL bSuccess = FALSE;
202. if(dwLen > 1000)
203. {
204. bSuccess = lpBuf[1000] == 'Y' ? TRUE : FALSE;
205. }
206. CString strNotify;
207. strNotify.Format("TransBufferEx_CallBack:dwUserid-%d, bufSize-%d,verify:%s",dwUserid,dwLen,bSuccess ? "Success" : "Fail");
208. pDemoDlg->AppendLogString(strNotify);
209. }
210. }
211. // 文件传输回调函数定义
212. void CALLBACK TransFile_CallBack(DWORD dwUserid, LPCTSTR lpFileName, LPCTSTR lpTempFilePath, DWORD dwFileLength, DWORD wParam, DWORD lParam, DWORD dwTaskId, LPVOID lpUserValue)
213. {
214. CBRAnyChatSDKDemoDlg* pDemoDlg = (CBRAnyChatSDKDemoDlg*)lpUserValue;
215. if(pDemoDlg)
216. {
217. CString strNotify;
218. strNotify.Format("TransFile_CallBack:dwUserid-%d, lpFileName-%s, lpTempFilePath-%s",dwUserid,lpFileName,lpTempFilePath);
219. pDemoDlg->AppendLogString(strNotify);
220. }
221. }
222.
223. // 录像、快照任务完成回调函数定义
224. void CALLBACK RecordSnapShot_CallBack(DWORD dwUserid, LPCTSTR lpFileName, DWORD dwParam, BOOL bRecordType, LPVOID lpUserValue)
225. {
226. CBRAnyChatSDKDemoDlg* pDemoDlg = (CBRAnyChatSDKDemoDlg*)lpUserValue;
227. if(pDemoDlg)
228. {
229. CString strNotify;
230. strNotify.Format("%s CallBack:dwUserid-%d, FilePathName-%s",bRecordType?"Record":"SnapShot",(int)dwUserid,lpFileName);
231. pDemoDlg->AppendLogString(strNotify);
232. }
233. }
234.
235. // SDK Filter 通信数据回调函数定义
236. void CALLBACK SDKFilterData_CallBack(LPBYTE lpBuf, DWORD dwLen, LPVOID lpUserValue)
237. {
238. CBRAnyChatSDKDemoDlg* pDemoDlg = (CBRAnyChatSDKDemoDlg*)lpUserValue;
239. if(pDemoDlg)
240. {
241. CString strNotify;
242. strNotify.Format("SDK Filter CallBack:%s",lpBuf);
243. pDemoDlg->AppendLogString(strNotify);
244. }
245. }
246.
247.
248. void CBRAnyChatSDKDemoDlg::DrawUserVideo(DWORD dwUserid, LPVOID lpBuf, DWORD dwLen, BITMAPINFOHEADER bmiHeader)
249. {
250. // 根据用户ID号找到合适的显示区域
251. DWORD dwSite = -1;
252. for(INT i=0; i<DEMO_SHOW_USER_NUM; i++)
253. {
254. if(m_iUserID[i] == (INT)dwUserid)
255. {
256. dwSite = i;
257. break;
258. }
259. }
260. if(dwSite == -1)
261. return;
262.
263. CRect dispRect = m_UserRect[dwSite];
264.
265. //构建Bitmap
266. BITMAPINFOHEADER *lpbmi = (BITMAPINFOHEADER*)malloc(sizeof(BITMAPINFOHEADER)+dwLen);
267. ZeroMemory(lpbmi,sizeof(BITMAPINFOHEADER)+dwLen);
268. memcpy((LPBYTE)lpbmi,&bmiHeader,sizeof(bmiHeader));
269. memcpy(((LPBYTE)lpbmi+sizeof(BITMAPINFOHEADER)),lpBuf,dwLen);
270.
271. HDC hdc = ::GetDC(m_hWnd);
272. HDC dcMem = ::CreateCompatibleDC(hdc);
273. HBITMAP hBitmap = CreateDIBitmap(hdc,lpbmi,CBM_INIT,(LPBYTE)lpbmi+sizeof(BITMAPINFOHEADER),(LPBITMAPINFO)lpbmi,DIB_RGB_COLORS);
274. //绘图
275. HBITMAP holdbm = (HBITMAP)SelectObject(dcMem,hBitmap);
276. ::SetStretchBltMode(hdc,COLORONCOLOR);
277. ::StretchBlt(hdc,dispRect.left,dispRect.top,dispRect.Width(),dispRect.Height(),dcMem,0,0,bmiHeader.biWidth,bmiHeader.biHeight,SRCCOPY);
278.
279. SelectObject(dcMem,holdbm);
280. ::DeleteDC(dcMem);
281. ::DeleteObject(hBitmap);
282. ::ReleaseDC(m_hWnd,hdc);
283. free(lpbmi);
284. lpbmi = NULL;
285. }
286.
287. BOOL CBRAnyChatSDKDemoDlg::OnInitDialog()
288. {
289. CDialog::OnInitDialog();
290.
291. // IDM_ABOUTBOX must be in the system command range.
292. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
293. ASSERT(IDM_ABOUTBOX < 0xF000);
294.
295. CMenu* pSysMenu = GetSystemMenu(FALSE);
296. if (pSysMenu != NULL)
297. {
298. CString strAboutMenu;
299. strAboutMenu.LoadString(IDS_ABOUTBOX);
300. if (!strAboutMenu.IsEmpty())
301. {
302. pSysMenu->AppendMenu(MF_SEPARATOR);
303. pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
304. }
305. }
306.
307. SetIcon(m_hIcon, TRUE); // Set big icon
308. SetIcon(m_hIcon, FALSE); // Set small icon
309.
310. // 初始化每个视频显示位置信息
311. GetDlgItem(IDC_STATIC_USER0)->ShowWindow(SW_HIDE);
312. GetDlgItem(IDC_STATIC_USER0)->GetClientRect(m_UserRect[0]);
313. GetDlgItem(IDC_STATIC_USER0)->ClientToScreen(m_UserRect[0]);
314. ScreenToClient(m_UserRect[0]);
315.
316. GetDlgItem(IDC_STATIC_USER1)->ShowWindow(SW_HIDE);
317. GetDlgItem(IDC_STATIC_USER1)->GetClientRect(m_UserRect[1]);
318. GetDlgItem(IDC_STATIC_USER1)->ClientToScreen(m_UserRect[1]);
319. ScreenToClient(m_UserRect[1]);
320.
321. GetDlgItem(IDC_STATIC_USER2)->ShowWindow(SW_HIDE);
322. GetDlgItem(IDC_STATIC_USER2)->GetClientRect(m_UserRect[2]);
323. GetDlgItem(IDC_STATIC_USER2)->ClientToScreen(m_UserRect[2]);
324. ScreenToClient(m_UserRect[2]);
325.
326. GetDlgItem(IDC_STATIC_USER3)->ShowWindow(SW_HIDE);
327. GetDlgItem(IDC_STATIC_USER3)->GetClientRect(m_UserRect[3]);
328. GetDlgItem(IDC_STATIC_USER3)->ClientToScreen(m_UserRect[3]);
329. ScreenToClient(m_UserRect[3]);
330.
331. // 隐藏录像状态标志
332. GetDlgItem(IDC_STATIC_RECORDSTATE0)->ShowWindow(SW_HIDE);
333. GetDlgItem(IDC_STATIC_RECORDSTATE1)->ShowWindow(SW_HIDE);
334. GetDlgItem(IDC_STATIC_RECORDSTATE2)->ShowWindow(SW_HIDE);
335. GetDlgItem(IDC_STATIC_RECORDSTATE3)->ShowWindow(SW_HIDE);
336.
337. for(INT i=0; i<DEMO_SHOW_USER_NUM; i++)
338. {
339. m_iUserID[i] = -1;
340. }
341.
342. m_dwTransTaskId = -1;
343.
344. m_iPort = 8906;
345. m_iRoomId = 1;
346. SetDlgItemText(IDC_IPADDRESS_SERVER,"211.155.25.90");
347. SetDlgItemText(IDC_EDIT_USERNAME,"AnyChat3");
348. UpdateData(FALSE);
349. return TRUE; // return TRUE unless you set the focus to a control
350. }
351.
352. void CBRAnyChatSDKDemoDlg::OnSysCommand(UINT nID, LPARAM lParam)
353. {
354. if ((nID & 0xFFF0) == IDM_ABOUTBOX)
355. {
356. CAboutDlg dlgAbout;
357. dlgAbout.DoModal();
358. }
359. else
360. {
361. CDialog::OnSysCommand(nID, lParam);
362. }
363. }
364.
365. // If you add a minimize button to your dialog, you will need the code below
366. // to draw the icon. For MFC applications using the document/view model,
367. // this is automatically done for you by the framework.
368.
369. void CBRAnyChatSDKDemoDlg::OnPaint()
370. {
371. if (IsIconic())
372. {
373. CPaintDC dc(this); // device context for painting
374.
375. SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
376.
377. // Center icon in client rectangle
378. int cxIcon = GetSystemMetrics(SM_CXICON);
379. int cyIcon = GetSystemMetrics(SM_CYICON);
380. CRect rect;
381. GetClientRect(&rect);
382. int x = (rect.Width() - cxIcon + 1) / 2;
383. int y = (rect.Height() - cyIcon + 1) / 2;
384.
385. // Draw the icon
386. dc.DrawIcon(x, y, m_hIcon);
387. }
388. else
389. {
390. CDialog::OnPaint();
391. }
392. }
393.
394. HCURSOR CBRAnyChatSDKDemoDlg::OnQueryDragIcon()
395. {
396. return (HCURSOR) m_hIcon;
397. }
398.
399. void CBRAnyChatSDKDemoDlg::OnDestroy()
400. {
401. BRAC_Release();
402. CDialog::OnDestroy();
403. }
404.
405. void CBRAnyChatSDKDemoDlg::OnButtonInit()
406. {
407. // 获取SDK的版本信息
408. DWORD dwMainVer,dwSubVer;
409. CHAR szCompileTime[100] = {0};
410. BRAC_GetSDKVersion(dwMainVer,dwSubVer,szCompileTime,sizeof(szCompileTime));
411.
412. CString logstr;
413. logstr.Format("AnyChat Core SDK Version:%d.%d(%s)",dwMainVer,dwSubVer,szCompileTime);
414. AppendLogString(logstr);
415.
416. // 打开(关闭)SDK的日志记录功能
417. BRAC_ActiveCallLog(TRUE);
418.
419. // 设置SDK核心组件所在目录(注:demo程序只是设置为当前目录,项目中需要设置为实际路径)
420. CHAR szCoreSDKPath[MAX_PATH] = {0};
421. GetModuleFileName(NULL,szCoreSDKPath,sizeof(szCoreSDKPath));
422. (strrchr(szCoreSDKPath,'\\'))[1] = 0;
423. BRAC_SetSDKOption(BRAC_SO_CORESDK_PATH,szCoreSDKPath,strlen(szCoreSDKPath));
424.
425. // 根据BRAC_InitSDK的第二个参数:dwFuncMode,来告诉SDK该如何处理相关的任务(详情请参考开发文档)
426. DWORD dwFuncMode = BRAC_FUNC_VIDEO_AUTODISP | BRAC_FUNC_AUDIO_AUTOPLAY | BRAC_FUNC_CHKDEPENDMODULE |
427. BRAC_FUNC_AUDIO_VOLUMECALC | BRAC_FUNC_NET_SUPPORTUPNP | BRAC_FUNC_FIREWALL_OPEN |
428. BRAC_FUNC_AUDIO_AUTOVOLUME| BRAC_FUNC_AUDIO_VOLUMECALC | BRAC_FUNC_CONFIG_LOCALINI;
429. BRAC_InitSDK(this->GetSafeHwnd(),dwFuncMode);
430. BRAC_SetVideoDataCallBack(BRAC_PIX_FMT_RGB24,VideoData_CallBack,this);
431. BRAC_SetAudioDataCallBack(AudioData_CallBack,this);
432. BRAC_SetVolumeChangeCallBack(VolumeChange_CallBack,this);
433. BRAC_SetTransBufferExCallBack(TransBufferEx_CallBack,this);
434. BRAC_SetTransBufferCallBack(TransBuffer_CallBack,this);
435. BRAC_SetTransFileCallBack(TransFile_CallBack,this);
436. BRAC_SetRecordSnapShotCallBack(RecordSnapShot_CallBack,this);
437. BRAC_SetSDKFilterDataCallBack(SDKFilterData_CallBack,this);
438. // BRAC_SelectVideoCapture("USB 视频设备"); // 设置指定的视频设备,则在后面打开时,就可以打开该设备,如果不调用该方法,则会打开默认的视频设备
439.
440. UpdateData(TRUE);
441. BRAC_SetSDKOption(BRAC_SO_AUDIO_AGCCTRL,(PCHAR)&m_bEnableAGC,sizeof(m_bEnableAGC));
442. BRAC_SetSDKOption(BRAC_SO_AUDIO_VADCTRL,(PCHAR)&m_bEnableVAD,sizeof(m_bEnableVAD));
443. BRAC_SetSDKOption(BRAC_SO_AUDIO_NSCTRL,(PCHAR)&m_bEnableNS,sizeof(m_bEnableNS));
444. BRAC_SetSDKOption(BRAC_SO_AUDIO_ECHOCTRL,(PCHAR)&m_bEnableEcho,sizeof(m_bEnableEcho));
445.
446. // 设置录像临时文件保存路径
447. CHAR szRecordDirectory[MAX_PATH] = {0};
448. ::GetModuleFileName(NULL,szRecordDirectory,MAX_PATH);
449. (strrchr(szRecordDirectory,'\\'))[1] = 0;
450. strcat(szRecordDirectory,"Record");
451. BRAC_SetSDKOption(BRAC_SO_RECORD_TMPDIR,szRecordDirectory,strlen(szRecordDirectory));
452. // 设置录像文件质量参数
453. DWORD dwVideoBitrate = 200 * 1000; // 200kbps
454. BRAC_SetSDKOption(BRAC_SO_RECORD_VIDEOBR,(PCHAR)&dwVideoBitrate,sizeof(DWORD));
455. DWORD dwAudioBitrate = 96 * 1000; // 96kbps
456. BRAC_SetSDKOption(BRAC_SO_RECORD_AUDIOBR,(PCHAR)&dwAudioBitrate,sizeof(DWORD));
457.
458. // 设置快照临时文件保存路径
459. CHAR szSnapShotDirectory[MAX_PATH] = {0};
460. ::GetModuleFileName(NULL,szSnapShotDirectory,MAX_PATH);
461. (strrchr(szSnapShotDirectory,'\\'))[1] = 0;
462. strcat(szSnapShotDirectory,"SnapShot");
463. BRAC_SetSDKOption(BRAC_SO_SNAPSHOT_TMPDIR,szSnapShotDirectory,strlen(szSnapShotDirectory));
464.
465. // 设置SDK临时文件路径
466. CHAR szTempPath[MAX_PATH] = {0};
467. ::GetModuleFileName(NULL,szTempPath,MAX_PATH);
468. (strrchr(szTempPath,'\\'))[1] = 0;
469. strcat(szTempPath,"Temp");
470. BRAC_SetSDKOption(BRAC_SO_CORESDK_TMPDIR,szTempPath,strlen(szTempPath));
471.
472. // 设置服务器认证密码
473. BRAC_SetServerAuthPass("BaiRuiTech"); // 需要与服务器配置项“SDKAuthPass”相同(大小写敏感),SDK才能正常连接到服务器
474.
475. DWORD dwVolume = 0;
476. BRAC_AudioGetVolume(BRAC_AD_WAVEOUT,dwVolume);
477. m_ctrlOutVolume.SetPos(dwVolume);
478.
479. dwVolume = 0;
480. BRAC_AudioGetVolume(BRAC_AD_WAVEIN,dwVolume);
481. m_ctrlInVolume.SetPos(dwVolume);
482.
483. SetTimer(REFRESH_SPEAKVOLUME_TIMER,100,NULL);
484. SetTimer(REFRESH_RECORDSTATE_TIMER,1000,NULL);
485. }
486.
487. void CBRAnyChatSDKDemoDlg::OnButtonLogin()
488. {
489. UpdateData(TRUE);
490. CString strServerIp,strUserName,strPassword;
491. GetDlgItemText(IDC_IPADDRESS_SERVER,strServerIp);
492. GetDlgItemText(IDC_EDIT_USERNAME,strUserName);
493. GetDlgItemText(IDC_EDIT_LOGINPASS,strPassword);
494. if(strServerIp.IsEmpty() || m_iPort <= 0)
495. {
496. AfxMessageBox("Invalid server ip address or port!");
497. return;
498. }
499. if(strUserName.IsEmpty())
500. {
501. AfxMessageBox("Must input username for login system!");
502. return;
503. }
504.
505. BRAC_Connect(strServerIp.GetBuffer(0),m_iPort);
506. BRAC_Login(strUserName.GetBuffer(0),strPassword.GetBuffer(0),0);
507. }
508.
509. void CBRAnyChatSDKDemoDlg::OnButtonEnterRoom()
510. {
511. UpdateData(TRUE);
512. BRAC_EnterRoom(m_iRoomId,"",0);
513. }
514.
515. void CBRAnyChatSDKDemoDlg::OnButtonLeaveRoom()
516. {
517. BRAC_LeaveRoom(1);
518.
519. // 保留自己的userid,因为这儿只是leaveroom,并非logout
520. for(INT i=1; i<DEMO_SHOW_USER_NUM; i++)
521. {
522. m_iUserID[i] = -1;
523. }
524. }
525.
526. void CBRAnyChatSDKDemoDlg::OnButtonLogout()
527. {
528. BRAC_Logout();
529. for(INT i=0; i<DEMO_SHOW_USER_NUM; i++)
530. {
531. m_iUserID[i] = -1;
532. }
533. }
534.
535. void CBRAnyChatSDKDemoDlg::OnButtonRelease()
536. {
537. BRAC_Release();
538.
539. for(INT i=0; i<DEMO_SHOW_USER_NUM; i++)
540. {
541. m_iUserID[i] = -1;
542. }
543. m_dwTransTaskId = -1;
544. }
545.
546.
547. LRESULT CBRAnyChatSDKDemoDlg::OnGVClientConnect(WPARAM wParam, LPARAM lParam)
548. {
549. BOOL bSuccess = (BOOL)wParam;
550. AppendLogString(bSuccess ? "连接服务器成功..." : "连接服务器失败...");
551. return 0;
552. }
553.
554. LRESULT CBRAnyChatSDKDemoDlg::OnGVClientLogin(WPARAM wParam, LPARAM lParam)
555. {
556. CString logstr;
557. DWORD dwUserID = wParam;
558. if(lParam == 0)
559. {
560. CHAR username[30]={0};
561. BRAC_GetUserName(dwUserID,username,sizeof(username));
562. logstr.Format("登录服务器成功,自己的用户编号为:%d(%s)",wParam,username);
563.
564. // 将用户的ID保存在第一个位置,否则在回调函数里面可能找不到绘制的位置
565. m_iUserID[0] = dwUserID;
566. }
567. else
568. logstr.Format("登录服务器失败,出错代码为: %d ",lParam);
569.
570. AppendLogString(logstr);
571.
572. return 0;
573. }
574.
575. LRESULT CBRAnyChatSDKDemoDlg::OnGVClientEnterRoom(WPARAM wParam, LPARAM lParam)
576. {
577. CString logstr;
578. INT roomid = (INT)wParam;
579. if(lParam == 0)
580. {
581. logstr.Format("成功进入编号为:%d 的房间",roomid);
582.
583. BRAC_SetVideoPos(-1,m_hWnd,m_UserRect[0].left,m_UserRect[0].top,m_UserRect[0].right,m_UserRect[0].bottom);
584. BRAC_UserCameraControl(-1,TRUE);
585. BRAC_UserSpeakControl(-1,TRUE);
586. }
587. else
588. logstr.Format("申请进入房间失败,出错代码为: %d ",lParam);
589.
590. AppendLogString(logstr);
591. return 0;
592. }
593.
594. void CBRAnyChatSDKDemoDlg::AppendLogString(CString logstr)
595. {
596. m_strLogInfo += (logstr + "\r\n");
597. m_ctrlEditLog.SetWindowText(m_strLogInfo);
598. m_ctrlEditLog.LineScroll(m_ctrlEditLog.GetLineCount());
599. }
600.
601.
602. LRESULT CBRAnyChatSDKDemoDlg::OnGVClientOnlineUser(WPARAM wParam, LPARAM lParam)
603. {
604. CString logstr;
605. INT onlinenum = (INT)wParam;
606.
607. logstr.Format("在编号为:%d 的房间共有 %d 位在线用户",lParam, onlinenum);
608. AppendLogString(logstr);
609.
610.
611.
612. DWORD dwUserNum = 0;
613. BRAC_GetOnlineUser(NULL,dwUserNum); ///< 首先获取房间内在线人数
614. if(!dwUserNum)
615. return 0;
616.
617. LPDWORD lpdwUserList = (LPDWORD)malloc(sizeof(DWORD)*dwUserNum);
618. BRAC_GetOnlineUser(lpdwUserList,dwUserNum); ///< 真正获取在线用户列表
619.
620. for(INT i=0; i< (INT)dwUserNum; i++)
621. {
622. DWORD userid = lpdwUserList[i];
623. // 给用户找一个空的位置显示面板(第0号位置留给自己)
624. INT site = -1;
625. for(INT i=1; i<DEMO_SHOW_USER_NUM; i++)
626. {
627. if(m_iUserID[i] == -1)
628. {
629. site = i;
630. break;
631. }
632. }
633. if(site != -1)
634. {
635. BRAC_SetVideoPos(userid,m_hWnd,m_UserRect[site].left,m_UserRect[site].top,m_UserRect[site].right,m_UserRect[site].bottom);
636. BRAC_UserCameraControl(userid,TRUE);
637. BRAC_UserSpeakControl(userid,TRUE);
638.
639. DWORD dwState = 0;
640. BRAC_GetCameraState(userid,dwState);
641. logstr.Format("用户%d 的视频状态是: %d",userid,dwState);
642. AppendLogString(logstr);
643.
644.
645. m_iUserID[site] = userid;
646. }
647. else ///< 已经没有位置了,Demo演示限制
648. break;
649. }
650.
651. free(lpdwUserList);
652.
653. return 0;
654. }
655.
656. LRESULT CBRAnyChatSDKDemoDlg::OnGVClientUserAtRoom(WPARAM wParam, LPARAM lParam)
657. {
658. CString logstr;
659. INT userid = (INT)wParam;
660. BOOL bEnter = (BOOL)lParam;
661.
662. CHAR username[30]={0};
663. BRAC_GetUserName(userid,username,sizeof(username));
664. logstr.Format("编号为:%d 的用户(%s) %s 房间",userid,username, bEnter ? "进入" : "离开");
665. AppendLogString(logstr);
666.
667. if(bEnter)
668. {
669. // 给用户找一个空的位置显示面板(第0号位置留给自己)
670. INT site = -1;
671. for(INT i=1; i<DEMO_SHOW_USER_NUM; i++)
672. {
673. if(m_iUserID[i] == -1)
674. {
675. site = i;
676. break;
677. }
678. }
679. if(site != -1)
680. {
681. BRAC_SetVideoPos(userid,m_hWnd,m_UserRect[site].left,m_UserRect[site].top,m_UserRect[site].right,m_UserRect[site].bottom);
682. BRAC_UserCameraControl(userid,TRUE);
683. BRAC_UserSpeakControl(userid,TRUE);
684. m_iUserID[site] = userid;
685. }
686.
687. }
688. else
689. {
690. //清除该用户占用位置的信息
691. for(INT i=1; i<DEMO_SHOW_USER_NUM; i++)
692. {
693. if(m_iUserID[i] == userid)
694. {
695. m_iUserID[i] = -1;
696. break;
697. }
698. }
699. }
700.
701. return 0;
702. }
703.
704.
705. LRESULT CBRAnyChatSDKDemoDlg::OnGVClientMicStateChange(WPARAM wParam, LPARAM lParam)
706. {
707. CString logstr;
708.
709. logstr.Format("编号为:%d 的用户 %s 本地Mic设备",wParam, lParam ? "打开" : "关闭");
710. AppendLogString(logstr);
711.
712. return 0;
713. }
714.
715.
716. LRESULT CBRAnyChatSDKDemoDlg::OnGVClientLinkClose(WPARAM wParam, LPARAM lParam)
717. {
718. AppendLogString("网络连接已关闭(断开)");
719.
720. for(INT i=0; i<DEMO_SHOW_USER_NUM; i++)
721. {
722. m_iUserID[i] = -1;
723. }
724. return 0;
725. }
726.
727.
728. LRESULT CBRAnyChatSDKDemoDlg::OnGVClientChatModeChange(WPARAM wParam, LPARAM lParam)
729. {
730. CString logstr;
731. INT userid = (INT)wParam;
732. INT chatmode = (INT)lParam;
733.
734. if(m_iUserID[0] == userid)
735. {
736. logstr.Format("自己(%d )的聊天模式改变,当前聊天模式为:%s",userid, chatmode == 0 ? "公聊模式" : "私聊模式");
737. }
738. else
739. logstr.Format("编号为:%d 的用户聊天模式改变,当前聊天模式为:%s",userid, chatmode == 0 ? "公聊模式" : "私聊模式");
740.
741. AppendLogString(logstr);
742. return 0;
743. }
744. void CBRAnyChatSDKDemoDlg::OnButtonVideoproperty()
745. {
746. BRAC_ShowLVProperty(m_hWnd,"AnyChat 本地视频画质调节");
747.
748. }
749.
750. void CBRAnyChatSDKDemoDlg::OnButtonRefreshCapture()
751. {
752. // 刷新视频采集设备下拉列表
753. PCHAR DeviceName[10] = {0};
754. DWORD DeviceNum = 10;
755. BRAC_EnumVideoCapture(DeviceName,DeviceNum);
756.
757.
758. m_cbVideoCapture.ResetContent();
759. INT i=0;
760. for(i=0; i<(INT)DeviceNum; i++)
761. {
762. if(DeviceName[i])
763. {
764. m_cbVideoCapture.AddString(DeviceName[i]);
765. ::GlobalFree((HGLOBAL)DeviceName[i]);
766. DeviceName[i] = NULL;
767. }
768. }
769.
770. // 选择当前打开的视频采集设备
771. CHAR szVideoDeviceName[100] = {0};
772. BRAC_GetCurVideoCapture(szVideoDeviceName,sizeof(szVideoDeviceName));
773. m_cbVideoCapture.SelectString(-1,szVideoDeviceName);
774.
775. // 刷新音频采集设备下拉列表
776. DeviceNum = 10;
777. BRAC_EnumAudioCapture(DeviceName,DeviceNum);
778.
779. m_cbAudioCapture.ResetContent();
780. for(i=0; i<(INT)DeviceNum; i++)
781. {
782. if(DeviceName[i])
783. {
784. m_cbAudioCapture.AddString(DeviceName[i]);
785. ::GlobalFree((HGLOBAL)DeviceName[i]);
786. DeviceName[i] = NULL;
787. }
788. }
789. // 选择当前打开的视频采集设备
790. CHAR szAudioDeviceName[100] = {0};
791. BRAC_GetCurAudioCapture(szAudioDeviceName,sizeof(szAudioDeviceName));
792. m_cbAudioCapture.SelectString(-1,szAudioDeviceName);
793. }
794.
795. void CBRAnyChatSDKDemoDlg::OnSelchangeComboVideoCapture()
796. {
797. CString strCaptureName;
798. m_cbVideoCapture.GetLBText(m_cbVideoCapture.GetCurSel(),strCaptureName);
799. BRAC_SelectVideoCapture(strCaptureName);
800. }
801.
802. void CBRAnyChatSDKDemoDlg::OnSelChangeComboAudioCapture()
803. {
804. CString strCaptureName;
805. m_cbAudioCapture.GetLBText(m_cbAudioCapture.GetCurSel(),strCaptureName);
806. BRAC_SelectAudioCapture(strCaptureName);
807. }
808.
809. void CBRAnyChatSDKDemoDlg::OnSliderOutVolumeChange(NMHDR* pNMHDR, LRESULT* pResult)
810. {
811. DWORD dwVolume = m_ctrlOutVolume.GetPos();
812. BRAC_AudioSetVolume(BRAC_AD_WAVEOUT,dwVolume);
813. *pResult = 0;
814. }
815.
816. void CBRAnyChatSDKDemoDlg::OnOnSliderInVolumeChange(NMHDR* pNMHDR, LRESULT* pResult)
817. {
818. DWORD dwVolume = m_ctrlInVolume.GetPos();
819. BRAC_AudioSetVolume(BRAC_AD_WAVEIN,dwVolume);
820. *pResult = 0;
821. }
822.
823. // 录音的音量发生改变
824. void CBRAnyChatSDKDemoDlg::OnWaveInVolumeChange(DWORD dwVolume)
825. {
826. m_ctrlInVolume.SetPos(dwVolume);
827. }
828. // 放音的音量发生改变
829. void CBRAnyChatSDKDemoDlg::OnWaveOutVolumeChange(DWORD dwVolume)
830. {
831. m_ctrlOutVolume.SetPos(dwVolume);
832. }
833.
834.
835.
836. void CBRAnyChatSDKDemoDlg::OnTimer(UINT nIDEvent)
837. {
838. switch(nIDEvent)
839. {
840. case REFRESH_TRANSTASK_STATUS_TIMER: // 刷新缓冲区传输任务状态
841. {
842. if(m_dwTransTaskId == -1)
843. {
844. KillTimer(REFRESH_TRANSTASK_STATUS_TIMER);
845. break;
846. }
847. DWORD ret;
848. DWORD dwStatus = 0;
849. ret = BRAC_QueryTransTaskInfo(-1,m_dwTransTaskId,BRAC_TRANSTASK_STATUS,(PCHAR)&dwStatus,sizeof(DWORD));
850. if(ret != GV_ERR_SUCCESS)
851. {
852. KillTimer(REFRESH_TRANSTASK_STATUS_TIMER);
853. m_dwTransTaskId = -1;
854. SetDlgItemText(IDC_STATIC_FILESTATUS,"");
855. if(ret == GV_ERR_TRANSBUF_NOTASK)
856. AppendLogString("传输任务不存在,可能对方已离开房间!");
857. else
858. AppendLogString("查询任务信息失败!");
859. break;
860. }
861. DOUBLE dbProgress = 0.0;
862. BRAC_QueryTransTaskInfo(-1,m_dwTransTaskId,BRAC_TRANSTASK_PROGRESS,(PCHAR)&dbProgress,sizeof(DOUBLE));
863. DWORD dwBitrate = 0;
864. BRAC_QueryTransTaskInfo(-1,m_dwTransTaskId,BRAC_TRANSTASK_BITRATE,(PCHAR)&dwBitrate,sizeof(DWORD));
865.
866. CString strStatus;
867. switch(dwStatus)
868. {
869. case 1: strStatus = "Ready"; break;
870. case 2: strStatus = "Process"; break;
871. case 3: strStatus = "Finish"; break;
872. case 4: strStatus = "Cancel"; break;
873. case 5: strStatus = "Reject"; break;
874. default: strStatus = "Unkonw"; break;
875. }
876. if(dwStatus == 3) // finish
877. {
878. KillTimer(REFRESH_TRANSTASK_STATUS_TIMER);
879. m_dwTransTaskId = -1;
880. AppendLogString("传输任务已完成!");
881. }
882. CString strBitrate;
883. if(dwBitrate >= 1000 * 1000)
884. strBitrate.Format("%.02f Mbps",(float)dwBitrate/1000/1000);
885. else if(dwBitrate >= 1000)
886. strBitrate.Format("%.02f Kbps",(float)dwBitrate/1000);
887. else
888. strBitrate.Format("%.02f bps",(float)dwBitrate);
889.
890. CString strNotify;
891. strNotify.Format("%s-%.02f%%-%s",strStatus,dbProgress,strBitrate);
892. SetDlgItemText(IDC_STATIC_FILESTATUS,strNotify);
893. }
894. case REFRESH_SPEAKVOLUME_TIMER: // 刷新用户说话音量
895. {
896. DOUBLE fSpeakVolume = 0.0;
897. if(m_iUserID[0] != -1 && BRAC_QueryUserState(m_iUserID[0],BRAC_USERSTATE_SPEAKVOLUME,(PCHAR)&fSpeakVolume,sizeof(DOUBLE)) == GV_ERR_SUCCESS)
898. m_ctrlSpeakVolume0.SetPos((INT)fSpeakVolume);
899. else
900. m_ctrlSpeakVolume0.SetPos(0);
901.
902. fSpeakVolume = 0.0;
903. if(m_iUserID[1] != -1 && BRAC_QueryUserState(m_iUserID[1],BRAC_USERSTATE_SPEAKVOLUME,(PCHAR)&fSpeakVolume,sizeof(DOUBLE)) == GV_ERR_SUCCESS)
904. m_ctrlSpeakVolume1.SetPos((INT)fSpeakVolume);
905. else
906. m_ctrlSpeakVolume1.SetPos(0);
907. fSpeakVolume = 0.0;
908. if(m_iUserID[2] != -1 && BRAC_QueryUserState(m_iUserID[2],BRAC_USERSTATE_SPEAKVOLUME,(PCHAR)&fSpeakVolume,sizeof(DOUBLE)) == GV_ERR_SUCCESS)
909. m_ctrlSpeakVolume2.SetPos((INT)fSpeakVolume);
910. else
911. m_ctrlSpeakVolume2.SetPos(0);
912. fSpeakVolume = 0.0;
913. if(m_iUserID[3] != -1 && BRAC_QueryUserState(m_iUserID[3],BRAC_USERSTATE_SPEAKVOLUME,(PCHAR)&fSpeakVolume,sizeof(DOUBLE)) == GV_ERR_SUCCESS)
914. m_ctrlSpeakVolume3.SetPos((INT)fSpeakVolume);
915. else
916. m_ctrlSpeakVolume3.SetPos(0);
917. }
918. break;
919. case REFRESH_RECORDSTATE_TIMER: // 刷新录像状态
920. {
921. DWORD dwRecordState = 0;
922. if(m_iUserID[0] != -1 && BRAC_QueryUserState(m_iUserID[0],BRAC_USERSTATE_RECORDING,(PCHAR)&dwRecordState,sizeof(DWORD)) == GV_ERR_SUCCESS)
923. {
924. static BOOL bShow = FALSE;
925. bShow = dwRecordState ? !bShow : FALSE;
926. GetDlgItem(IDC_STATIC_RECORDSTATE0)->ShowWindow(bShow ? SW_SHOW : SW_HIDE);
927. }
928. dwRecordState = 0;
929. if(m_iUserID[1] != -1 && BRAC_QueryUserState(m_iUserID[1],BRAC_USERSTATE_RECORDING,(PCHAR)&dwRecordState,sizeof(DWORD)) == GV_ERR_SUCCESS)
930. {
931. static BOOL bShow = FALSE;
932. bShow = dwRecordState ? !bShow : FALSE;
933. GetDlgItem(IDC_STATIC_RECORDSTATE1)->ShowWindow(bShow ? SW_SHOW : SW_HIDE);
934. }
935. dwRecordState = 0;
936. if(m_iUserID[2] != -1 && BRAC_QueryUserState(m_iUserID[2],BRAC_USERSTATE_RECORDING,(PCHAR)&dwRecordState,sizeof(DWORD)) == GV_ERR_SUCCESS)
937. {
938. static BOOL bShow = FALSE;
939. bShow = dwRecordState ? !bShow : FALSE;
940. GetDlgItem(IDC_STATIC_RECORDSTATE2)->ShowWindow(bShow ? SW_SHOW : SW_HIDE);
941. }
942. dwRecordState = 0;
943. if(m_iUserID[3] != -1 && BRAC_QueryUserState(m_iUserID[3],BRAC_USERSTATE_RECORDING,(PCHAR)&dwRecordState,sizeof(DWORD)) == GV_ERR_SUCCESS)
944. {
945. static BOOL bShow = FALSE;
946. bShow = dwRecordState ? !bShow : FALSE;
947. GetDlgItem(IDC_STATIC_RECORDSTATE3)->ShowWindow(bShow ? SW_SHOW : SW_HIDE);
948. }
949. }
950. break;
951. default:
952. break;
953. }
954.
955. CDialog::OnTimer(nIDEvent);
956. }
957.
958. void CBRAnyChatSDKDemoDlg::OnButtonSendFile()
959. {
960. if(m_dwTransTaskId != -1) // 演示程序为了简洁,同时只允许传一个任务,实际上SDK是可以多任务并发的
961. return;
962.
963. static TCHAR BASED_CODE szFilter[] = _T("All Files (*.*)||*.*\0");
964. CFileDialog dlg(TRUE, NULL, NULL, OFN_OVERWRITEPROMPT | OFN_ALLOWMULTISELECT, szFilter, this);
965. if (dlg.DoModal() == IDOK)
966. {
967. CString strFileName = dlg.GetPathName();
968. DWORD dwTaskId = 0;
969. DWORD wParam = 1; // 上层应用程序可自定义wParam、lParam的值,这两个参数的值将被回调给对方
970. DWORD lParam = 2;
971. DWORD dwFlags = 0; // 该标志设置为0,则SDK将自动根据网络状态选择合适的传输途径(TCP、UDP or P2P)
972. DWORD ret = BRAC_TransFile(m_iUserID[1],strFileName.GetBuffer(0),wParam,lParam,dwFlags,dwTaskId);
973. if(ret == GV_ERR_SUCCESS)
974. {
975. m_dwTransTaskId = dwTaskId;
976. SetTimer(REFRESH_TRANSTASK_STATUS_TIMER,100,NULL);
977. }
978. else
979. {
980. CString strError;
981. strError.Format("创建文件传输任务失败,出错代码:%d",ret);
982. AppendLogString(strError);
983. SetDlgItemText(IDC_STATIC_FILESTATUS,"");
984. }
985. }
986. }
987. // 传输超大缓冲区任务演示
988. void CBRAnyChatSDKDemoDlg::OnButtonTransbuf()
989. {
990. if(m_dwTransTaskId != -1) // 演示程序为了简洁,同时只允许传一个任务,实际上SDK是可以多任务并发的
991. return;
992.
993. PCHAR lpBuf = (PCHAR)malloc(10*1024); // 为了演示,创建一个10KByte大小的缓冲区
994. DWORD dwLen = 10*1024;
995. if(!lpBuf)
996. return;
997. lpBuf[1000] = 'Y'; // 演示的需要,为了验证收到的数据是否正确,在缓冲区中间某个位置设置一个标志,对方接收后,可判断该标志是否为设定值
998.
999. DWORD dwTaskId = 0;
1000. DWORD wParam = 3; // 上层应用程序可自定义wParam、lParam的值,这两个参数的值将被回调给对方
1001. DWORD lParam = 4;
1002. DWORD dwFlags = 0; // 该标志设置为0,则SDK将自动根据网络状态选择合适的传输途径(TCP、UDP or P2P)
1003.
发表评论
-
手机视频会议
2012-11-16 14:03 844在这个时代,手机被开发者们所赋予的意义已经远远超出了大众的期望 ... -
视频通讯demo源码
2012-11-09 15:23 1173以下为anychat视频通讯系统中的部分回调函数源码: 具体 ... -
浅谈网络语音技术
2012-08-31 14:35 972浅谈网络语音技术 当我们使用像Sky ... -
手机音视频应用开发(专注于Symbian、iPhone、Android等跨平台音视频应用开发方案)
2012-08-24 14:47 1150一款好的手机应用, 能让用户在第一分钟就爱上他, 一款烂的手 ... -
手机视频通讯开发
2012-08-24 14:46 823如今,3G网络快速发展 ... -
音视频点播直播系统
2012-08-20 10:32 1473音视频点播直 ... -
网络游戏与实时视频结合,拉动网游的进步 .
2012-08-20 09:58 8172011年被称为中国网络 ... -
android视频聊天软件推荐
2012-08-15 17:00 1065正在当前那个社会 ... -
音视频交流服务系统
2012-03-15 16:22 911下面的这个平台是一种视频服务的应用,比如A(客户端)打视频电话 ... -
音视频开发平台
2012-03-15 16:12 839近日,腾讯公司发布了Q ... -
即时通讯开发平台(音视频)
2012-03-15 16:11 935近日,腾讯公司发布了Q ... -
一百年后,人类怎样编程?
2011-03-30 18:00 782很难预测一百年后的人 ... -
500个C语言开发中必须明白的问题
2011-03-16 18:01 952附件中的就是500个C语言开发中必须明白的问题。 有需要的人 ... -
用Vc++写的音视频即时通话程序(部分代码)
2011-01-06 16:16 4249// BRAnyChatSDKDemoDlg.cpp : im ... -
Android编译本地C++程序方法
2011-01-04 15:55 992Android编译本地C++程序方法 在Android ... -
视频会议源码(客户端和服务器端,包含完整的开发文档)
2010-12-13 17:14 2514一、SDK包概述 AnyChat音视频互动开发平台(SDK ... -
音视频编码库 FFmpeg(源码)
2010-12-13 17:01 1185发布公司:ffmpeg.org授权方式:免费版软件评级:评级标 ... -
音视频编解码的一些源代码
2010-12-13 16:32 1307音视频编解码的一些源代码 (转) 资料名称:音视频编解码的一 ... -
音视频源码 (可用于各种音视频平台)
2010-12-10 17:38 11911. BRAnyChatSDKDemoDlg.cpp : ... -
用于二次开发企业即时通讯源码
2010-12-09 15:28 2264用于二次开发企业即时通讯源码(C++/MFC),现在,做一个普 ...
相关推荐
前端开发语言:VUE( 安卓,IOS,WEB为一套前端代码) ...数据库:MySql + mongodb 前端打包工具:Hbuilder 服务器搭建工具:宝塔 + Xshell 短信接口: 支持阿里云 支付接口:支持支付宝 服务器配置: 4核8G宽带10兆以上...
本资源包含的"飞机即时通讯源码"适用于iOS和Android两大主流移动操作系统,为开发者提供了一个跨平台的解决方案。下面将详细讨论即时通讯系统的基本概念、设计原理、以及iOS和Android平台上的实现技术。 即时通讯...
伊语IM即时通讯源码/im商城系统/纯源码IM通讯系统安卓+IOS前端纯原生源码,后端是java源码。
本资源提供了一套多语言的IM即时通讯源码,特别强调了其支持7个不同终端之间的互通通讯。这通常意味着该系统能够适应包括iOS、Android、Web、Windows、Mac OS、Linux以及各种小程序在内的多种平台,为用户提供无缝的...
现对外公开低价出售P2P即时通讯源码,无加密,组件齐全,调试非常简单方便! 发送联机或脱机消息,同时可自定义消息字体、颜色、大小等信息,支持插入表情符号,屏幕截取。支持多人 消息群发等功能; 在线...
在这款8000元购买的默往IM即时通讯源码中,我们可以深入学习到以下关键知识点: 1. **服务器架构**:源码可能包含了服务器端的架构设计,包括如何处理大规模并发连接,如何保证消息的可靠传输,以及如何有效地存储...
即时通讯(IM)功能通常由专门的消息传递系统支持,允许用户进行一对一或群组聊天,甚至可能包括语音和视频通话。 首先,我们来详细了解一下商城源码。商城源码是电子商务平台的核心,它包含了网站的前端展示、后台...
在本案例中,我们关注的是一个基于C#编写的即时通讯源码,它实现了点对点和群聊功能,与我们熟知的QQ等社交软件有相似之处。 首先,我们要理解C#作为编程语言的角色。C#是由微软公司开发的一种面向对象的编程语言,...
即时通讯源码_ 青柚 H5 聊天系统,即时通讯,IM 聊天 APP、带原生/安卓苹果端 APP 源码+详细视频教程 购买来的通讯,全原生,并不是视酷或酷信的二开版本,从底层开始结构就完全不一样,mongodb 的库,uniapp 混编手端...
用JAVA语言,基于t-io开发的轻量、高性能、单机支持几十万至百万在线用户IM,主要目标降低即时通讯门槛,快速打造低成本接入在线IM系统,通过极简洁的消息格式就可以实现多端不同协议间的消息发送如内置(Http、...
【PHP开发的网页即时通讯源码】是一种基于PHP编程语言实现的实时通信系统,它允许用户在网页上进行即时的消息传递,无需刷新页面即可实现聊天功能。这种技术在现代Web应用中广泛使用,如在线客服、社交网络和协作...
总结,C# .NET 2.0即时通讯源码涉及到网络编程、协议设计、多线程、数据序列化、安全通信等多个技术领域,需要深入理解并熟练运用这些技术,才能构建出稳定高效的即时通讯系统。LanMsgC#2.1.3可能就是这样一个实现,...
即时通讯(Instant Messaging,简称IM)是现代移动应用中不可或缺的一部分,它允许用户实时地进行文字、语音、视频通信以及分享各类信息。本资源提供的是一款高仿微信的即时通讯APP源码,对于开发者来说,这是一个...
在本文中,我们将深入探讨即时通讯源码背后的技术细节,包括消息传递、媒体处理和用户体验优化等方面。 1. **消息传递机制**: 即时通讯的核心在于高效的消息传递。常见的实现方式有基于TCP的长连接或基于HTTP的短...
本知识点将深入探讨C#.NET中的Socket即时通讯源码及其相关编程概念。 首先,Socket是网络通信的基本构建块,它代表了网络上的一个通信端点,可以理解为两台计算机之间的通信管道。在C#.NET中,Socket类位于System...
P2P即时通讯源码(DELPHI编写),无加密,组件齐全,调试非常简单方便! 发送联机或脱机消息,同时可自定义消息字体、颜色、大小等信息,支持插入表情符号,屏幕截取。 支持多人消息群发等功能;在线即时语音、视频...
本篇将深入探讨“微聊源码”,一套完整的即时通讯源码,它特别适用于内嵌到各种CP(Content Provider)或刷单等业务场景中。该源码的亮点在于其便捷性,允许用户在后台直接挂载地址,简化了集成过程。 首先,我们要...
这款C++即时通讯源码为我们提供了一个深入理解即时通讯系统设计与实现的实例。 源码的核心知识点可能包含以下几个方面: 1. **网络编程**:即时通讯系统基于网络通信,因此涉及TCP/IP协议栈,包括socket编程,连接...
即时通讯(Instant Messaging, IM)是一种实时通信技术,允许用户通过互联网进行文本、语音、视频等多种形式的交流。在安卓平台上,实现类似微信的即时通讯功能,需要涉及以下几个关键技术点: 1. **网络通信协议**...
本资源提供的是一个针对Android平台的完整音视频即时通讯源码,这对于开发者来说是一个宝贵的参考资料,可以帮助他们深入理解并实现自己的音视频通信功能。 首先,我们需要了解音视频即时通讯的基本概念。它基于...