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.

302 lines
9.2 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. // ConfRoomTalkerWnd.cpp
  24. //
  25. #include "stdafx.h"
  26. #include "TapiDialer.h"
  27. #include "ConfRoom.h"
  28. #include "VideoFeed.h"
  29. CConfRoomTalkerWnd::CConfRoomTalkerWnd()
  30. {
  31. m_pConfRoomWnd = NULL;
  32. m_dlgTalker.m_pConfRoomTalkerWnd = this;
  33. }
  34. CConfRoomTalkerWnd::~CConfRoomTalkerWnd()
  35. {
  36. }
  37. LRESULT CConfRoomTalkerWnd::OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
  38. {
  39. m_dlgTalker.Create( m_hWnd );
  40. return 0;
  41. }
  42. HRESULT CConfRoomTalkerWnd::Layout( IAVTapiCall *pAVCall, const SIZE& sz )
  43. {
  44. _ASSERT( m_pConfRoomWnd );
  45. if ( !m_pConfRoomWnd ) return E_UNEXPECTED;
  46. m_critLayout.Lock();
  47. HRESULT hr = S_OK;
  48. CALL_STATE nState;
  49. bool bConfConnected = (bool) (pAVCall && SUCCEEDED(pAVCall->get_callState(&nState)) && (nState == CS_CONNECTED));
  50. // Set up conference information
  51. if ( IsWindow(m_dlgTalker.m_hWnd) )
  52. {
  53. IVideoWindow *pVideo = NULL;
  54. // Locate the talker window on the appropriate host window.
  55. if ( bConfConnected )
  56. {
  57. // Should have a valid IVideoWindow pointer by now
  58. m_pConfRoomWnd->m_pConfRoom->get_TalkerVideo( (IDispatch **) &pVideo );
  59. // Force a selection if we don't already have one
  60. // if ( !pVideo )
  61. // if ( SUCCEEDED(m_pConfRoomWnd->m_wndMembers.GetFirstVideoWindowThatsStreaming(&pVideo)) )
  62. // m_pConfRoomWnd->m_pConfRoom->set_TalkerVideo( pVideo, false, true );
  63. SetHostWnd( pVideo );
  64. }
  65. ///////////////////////////////////////////////////////////////////////
  66. // Update dialog data
  67. //
  68. // Clean up existing strings
  69. SysFreeString( m_dlgTalker.m_bstrCallerID );
  70. SysFreeString( m_dlgTalker.m_bstrCallerInfo );
  71. m_dlgTalker.m_bstrCallerID = NULL;
  72. m_dlgTalker.m_bstrCallerInfo = NULL;
  73. // Retrieve name for talker either from the video or the participant
  74. if ( pVideo )
  75. {
  76. m_pConfRoomWnd->m_wndMembers.GetNameFromVideo( pVideo, &m_dlgTalker.m_bstrCallerID, &m_dlgTalker.m_bstrCallerInfo, true, m_pConfRoomWnd->m_pConfRoom->IsPreviewVideo(pVideo) );
  77. pVideo->Release();
  78. }
  79. else if ( bConfConnected )
  80. {
  81. // Retrieve participant that's talking
  82. ITParticipant *pTalkerParticipant;
  83. if ( SUCCEEDED(m_pConfRoomWnd->m_pConfRoom->get_TalkerParticipant(&pTalkerParticipant)) )
  84. {
  85. CVideoFeed::GetNameFromParticipant( pTalkerParticipant, &m_dlgTalker.m_bstrCallerID, &m_dlgTalker.m_bstrCallerInfo );
  86. pTalkerParticipant->Release();
  87. }
  88. else
  89. {
  90. // This is the ME participant
  91. USES_CONVERSION;
  92. TCHAR szText[255];
  93. LoadString( _Module.GetResourceInstance(), IDS_VIDEOPREVIEW, szText, ARRAYSIZE(szText) );
  94. SysReAllocString( &m_dlgTalker.m_bstrCallerID, T2COLE(szText) );
  95. }
  96. }
  97. }
  98. m_critLayout.Unlock();
  99. // Show dialog data on dialog
  100. if ( IsWindow(m_dlgTalker.m_hWnd) )
  101. m_dlgTalker.UpdateData( false );
  102. return hr;
  103. }
  104. ///////////////////////////////////////////////////////////////////////////////
  105. // Message Handlers
  106. //
  107. LRESULT CConfRoomTalkerWnd::OnPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
  108. {
  109. PAINTSTRUCT ps;
  110. HDC hDC = BeginPaint( &ps );
  111. if ( !hDC ) return 0;
  112. // Draw stock bitmap
  113. if ( m_pConfRoomWnd && m_pConfRoomWnd->m_pConfRoom )
  114. {
  115. // Are we presently streaming video?
  116. if ( !m_pConfRoomWnd->m_pConfRoom->IsTalkerStreaming() )
  117. {
  118. // Center vertically in client area
  119. int dy = 0;
  120. SIZE sz = m_pConfRoomWnd->m_pConfRoom->m_szTalker;
  121. RECT rc;
  122. GetClientRect( &rc );
  123. if ( rc.bottom > sz.cy )
  124. dy = (rc.bottom - sz.cy) / 2;
  125. rc.left = VID_DX;
  126. rc.top = dy;
  127. rc.right = rc.left + sz.cx;
  128. rc.bottom = rc.top + sz.cy;
  129. // Draw video feed, use Audio bitmap in case of talker that has no video
  130. ITParticipant *pParticipant = NULL;
  131. m_pConfRoomWnd->m_pConfRoom->get_TalkerParticipant( &pParticipant );
  132. // If no participant and talker window then it must be the Me participant
  133. bool bConfRoomInUse = false;
  134. if ( !pParticipant )
  135. bConfRoomInUse = (bool) (m_pConfRoomWnd->m_pConfRoom->IsConfRoomConnected() == S_OK);
  136. HBITMAP hBmp = (pParticipant || bConfRoomInUse) ? m_pConfRoomWnd->m_hBmpFeed_LargeAudio : m_pConfRoomWnd->m_hBmpFeed_Large;
  137. RELEASE(pParticipant);
  138. Draw( hDC, hBmp, VID_DX, dy, max(0, min(sz.cx, ps.rcPaint.right - VID_DX)), max(0, min(sz.cy, ps.rcPaint.bottom - dy)), true );
  139. Draw( hDC, hBmp, VID_DX, dy, sz.cx, sz.cy, true );
  140. }
  141. }
  142. EndPaint( &ps );
  143. bHandled = true;
  144. return 0;
  145. }
  146. LRESULT CConfRoomTalkerWnd::OnEraseBkgnd(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
  147. {
  148. /*
  149. bHandled = true;
  150. RECT rc;
  151. GetClientRect( &rc );
  152. HBRUSH hBrNew = (HBRUSH) GetSysColorBrush( COLOR_ACTIVEBORDER );
  153. HBRUSH hBrOld;
  154. if ( hBrNew ) hBrOld = (HBRUSH) SelectObject( (HDC) wParam, hBrNew);
  155. PatBlt( (HDC) wParam, 0, 0, RECTWIDTH(&rc), RECTHEIGHT(&rc), PATCOPY );
  156. if ( hBrNew ) SelectObject( (HDC) wParam, hBrOld );
  157. */
  158. return true;
  159. }
  160. LRESULT CConfRoomTalkerWnd::OnContextMenu(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
  161. {
  162. bHandled = true;
  163. return ::SendMessage( GetParent(), nMsg, wParam, lParam );
  164. }
  165. LRESULT CConfRoomTalkerWnd::OnSize(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
  166. {
  167. BOOL bHandleLayout;
  168. return OnLayout( WM_LAYOUT, wParam, lParam, bHandleLayout );
  169. }
  170. LRESULT CConfRoomTalkerWnd::OnLayout(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
  171. {
  172. _ASSERT( m_pConfRoomWnd && m_pConfRoomWnd->m_pConfRoom );
  173. bHandled = true;
  174. // Initial coordinate info
  175. int dy = 0;
  176. RECT rc;
  177. GetClientRect( &rc );
  178. SIZE sz;
  179. m_pConfRoomWnd->m_pConfRoom->get_szTalker( &sz );
  180. if ( rc.bottom > sz.cy ) dy = (rc.bottom - sz.cy) / 2;
  181. // Get the video window we'll be laying out
  182. IVideoWindow *pVideo;
  183. if ( SUCCEEDED(m_pConfRoomWnd->m_pConfRoom->get_TalkerVideo((IDispatch **) &pVideo)) )
  184. {
  185. if ( SetHostWnd(pVideo) )
  186. {
  187. pVideo->SetWindowPosition( VID_DX, dy, sz.cx, sz.cy );
  188. pVideo->put_Visible( OATRUE );
  189. }
  190. pVideo->Release();
  191. }
  192. // Adjust position of talker dialog and child controls
  193. if ( IsWindow(m_dlgTalker.m_hWnd) )
  194. {
  195. m_dlgTalker.SetWindowPos( NULL, VID_DX + sz.cx, dy, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW );
  196. // Adjust STATUS to proper position
  197. HWND hWndTemp = m_dlgTalker.GetDlgItem( IDC_LBL_STATUS );
  198. RECT rcTemp;
  199. ::GetWindowRect( hWndTemp, &rcTemp );
  200. m_dlgTalker.ScreenToClient( &rcTemp );
  201. ::SetWindowPos( hWndTemp, NULL, rcTemp.left, rc.bottom - (dy + RECTHEIGHT(&rcTemp)), 0, 0, SWP_NOSIZE | SWP_NOACTIVATE );
  202. // Adjust ANIMATE to proper position
  203. float fMult = (m_dlgTalker.m_callState == CS_DISCONNECTED) ? 1 : 1.3;
  204. hWndTemp = m_dlgTalker.GetDlgItem( IDC_ANIMATE );
  205. ::GetWindowRect( hWndTemp, &rcTemp );
  206. m_dlgTalker.ScreenToClient( &rcTemp );
  207. ::SetWindowPos( hWndTemp, NULL, rcTemp.left, rc.bottom - (dy + RECTHEIGHT(&rcTemp) * fMult), 0, 0, SWP_NOSIZE | SWP_NOACTIVATE );
  208. }
  209. return 0;
  210. }
  211. void CConfRoomTalkerWnd::UpdateNames( ITParticipant *pParticipant )
  212. {
  213. if ( !m_pConfRoomWnd || !m_pConfRoomWnd->m_pConfRoom ) return;
  214. // Set caller ID based on participant info
  215. IVideoWindow *pVideo = NULL;
  216. if ( pParticipant || SUCCEEDED(m_pConfRoomWnd->m_pConfRoom->get_TalkerVideo((IDispatch **) &pVideo)) )
  217. {
  218. SysFreeString( m_dlgTalker.m_bstrCallerID );
  219. SysFreeString( m_dlgTalker.m_bstrCallerInfo );
  220. m_dlgTalker.m_bstrCallerID = NULL;
  221. m_dlgTalker.m_bstrCallerInfo = NULL;
  222. if ( pParticipant )
  223. CVideoFeed::GetNameFromParticipant( pParticipant, &m_dlgTalker.m_bstrCallerID, &m_dlgTalker.m_bstrCallerInfo );
  224. else
  225. m_pConfRoomWnd->m_wndMembers.GetNameFromVideo( pVideo, &m_dlgTalker.m_bstrCallerID, &m_dlgTalker.m_bstrCallerInfo, true, m_pConfRoomWnd->m_pConfRoom->IsPreviewVideo(pVideo) );
  226. m_dlgTalker.UpdateData( false );
  227. }
  228. RELEASE( pVideo );
  229. }
  230. bool CConfRoomTalkerWnd::SetHostWnd( IVideoWindow *pVideo )
  231. {
  232. bool bRet = false;
  233. if ( pVideo )
  234. {
  235. // Get the video window we'll be laying out
  236. HWND hWndOwner;
  237. if ( SUCCEEDED(pVideo->get_Owner((OAHWND FAR*) &hWndOwner)) )
  238. {
  239. bRet = true;
  240. if ( hWndOwner != m_hWnd )
  241. {
  242. pVideo->put_Visible( OAFALSE );
  243. pVideo->put_Owner( (ULONG_PTR) m_hWnd );
  244. pVideo->put_MessageDrain( (ULONG_PTR) GetParent() );
  245. pVideo->put_WindowStyle( WS_CHILD | WS_BORDER );
  246. }
  247. }
  248. }
  249. return bRet;
  250. }