WavTgtFactory.cpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /******************************************************************************
  2. |* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  3. |* ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  4. |* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  5. |* PARTICULAR PURPOSE.
  6. |*
  7. |* Copyright 1995-2005 Nero AG. All Rights Reserved.
  8. |*-----------------------------------------------------------------------------
  9. |* PROJECT: Nero Plugin Manager Example
  10. |*
  11. |* FILE: WavTgtFactory.cpp
  12. |*
  13. |* PURPOSE: Implementation of the wave target factory
  14. ******************************************************************************/
  15. #include "stdafx.h"
  16. #include "WavTgtFactory.h"
  17. // {9E424B23-3D6A-48ca-A41D-B65927057499}
  18. EXTERN_GUID(COMPID_TgtFactory , 0x9e424b23, 0x3d6a, 0x48ca, 0xa4, 0x1d, 0xb6, 0x59, 0x27, 0x5, 0x74, 0x99);
  19. // Wave Target class
  20. #include "WavTgt.h"
  21. // Wave Settings dialog
  22. #include "dlg_WavSettings.h"
  23. extern IAudioPluginMgr* g_pPluginMgr;
  24. void CWavTgtFactory::GetID(GUID *pGUID)
  25. {
  26. ASSERT(pGUID);
  27. if(pGUID)
  28. memcpy(pGUID, &COMPID_TgtFactory, sizeof(GUID));
  29. }
  30. const char* CWavTgtFactory::GetName()
  31. {
  32. return "PCM Wav file";
  33. }
  34. EAudioComponentType CWavTgtFactory::GetType()
  35. {
  36. return ACT_AudioURLTargetFactory;
  37. }
  38. bool CWavTgtFactory::Init(IAudioPluginMgr* pMgr, IStatus** ppStatus)
  39. {
  40. if(ppStatus)
  41. {
  42. *ppStatus = NULL;
  43. }
  44. if(g_pPluginMgr)
  45. {
  46. ASSERT(g_pPluginMgr == pMgr);
  47. }
  48. else
  49. {
  50. g_pPluginMgr = pMgr;
  51. }
  52. // success
  53. return true;
  54. }
  55. bool CWavTgtFactory::Done()
  56. {
  57. return true;
  58. }
  59. // IURLAudioTargetFactory
  60. bool CWavTgtFactory::CreateURLAudioTarget(IUnknown** ppTgt,
  61. const SWavFormat& formatSrc,
  62. IStatus** ppStatus)
  63. {
  64. if(ppStatus)
  65. {
  66. *ppStatus = NULL;
  67. }
  68. *ppTgt = static_cast<IAggregatable*>
  69. (new CWavTgt(formatSrc, (IAudioComponent*)this));
  70. if(*ppTgt)
  71. {
  72. (*ppTgt)->AddRef();
  73. }
  74. return true;
  75. }
  76. bool CWavTgtFactory::EditSettings(IUnknown **ppTgt, int iCount)
  77. {
  78. SWavFormat **ppDlgData = new SWavFormat*[iCount];
  79. if(!(ppTgt && iCount && ppDlgData))
  80. {
  81. ASSERT(FALSE);
  82. return false;
  83. }
  84. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  85. for(int i = 0; i < iCount; i++)
  86. {
  87. CComQIPtr<IWavTgtSetDlgData> pDlgData = ppTgt[i];
  88. if(!pDlgData)
  89. {
  90. // This is an object of not a valid type because we cannot
  91. // retrieve our internal interface from it.
  92. ASSERT(FALSE);
  93. return false;
  94. }
  95. ppDlgData[i] = pDlgData->GetDlgData();
  96. }
  97. CWavSettingsDlg dlg(ppDlgData, iCount);
  98. int iDlgRet = dlg.DoModal();
  99. delete ppDlgData;
  100. return (iDlgRet == IDOK);
  101. }
  102. // Application should first call this function to determine if this
  103. // factory can edit settings for items.
  104. bool CWavTgtFactory::CanEditSettings()
  105. {
  106. return true;
  107. }
  108. EURLType CWavTgtFactory::GetSupportedURLTypes()
  109. {
  110. return URL_LocalFile;
  111. }
  112. // IExtEnum
  113. int CWavTgtFactory::GetCount()
  114. {
  115. return 2;
  116. }
  117. // The returned value can't be stored for later use.
  118. // The application must copy it.
  119. const char* CWavTgtFactory::GetExt(int iNum)
  120. {
  121. if(0 == iNum)
  122. {
  123. return "wav";
  124. }
  125. else if(1 == iNum)
  126. {
  127. return "wave";
  128. }
  129. ASSERT(FALSE);
  130. return NULL;
  131. }
  132. long CWavTgtFactory::GetRefCount()
  133. {
  134. return m_lRef;
  135. }