Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

345 lines
9.7 KiB

  1. /////////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1997 Active Voice Corporation. All Rights Reserved.
  4. //
  5. // Active Agent(r) and Unified Communications(tm) are trademarks of Active Voice Corporation.
  6. //
  7. // Other brand and product names used herein are trademarks of their respective owners.
  8. //
  9. // The entire program and user interface including the structure, sequence, selection,
  10. // and arrangement of the dialog, the exclusively "yes" and "no" choices represented
  11. // by "1" and "2," and each dialog message are protected by copyrights registered in
  12. // the United States and by international treaties.
  13. //
  14. // Protected by one or more of the following United States patents: 5,070,526, 5,488,650,
  15. // 5,434,906, 5,581,604, 5,533,102, 5,568,540, 5,625,676, 5,651,054.
  16. //
  17. // Active Voice Corporation
  18. // Seattle, Washington
  19. // USA
  20. //
  21. /////////////////////////////////////////////////////////////////////////////////////////
  22. //////////////////////////////////////////////////////////
  23. // ConfRoomWnd.cpp
  24. //
  25. #include "stdafx.h"
  26. #include "TapiDialer.h"
  27. #include "AVTapi.h"
  28. #include "ConfRoom.h"
  29. // Hard coded video values
  30. #define WND_DX 4
  31. #define WND_DY 3
  32. CConfRoomWnd::CConfRoomWnd()
  33. {
  34. m_pConfRoom = NULL;
  35. m_wndMembers.m_pConfRoomWnd = this;
  36. m_wndTalker.m_pConfRoomWnd = this;
  37. m_hBmpFeed_Large = NULL;
  38. m_hBmpFeed_Small = NULL;
  39. m_hBmpFeed_LargeAudio = NULL;
  40. }
  41. bool CConfRoomWnd::CreateStockWindows()
  42. {
  43. CErrorInfo er( IDS_ER_CREATE_WINDOWS, 0 );
  44. bool bRet = true;
  45. RECT rc = {0};
  46. // Talker window is top frame
  47. if ( !IsWindow(m_wndTalker.m_hWnd) )
  48. {
  49. m_wndTalker.m_hWnd = NULL;
  50. m_wndTalker.Create( m_hWnd, rc, NULL, WS_CHILD | WS_BORDER | WS_VISIBLE, WS_EX_CLIENTEDGE, IDW_TALKER );
  51. bRet = (bool) (m_wndTalker != NULL);
  52. }
  53. // Member window is bottom frame
  54. if ( !IsWindow(m_wndMembers.m_hWnd) )
  55. {
  56. m_wndMembers.m_hWnd = NULL;
  57. m_wndMembers.Create( m_hWnd, rc, NULL, WS_CHILD | WS_BORDER | WS_VISIBLE | WS_VSCROLL, WS_EX_CLIENTEDGE, IDW_MEMBERS );
  58. // Make sure window accepts double clicks
  59. if ( m_wndMembers.m_hWnd )
  60. {
  61. ULONG_PTR ulpClass = GetClassLongPtr( m_wndMembers.m_hWnd, GCL_STYLE );
  62. ulpClass |= CS_DBLCLKS;
  63. SetClassLongPtr( m_wndMembers.m_hWnd, GCL_STYLE, ulpClass );
  64. }
  65. else
  66. {
  67. bRet = false;
  68. }
  69. }
  70. _ASSERT( bRet );
  71. if ( !bRet ) er.set_hr( E_UNEXPECTED );
  72. return bRet;
  73. }
  74. HRESULT CConfRoomWnd::LayoutRoom( LayoutStyles_t layoutStyle, bool bRedraw )
  75. {
  76. // Push the request onto a FIFO
  77. m_critLayout.Lock();
  78. DWORD dwInfo = layoutStyle;
  79. m_lstLayout.push_back( dwInfo );
  80. m_critLayout.Unlock();
  81. // Queue request if critical section already locked.
  82. if ( TryEnterCriticalSection(&m_critThis.m_sec) == FALSE )
  83. return E_PENDING;
  84. // Create the conference room windows if not already created
  85. if ( !m_pConfRoom || !IsWindow(m_hWnd) )
  86. {
  87. m_critLayout.Lock();
  88. m_lstLayout.pop_front();
  89. m_critLayout.Unlock();
  90. m_critThis.Unlock();
  91. return E_FAIL;
  92. }
  93. // Pull next item off of the list.
  94. for (;;)
  95. {
  96. m_critLayout.Lock();
  97. // No more items on list to process
  98. if ( m_lstLayout.empty() )
  99. {
  100. m_critLayout.Unlock();
  101. break;
  102. }
  103. dwInfo = m_lstLayout.front();
  104. m_lstLayout.pop_front();
  105. m_critLayout.Unlock();
  106. // Extract function parameters
  107. layoutStyle = (LayoutStyles_t) dwInfo;
  108. // Layout members of the conference
  109. if ( (layoutStyle & CREATE_MEMBERS) != 0 )
  110. m_wndMembers.Layout();
  111. // Resize conference room window to parent's size
  112. if ( (layoutStyle & LAYOUT_TALKER) != 0 )
  113. {
  114. IAVTapiCall *pAVCall = NULL;
  115. m_pConfRoom->get_IAVTapiCall( &pAVCall );
  116. m_wndTalker.Layout( pAVCall, m_pConfRoom->m_szTalker );
  117. // m_wndTalker.SendMessage( WM_LAYOUT );
  118. // if ( bRedraw ) m_wndTalker.RedrawWindow();
  119. m_wndTalker.PostMessage( WM_LAYOUT );
  120. if ( bRedraw ) m_wndTalker.Invalidate();
  121. RELEASE( pAVCall );
  122. }
  123. if ( (layoutStyle & LAYOUT_MEMBERS) != 0 )
  124. {
  125. // m_wndMembers.SendMessage( WM_LAYOUT );
  126. // if ( bRedraw ) m_wndMembers.RedrawWindow();
  127. m_wndMembers.PostMessage( WM_LAYOUT, -1, -1 );
  128. if ( bRedraw ) m_wndMembers.Invalidate();
  129. }
  130. }
  131. // Release crit section and exit
  132. m_critThis.Unlock();
  133. return S_OK;
  134. }
  135. //////////////////////////////////////////////////////////////////////////
  136. // Message Handlers
  137. LRESULT CConfRoomWnd::OnDestroy(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
  138. {
  139. if ( m_hBmpFeed_Large ) DeleteObject( m_hBmpFeed_Large );
  140. if ( m_hBmpFeed_Small ) DeleteObject( m_hBmpFeed_Small );
  141. if ( m_hBmpFeed_LargeAudio ) DeleteObject( m_hBmpFeed_LargeAudio );
  142. return 0;
  143. }
  144. LRESULT CConfRoomWnd::OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
  145. {
  146. SetClassLongPtr( m_hWnd, GCLP_HBRBACKGROUND, (LONG_PTR) GetSysColorBrush(COLOR_BTNFACE) );
  147. if ( !m_hBmpFeed_Large )
  148. m_hBmpFeed_Large = LoadBitmap( GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_STOCK_VIDEO_LARGE) );
  149. if ( !m_hBmpFeed_Small )
  150. m_hBmpFeed_Small = LoadBitmap( GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_STOCK_VIDEO_SMALL) );
  151. if ( !m_hBmpFeed_LargeAudio )
  152. m_hBmpFeed_LargeAudio = LoadBitmap( GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_VIDEO_AUDIO_ONLY2) );
  153. CreateStockWindows();
  154. return 0;
  155. }
  156. LRESULT CConfRoomWnd::OnSize(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
  157. {
  158. bHandled = true;
  159. if ( m_pConfRoom )
  160. {
  161. // Resize conference room window to parent's size
  162. RECT rc;
  163. ::GetClientRect( GetParent(), &rc );
  164. SetWindowPos( NULL, &rc, SWP_NOACTIVATE );
  165. // Size Talker window
  166. RECT rcClient = { WND_DX, WND_DY, max(WND_DX, rc.right - WND_DX), WND_DY + m_pConfRoom->m_szTalker.cy + 2 * VID_DY };
  167. m_wndTalker.SetWindowPos( NULL, &rcClient, SWP_NOACTIVATE );
  168. // Size Members window
  169. OffsetRect( &rcClient, 0, rcClient.bottom + WND_DY );
  170. rcClient.bottom = max( rcClient.top, rc.bottom - WND_DY );
  171. m_wndMembers.SetWindowPos(NULL, &rcClient, SWP_NOACTIVATE );
  172. }
  173. return 0;
  174. }
  175. LRESULT CConfRoomWnd::OnContextMenu(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
  176. {
  177. // Only handle if we have a detail view to work with
  178. if ( !m_pConfRoom ) return 0;
  179. bHandled = true;
  180. // Load popup menu for Details View
  181. HMENU hMenu = LoadMenu( _Module.GetResourceInstance(), MAKEINTRESOURCE(IDR_POPUP_CONFROOM_DETAILS) );
  182. HMENU hMenuPopup = GetSubMenu( hMenu, 0 );
  183. if ( hMenuPopup )
  184. {
  185. // Get current mouse position
  186. POINT pt = { 10, 10 };
  187. ClientToScreen( &pt );
  188. if ( lParam != -1 )
  189. GetCursorPos( &pt );
  190. IVideoFeed *pFeed = NULL;
  191. IVideoWindow *pVideo = NULL;
  192. if ( SUCCEEDED(m_wndMembers.HitTest(pt, &pFeed)) )
  193. pFeed->get_IVideoWindow( (IUnknown **) &pVideo );
  194. // Enable menus accordingly
  195. if ( m_pConfRoom->CanDisconnect() == S_FALSE )
  196. EnableMenuItem( hMenuPopup, ID_POPUP_DISCONNECT, MF_BYCOMMAND | MF_GRAYED );
  197. else
  198. EnableMenuItem( hMenuPopup, ID_POPUP_JOIN, MF_BYCOMMAND | MF_GRAYED );
  199. if ( !pVideo )
  200. {
  201. // Don't allow QOS on preview
  202. VARIANT_BOOL bPreview = FALSE;
  203. if ( pFeed ) pFeed->get_bPreview( &bPreview );
  204. if ( !bPreview )
  205. EnableMenuItem( hMenuPopup, ID_POPUP_FASTVIDEO, MF_BYCOMMAND | MF_GRAYED );
  206. }
  207. // Quality of service
  208. VARIANT_BOOL bQOS = FALSE;
  209. if ( pFeed )
  210. pFeed->get_bRequestQOS( &bQOS );
  211. CheckMenuItem( hMenuPopup, ID_POPUP_FASTVIDEO, MF_BYCOMMAND | (bQOS) ? MF_CHECKED : MF_UNCHECKED );
  212. // Full size video
  213. short nSize = 50;
  214. m_pConfRoom->get_MemberVideoSize( &nSize );
  215. CheckMenuItem( hMenuPopup, ID_POPUP_FULLSIZEVIDEO, MF_BYCOMMAND | (nSize > 50) ? MF_CHECKED : MF_UNCHECKED );
  216. // Show names
  217. VARIANT_BOOL bShowNames;
  218. m_pConfRoom->get_bShowNames( &bShowNames );
  219. CheckMenuItem( hMenuPopup, ID_POPUP_SHOWNAMES, MF_BYCOMMAND | (bShowNames) ? MF_CHECKED : MF_UNCHECKED );
  220. HMENU hMenuScale = GetSubMenu( hMenuPopup, 5 );
  221. if ( hMenuScale )
  222. {
  223. short nScale;
  224. m_pConfRoom->get_TalkerScale( &nScale );
  225. CheckMenuItem( hMenuScale, (nScale - 100) / 50, MF_BYPOSITION | MFT_RADIOCHECK | MFS_CHECKED );
  226. }
  227. // Show popup menu
  228. int nRet = TrackPopupMenu( hMenuPopup,
  229. TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RETURNCMD | TPM_RIGHTBUTTON,
  230. pt.x, pt.y,
  231. 0, m_hWnd, NULL );
  232. // Process command
  233. switch ( nRet )
  234. {
  235. // Join a conference
  236. case ID_POPUP_JOIN:
  237. {
  238. CComPtr<IAVTapi> pAVTapi;
  239. if ( SUCCEEDED(_Module.get_AVTapi(&pAVTapi)) )
  240. pAVTapi->JoinConference( NULL, true, NULL );
  241. }
  242. break;
  243. // Hang up the conference
  244. case ID_POPUP_DISCONNECT:
  245. m_pConfRoom->Disconnect();
  246. break;
  247. // Switch default size of video screens
  248. case ID_POPUP_FULLSIZEVIDEO:
  249. nSize = (nSize > 50) ? 50 : 100;
  250. m_pConfRoom->put_MemberVideoSize( nSize );
  251. break;
  252. // Toggle show names property
  253. case ID_POPUP_SHOWNAMES:
  254. m_pConfRoom->put_bShowNames( !bShowNames );
  255. break;
  256. // Toggle quality of service
  257. case ID_POPUP_FASTVIDEO:
  258. if ( pFeed ) pFeed->put_bRequestQOS( !bQOS );
  259. {
  260. IAVTapiCall *pAVCall = NULL;
  261. if ( SUCCEEDED(m_pConfRoom->get_IAVTapiCall(&pAVCall)) )
  262. {
  263. pAVCall->PostMessage( 0, CAVTapiCall::TI_REQUEST_QOS );
  264. pAVCall->Release();
  265. }
  266. }
  267. break;
  268. case ID_POPUP_SELECTEDVIDEOSCALE_100: m_pConfRoom->put_TalkerScale( 100 ); break;
  269. case ID_POPUP_SELECTEDVIDEOSCALE_150: m_pConfRoom->put_TalkerScale( 150 ); break;
  270. case ID_POPUP_SELECTEDVIDEOSCALE_200: m_pConfRoom->put_TalkerScale( 200 ); break;
  271. }
  272. RELEASE( pVideo );
  273. RELEASE( pFeed );
  274. }
  275. // Clean up
  276. if ( hMenu ) DestroyMenu( hMenu );
  277. return 0;
  278. }
  279. void CConfRoomWnd::UpdateNames( ITParticipant *pParticipant )
  280. {
  281. m_wndTalker.UpdateNames( NULL );
  282. m_wndMembers.UpdateNames( pParticipant );
  283. }