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.

234 lines
6.5 KiB

  1. //==========================================================================;
  2. //
  3. // Copyright (c) Microsoft Corporation 1999-2000.
  4. //
  5. //--------------------------------------------------------------------------;
  6. //
  7. // MSVidStreamBufferSink.cpp : Implementation of CMSVidStreamBufferSink
  8. //
  9. #include "stdafx.h"
  10. #ifndef TUNING_MODEL_ONLY
  11. #include <encdec.h>
  12. #include "MSVidCtl.h"
  13. #include "MSVidSbeSink.h"
  14. DEFINE_EXTERN_OBJECT_ENTRY(CLSID_MSVidStreamBufferSink, CMSVidStreamBufferSink)
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CMSVidStreamBufferSink
  17. STDMETHODIMP CMSVidStreamBufferSink::InterfaceSupportsErrorInfo(REFIID riid){
  18. static const IID* arr[] =
  19. {
  20. &IID_IMSVidStreamBufferSink
  21. };
  22. for (int i=0; i < sizeof(arr) / sizeof(arr[0]); i++)
  23. {
  24. if (InlineIsEqualGUID(*arr[i],riid))
  25. return S_OK;
  26. }
  27. return S_FALSE;
  28. }
  29. STDMETHODIMP CMSVidStreamBufferSink::get_SinkName(BSTR *pName){
  30. try{
  31. if(!pName){
  32. return E_POINTER;
  33. }
  34. *pName = m_SinkName.Copy();
  35. return S_OK;
  36. }
  37. catch(...){
  38. return E_UNEXPECTED;
  39. }
  40. }
  41. // This function has to be called before the graph is running
  42. // so before or after build but before run is called
  43. STDMETHODIMP CMSVidStreamBufferSink::put_SinkName(BSTR Name){
  44. try{
  45. if(!wcslen(Name)){
  46. return E_INVALIDARG;
  47. }
  48. m_SinkName = Name;
  49. m_bNameSet = FALSE;
  50. CComQIPtr<IMSVidCtl> pq_vidCtl;
  51. if(!m_pContainer){
  52. return S_OK;
  53. }
  54. else{
  55. HRESULT hr = m_pContainer->QueryInterface(IID_IMSVidCtl, reinterpret_cast<void**>(&pq_vidCtl));
  56. if(FAILED(hr)){
  57. return hr;
  58. }
  59. MSVidCtlStateList state;
  60. hr = pq_vidCtl->get_State(&state);
  61. if(FAILED(hr)){
  62. return hr;
  63. }
  64. if(state == STATE_UNBUILT || state == STATE_STOP){
  65. hr = m_ptsSink->IsProfileLocked();
  66. if(FAILED(hr)){
  67. return hr;
  68. }
  69. else if(hr != S_FALSE){
  70. return E_FAIL; // should be called after run called on sink
  71. }
  72. }
  73. else{
  74. return E_FAIL; // should be called after run called on sink
  75. }
  76. }
  77. return S_OK;
  78. }
  79. catch(...){
  80. return E_UNEXPECTED;
  81. }
  82. }
  83. void CMSVidStreamBufferSink::Expunge(){
  84. if(!( !m_RecordObj)){// not not'ing smart pointer, they assert if p == 0
  85. m_RecordObj.Release();
  86. }
  87. return;
  88. }
  89. HRESULT CMSVidStreamBufferSink::get_ContentRecorder(BSTR pszFilename, IMSVidStreamBufferRecordingControl ** ppRecording){
  90. try{
  91. if(!pszFilename || !ppRecording){
  92. return E_POINTER;
  93. }
  94. if(!( !m_RecordObj)){// not not'ing smart pointer, they assert if p == 0
  95. m_RecordObj.Release();
  96. }
  97. // Create the new recorder if needed and insert it
  98. PUnknown tempUnknown;
  99. if(!m_ptsSink){
  100. //return not_init
  101. return E_FAIL; // should be invalid state
  102. }
  103. CComBSTR val = pszFilename;
  104. HRESULT hr = m_ptsSink->CreateRecorder(val, RECORDING_TYPE_CONTENT,&tempUnknown);
  105. if(FAILED(hr)){
  106. return hr;
  107. }
  108. pqSBERecControl newRec(tempUnknown);
  109. if(!newRec){
  110. return E_UNEXPECTED;
  111. }
  112. tempUnknown.Release();
  113. m_RecordObj = new CMSVidStreamBufferRecordingControl(newRec.Detach(), val.Detach(), RECORDING_TYPE_CONTENT);
  114. if(!m_RecordObj){
  115. ASSERT(false);
  116. return E_UNEXPECTED;
  117. }
  118. /*
  119. CComQIPtr<IMSVidStreamBufferRecorder>retObj(m_RecordObj);
  120. if(!retObj){
  121. ASSERT(false);
  122. return E_UNEXPECTED;
  123. }
  124. *ppRecording = retObj.Detach();
  125. */
  126. //m_RecordObj->AddRef();
  127. hr = m_RecordObj.CopyTo(ppRecording);
  128. if(!ppRecording || FAILED(hr)){
  129. ASSERT(false);
  130. return E_UNEXPECTED;
  131. }
  132. }
  133. catch(...){
  134. return E_UNEXPECTED;
  135. }
  136. return S_OK;
  137. }
  138. HRESULT CMSVidStreamBufferSink::get_ReferenceRecorder(BSTR pszFilename, IMSVidStreamBufferRecordingControl ** ppRecording){
  139. try{
  140. if(!pszFilename || !ppRecording){
  141. return E_POINTER;
  142. }
  143. if(!( !m_RecordObj)){// not not'ing smart pointer, they assert if p == 0
  144. m_RecordObj.Release();
  145. }
  146. // Create the new recorder if needed and insert it
  147. PUnknown tempUnknown;
  148. if(!m_ptsSink){
  149. //return not_init
  150. return E_FAIL; // should be invalid state
  151. }
  152. CComBSTR val = pszFilename;
  153. HRESULT hr = m_ptsSink->CreateRecorder(val, RECORDING_TYPE_REFERENCE, &tempUnknown);
  154. if(FAILED(hr)){
  155. return hr;
  156. }
  157. pqSBERecControl newRec(tempUnknown);
  158. if(!newRec){
  159. return E_UNEXPECTED;
  160. }
  161. tempUnknown.Release();
  162. m_RecordObj = new CMSVidStreamBufferRecordingControl(newRec.Detach(), val.Detach(), RECORDING_TYPE_REFERENCE);
  163. if(!m_RecordObj){
  164. ASSERT(false);
  165. return E_UNEXPECTED;
  166. }
  167. /*
  168. CComQIPtr<IMSVidStreamBufferRecordingControl>retObj(m_RecordObj);
  169. if(!retObj){
  170. ASSERT(false);
  171. return E_UNEXPECTED;
  172. }
  173. *ppRecording = retObj.Detach();
  174. */
  175. //m_RecordObj->AddRef();
  176. hr = m_RecordObj.CopyTo(ppRecording);
  177. if(!ppRecording || FAILED(hr)){
  178. ASSERT(false);
  179. return E_UNEXPECTED;
  180. }
  181. }
  182. catch(...){
  183. return E_UNEXPECTED;
  184. }
  185. return S_OK;
  186. }
  187. HRESULT CMSVidStreamBufferSink::get_SBESink(IUnknown ** sbeConfig){
  188. if(!sbeConfig){
  189. return E_POINTER;
  190. }
  191. if(m_StreamBuffersink == -1){
  192. return E_UNEXPECTED;
  193. }
  194. CComQIPtr<IBaseFilter> spSinkFilter(m_Filters[m_StreamBuffersink]);
  195. CComPtr<IUnknown>spUnk;
  196. spUnk = spSinkFilter;
  197. if(!spUnk){
  198. return E_UNEXPECTED;
  199. }
  200. *sbeConfig = spUnk.Detach();
  201. return NOERROR;
  202. }
  203. HRESULT CMSVidStreamBufferSink::Fire(GUID gEventID) {
  204. TRACELSM(TRACE_DETAIL, (dbgDump << "CMSVidStreamBufferSink::Fire() guid = " << GUID2(gEventID)), "");
  205. if (gEventID == EVENTID_ETDTFilterLicenseFailure) {
  206. Fire_CertificateFailure();
  207. } else if (gEventID == EVENTID_ETDTFilterLicenseOK) {
  208. TRACELSM(TRACE_ERROR, (dbgDump << "CMSVidStreamBufferSink::Fire() Certificate Success"), "");
  209. Fire_CertificateSuccess();
  210. }
  211. return NOERROR;
  212. }
  213. #endif //TUNING_MODEL_ONLY
  214. // end of file - MSVidStreamBufferSink.cpp