2 #include <lib/base/eerror.h>
3 #include <lib/base/object.h>
4 #include <lib/base/ebase.h>
5 #include <lib/base/nconfig.h>
7 #include <lib/service/service.h>
8 #include <lib/base/init_num.h>
9 #include <lib/base/init.h>
10 #include <lib/gui/esubtitle.h>
11 #include <lib/gdi/gpixmap.h>
14 #include <netinet/in.h>
16 #error no byte order defined!
20 #include <dreamdvd/ddvdlib.h>
22 #include "servicedvd.h"
26 eServiceFactoryDVD::eServiceFactoryDVD()
28 ePtr<eServiceCenter> sc;
30 eServiceCenter::getPrivInstance(sc);
33 std::list<std::string> extensions;
34 extensions.push_back("iso");
35 extensions.push_back("img");
36 sc->addServiceFactory(eServiceFactoryDVD::id, this, extensions);
40 eServiceFactoryDVD::~eServiceFactoryDVD()
42 ePtr<eServiceCenter> sc;
44 eServiceCenter::getPrivInstance(sc);
46 sc->removeServiceFactory(eServiceFactoryDVD::id);
49 DEFINE_REF(eServiceFactoryDVD)
52 RESULT eServiceFactoryDVD::play(const eServiceReference &ref, ePtr<iPlayableService> &ptr)
55 ptr = new eServiceDVD(ref);
59 RESULT eServiceFactoryDVD::record(const eServiceReference &/*ref*/, ePtr<iRecordableService> &ptr)
65 RESULT eServiceFactoryDVD::list(const eServiceReference &, ePtr<iListableService> &ptr)
72 RESULT eServiceFactoryDVD::info(const eServiceReference &/*ref*/, ePtr<iStaticServiceInformation> &ptr)
78 RESULT eServiceFactoryDVD::offlineOperations(const eServiceReference &, ePtr<iServiceOfflineOperations> &ptr)
86 DEFINE_REF(eServiceDVD);
88 eServiceDVD::eServiceDVD(eServiceReference ref):
89 m_ref(ref), m_ddvdconfig(ddvd_create()), m_subtitle_widget(0), m_state(stIdle),
90 m_current_trick(0), m_pump(eApp, 1), m_width(-1), m_height(-1),
91 m_aspect(-1), m_framerate(-1), m_progressive(-1)
93 int aspect = DDVD_16_9;
94 int policy = DDVD_PAN_SCAN;
95 int policy2 = DDVD_PAN_SCAN;
100 m_sn = eSocketNotifier::create(eApp, ddvd_get_messagepipe_fd(m_ddvdconfig), eSocketNotifier::Read|eSocketNotifier::Priority|eSocketNotifier::Error|eSocketNotifier::Hungup);
101 eDebug("SERVICEDVD construct!");
103 ddvd_set_dvd_path(m_ddvdconfig, ref.path.c_str());
104 ddvd_set_ac3thru(m_ddvdconfig, 0);
106 std::string ddvd_language;
107 if (!ePythonConfigQuery::getConfigValue("config.osd.language", ddvd_language))
108 ddvd_set_language(m_ddvdconfig, (ddvd_language.substr(0,2)).c_str());
110 int fd = open("/proc/stb/video/aspect", O_RDONLY);
113 rd = read(fd, tmp, 255);
114 if (rd > 2 && !strncmp(tmp, "4:3", 3))
116 else if (rd > 4 && !strncmp(tmp, "16:10", 5))
121 fd = open("/proc/stb/video/policy", O_RDONLY);
124 rd = read(fd, tmp, 255);
125 if (rd > 6 && !strncmp(tmp, "bestfit", 7))
126 policy = DDVD_JUSTSCALE;
127 else if (rd > 8 && !strncmp(tmp, "letterbox", 9))
128 policy = DDVD_LETTERBOX;
132 #ifdef DDVD_SUPPORTS_16_10_SCALING
133 fd = open("/proc/stb/video/policy2", O_RDONLY);
136 rd = read(fd, tmp, 255);
137 if (rd > 6 && !strncmp(tmp, "bestfit", 7))
138 policy2 = DDVD_JUSTSCALE;
139 else if (rd > 8 && !strncmp(tmp, "letterbox", 9))
140 policy2 = DDVD_LETTERBOX;
143 ddvd_set_video_ex(m_ddvdconfig, aspect, policy, policy2, DDVD_PAL /*unused*/);
145 ddvd_set_video(m_ddvdconfig, aspect, policy, DDVD_PAL /*unused*/);
146 #warning please update libdreamdvd for 16:10 scaling support!
149 CONNECT(m_sn->activated, eServiceDVD::gotMessage);
150 CONNECT(m_pump.recv_msg, eServiceDVD::gotThreadMessage);
151 strcpy(m_ddvd_titlestring,"");
156 void eServiceDVD::gotThreadMessage(const int &msg)
160 case 1: // thread stopped
162 m_event(this, evStopped);
167 void eServiceDVD::gotMessage(int /*what*/)
169 switch(ddvd_get_next_message(m_ddvdconfig,1))
171 case DDVD_COLORTABLE_UPDATE:
174 struct ddvd_color ctmp[4];
175 ddvd_get_last_colortable(ddvdconfig, ctmp);
179 rd1[252+i]=ctmp[i].red;
180 bl1[252+i]=ctmp[i].blue;
181 gn1[252+i]=ctmp[i].green;
182 tr1[252+i]=ctmp[i].trans;
185 if(ioctl(fb, FBIOPUTCMAP, &colormap) == -1)
187 printf("Framebuffer: <FBIOPUTCMAP failed>\n");
191 eDebug("no support for 8bpp framebuffer in dvdplayer yet!");
194 case DDVD_SCREEN_UPDATE:
195 eDebug("DVD_SCREEN_UPDATE!");
196 if (m_subtitle_widget) {
198 ddvd_get_last_blit_area(m_ddvdconfig, &x1, &x2, &y1, &y2);
200 int x_offset = 0, y_offset = 0, width = 720, height = 576;
202 #ifdef DDVD_SUPPORTS_GET_BLIT_DESTINATION
203 ddvd_get_blit_destination(m_ddvdconfig, &x_offset, &y_offset, &width, &height);
204 eDebug("values got from ddvd: %d %d %d %d", x_offset, y_offset, width, height);
205 y_offset = -y_offset;
206 width -= x_offset * 2;
207 height -= y_offset * 2;
209 eRect dest(x_offset, y_offset, width, height);
211 if (dest.width() && dest.height())
212 m_subtitle_widget->setPixmap(m_pixmap, eRect(x1, y1, (x2-x1)+1, (y2-y1)+1), dest);
215 case DDVD_SHOWOSD_STATE_PLAY:
217 eDebug("DVD_SHOWOSD_STATE_PLAY!");
219 m_event(this, evUser+1);
222 case DDVD_SHOWOSD_STATE_PAUSE:
224 eDebug("DVD_SHOWOSD_STATE_PAUSE!");
225 m_event(this, evUser+2);
228 case DDVD_SHOWOSD_STATE_FFWD:
230 eDebug("DVD_SHOWOSD_STATE_FFWD!");
231 m_event(this, evUser+3);
234 case DDVD_SHOWOSD_STATE_FBWD:
236 eDebug("DVD_SHOWOSD_STATE_FBWD!");
237 m_event(this, evUser+4);
240 case DDVD_SHOWOSD_STRING:
242 eDebug("DVD_SHOWOSD_STRING!");
243 m_event(this, evUser+5);
246 case DDVD_SHOWOSD_AUDIO:
248 eDebug("DVD_SHOWOSD_STRING!");
249 m_event(this, evUser+6);
252 case DDVD_SHOWOSD_SUBTITLE:
254 eDebug("DVD_SHOWOSD_SUBTITLE!");
255 m_event((iPlayableService*)this, evUpdatedInfo);
256 m_event(this, evUser+7);
259 case DDVD_EOF_REACHED:
260 eDebug("DVD_EOF_REACHED!");
261 m_event(this, evEOF);
263 case DDVD_SOF_REACHED:
264 eDebug("DVD_SOF_REACHED!");
265 m_event(this, evSOF);
267 case DDVD_SHOWOSD_ANGLE:
270 ddvd_get_angle_info(m_ddvdconfig, ¤t, &num);
271 eDebug("DVD_ANGLE_INFO: %d / %d", current, num);
272 m_event(this, evUser+13);
275 case DDVD_SHOWOSD_TIME:
277 static struct ddvd_time last_info;
278 struct ddvd_time info;
279 // eDebug("DVD_SHOWOSD_TIME!");
280 ddvd_get_last_time(m_ddvdconfig, &info);
281 if ( info.pos_chapter != last_info.pos_chapter )
282 m_event(this, evUser+8); // chapterUpdated
283 if ( info.pos_title != last_info.pos_title )
284 m_event(this, evUser+9); // titleUpdated
285 memcpy(&last_info, &info, sizeof(struct ddvd_time));
288 case DDVD_SHOWOSD_TITLESTRING:
290 ddvd_get_title_string(m_ddvdconfig, m_ddvd_titlestring);
291 eDebug("DDVD_SHOWOSD_TITLESTRING: %s",m_ddvd_titlestring);
295 m_event(this, evStart);
298 case DDVD_MENU_OPENED:
299 eDebug("DVD_MENU_OPENED!");
301 m_event(this, evSeekableStatusChanged);
302 m_event(this, evUser+11);
304 case DDVD_MENU_CLOSED:
305 eDebug("DVD_MENU_CLOSED!");
307 m_event(this, evSeekableStatusChanged);
308 m_event(this, evUser+12);
310 #ifdef DDVD_SUPPORTS_PICTURE_INFO
311 case DDVD_SIZE_CHANGED:
313 int changed = m_width != -1 && m_height != -1 && m_aspect != -1;
314 ddvd_get_last_size(m_ddvdconfig, &m_width, &m_height, &m_aspect);
316 m_event((iPlayableService*)this, evVideoSizeChanged);
319 case DDVD_PROGRESSIVE_CHANGED:
321 int changed = m_progressive != -1;
322 ddvd_get_last_progressive(m_ddvdconfig, &m_progressive);
324 m_event((iPlayableService*)this, evVideoProgressiveChanged);
327 case DDVD_FRAMERATE_CHANGED:
329 int changed = m_framerate != -1;
330 ddvd_get_last_framerate(m_ddvdconfig, &m_framerate);
332 m_event((iPlayableService*)this, evVideoFramerateChanged);
341 eServiceDVD::~eServiceDVD()
343 eDebug("SERVICEDVD destruct!");
346 ddvd_close(m_ddvdconfig);
350 RESULT eServiceDVD::connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection)
352 connection = new eConnection((iPlayableService*)this, m_event.connect(event));
356 RESULT eServiceDVD::start()
358 ASSERT(m_state == stIdle);
360 eDebug("eServiceDVD starting");
361 // m_event(this, evStart);
365 RESULT eServiceDVD::stop()
367 ASSERT(m_state != stIdle);
368 if (m_state == stStopped)
370 eDebug("DVD: stop %s", m_ref.path.c_str());
372 ddvd_send_key(m_ddvdconfig, DDVD_KEY_EXIT);
377 RESULT eServiceDVD::setTarget(int /*target*/)
382 RESULT eServiceDVD::pause(ePtr<iPauseableService> &ptr)
388 RESULT eServiceDVD::seek(ePtr<iSeekableService> &ptr)
394 RESULT eServiceDVD::subtitle(ePtr<iSubtitleOutput> &ptr)
400 RESULT eServiceDVD::audioTracks(ePtr<iAudioTrackSelection> &ptr)
406 int eServiceDVD::getNumberOfTracks()
409 ddvd_get_audio_count(m_ddvdconfig, &i);
413 int eServiceDVD::getCurrentTrack()
415 int audio_id,audio_type;
417 ddvd_get_last_audio(m_ddvdconfig, &audio_id, &audio_lang, &audio_type);
421 RESULT eServiceDVD::selectTrack(unsigned int i)
423 ddvd_set_audio(m_ddvdconfig, i);
427 RESULT eServiceDVD::getTrackInfo(struct iAudioTrackInfo &info, unsigned int audio_id)
431 ddvd_get_audio_byid(m_ddvdconfig, audio_id, &audio_lang, &audio_type);
432 char audio_string[3]={audio_lang >> 8, audio_lang, 0};
433 info.m_pid = audio_id+1;
434 info.m_language = audio_string;
438 info.m_description = "MPEG";
441 info.m_description = "AC3";
444 info.m_description = "DTS";
447 info.m_description = "LPCM";
450 info.m_description = "und";
455 RESULT eServiceDVD::keys(ePtr<iServiceKeys> &ptr)
462 RESULT eServiceDVD::setSlowMotion(int /*ratio*/)
467 RESULT eServiceDVD::setFastForward(int trick)
469 eDebug("setTrickmode(%d)", trick);
470 while (m_current_trick > trick && m_current_trick != -64)
472 ddvd_send_key(m_ddvdconfig, DDVD_KEY_FBWD);
473 if (m_current_trick == 0)
474 m_current_trick = -2;
475 else if (m_current_trick > 0)
477 m_current_trick /= 2;
478 if (abs(m_current_trick) == 1)
482 m_current_trick *= 2;
484 while (m_current_trick < trick && m_current_trick != 64)
486 ddvd_send_key(m_ddvdconfig, DDVD_KEY_FFWD);
487 if (m_current_trick == 0)
489 else if (m_current_trick < 0)
491 m_current_trick /= 2;
492 if (abs(m_current_trick) == 1)
496 m_current_trick *= 2;
501 RESULT eServiceDVD::pause()
503 eDebug("set pause!\n");
504 ddvd_send_key(m_ddvdconfig, DDVD_KEY_PAUSE);
508 RESULT eServiceDVD::unpause()
510 eDebug("set unpause!\n");
511 ddvd_send_key(m_ddvdconfig, DDVD_KEY_PLAY);
515 void eServiceDVD::thread()
517 eDebug("eServiceDVD dvd thread started");
519 ddvd_run(m_ddvdconfig);
522 void eServiceDVD::thread_finished()
524 eDebug("eServiceDVD dvd thread finished");
525 m_pump.send(1); // inform main thread
528 RESULT eServiceDVD::info(ePtr<iServiceInformation>&i)
534 RESULT eServiceDVD::getName(std::string &name)
536 if ( m_ddvd_titlestring[0] != '\0' )
537 name = m_ddvd_titlestring;
539 if ( !m_ref.name.empty() )
546 int eServiceDVD::getInfo(int w)
550 case sCurrentChapter:
552 struct ddvd_time info;
553 ddvd_get_last_time(m_ddvdconfig, &info);
554 return info.pos_chapter;
558 struct ddvd_time info;
559 ddvd_get_last_time(m_ddvdconfig, &info);
560 return info.end_chapter;
564 struct ddvd_time info;
565 ddvd_get_last_time(m_ddvdconfig, &info);
566 return info.pos_title;
570 struct ddvd_time info;
571 ddvd_get_last_time(m_ddvdconfig, &info);
572 return info.end_title;
574 case sTXTPID: // we abuse HAS_TELEXT icon in InfoBar to signalize subtitles status
578 ddvd_get_last_spu(m_ddvdconfig, &spu_id, &spu_lang);
584 return resIsPyObject;
585 #ifdef DDVD_SUPPORTS_PICTURE_INFO
593 return m_progressive;
602 std::string eServiceDVD::getInfoString(int w)
607 return m_ref.toString();
609 eDebug("unhandled getInfoString(%d)", w);
614 PyObject *eServiceDVD::getInfoObject(int w)
620 ePyObject tuple = PyTuple_New(3);
621 int audio_id,audio_type;
623 ddvd_get_last_audio(m_ddvdconfig, &audio_id, &audio_lang, &audio_type);
624 char audio_string[3]={audio_lang >> 8, audio_lang, 0};
625 PyTuple_SetItem(tuple, 0, PyInt_FromLong(audio_id+1));
626 PyTuple_SetItem(tuple, 1, PyString_FromString(audio_string));
630 PyTuple_SetItem(tuple, 2, PyString_FromString("MPEG"));
633 PyTuple_SetItem(tuple, 2, PyString_FromString("AC3"));
636 PyTuple_SetItem(tuple, 2, PyString_FromString("DTS"));
639 PyTuple_SetItem(tuple, 2, PyString_FromString("LPCM"));
642 PyTuple_SetItem(tuple, 2, PyString_FromString(""));
648 ePyObject tuple = PyTuple_New(2);
651 ddvd_get_last_spu(m_ddvdconfig, &spu_id, &spu_lang);
652 char spu_string[3]={spu_lang >> 8, spu_lang, 0};
655 PyTuple_SetItem(tuple, 0, PyInt_FromLong(0));
656 PyTuple_SetItem(tuple, 1, PyString_FromString(""));
660 PyTuple_SetItem(tuple, 0, PyInt_FromLong(spu_id+1));
661 PyTuple_SetItem(tuple, 1, PyString_FromString(spu_string));
667 ePyObject tuple = PyTuple_New(2);
669 ddvd_get_angle_info(m_ddvdconfig, ¤t, &num);
670 PyTuple_SetItem(tuple, 0, PyInt_FromLong(current));
671 PyTuple_SetItem(tuple, 1, PyInt_FromLong(num));
676 eDebug("unhandled getInfoObject(%d)", w);
681 RESULT eServiceDVD::enableSubtitles(eWidget *parent, ePyObject tuple)
683 delete m_subtitle_widget;
684 eSize size = eSize(720, 576);
686 m_subtitle_widget = new eSubtitleWidget(parent);
687 m_subtitle_widget->resize(parent->size());
691 if ( tuple != Py_None )
694 int tuplesize = PyTuple_Size(tuple);
695 if (!PyTuple_Check(tuple))
699 entry = PyTuple_GET_ITEM(tuple, 1);
700 if (!PyInt_Check(entry))
702 pid = PyInt_AsLong(entry)-1;
704 ddvd_set_spu(m_ddvdconfig, pid);
706 eDebug("eServiceDVD::enableSubtitles %i", pid);
710 m_pixmap = new gPixmap(size, 32, 1); /* allocate accel surface (if possible) */
711 #ifdef DDVD_SUPPORTS_GET_BLIT_DESTINATION
712 ddvd_set_lfb_ex(m_ddvdconfig, (unsigned char *)m_pixmap->surface->data, size.width(), size.height(), 4, size.width()*4, 1);
714 ddvd_set_lfb(m_ddvdconfig, (unsigned char *)m_pixmap->surface->data, size.width(), size.height(), 4, size.width()*4);
715 #warning please update libdreamdvd for fast scaling
717 run(); // start the thread
720 m_subtitle_widget->setZPosition(-1);
721 m_subtitle_widget->show();
729 RESULT eServiceDVD::disableSubtitles(eWidget */*parent*/)
731 delete m_subtitle_widget;
732 m_subtitle_widget = 0;
736 PyObject *eServiceDVD::getSubtitleList()
738 ePyObject l = PyList_New(0);
739 unsigned int spu_count = 0;
740 ddvd_get_spu_count(m_ddvdconfig, &spu_count);
742 for ( unsigned int spu_id = 0; spu_id < spu_count; spu_id++ )
745 ddvd_get_spu_byid(m_ddvdconfig, spu_id, &spu_lang);
746 char spu_string[3]={spu_lang >> 8, spu_lang, 0};
748 ePyObject tuple = PyTuple_New(5);
749 PyTuple_SetItem(tuple, 0, PyInt_FromLong(2));
750 PyTuple_SetItem(tuple, 1, PyInt_FromLong(spu_id+1));
751 PyTuple_SetItem(tuple, 2, PyInt_FromLong(3));
752 PyTuple_SetItem(tuple, 3, PyInt_FromLong(0));
753 PyTuple_SetItem(tuple, 4, PyString_FromString(spu_string));
754 PyList_Append(l, tuple);
760 PyObject *eServiceDVD::getCachedSubtitle()
762 eDebug("eServiceDVD::getCachedSubtitle nyi");
766 RESULT eServiceDVD::getLength(pts_t &len)
768 // eDebug("eServiceDVD::getLength");
769 struct ddvd_time info;
770 ddvd_get_last_time(m_ddvdconfig, &info);
771 len = info.end_hours * 3600;
772 len += info.end_minutes * 60;
773 len += info.end_seconds;
778 RESULT eServiceDVD::seekTo(pts_t to)
780 eDebug("eServiceDVD::seekTo(%lld)",to);
783 eDebug("set_resume_pos: resume_info.title=%d, chapter=%d, block=%lu, audio_id=%d, audio_lock=%d, spu_id=%d, spu_lock=%d",m_resume_info.title,m_resume_info.chapter,m_resume_info.block,m_resume_info.audio_id, m_resume_info.audio_lock, m_resume_info.spu_id, m_resume_info.spu_lock);
784 ddvd_set_resume_pos(m_ddvdconfig, m_resume_info);
789 RESULT eServiceDVD::seekRelative(int direction, pts_t to)
791 int seconds = to / 90000;
792 seconds *= direction;
793 eDebug("seekRelative %d %d", direction, seconds);
794 ddvd_skip_seconds(m_ddvdconfig, seconds);
798 RESULT eServiceDVD::getPlayPosition(pts_t &pos)
800 struct ddvd_time info;
801 ddvd_get_last_time(m_ddvdconfig, &info);
802 pos = info.pos_hours * 3600;
803 pos += info.pos_minutes * 60;
804 pos += info.pos_seconds;
805 // eDebug("getPlayPosition %lld", pos);
810 RESULT eServiceDVD::seekTitle(int title)
812 eDebug("setTitle %d", title);
813 ddvd_set_title(m_ddvdconfig, title);
817 RESULT eServiceDVD::seekChapter(int chapter)
819 eDebug("setChapter %d", chapter);
821 ddvd_set_chapter(m_ddvdconfig, chapter);
825 RESULT eServiceDVD::setTrickmode(int /*trick*/)
830 RESULT eServiceDVD::isCurrentlySeekable()
832 return m_state == stRunning ? 3 : 0;
835 RESULT eServiceDVD::keyPressed(int key)
839 case iServiceKeys::keyLeft:
840 ddvd_send_key(m_ddvdconfig, DDVD_KEY_LEFT);
842 case iServiceKeys::keyRight:
843 ddvd_send_key(m_ddvdconfig, DDVD_KEY_RIGHT);
845 case iServiceKeys::keyUp:
846 ddvd_send_key(m_ddvdconfig, DDVD_KEY_UP);
848 case iServiceKeys::keyDown:
849 ddvd_send_key(m_ddvdconfig, DDVD_KEY_DOWN);
851 case iServiceKeys::keyOk:
852 ddvd_send_key(m_ddvdconfig, DDVD_KEY_OK);
854 case iServiceKeys::keyUser:
855 ddvd_send_key(m_ddvdconfig, DDVD_KEY_AUDIO);
857 case iServiceKeys::keyUser+1:
858 ddvd_send_key(m_ddvdconfig, DDVD_KEY_SUBTITLE);
860 case iServiceKeys::keyUser+2:
861 ddvd_send_key(m_ddvdconfig, DDVD_KEY_AUDIOMENU);
863 case iServiceKeys::keyUser+3:
864 ddvd_send_key(m_ddvdconfig, DDVD_KEY_NEXT_CHAPTER);
866 case iServiceKeys::keyUser+4:
867 ddvd_send_key(m_ddvdconfig, DDVD_KEY_PREV_CHAPTER);
869 case iServiceKeys::keyUser+5:
870 ddvd_send_key(m_ddvdconfig, DDVD_KEY_NEXT_TITLE);
872 case iServiceKeys::keyUser+6:
873 ddvd_send_key(m_ddvdconfig, DDVD_KEY_PREV_TITLE);
875 case iServiceKeys::keyUser+7:
876 ddvd_send_key(m_ddvdconfig, DDVD_KEY_MENU);
878 case iServiceKeys::keyUser+8:
879 ddvd_send_key(m_ddvdconfig, DDVD_KEY_ANGLE);
887 RESULT eServiceDVD::cueSheet(ePtr<iCueSheet> &ptr)
898 PyObject *eServiceDVD::getCutList()
900 ePyObject list = PyList_New(1);
901 ePyObject tuple = PyTuple_New(2);
902 PyTuple_SetItem(tuple, 0, PyLong_FromLongLong(m_cue_pts));
903 PyTuple_SetItem(tuple, 1, PyInt_FromLong(3));
904 PyList_SetItem(list, 0, tuple);
908 void eServiceDVD::setCutList(ePyObject /*list*/)
912 void eServiceDVD::setCutListEnable(int /*enable*/)
916 void eServiceDVD::loadCuesheet()
919 if ( m_ddvd_titlestring[0] != '\0' )
920 snprintf(filename, 128, "/home/root/dvd-%s.cuts", m_ddvd_titlestring);
922 snprintf(filename, 128, "%s/dvd.cuts", m_ref.path.c_str());
924 eDebug("eServiceDVD::loadCuesheet() filename=%s",filename);
926 FILE *f = fopen(filename, "rb");
930 unsigned long long where;
933 if (!fread(&where, sizeof(where), 1, f))
935 if (!fread(&what, sizeof(what), 1, f))
937 #if BYTE_ORDER == LITTLE_ENDIAN
938 where = bswap_64(where);
942 if (!fread(&m_resume_info, sizeof(struct ddvd_resume), 1, f))
944 if (!fread(&what, sizeof(what), 1, f))
955 eDebug("cutfile not found!");
959 m_event((iPlayableService*)this, evCuesheetChanged);
960 eDebug("eServiceDVD::loadCuesheet() pts=%lld",m_cue_pts);
964 void eServiceDVD::saveCuesheet()
966 eDebug("eServiceDVD::saveCuesheet()");
968 struct ddvd_resume resume_info;
969 ddvd_get_resume_pos(m_ddvdconfig, &resume_info);
971 if (resume_info.title)
973 struct ddvd_time info;
974 ddvd_get_last_time(m_ddvdconfig, &info);
976 pos = info.pos_hours * 3600;
977 pos += info.pos_minutes * 60;
978 pos += info.pos_seconds;
981 eDebug("ddvd_get_resume_pos resume_info.title=%d, chapter=%d, block=%lu, audio_id=%d, audio_lock=%d, spu_id=%d, spu_lock=%d (pts=%llu)",resume_info.title,resume_info.chapter,resume_info.block,resume_info.audio_id, resume_info.audio_lock, resume_info.spu_id, resume_info.spu_lock,m_cue_pts);
985 eDebug("we're in a menu or somewhere else funny. so save cuesheet with pts=0");
990 if ( m_ddvd_titlestring[0] != '\0' )
991 snprintf(filename, 128, "/home/root/dvd-%s.cuts", m_ddvd_titlestring);
993 snprintf(filename, 128, "%s/dvd.cuts", m_ref.path.c_str());
995 FILE *f = fopen(filename, "wb");
999 unsigned long long where;
1002 #if BYTE_ORDER == BIG_ENDIAN
1005 where = bswap_64(m_cue_pts);
1008 fwrite(&where, sizeof(where), 1, f);
1009 fwrite(&what, sizeof(what), 1, f);
1012 fwrite(&resume_info, sizeof(struct ddvd_resume), 1, f);
1013 fwrite(&what, sizeof(what), 1, f);
1019 eAutoInitPtr<eServiceFactoryDVD> init_eServiceFactoryDVD(eAutoInitNumbers::service+1, "eServiceFactoryDVD");
1022 initservicedvd(void)
1024 Py_InitModule("servicedvd", NULL);