corehandle.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. #ifndef _COREHANDLE_H
  2. #define _COREHANDLE_H
  3. #include <api/syscb/callbacks/corecb.h>
  4. // a helper class to access the playback cores within an object for you
  5. typedef unsigned int CoreToken;
  6. #define NO_CORE_TOKEN (CoreToken)(0xffffffff)
  7. // Fwd References
  8. class CfgItem;
  9. class ItemSequencer;
  10. /**
  11. Helper class to access the currently instantiated
  12. playback cores.
  13. To create a corehandle on the main playback core
  14. use the core token value from the enum ("maincore_token") or
  15. the core name "main".
  16. Here is an example:
  17. CoreHandle * ch = new CoreHandle("main");
  18. @short Access playback cores.
  19. @author Nullsoft
  20. @ver 1.0
  21. @see Core
  22. */
  23. class CoreHandle {
  24. public:
  25. enum { maincore_token=0 };
  26. /**
  27. Create a new CoreHandle while optionally
  28. setting the core token to be used.
  29. Core tokens are handles to cores
  30. currently instantiated.
  31. @see CoreHandle(const char *name)
  32. @param token Core token of the core to attach to.
  33. */
  34. CoreHandle(CoreToken token=maincore_token);
  35. /**
  36. Create a new CoreHandle for a core
  37. using it's name.
  38. The main core name is "main".
  39. @see CoreHandle(CoreToken toke=maincore_token)
  40. @param name Name of the core to attach to.
  41. */
  42. CoreHandle(const wchar_t *name);
  43. /**
  44. Detaches the CoreHandle from the Core.
  45. */
  46. virtual ~CoreHandle();
  47. int isCoreLoaded(); // are we attached to a core?
  48. /**
  49. Get the list of supported extensions
  50. from the core. This is a zero delimited list
  51. with double zero termination.
  52. @see getExtSupportedExtensions()
  53. @see getExtensionFamily()
  54. @ret List of supported extensions.
  55. */
  56. const char *getSupportedExtensions(); //just the *.mp3 or whatever
  57. /**
  58. Get the extended list of supported extensions
  59. from the core. This will include the proper
  60. names of the extensions, for example:
  61. "MP3 Files (*.mp3)".
  62. This is returned as a zero delimited list with double
  63. zero termination.
  64. @see getSupportedExtensions()
  65. @see getExtensionFamily()
  66. @ret Extended list of supported extensions.
  67. */
  68. const char *getExtSupportedExtensions(); // including names
  69. /**
  70. Get the family name to which the extension
  71. is associated with (Families are "Audio", "Video", etc.)
  72. @see getExtSupportedExtensions()
  73. @see getSupportedExtensions()
  74. @ret Family name of the extension.
  75. @param extension Extension to get family name of.
  76. */
  77. const wchar_t *getExtensionFamily(const wchar_t *extension);
  78. /**
  79. Register an extension with the core.
  80. @see unregisterExtension()
  81. @see getExtSupportedExtensions()
  82. @see getSupportedExtensions()
  83. @see getExtensionFamily()
  84. @param extensions Extension to register.
  85. @param extension_name Name of the extension.
  86. */
  87. void registerExtension(const char *extensions, const char *extension_name);
  88. /**
  89. Unregister an extension with the core.
  90. @see registerExtension()
  91. @see getExtSupportedExtensions()
  92. @see getSupportedExtensions()
  93. @see getExtensionFamily()
  94. @param extensions Extension to unregister.
  95. */
  96. void unregisterExtension(const char *extensions);
  97. String getTitle();
  98. /**
  99. Set the next file to be played by the core.
  100. You can manually select the output of this
  101. file. Either "WAVEOUT" or "DIRECTSOUND". If
  102. you do not specify one, it will be automatically
  103. selected for you.
  104. @ret 1, success; 0, failure;
  105. @param playstring Playstring of the next file to be played.
  106. @param destination Output to be used for the next file.
  107. */
  108. int setNextFile(const char *playstring, const char *destination=NULL);
  109. /**
  110. Get the playback status of the core.
  111. @see pause()
  112. @see play()
  113. @see stop()
  114. @ret -1, Paused; 0, Stopped; 1, Playing;
  115. */
  116. int getStatus(); // returns -1 if paused, 0 if stopped and 1 if playing
  117. /**
  118. Get the playstring of the currently playing
  119. item.
  120. @ret Playstring of the currently playing item.
  121. */
  122. const char *getCurrent();
  123. /**
  124. Get the number of items (tracks) present
  125. in the currently registered sequencer.
  126. @see getCurPlaybackNumber()
  127. @ret Number of items present in the sequencer.
  128. */
  129. int getNumTracks();
  130. /**
  131. Get the index number of the currently
  132. playing item of the currently registered
  133. sequencer.
  134. @see getNumTracks()
  135. @ret Index number (in the sequencer) of the item playing.
  136. */
  137. int getCurPlaybackNumber();
  138. /**
  139. Get the playback position of the currently
  140. playing file.
  141. @see getWritePosition()
  142. @see getLength()
  143. @see setPosition()
  144. @ret Position in the file (in milliseconds).
  145. */
  146. int getPosition();
  147. /**
  148. Help?
  149. @see getPosition()
  150. @see getLength()
  151. @see setPosition()
  152. @ret Current write position (in milliseconds).
  153. */
  154. int getWritePosition();
  155. /**
  156. Seek to a specific position in the
  157. currently playing item.
  158. @see getPosition()
  159. @see getLength()
  160. @see getWritePosition()
  161. @ret 1, Success; 0, Failure;
  162. @param ms Position in the file (in milliseconds, 0 being the beginning).
  163. */
  164. int setPosition(int ms);
  165. /**
  166. Get the length of the currently
  167. playing item.
  168. @see getPosition()
  169. @see setPosition()
  170. @see getWritePosition()
  171. @ret Length of the item (in milliseconds).
  172. */
  173. int getLength();
  174. // this method queries the core plugins directly, bypassing the db
  175. /**
  176. */
  177. int getPluginData(const char *playstring, const char *name,
  178. char *data, int data_len, int data_type=0); // returns size of data
  179. /**
  180. Get the volume of the core.
  181. @see setVolume()
  182. @see getMute()
  183. @see setMute()
  184. @ret Volume (0 to 255).
  185. */
  186. unsigned int getVolume(); // 0..255
  187. /**
  188. Set the volume of the core.
  189. @see getVolume()
  190. @see getMute()
  191. @see setMute()
  192. @param vol Volume (0 to 255).
  193. */
  194. void setVolume(unsigned int vol); // 0..255
  195. /**
  196. Get the panning value of the core.
  197. @see setPan()
  198. @ret Panning value (-127 [left] to 127 [right]).
  199. */
  200. int getPan(); // -127..127
  201. /**
  202. Set the panning value of the core.
  203. @see getPan()
  204. @param bal Panning value (-127 [left] to 127 [right])
  205. */
  206. void setPan(int bal); // -127..127
  207. /**
  208. Mute the output.
  209. @see getVolume()
  210. @see setVolume()
  211. @see getMute()
  212. @param mute 0, No muting; 1, Mute;
  213. */
  214. void setMute(int mute);
  215. /**
  216. Get the mute state of the output.
  217. @see getVolume()
  218. @see setVolume()
  219. @see setMute()
  220. @ret 0, Not muted; 1, Muted;
  221. */
  222. int getMute();
  223. // register here for general callbacks in core status.
  224. /**
  225. Register a callback with the core to
  226. receive core status callbacks.
  227. @see delCallback()
  228. @param cb Core Callback to register.
  229. */
  230. void addCallback(CoreCallback *cb);
  231. /**
  232. Unregister a callback with the core.
  233. @see addCallback()
  234. @param cb Core Callback to unregister.
  235. */
  236. void delCallback(CoreCallback *cb);
  237. // get visualization data, returns 0 if you should blank out
  238. /**
  239. Get visualization data for the currently
  240. playing item.
  241. We suggest using a struct like this to read the vis
  242. data:
  243. typedef struct {
  244. enum {
  245. LEFT = 0,
  246. RIGHT = 1
  247. };
  248. unsigned char spectrumData[2][576];
  249. char waveformData[2][576];
  250. } VisData;
  251. A call using this struct would like so:
  252. getVisData(&myVisData, sizeof(VisData));
  253. @see getLeftVuMeter()
  254. @see getRightVuMeter()
  255. @ret 0, If there is no VIS data; > 0, VIS data available;
  256. @param dataptr Buffer to receive VIS data.
  257. @param sizedataptr Size of the buffer.
  258. */
  259. int getVisData(void *dataptr, int sizedataptr);
  260. /**
  261. Get the value of the left VU meter.
  262. @see getVisData()
  263. @see getRightVuMeter()
  264. @ret Value of the left VU meter (0 to 255).
  265. */
  266. int getLeftVuMeter();
  267. /**
  268. Get the value of the left VU meter.
  269. @see getVisData()
  270. @see getLeftVuMeter()
  271. @ret Value of the right VU meter (0 to 255).
  272. */
  273. int getRightVuMeter();
  274. /**
  275. Register an item sequencer with the core.
  276. The item sequencer feeds the playstrings
  277. of the next item to be played to the core.
  278. @see deregisterSequencer()
  279. @ret 1, Success; 0, Failure;
  280. @param seq Sequencer to register.
  281. */
  282. int registerSequencer(ItemSequencer *seq);
  283. /**
  284. Unregister a sequencer with the core.
  285. @see registerSequencer()
  286. @ret 1, Success; 0, Failure;
  287. @param seq Sequencer to unregister.
  288. */
  289. int deregisterSequencer(ItemSequencer *seq);
  290. ItemSequencer *getSequencer();
  291. /**
  292. Get the EQ status.
  293. @see setEqStatus()
  294. @see getEqPreamp()
  295. @see setEqPreamp()
  296. @see getEqBand()
  297. @see setEqBand()
  298. @ret 1, On; 0, Off;
  299. */
  300. int getEqStatus(); // returns 1 if on, 0 if off
  301. /**
  302. Set the EQ state.
  303. @see getEqStatus()
  304. @see getEqPreamp()
  305. @see setEqPreamp()
  306. @see getEqBand()
  307. @see setEqBand()
  308. @param enable 1, On; 0, Off;
  309. */
  310. void setEqStatus(int enable);
  311. /**
  312. Get the pre-amp value of the EQ.
  313. @see setEqStatus()
  314. @see getEqStatus()
  315. @see setEqPreamp()
  316. @see getEqBand()
  317. @see setEqBand()
  318. @ret Pre-amp value (-127 [-20dB] to 127 [+20dB]).
  319. */
  320. int getEqPreamp(); // -127 to 127 (-20db to +20db)
  321. /**
  322. Set the pre-amp value of the EQ.
  323. @see setEqStatus()
  324. @see getEqStatus()
  325. @see getEqPreamp()
  326. @see getEqBand()
  327. @see setEqBand()
  328. @param pre Pre-amp value (-127 [-20dB] to 127 [+20dB]).
  329. */
  330. void setEqPreamp(int pre);
  331. /**
  332. Get the value of an EQ band. There
  333. are 10 bands available.
  334. Here is the list:
  335. 0 - 60 Hz 1 - 170 Hz
  336. 2 - 310 Hz 3 - 600 Hz
  337. 4 - 1 kHz 5 - 3 kHz
  338. 6 - 6 kHz 7 - 12 kHz
  339. 8 - 14 kHz 9 - 16 kHz
  340. @see setEqStatus()
  341. @see getEqStatus()
  342. @see getEqPreamp()
  343. @see setEqBand()
  344. @ret EQ band value (-127 [-20dB] to 127 [+20dB]).
  345. @param band EQ band to read (0 to 9).
  346. */
  347. int getEqBand(int band); // band=0-9
  348. /**
  349. Set the value of an EQ band. There
  350. are 10 bands available.
  351. Here is the list:
  352. 0 - 60 Hz 1 - 170 Hz
  353. 2 - 310 Hz 3 - 600 Hz
  354. 4 - 1 kHz 5 - 3 kHz
  355. 6 - 6 kHz 7 - 12 kHz
  356. 8 - 14 kHz 9 - 16 kHz
  357. @see setEqStatus()
  358. @see getEqStatus()
  359. @see getEqPreamp()
  360. @see setEqBand()
  361. @param band EQ band to set (0 to 9)
  362. @param val EQ band value (-127 [-20dB] to 127 [+20dB]).
  363. */
  364. void setEqBand(int band, int val);
  365. /**
  366. Get the automatic EQ preset loading state.
  367. @see setEqAuto()
  368. @ret 1, On; 0, Off;
  369. */
  370. int getEqAuto(); // returns 1 if on, 0 if off
  371. /**
  372. Set the automatic EQ preset loading.
  373. @see getEqAuto()
  374. @param enable 1, On; 0, Off;
  375. */
  376. void setEqAuto(int enable);
  377. /**
  378. Trigger the previous event.
  379. @see next()
  380. @see play()
  381. @see stop()
  382. @see pause()
  383. */
  384. void prev();
  385. /**
  386. Trigger the play event.
  387. @see prev()
  388. @see next()
  389. @see stop()
  390. @see pause()
  391. */
  392. void play();
  393. /**
  394. Trigger the pause event.
  395. @see prev()
  396. @see next()
  397. @see stop()
  398. @see play()
  399. */
  400. void pause();
  401. /**
  402. Trigger the stop event.
  403. */
  404. void stop();
  405. /**
  406. Trigger the next event.
  407. @see prev()
  408. @see stop()
  409. @see play()
  410. @see pause()
  411. */
  412. void next();
  413. /**
  414. Set the thread priority of the core.
  415. @see getPriority()
  416. @param priority Thread priority.
  417. */
  418. void setPriority(int priority);
  419. /**
  420. Get the thread priority of the core.
  421. @see setPriority()
  422. @ret Thread priority level.
  423. */
  424. int getPriority();
  425. /**
  426. As the function name implies, rebuilds the converters chain (no shit?)
  427. */
  428. void rebuildConvertersChain();
  429. /**
  430. Send a message to all converters in the current
  431. playback chain of a core.
  432. It's possible to pass any pointer using this messanging
  433. system, as long as the pointer is valid across dll boundries.
  434. @param msg Message.
  435. @param value Message value.
  436. */
  437. int sendConvertersMsg(const char *msg, const char *value);
  438. private:
  439. void userButton(int button);
  440. CoreToken token;
  441. int createdcore;
  442. };
  443. #endif