Source code of Windows XP (NT5)
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.

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