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.

158 lines
3.1 KiB

  1. /* - - - - - - - - */
  2. /*
  3. ** Copyright (C) Microsoft Corporation 1993. All rights reserved.
  4. */
  5. /* - - - - - - - - */
  6. #include <win32.h>
  7. //#include <mmddk.h>
  8. #include <compobj.h>
  9. #include <avifmt.h>
  10. #include "avifile.h"
  11. #include "avifilei.h"
  12. #include "avicmprs.h"
  13. #include "unmarsh.h"
  14. #include "editstrm.h"
  15. /* - - - - - - - - */
  16. HRESULT CAVIFileCF::Create(
  17. const CLSID FAR& rclsid,
  18. REFIID riid,
  19. LPVOID FAR* ppv)
  20. {
  21. CAVIFileCF FAR* pAVIFileCF;
  22. IUnknown FAR* pUnknown;
  23. HRESULT hresult;
  24. pAVIFileCF = new FAR CAVIFileCF(rclsid, &pUnknown);
  25. if (pAVIFileCF == NULL)
  26. return ResultFromScode(E_OUTOFMEMORY);
  27. hresult = pUnknown->QueryInterface(riid, ppv);
  28. if (FAILED(GetScode(hresult)))
  29. delete pAVIFileCF;
  30. return hresult;
  31. }
  32. /* - - - - - - - - */
  33. CAVIFileCF::CAVIFileCF(
  34. const CLSID FAR& rclsid,
  35. IUnknown FAR* FAR* ppUnknown) :
  36. m_Unknown(this),
  37. m_Factory(this)
  38. {
  39. m_clsid = rclsid;
  40. *ppUnknown = &m_Unknown;
  41. }
  42. /* - - - - - - - - */
  43. CAVIFileCF::CUnknownImpl::CUnknownImpl(
  44. CAVIFileCF FAR* pAVIFileCF)
  45. {
  46. m_pAVIFileCF = pAVIFileCF;
  47. m_refs = 0;
  48. }
  49. /* - - - - - - - - */
  50. STDMETHODIMP CAVIFileCF::CUnknownImpl::QueryInterface(
  51. REFIID iid,
  52. LPVOID FAR* ppv)
  53. {
  54. if (iid == IID_IUnknown)
  55. *ppv = &m_pAVIFileCF->m_Unknown;
  56. else if (iid == IID_IClassFactory)
  57. *ppv = &m_pAVIFileCF->m_Factory;
  58. else
  59. return ResultFromScode(E_NOINTERFACE);
  60. AddRef();
  61. return AVIERR_OK;
  62. }
  63. /* - - - - - - - - */
  64. STDMETHODIMP_(ULONG) CAVIFileCF::CUnknownImpl::AddRef()
  65. {
  66. return ++m_refs;
  67. }
  68. /* - - - - - - - - */
  69. STDMETHODIMP_(ULONG) CAVIFileCF::CUnknownImpl::Release()
  70. {
  71. if (!--m_refs) {
  72. delete this;
  73. return 0;
  74. }
  75. return m_refs;
  76. }
  77. /* - - - - - - - - */
  78. CAVIFileCF::CFactoryImpl::CFactoryImpl(
  79. CAVIFileCF FAR* pAVIFileCF)
  80. {
  81. m_pAVIFileCF = pAVIFileCF;
  82. }
  83. /* - - - - - - - - */
  84. STDMETHODIMP CAVIFileCF::CFactoryImpl::QueryInterface(
  85. REFIID iid,
  86. LPVOID FAR* ppv)
  87. {
  88. return m_pAVIFileCF->m_Unknown.QueryInterface(iid, ppv);
  89. }
  90. /* - - - - - - - - */
  91. STDMETHODIMP_(ULONG) CAVIFileCF::CFactoryImpl::AddRef()
  92. {
  93. return m_pAVIFileCF->m_Unknown.AddRef();
  94. }
  95. /* - - - - - - - - */
  96. STDMETHODIMP_(ULONG) CAVIFileCF::CFactoryImpl::Release()
  97. {
  98. return m_pAVIFileCF->m_Unknown.Release();
  99. }
  100. /* - - - - - - - - */
  101. STDMETHODIMP CAVIFileCF::CFactoryImpl::CreateInstance(
  102. IUnknown FAR* pUnknownOuter,
  103. REFIID riid,
  104. LPVOID FAR* ppv)
  105. {
  106. if (IsEqualCLSID(m_pAVIFileCF->m_clsid, CLSID_AVIFile)) {
  107. return CAVIFile::Create(pUnknownOuter, riid, ppv);
  108. } else
  109. if (IsEqualCLSID(m_pAVIFileCF->m_clsid, CLSID_AVICmprsStream)) {
  110. return CAVICmpStream::Create(pUnknownOuter, riid, ppv);
  111. } else
  112. if (IsEqualCLSID(m_pAVIFileCF->m_clsid, CLSID_AVISimpleUnMarshal)) {
  113. return CUnMarshal::Create(pUnknownOuter, riid, ppv);
  114. } else
  115. if (IsEqualCLSID(m_pAVIFileCF->m_clsid, CLSID_EditStream)) {
  116. return CEditStream::NewInstance(pUnknownOuter, riid, ppv);
  117. } else {
  118. return ResultFromScode(CO_E_CANTDETERMINECLASS); // !!!
  119. }
  120. }
  121. /* - - - - - - - - */
  122. STDMETHODIMP CAVIFileCF::CFactoryImpl::LockServer(
  123. BOOL fLock)
  124. {
  125. fLocked = fLock;
  126. return AVIERR_OK;
  127. }
  128. /* - - - - - - - - */