audiopluginenv.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709
  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. |* NeroSDK / AudioPluginManager
  10. |*
  11. |* FILE: audiopluginenv.h
  12. |*
  13. |* PURPOSE: Definition of the audio plugin manager interfaces
  14. ******************************************************************************/
  15. #ifndef _AUDIO_PLUGIN_ENV_
  16. # define _AUDIO_PLUGIN_ENV_
  17. #include "AuxDefs.h"
  18. #include "WavFormat.h"
  19. #include "AudioTypes.h"
  20. #include "AudioPluginEnvIID.h"
  21. #include "AudioErrors.h"
  22. ///////////////////////////// GENERIC INTERFACES ///////////////////////////////
  23. interface IIdentifiable : public IUnknown
  24. {
  25. virtual void
  26. GetID(GUID *pGUID) PURE;
  27. };
  28. //////////////////////////////////////////////////////////////// IExAudioInfo //
  29. interface IExAudioInfo : public IUnknown
  30. {
  31. virtual int
  32. GetBitrate() PURE;
  33. };
  34. //////////////////////////////////////////////////////////////////// IControl //
  35. interface IControl : public IUnknown
  36. {
  37. virtual const char *
  38. GetClassName() PURE;
  39. virtual const char *
  40. GetTitle() PURE;
  41. virtual int
  42. GetID() PURE;
  43. };
  44. ///////////////////////////////////////////////////////////////// IURLSupport //
  45. interface IURLSupport : public IUnknown
  46. {
  47. virtual EURLType
  48. GetSupportedURLTypes() PURE;
  49. };
  50. ////////////////////////////////////////////////////////////////// IAbortable //
  51. interface IAbortable : public IUnknown
  52. {
  53. virtual bool
  54. Abort() PURE;
  55. };
  56. /////////////////////////////////////////////////////////////////// ISeekable //
  57. // Seeks in audio stream.
  58. interface ISeekable : public IUnknown
  59. {
  60. // Moves the current position in the stream. UiNewPos contains the new
  61. // position in blocks.
  62. virtual bool
  63. Seek(ULONGLONG uiNewPos, IStatus **ppStatus = NULL) PURE;
  64. };
  65. /////////////////////////////////////////////////////////////// IConfigurable //
  66. // Any object can expose this interface and become configurable
  67. interface IConfigurable : public IUnknown
  68. {
  69. virtual bool
  70. Configure() PURE;
  71. };
  72. /////////////////////////////////////////////////////////////// IAggregatable //
  73. // Allows the object to be aggregated by outer objects in order to override
  74. // some functionality. For example outer object will aggregate IAudioRawReader
  75. // interfaces in order to perform conversion from plugin format to the format
  76. // requested by the application.
  77. interface IAggregatable : public IUnknown
  78. {
  79. virtual bool
  80. SetAggregator(IUnknown *pAggregator) PURE;
  81. virtual bool
  82. GetAggregator(IUnknown **ppAggregator) PURE;
  83. virtual HRESULT STDMETHODCALLTYPE
  84. InnerQueryInterface( REFIID riid, void __RPC_FAR *__RPC_FAR *ppObj) PURE;
  85. virtual ULONG
  86. STDMETHODCALLTYPE InnerAddRef() PURE;
  87. virtual ULONG
  88. STDMETHODCALLTYPE InnerRelease() PURE;
  89. };
  90. ///////////////////////////////////////////////////////////////////// IStatus //
  91. // Pointers of this type are passed to some functions in audio items, factories
  92. // and others. If error occures those functions create objects exposing this
  93. // interface and the application can obtain the detailed information about the
  94. // error occured.
  95. interface IStatus : public IUnknown
  96. {
  97. virtual const char *
  98. GetDescription() PURE;
  99. virtual EAudioError
  100. GetAudioError() PURE;
  101. virtual DWORD
  102. GetSysError() PURE;
  103. };
  104. ///////////////////////////////////////////////////////////// IStatusCategory //
  105. interface IStatusCategory : public IUnknown
  106. {
  107. virtual EStatusCategory
  108. GetCategory() PURE;
  109. };
  110. ///////////////////////////////////////////////////////////////////// Process //
  111. // Exposes functionality of some object that can be started and ended.
  112. // Currently is used as a part of source and target items.
  113. interface IProcess : public IUnknown
  114. {
  115. virtual bool
  116. Start(IStatus **ppStatus = NULL) PURE;
  117. virtual bool
  118. End(IStatus **ppStatus = NULL) PURE;
  119. virtual bool
  120. IsInProcess() PURE;
  121. };
  122. ////////////////////////////////////////////////////////////////// IURLHolder //
  123. // Allows the owner object to store, change, retrieve and determine the type
  124. // of URL. Currently used as a part of IURLAudioSource and IURLAudioTarget.
  125. interface IURLHolder : public IUnknown
  126. {
  127. virtual bool
  128. SetURL(const char *szURL, IStatus **ppStatus = NULL) PURE;
  129. virtual const char *
  130. GetURL() PURE;
  131. virtual EURLType
  132. GetType() PURE;
  133. };
  134. /////////////////////////////////////////////////////////////////// ILanguage //
  135. // Changes the current language for all the windows shown by plugins.
  136. // Plugin manager stores the current language in it and since all the
  137. // components can reach the plugin manager, they can obtain and use it
  138. // whenever is necessary.
  139. interface ILanguage : public IUnknown
  140. {
  141. virtual bool
  142. SetLanguage(LANGID id, IStatus **ppStatus = NULL) PURE;
  143. virtual LANGID
  144. GetLanguage() PURE;
  145. };
  146. //////////////////////////////////////////////////////////////////// IProfile //
  147. // This information is very useful for plugins if they want to store some
  148. // settings in registry. For different products using this library all those
  149. // settings thus will be stored in different places. Of course the application
  150. // must not forget to specify these parameters to the plugin manager.
  151. interface IProfile : public IUnknown
  152. {
  153. virtual bool
  154. SetVendor(const char *szVendor, IStatus **ppStatus = NULL) PURE;
  155. virtual const char *
  156. GetVendor() PURE;
  157. virtual bool
  158. SetProduct(const char *szProduct, IStatus **ppStatus = NULL) PURE;
  159. virtual const char *
  160. GetProduct() PURE;
  161. };
  162. //////////////////////////////////////////////////////////////////// IExtEnum //
  163. // Enumerates the extensions supported by certain source/target audio factories.
  164. interface IExtEnum : public IUnknown
  165. {
  166. virtual int
  167. GetCount() PURE;
  168. // The returned value can't be stored for later use.
  169. // The application must copy it.
  170. virtual const char *
  171. GetExt(int iNum) PURE;
  172. };
  173. ///////////////////////////////////////////////////////// ISourceStreamLength //
  174. // This might be useful in some cases when the efficiency of encoding depends
  175. // on the prior knowledge about the source.
  176. interface ISourceStreamLength : public IUnknown
  177. {
  178. // dwLength is the source stream length in blocks
  179. virtual void
  180. SetLength(DWORD dwLength) PURE;
  181. };
  182. /////////////////////////// INTERRELATED INTERFACES ////////////////////////////
  183. ///////////////////////////////////////////////////////////// IAudioComponent //
  184. interface IAudioPluginMgr;
  185. // Exposed by all the audio plugins, i.e. source and target audio factories,
  186. // audio RAW convertor factories, etc.
  187. interface IAudioComponent : public IUnknown
  188. {
  189. virtual const char *
  190. GetName() PURE;
  191. // Application should first call this method to determine the type
  192. // of the component and after that query the appropriate interface.
  193. virtual EAudioComponentType
  194. GetType() PURE;
  195. // This method is called after all the components are enumerated.
  196. // It should perform the actual initialization and store pMgr for
  197. // later use to access functionality provided by other plugins.
  198. // If the component initialization fails, it should return false
  199. // and the plugin manager will remove it from components list so
  200. // it will not be available.
  201. virtual bool
  202. Init(IAudioPluginMgr *pMgr, IStatus **ppStatus = NULL) PURE;
  203. virtual bool
  204. Done() PURE;
  205. };
  206. ///////////////////////////////////////////////////////////////// IVendorInfo //
  207. interface IVendorInfo : public IUnknown
  208. {
  209. virtual const char *
  210. GetVendorName() PURE;
  211. virtual bool
  212. CanDisplayAboutBox() PURE;
  213. virtual void
  214. DisplayAboutBox() PURE;
  215. };
  216. ////////////////////////////////////////////////////////////////// IAudioItem //
  217. // Exported by audio items: sources, targets and others. Supplies the
  218. // general information about them.
  219. interface IAudioItem : public IUnknown
  220. {
  221. virtual bool
  222. GetCreator(IAudioComponent **pCreator) PURE;
  223. // Bitmask of auxiliary flags
  224. virtual EAuxFlags
  225. GetAuxFlags() PURE;
  226. virtual void
  227. SetAuxFlags(EAuxFlags flags) PURE;
  228. };
  229. ///////////////////////////////////////////////////////////// IAudioRawReader //
  230. // Audio items expose this interface when they can extract audio RAW data.
  231. // This interface corresponds to the EAF_Readable auxiliary audio item flag.
  232. interface IAudioRawReader : public IUnknown
  233. {
  234. virtual SWavFormat
  235. GetRawFormat() PURE;
  236. // iBufSize must contain the size in bytes of the buffer pointed by pBuf.
  237. virtual bool
  238. RawRead(BYTE *pBuf, int iBufSize, int *piRead, EAudioRawState &state,
  239. IStatus **ppStatus = NULL) PURE;
  240. // Returns RAW data length in bytes.
  241. virtual ULONGLONG
  242. GetRawLen() PURE;
  243. };
  244. //////////////////////////////////////////////////////////////// IAudioSource //
  245. interface IAudioSource : public IUnknown
  246. {
  247. // Returns free-form text string about the item.
  248. virtual const char *
  249. GetInfo() PURE;
  250. // Returns the file duration in milliseconds.
  251. virtual ULONGLONG
  252. GetDuration() PURE;
  253. };
  254. ///////////////////////////////////////////////////////// IAudioSourceFactory //
  255. interface IAudioSourceFactory
  256. {
  257. virtual EAuxFlags
  258. GetAuxFlags() PURE;
  259. };
  260. ////////////////////////////////////////////////////// IURLAudioSourceFactory //
  261. // Opens source audio items by URLs.
  262. interface IURLAudioSourceFactory : public IAudioSourceFactory, IURLSupport
  263. {
  264. // "format" specifies the raw data format which the application
  265. // wants to get.
  266. virtual bool
  267. Open( const char *szURL,
  268. IUnknown **ppSrc,
  269. EAuxFlags flagsInclude = EAF_None,
  270. EAuxFlags flagsExclude = EAF_None,
  271. IStatus **ppStatus = NULL) PURE;
  272. };
  273. ////////////////////////////////////////////////////////////////// IConvertor //
  274. interface IConvertor : public IUnknown
  275. {
  276. virtual bool
  277. Convert(BYTE *pData, int iNumberOfBytes, IStatus **ppStatus) PURE;
  278. virtual int
  279. GetOutputBufSize() PURE;
  280. virtual BYTE *
  281. GetOutputBuf() PURE;
  282. };
  283. ////////////////////////////////////////////////////////// IConvertorFactory2 //
  284. interface IConvertorFactory2 : public IUnknown
  285. {
  286. virtual void
  287. SetMode(EConvFactoryMode mode) PURE;
  288. };
  289. /////////////////////////////////////////////////////////// IConvertorFactory //
  290. // Produces instances of certain type raw convertor objects.
  291. interface IConvertorFactory : public IUnknown
  292. {
  293. virtual EMediaType
  294. GetSupportedMediaTypes() PURE;
  295. virtual bool
  296. CreateConvertor(const SWavFormat &src,
  297. const SWavFormat &tgt,
  298. IConvertor **ppConv,
  299. IStatus **ppStatus = NULL) PURE;
  300. };
  301. ////////////////////////////////////////////////////////////// IEventReceiver //
  302. interface IEventReceiver : public IUnknown
  303. {
  304. virtual void
  305. ReceiveEvent(EEvent event, IUnknown *pSource) PURE;
  306. };
  307. ////////////////////////////////////////////////////////////// IComponentEnum //
  308. // Enumerates audio plugin components. Exposed by the central plugin manager
  309. // and by all the audio plugin DLLs that need to incapsulate more than one
  310. // component.
  311. interface IComponentEnum : public IUnknown
  312. {
  313. virtual int
  314. GetCount() PURE;
  315. virtual bool
  316. GetComponent(int iNum, IAudioComponent **ppComp) PURE;
  317. };
  318. ////////////////////////////////////////////////////////// IAudioRawBlockInfo //
  319. // Provides information about an audio source in blocks (current position,
  320. // size of block, size of the source in blocks).
  321. interface IAudioRawBlockInfo : public IUnknown
  322. {
  323. virtual ULONGLONG
  324. GetPos() PURE;
  325. virtual ULONGLONG
  326. GetBlockSize() PURE;
  327. // If the audio source is infinite like in internet streams, return value
  328. // will be NO_LENGTH. Otherwise this method returns the length of RAW data
  329. // in blocks.
  330. virtual ULONGLONG
  331. GetDataLength() PURE;
  332. };
  333. ///////////////////////////////////////////////////////////// IAudioRawWriter //
  334. // Allows to write audio RAW data into an object.
  335. interface IAudioRawWriter : public IUnknown
  336. {
  337. virtual bool
  338. RawWrite(BYTE *pData, int iNumberOfBytesToWrite, EAudioRawState &state,
  339. IStatus **ppStatus = NULL) PURE;
  340. // Since the object is created, this function can return different values
  341. // depending on output target settings. This only cannot be changed during
  342. // the writing process so the application/aggregator call this function
  343. // immediately before the process starting.
  344. virtual SWavFormat
  345. GetRawFormat() PURE;
  346. };
  347. ///////////////////////////////////////////////////////// IAudioTargetFactory //
  348. interface IAudioTargetFactory
  349. {
  350. // Returns true if settings are changed, otherwise returns false.
  351. virtual bool
  352. EditSettings(IUnknown **ppTgt, int iCount) PURE;
  353. virtual bool
  354. CanEditSettings() PURE;
  355. };
  356. ////////////////////////////////////////////////////// IURLAudioTargetFactory //
  357. // Creates target audio items at URLs.
  358. interface IURLAudioTargetFactory : public IAudioTargetFactory, IURLSupport
  359. {
  360. // Caller must fill "formatSrc" accordingly to the format of source data
  361. // that is to be written in this target.
  362. virtual bool
  363. CreateURLAudioTarget( IUnknown **ppTgt,
  364. const SWavFormat &formatSrc,
  365. IStatus **ppStatus = NULL) PURE;
  366. };
  367. ///////////////////////////////////////////////////////////////// IInfoReader //
  368. // Allows to obtain the additional information from a source item.
  369. interface IInfoReader : public IUnknown
  370. {
  371. // All these functions can return NULL for no data indication.
  372. virtual const char *
  373. GetTitle() PURE;
  374. virtual const char *
  375. GetArtist() PURE;
  376. virtual const char *
  377. GetAlbum() PURE;
  378. virtual const char *
  379. GetYear() PURE;
  380. virtual const char *
  381. GetGenre() PURE;
  382. };
  383. ///////////////////////////////////////////////////////////////// IInfoWriter //
  384. interface IInfoWriter : public IUnknown
  385. {
  386. virtual void
  387. SetTitle(const char *szTitle) PURE;
  388. virtual void
  389. SetArtist(const char *szArtist) PURE;
  390. virtual void
  391. SetAlbum(const char *szAlbum) PURE;
  392. virtual void
  393. SetYear(const char *szYear) PURE;
  394. virtual void
  395. SetGenre(const char *szGenre) PURE;
  396. };
  397. //////////////////////////////////////////////////////////////// ITrackNumber //
  398. interface ITrackNumber : public IUnknown
  399. {
  400. // 0-based index or -1 if no track number is available
  401. virtual int
  402. Get() PURE;
  403. virtual bool
  404. Set(int iNum) PURE;
  405. };
  406. //////////////////////////////////////////////////////////// ISrcInfoCallback //
  407. interface ISrcInfoCallback : public IUnknown
  408. {
  409. virtual int
  410. GetCustomControlCount() PURE;
  411. virtual bool
  412. GetControl(int iNum, IControl **ppControl) PURE;
  413. virtual void
  414. OnModified(bool b) PURE;
  415. virtual void
  416. OnCustomButton(int iID) PURE;
  417. virtual bool
  418. OnSave() PURE;
  419. virtual bool
  420. OnClose() PURE;
  421. };
  422. //////////////////////////////////////////////////////// ISrcInfoViewerEditor //
  423. // Brings a dialog with additional information about an audio source and
  424. // sometimes allows to edit it and store back in the source (for example
  425. // in the mp3 URL audio source item).
  426. interface ISrcInfoViewerEditor : public IUnknown
  427. {
  428. virtual bool
  429. GetCallback(ISrcInfoCallback **ppNewCallback) PURE;
  430. virtual void
  431. SetCallback(ISrcInfoCallback *pNewCallback) PURE;
  432. virtual bool
  433. DoModal(IStatus **ppStatus = NULL) PURE;
  434. virtual bool
  435. CloseModal(IStatus **ppStatus = NULL) PURE;
  436. virtual bool
  437. SaveDialogToObject(IStatus **ppStatus = NULL) PURE;
  438. virtual bool
  439. SaveObjectToFile(IStatus **ppStatus = NULL) PURE;
  440. virtual bool
  441. CanSaveObjectToFile() PURE;
  442. };
  443. ////////////////////////////////////////////////////////////////////// ILimit //
  444. interface ILimit : public IUnknown
  445. {
  446. virtual bool
  447. IsUnlimited() PURE;
  448. virtual const char *
  449. GetDescription() PURE;
  450. };
  451. ///////////////////////////////////////////////////////////////// IIndexArray //
  452. interface IIndexArray : public IUnknown
  453. {
  454. virtual int
  455. GetIndexNumber() PURE;
  456. virtual int
  457. GetIndex(int iNum) PURE;
  458. };
  459. ///////////////////////////////////////////////////////////// IAudioPluginMgr //
  460. // The general interface of the central plugin manager. All the components
  461. // in the system receive it's pointer during the initialization and can refer
  462. // to it to obtain, for example the profile information, language settings and
  463. // so on. Also applications work with this interface to open and create
  464. // source/target audio items.
  465. interface IAudioPluginMgr : public IUnknown
  466. {
  467. virtual bool
  468. SetPluginDirectory(const char *szPluginDir) PURE;
  469. virtual bool
  470. LoadPlugins() PURE;
  471. virtual bool
  472. CanUnloadPlugins() PURE;
  473. virtual bool
  474. UnloadPlugins() PURE;
  475. virtual bool
  476. SetConvertor(IConvertorFactory *pCF, IStatus **ppStatus = NULL) PURE;
  477. virtual bool
  478. GetConvertor(IConvertorFactory **ppConvFactory) PURE;
  479. virtual bool
  480. GetUnsupportedComponents(IComponentEnum **ppEnum) PURE;
  481. // Event functions
  482. // Sends an event to all the subscribed event receivers, they can be either
  483. // application-side objects, plugins, plugin manager itself or other
  484. // objects.
  485. virtual bool
  486. SendEvent(EEvent event, IUnknown *pSource) PURE;
  487. virtual bool
  488. SubscribeToEvents(IEventReceiver *pReceiver) PURE;
  489. virtual bool
  490. UnsubscribeToEvents(IEventReceiver *pReceiver) PURE;
  491. // Other
  492. // Opens an audio file from URL and if the source quality is not the same
  493. // as "pFormat", it creates a wrapper object which aggregates the source.
  494. // pFormat can be NULL, in this case the original format will be received.
  495. virtual bool
  496. OpenURLAudioFile( const char *szURL,
  497. const SWavFormat *pFormat,
  498. IUnknown **ppSrc,
  499. int iTries,
  500. EAuxFlags flagsInclude,
  501. EAuxFlags flagsExclude,
  502. IStatus **ppStatus) PURE;
  503. // Application should never create targets directly by target factories
  504. // because, it will be necessary to perform attitional format conversion
  505. // which plugin manager does automatically.
  506. virtual bool
  507. CreateURLAudioTarget( IURLAudioTargetFactory *pFactory,
  508. IUnknown **pTgt,
  509. const SWavFormat &formatSrc,
  510. IStatus **ppStatus = NULL) PURE;
  511. // Some nonstandard objects can be attached to the plugin manager by
  512. // plugins and requested and handled by others. Only a single object of
  513. // a CLSID can be attached to the plugin manager at a time.
  514. // This method attaches an auxiliary object to the plugin manager.
  515. // Returns false if such object is already attached.
  516. virtual bool
  517. AttachAuxObject(REFCLSID clsID, IUnknown *pUnknown) PURE;
  518. virtual bool
  519. DetachAuxObject(REFCLSID clsID) PURE;
  520. // Reguests an auxiliary object from the plugin manager. Returns false if
  521. // no such object is attached. Second parameter can be NULL, this is useful
  522. // for determining if such object is attached to the manager.
  523. virtual bool
  524. GetAuxObject(REFCLSID clsID, IUnknown **ppUnknown) PURE;
  525. virtual bool
  526. TranslateError(IStatus *pInStatus, IStatus **ppOutStatus) PURE;
  527. };
  528. #endif // _AUDIO_PLUGIN_ENV_