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.

396 lines
8.7 KiB

  1. #include "precomp.h"
  2. #include "confroom.h"
  3. #include "NmEnum.h"
  4. #include "SDKInternal.h"
  5. #include "NmConference.h"
  6. #include "NmChannel.h"
  7. #include "NmChannelVideo.h"
  8. CNmChannelVideoObj::CNmChannelVideoObj()
  9. {
  10. DBGENTRY(CNmChannelVideoObj::CNmChannelVideoObj);
  11. DBGEXIT(CNmChannelVideoObj::CNmChannelVideoObj);
  12. }
  13. CNmChannelVideoObj::~CNmChannelVideoObj()
  14. {
  15. DBGENTRY(CNmChannelVideoObj::~CNmChannelVideoObj);
  16. DBGEXIT(CNmChannelVideoObj::~CNmChannelVideoObj);
  17. }
  18. //
  19. HRESULT CNmChannelVideoObj::CreateInstance(CNmConferenceObj* pConfObj, INmChannel** ppChannel, bool bIsIncoming)
  20. {
  21. DBGENTRY(CNmChannelVideoObj::CreateInstance);
  22. HRESULT hr = S_OK;
  23. typedef CNmChannel<CNmChannelVideoObj, &IID_INmChannelVideo, NMCH_VIDEO> channel_type;
  24. channel_type* p = NULL;
  25. p = new CComObject<channel_type>(NULL);
  26. if (p != NULL)
  27. {
  28. if(ppChannel)
  29. {
  30. p->SetVoid(NULL);
  31. hr = p->QueryInterface(IID_INmChannel, reinterpret_cast<void**>(ppChannel));
  32. if(SUCCEEDED(hr))
  33. {
  34. p->m_bIsIncoming = bIsIncoming;
  35. // We don't have to RefCount this because our lifetime is
  36. // contained in the CConf's lifetime
  37. p->m_pConfObj = pConfObj;
  38. }
  39. if(FAILED(hr))
  40. {
  41. *ppChannel = NULL;
  42. }
  43. }
  44. else
  45. {
  46. hr = E_POINTER;
  47. }
  48. }
  49. else
  50. {
  51. hr = E_OUTOFMEMORY;
  52. }
  53. if(FAILED(hr))
  54. {
  55. delete p;
  56. }
  57. DBGEXIT_HR(CNmChannelVideoObj::CreateInstance,hr);
  58. return hr;
  59. }
  60. ///////////////////////////////////////////////////////////////////////////////////
  61. // INmChannelVideo2 methods
  62. ///////////////////////////////////////////////////////////////////////////////////
  63. STDMETHODIMP CNmChannelVideoObj::IsIncoming(void)
  64. {
  65. DBGENTRY(CNmChannelVideoObj::IsIncoming);
  66. HRESULT hr = E_UNEXPECTED;
  67. hr = m_bIsIncoming ? S_OK : S_FALSE;
  68. DBGEXIT_HR(CNmChannelVideoObj::IsIncoming,hr);
  69. return hr;
  70. }
  71. STDMETHODIMP CNmChannelVideoObj::GetState(NM_VIDEO_STATE *puState)
  72. {
  73. DBGENTRY(CNmChannelVideoObj::GetState);
  74. HRESULT hr = E_POINTER;
  75. if(puState)
  76. {
  77. if(m_bIsIncoming)
  78. {
  79. hr = GetRemoteVideoState(puState);
  80. }
  81. else
  82. {
  83. hr = GetLocalVideoState(puState);
  84. }
  85. }
  86. DBGEXIT_HR(CNmChannelVideoObj::GetState,hr);
  87. return hr;
  88. }
  89. STDMETHODIMP CNmChannelVideoObj::GetProperty(NM_VIDPROP uID,ULONG_PTR *puValue)
  90. {
  91. DBGENTRY(CNmChannelVideoObj::GetProperty);
  92. HRESULT hr = E_INVALIDARG;
  93. ULONG ulValue;
  94. switch(uID)
  95. {
  96. case NM_VIDPROP_PAUSE:
  97. if(m_bIsIncoming)
  98. {
  99. *puValue = IsRemoteVideoPaused();
  100. }
  101. else
  102. {
  103. *puValue = IsLocalVideoPaused();
  104. }
  105. hr = S_OK;
  106. break;
  107. case NM_VIDPROP_IMAGE_QUALITY:
  108. hr = GetImageQuality(&ulValue, m_bIsIncoming);
  109. *puValue = ulValue;
  110. break;
  111. case NM_VIDPROP_CAMERA_DIALOG:
  112. if(m_bIsIncoming)
  113. {
  114. return E_FAIL;
  115. }
  116. hr = GetCameraDialog(&ulValue);
  117. *puValue = ulValue;
  118. break;
  119. case NM_VIDPROP_WINDOW_AUTO_SIZE:
  120. case NM_VIDPROP_WINDOW_SIZE:
  121. case NM_VIDPROP_WINDOW_POSITION:
  122. case NM_VIDPROP_WINDOW_TOP_MOST:
  123. case NM_VIDPROP_WINDOW_VISIBLE:
  124. case NM_VIDPROP_IMAGE_PREFERRED_SIZE:
  125. hr = E_FAIL;
  126. break;
  127. }
  128. DBGEXIT_HR(CNmChannelVideoObj::GetProperty,hr);
  129. return hr;
  130. }
  131. STDMETHODIMP CNmChannelVideoObj::SetProperty(NM_VIDPROP uID,ULONG_PTR uValue)
  132. {
  133. DBGENTRY(CNmChannelVideoObj::SetProperty);
  134. HRESULT hr = E_INVALIDARG;
  135. switch(uID)
  136. {
  137. case NM_VIDPROP_PAUSE:
  138. if(m_bIsIncoming)
  139. {
  140. PauseRemoteVideo((ULONG)uValue);
  141. }
  142. else
  143. {
  144. PauseLocalVideo((ULONG)uValue);
  145. }
  146. hr = S_OK;
  147. break;
  148. case NM_VIDPROP_IMAGE_QUALITY:
  149. hr = SetImageQuality((ULONG)uValue, m_bIsIncoming);
  150. break;
  151. case NM_VIDPROP_CAMERA_DIALOG:
  152. if (m_bIsIncoming)
  153. {
  154. hr = E_FAIL;
  155. }
  156. else
  157. {
  158. hr = E_INVALIDARG;
  159. if((NM_VIDEO_SOURCE_DIALOG == uValue) || (NM_VIDEO_FORMAT_DIALOG == uValue))
  160. {
  161. hr = SetCameraDialog((ULONG)uValue);
  162. }
  163. }
  164. break;
  165. case NM_VIDPROP_WINDOW_AUTO_SIZE:
  166. case NM_VIDPROP_WINDOW_SIZE:
  167. case NM_VIDPROP_WINDOW_POSITION:
  168. case NM_VIDPROP_WINDOW_TOP_MOST:
  169. case NM_VIDPROP_WINDOW_VISIBLE:
  170. case NM_VIDPROP_IMAGE_PREFERRED_SIZE:
  171. hr = E_FAIL;
  172. break;
  173. }
  174. DBGEXIT_HR(CNmChannelVideoObj::SetProperty,hr);
  175. return hr;
  176. }
  177. ///////////////////////////////////////////////////////////////////////////////////
  178. //INmChannelVideoNotify2
  179. ///////////////////////////////////////////////////////////////////////////////////
  180. STDMETHODIMP CNmChannelVideoObj::StateChanged(NM_VIDEO_STATE uState)
  181. {
  182. DBGENTRY(CNmChannelVideoObj::StateChanged);
  183. HRESULT hr = S_OK;
  184. Activate(NM_VIDEO_IDLE != uState);
  185. hr = Fire_StateChanged(uState);
  186. DBGEXIT_HR(CNmChannelVideoObj::StateChanged,hr);
  187. return hr;
  188. }
  189. STDMETHODIMP CNmChannelVideoObj::PropertyChanged(DWORD dwReserved)
  190. {
  191. DBGENTRY(CNmChannelVideoObj::PropertyChanged);
  192. HRESULT hr = S_OK;
  193. hr = Fire_PropertyChanged(dwReserved);
  194. DBGEXIT_HR(CNmChannelVideoObj::PropertyChanged,hr);
  195. return hr;
  196. }
  197. ///////////////////////////////////////////////////////////////////////////////
  198. // IInternalChannelObj methods
  199. ///////////////////////////////////////////////////////////////////////////////
  200. STDMETHODIMP CNmChannelVideoObj::GetInternalINmChannel(INmChannel** ppChannel)
  201. {
  202. DBGENTRY(CNmChannelVideoObj::GetInternalINmChannel);
  203. HRESULT hr = E_POINTER;
  204. if(ppChannel)
  205. {
  206. *ppChannel = NULL;
  207. hr = S_OK;
  208. }
  209. DBGEXIT_HR(CNmChannelVideoObj::GetInternalINmChannel,hr);
  210. return hr;
  211. }
  212. HRESULT CNmChannelVideoObj::ChannelRemoved()
  213. {
  214. HRESULT hr = S_OK;
  215. RemoveMembers();
  216. CNmConferenceObj* pConfObj = GetConfObj();
  217. if(pConfObj)
  218. {
  219. hr = pConfObj->Fire_ChannelChanged(NM_CHANNEL_REMOVED, com_cast<INmChannel>(GetUnknown()));
  220. }
  221. else
  222. {
  223. ERROR_OUT(("ChannelRemoved, but no ConfObject"));
  224. hr = E_UNEXPECTED;
  225. }
  226. return hr;
  227. }
  228. ///////////////////////////////////////////////////////////////////////////////
  229. // Helpers
  230. ///////////////////////////////////////////////////////////////////////////////
  231. HRESULT CNmChannelVideoObj::Fire_MemberChanged(NM_MEMBER_NOTIFY uNotify, INmMember *pMember)
  232. {
  233. DBGENTRY(CNmChannelVideoObj::Fire_MemberChanged);
  234. HRESULT hr = S_OK;
  235. /////////////////////////////////////////////////////
  236. // INmChannelNotify
  237. /////////////////////////////////////////////////////
  238. IConnectionPointImpl<CNmChannelVideoObj, &IID_INmChannelNotify, CComDynamicUnkArray>* pCP = this;
  239. for(int i = 0; i < pCP->m_vec.GetSize(); ++i )
  240. {
  241. INmChannelNotify* pNotify = reinterpret_cast<INmChannelNotify*>(pCP->m_vec.GetAt(i));
  242. if(pNotify)
  243. {
  244. pNotify->MemberChanged(uNotify, pMember);
  245. }
  246. }
  247. /////////////////////////////////////////////////////
  248. // INmChannelVideoNotify
  249. /////////////////////////////////////////////////////
  250. IConnectionPointImpl<CNmChannelVideoObj, &IID_INmChannelVideoNotify, CComDynamicUnkArray>* pCP2 = this;
  251. for(i = 0; i < pCP2->m_vec.GetSize(); ++i )
  252. {
  253. INmChannelVideoNotify* pNotify2 = reinterpret_cast<INmChannelVideoNotify*>(pCP2->m_vec.GetAt(i));
  254. if(pNotify2)
  255. {
  256. pNotify2->MemberChanged(uNotify, pMember);
  257. }
  258. }
  259. DBGEXIT_HR(CNmChannelVideoObj::Fire_MemberChanged,hr)
  260. return hr;
  261. }
  262. HRESULT CNmChannelVideoObj::Fire_StateChanged(NM_VIDEO_STATE uState)
  263. {
  264. HRESULT hr = S_OK;
  265. /////////////////////////////////////////////////////
  266. // INmChannelVideoNotify
  267. /////////////////////////////////////////////////////
  268. IConnectionPointImpl<CNmChannelVideoObj, &IID_INmChannelVideoNotify, CComDynamicUnkArray>* pCP2 = this;
  269. for(int i = 0; i < pCP2->m_vec.GetSize(); ++i )
  270. {
  271. INmChannelVideoNotify* pNotify2 = reinterpret_cast<INmChannelVideoNotify*>(pCP2->m_vec.GetAt(i));
  272. if(pNotify2)
  273. {
  274. pNotify2->StateChanged(uState);
  275. }
  276. }
  277. DBGEXIT_HR(CNmChannelVideoObj::Fire_MemberChanged,hr)
  278. return hr;
  279. }
  280. HRESULT CNmChannelVideoObj::Fire_PropertyChanged(DWORD dwReserved)
  281. {
  282. HRESULT hr = S_OK;
  283. /////////////////////////////////////////////////////
  284. // INmChannelVideoNotify
  285. /////////////////////////////////////////////////////
  286. IConnectionPointImpl<CNmChannelVideoObj, &IID_INmChannelVideoNotify, CComDynamicUnkArray>* pCP2 = this;
  287. for(int i = 0; i < pCP2->m_vec.GetSize(); ++i )
  288. {
  289. INmChannelVideoNotify* pNotify2 = reinterpret_cast<INmChannelVideoNotify*>(pCP2->m_vec.GetAt(i));
  290. if(pNotify2)
  291. {
  292. pNotify2->PropertyChanged(dwReserved);
  293. }
  294. }
  295. DBGEXIT_HR(CNmChannelVideoObj::Fire_MemberChanged,hr)
  296. return hr;
  297. }
  298. HRESULT CNmChannelVideoObj::_IsActive()
  299. {
  300. return GetbActive() ? S_OK : S_FALSE;
  301. }
  302. HRESULT CNmChannelVideoObj::_SetActive(BOOL bActive)
  303. {
  304. if (GetbActive() == bActive)
  305. return S_FALSE;
  306. return E_FAIL;
  307. }
  308.