svc_burner.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. #ifndef _SVC_BURNER_H
  2. #define _SVC_BURNER_H
  3. #include <bfc/dispatch.h>
  4. #include <bfc/depend.h>
  5. #include <bfc/string/string.h>
  6. #include <api/service/services.h>
  7. namespace MediaRecorder {
  8. class Session : public Dispatchable {
  9. protected:
  10. Session() {} // protect constructor
  11. public:
  12. int getSessionType() { return _call(GETSESSIONTYPE,0); }
  13. enum {
  14. Session_REDBOOK, Session_DATA, Session_ISO
  15. };
  16. int closeSession() { return _call(CLOSESESSION,0); }
  17. int getNumEntries() { return _call(GETNUMENTRIES,0); }
  18. const char *enumEntry(int n) { return _call(ENUMENTRY,(const char *)NULL,n); }
  19. int getTotalBytes() { return _call(GETTOTALBYTES,0); }
  20. int getTotalTime() { return _call(GETTOTALTIME,0); }
  21. enum {
  22. GETSESSIONTYPE=10,
  23. CLOSESESSION=20,
  24. GETNUMENTRIES=30,
  25. ENUMENTRY=40,
  26. GETTOTALBYTES=50,
  27. GETTOTALTIME=60,
  28. };
  29. };
  30. // this represents one session on the cd
  31. // normal audio cds have 1 redbook session, mixed mode has 2 (or more), with
  32. // 1 audio followed by 1 or more data
  33. class SessionI : public Session {
  34. public:
  35. virtual int getSessionType()=0;
  36. virtual int closeSession()=0;
  37. virtual int getNumEntries()=0;
  38. virtual const char *enumEntry(int n)=0;
  39. virtual int getTotalBytes()=0; //total space used in bytes
  40. virtual int getTotalTime()=0; //total time used in ms
  41. protected:
  42. RECVS_DISPATCH;
  43. };
  44. class RedbookSession : public SessionI {
  45. public:
  46. virtual ~RedbookSession() { m_tracks.deleteAll(); }
  47. int getSessionType() { return Session_REDBOOK; }
  48. int closeSession() { return 1; }
  49. void addEntry(const char *file) { m_tracks.addItem(new String(file)); }
  50. int getNumEntries() { return m_tracks.getNumItems(); }
  51. void removeEntry(int n) { m_tracks.deleteItem(n); }
  52. void clearEntries() { m_tracks.deleteAll(); }
  53. const char *enumEntry(int n);
  54. int getTotalBytes();
  55. int getTotalTime();
  56. protected:
  57. PtrList<String> m_tracks;
  58. };
  59. // this is the physical device
  60. class Device : public Dispatchable {
  61. protected:
  62. Device() {} // protect constructor
  63. public:
  64. static const GUID *depend_getClassGuid() {
  65. // {23F48039-455D-4348-86D5-0A82754678FC}
  66. static const GUID ret =
  67. { 0x23f48039, 0x455d, 0x4348, { 0x86, 0xd5, 0xa, 0x82, 0x75, 0x46, 0x78, 0xfc } };
  68. return &ret;
  69. }
  70. api_dependent *getDependencyPtr() { return _call(GETDEPENDENCYPTR,(api_dependent *)NULL); }
  71. const char *getDeviceName() { return _call(GETDEVICENAME,(const char *)NULL); }
  72. const char *getDeviceType() { return _call(GETDEVICETYPE,(const char *)NULL); }
  73. const char *getDeviceDescription() { return _call(GETDEVICEDESCRIPTION,(const char *)NULL); }
  74. int enumDeviceSpeeds(int n) { return _call(ENUMDEVICESPEEDS,0,n); }
  75. int getMediaSize() { return _call(GETMEDIASIZE,0); }
  76. int getMediaFree() { return _call(GETMEDIAFREE,0); }
  77. void clearSessions() { _voidcall(CLEARSESSIONS); }
  78. int addSession(Session *session) { return _call(ADDSESSION,0,session); }
  79. Session *getSession(int num) { return _call(GETSESSION,(Session *)NULL,num); }
  80. int setRecordSpeed(int kbps) { return _call(SETRECORDSPEED,0,kbps); }
  81. int setTest(int testmode) { return _call(SETTEST,0,testmode); }
  82. int setCloseDisc(int closedisc) { return _call(SETCLOSEDISC,0,closedisc); }
  83. int canBurnNow() { return _call(CANBURNNOW,0); }
  84. int canCancel() { return _call(CANCANCEL,0); }
  85. int begin() { return _call(BEGIN,0); }
  86. int end() { return _call(END,0); }
  87. int cancel() { return _call(CANCEL,0); }
  88. int getStatus() { return _call(GETSTATUS,0); }
  89. enum {
  90. Status_IDLE, Status_PREPARING, Status_BURNING, Status_DONE,
  91. };
  92. int getProgress() { return _call(GETPROGRESS,0); }
  93. const char *getStatusText() { return _call(GETSTATUSTEXT,(const char *)NULL); }
  94. const char *getLastError() { return _call(GETLASTERROR,(const char *)NULL); }
  95. enum {
  96. Event_PREPAREBEGIN=100,
  97. Event_MEDIATRANSCODED=200, // params is item #
  98. Event_PREPAREEND=300,
  99. Event_BURNBEGIN=400,
  100. Event_ENTRYCOMPLETE=500, // param is the position in bytes
  101. Event_SESSIONCOMPLETE=600,
  102. Event_BURNEND=700,
  103. Event_ERROR=800,
  104. Event_MEDIACHANGE=900, // user put in a different disc
  105. };
  106. enum {
  107. GETDEPENDENCYPTR=10,
  108. GETDEVICENAME=20,
  109. GETDEVICETYPE=30,
  110. GETDEVICEDESCRIPTION=40,
  111. ENUMDEVICESPEEDS=50,
  112. GETMEDIASIZE=60,
  113. GETMEDIAFREE=70,
  114. CLEARSESSIONS=80,
  115. ADDSESSION=90,
  116. GETSESSION=100,
  117. SETRECORDSPEED=110,
  118. SETTEST=120,
  119. SETCLOSEDISC=130,
  120. CANBURNNOW=140,
  121. CANCANCEL=150,
  122. BEGIN=160,
  123. END=170,
  124. CANCEL=180,
  125. GETSTATUS=190,
  126. GETPROGRESS=200,
  127. GETSTATUSTEXT=210,
  128. GETLASTERROR=220,
  129. };
  130. };
  131. class DeviceI : public Device {
  132. public:
  133. virtual api_dependent *getDependencyPtr()=0; // for events
  134. virtual const char *getDeviceName()=0; // internal device name
  135. virtual const char *getDeviceType()=0; // "CD-R", "CD-RW", "DVD-R" etc
  136. virtual const char *getDeviceDescription()=0; // user readable string
  137. virtual int enumDeviceSpeeds(int n)=0; // in kb/s
  138. virtual int getMediaSize()=0; // total space in bytes
  139. virtual int getMediaFree()=0; // free space in bytes
  140. virtual void clearSessions()=0;
  141. virtual int addSession(Session *session)=0;
  142. virtual Session *getSession(int num)=0;
  143. virtual int setRecordSpeed(int kbps)=0; //kbps==0 means max speed
  144. virtual int setTest(int testmode)=0; // if true, don't really burn
  145. virtual int setCloseDisc(int closedisc)=0; // if true, close entire disc at end
  146. virtual int canBurnNow()=0; // return 1 if everything's ready
  147. virtual int canCancel()=0; // return 1 if we can cancel (during burning)
  148. virtual int begin()=0;
  149. virtual int end()=0;
  150. virtual int cancel()=0;
  151. virtual int getStatus()=0;
  152. virtual int getProgress()=0; // # of bytes written
  153. virtual const char *getStatusText()=0; // like "xx% complete" or something
  154. virtual const char *getLastError()=0;
  155. protected:
  156. RECVS_DISPATCH;
  157. };
  158. }; // end namespace MediaRecorder
  159. //don't override this one
  160. class NOVTABLE svc_mediaRecorder : public Dispatchable {
  161. protected:
  162. svc_mediaRecorder() {} // protect constructor
  163. public:
  164. static FOURCC getServiceType() { return WaSvc::MEDIARECORDER; }
  165. int isSessionSupported(MediaRecorder::Session *session) { return _call(ISSESSIONSUPPORTED,0,session); }
  166. int isMediaSupported(const char *medianame) { return _call(ISMEDIASUPPORTED,0,medianame); }
  167. int getNumDevices() { return _call(GETNUMDEVICES,0); }
  168. MediaRecorder::Device *enumDevice(int n) { return _call(ENUMDEVICE,(MediaRecorder::Device*)NULL,n); }
  169. void refreshDevices() { _voidcall(REFRESHDEVICES); }
  170. enum {
  171. ISSESSIONSUPPORTED=10,
  172. ISMEDIASUPPORTED=20,
  173. GETNUMDEVICES=30,
  174. ENUMDEVICE=40,
  175. REFRESHDEVICES=50,
  176. };
  177. };
  178. // this should be implemented by a given burning lib
  179. class NOVTABLE svc_mediaRecorderI : public svc_mediaRecorder {
  180. public:
  181. static FOURCC getServiceType() { return WaSvc::MEDIARECORDER; }
  182. virtual int isSessionSupported(MediaRecorder::Session *session)=0;
  183. virtual int isMediaSupported(const char *medianame)=0;// "CD-R", "DVD-R", etc.
  184. virtual int getNumDevices()=0;
  185. virtual MediaRecorder::Device *enumDevice(int n)=0;
  186. virtual void refreshDevices()=0;
  187. protected:
  188. RECVS_DISPATCH;
  189. };
  190. #endif