1 #include <lib/base/ebase.h>
2 #include <lib/base/eerror.h>
3 #include <lib/dvb/decoder.h>
4 #if HAVE_DVB_API_VERSION < 3
5 #define audioStatus audio_status
6 #define videoStatus video_status
7 #define pesType pes_type
8 #define playState play_state
9 #define audioStreamSource_t audio_stream_source_t
10 #define videoStreamSource_t video_stream_source_t
11 #define streamSource stream_source
12 #define dmxPesFilterParams dmx_pes_filter_params
13 #define DMX_PES_VIDEO0 DMX_PES_VIDEO
14 #define DMX_PES_AUDIO0 DMX_PES_AUDIO
15 #define DMX_PES_VIDEO1 DMX_PES_VIDEO
16 #define DMX_PES_AUDIO1 DMX_PES_AUDIO
18 #include <ost/video.h>
19 #include <ost/audio.h>
21 #include <linux/dvb/audio.h>
22 #include <linux/dvb/video.h>
23 #include <linux/dvb/dmx.h>
28 #include <sys/ioctl.h>
31 /* these are quite new... */
33 #define AUDIO_GET_PTS _IOR('o', 19, __u64)
34 #define VIDEO_GET_PTS _IOR('o', 57, __u64)
37 DEFINE_REF(eDVBAudio);
39 eDVBAudio::eDVBAudio(eDVBDemux *demux, int dev)
40 :m_demux(demux), m_dev(dev), m_is_freezed(0)
43 #if HAVE_DVB_API_VERSION < 3
44 sprintf(filename, "/dev/dvb/card%d/audio%d", demux->adapter, dev);
46 sprintf(filename, "/dev/dvb/adapter%d/audio%d", demux->adapter, dev);
48 m_fd = ::open(filename, O_RDWR);
50 eWarning("%s: %m", filename);
51 #if HAVE_DVB_API_VERSION < 3
52 sprintf(filename, "/dev/dvb/card%d/demux%d", demux->adapter, demux->demux);
54 sprintf(filename, "/dev/dvb/adapter%d/demux%d", demux->adapter, demux->demux);
56 m_fd_demux = ::open(filename, O_RDWR);
58 eWarning("%s: %m", filename);
61 #if HAVE_DVB_API_VERSION < 3
62 int eDVBAudio::setPid(int pid, int type)
64 if ((m_fd < 0) || (m_fd_demux < 0))
84 if (::ioctl(m_fd, AUDIO_SET_BYPASS_MODE, bypass) < 0)
85 eDebug("failed (%m)");
87 dmx_pes_filter_params pes;
90 pes.input = DMX_IN_FRONTEND;
91 pes.output = DMX_OUT_DECODER;
92 pes.pes_type = m_dev ? DMX_PES_AUDIO1 : DMX_PES_AUDIO0; /* FIXME */
94 eDebugNoNewLine("DMX_SET_PES_FILTER(0x%02x) - audio - ", pid);
95 if (::ioctl(m_fd_demux, DMX_SET_PES_FILTER, &pes) < 0)
97 eDebug("failed (%m)");
105 int eDVBAudio::startPid()
107 eDebugNoNewLine("DEMUX_START - audio - ");
108 if (::ioctl(m_fd_demux, DMX_START) < 0)
110 eDebug("failed (%m)");
117 int eDVBAudio::start()
119 eDebugNoNewLine("AUDIO_PLAY - ");
120 if (::ioctl(m_fd, AUDIO_PLAY) < 0)
122 eDebug("failed (%m)");
129 int eDVBAudio::stopPid()
131 eDebugNoNewLine("DEMUX_STOP - audio - ");
132 if (::ioctl(m_fd_demux, DMX_STOP) < 0)
134 eDebug("failed (%m)");
141 int eDVBAudio::setAVSync(int val)
143 eDebugNoNewLine("AUDIO_SET_AV_SYNC - ");
144 if (::ioctl(m_fd, AUDIO_SET_AV_SYNC, val) < 0)
146 eDebug("failed (%m)");
153 int eDVBAudio::startPid(int pid, int type)
155 if ((m_fd < 0) || (m_fd_demux < 0))
157 dmx_pes_filter_params pes;
160 pes.input = DMX_IN_FRONTEND;
161 pes.output = DMX_OUT_DECODER;
162 pes.pes_type = m_dev ? DMX_PES_AUDIO1 : DMX_PES_AUDIO0; /* FIXME */
164 eDebugNoNewLine("DMX_SET_PES_FILTER(0x%02x) - audio - ", pid);
165 if (::ioctl(m_fd_demux, DMX_SET_PES_FILTER, &pes) < 0)
167 eDebug("failed (%m)");
171 eDebugNoNewLine("DEMUX_START - audio - ");
172 if (::ioctl(m_fd_demux, DMX_START) < 0)
174 eDebug("failed (%m)");
195 eDebugNoNewLine("AUDIO_SET_BYPASS - ");
196 if (::ioctl(m_fd, AUDIO_SET_BYPASS_MODE, bypass) < 0)
197 eDebug("failed (%m)");
202 eDebugNoNewLine("AUDIO_PLAY - ");
203 if (::ioctl(m_fd, AUDIO_PLAY) < 0)
204 eDebug("failed (%m)");
211 void eDVBAudio::stop()
213 #if HAVE_DVB_API_VERSION > 2
216 eDebugNoNewLine("AUDIO_STOP - ");
217 if (::ioctl(m_fd, AUDIO_STOP) < 0)
218 eDebug("failed (%m)");
221 #if HAVE_DVB_API_VERSION > 2
222 eDebugNoNewLine("DEMUX_STOP - audio - ");
223 if (::ioctl(m_fd_demux, DMX_STOP) < 0)
224 eDebug("failed (%m)");
230 void eDVBAudio::flush()
232 eDebugNoNewLine("AUDIO_CLEAR_BUFFER - ");
233 if (::ioctl(m_fd, AUDIO_CLEAR_BUFFER) < 0)
234 eDebug("failed (%m)");
239 void eDVBAudio::freeze()
243 eDebugNoNewLine("AUDIO_PAUSE - ");
244 if (::ioctl(m_fd, AUDIO_PAUSE) < 0)
245 eDebug("failed (%m)");
252 void eDVBAudio::unfreeze()
256 eDebugNoNewLine("AUDIO_CONTINUE - ");
257 if (::ioctl(m_fd, AUDIO_CONTINUE) < 0)
258 eDebug("failed (%m)");
265 void eDVBAudio::setChannel(int channel)
267 int val = AUDIO_STEREO;
270 case aMonoLeft: val = AUDIO_MONO_LEFT; break;
271 case aMonoRight: val = AUDIO_MONO_RIGHT; break;
274 eDebugNoNewLine("AUDIO_CHANNEL_SELECT(%d) - ", val);
275 if (::ioctl(m_fd, AUDIO_CHANNEL_SELECT, val) < 0)
276 eDebug("failed (%m)");
281 int eDVBAudio::getPTS(pts_t &now)
283 eDebugNoNewLine("AUDIO_GET_PTS - ");
284 if (::ioctl(m_fd, AUDIO_GET_PTS, &now) < 0)
285 eDebug("failed (%m)");
291 eDVBAudio::~eDVBAudio()
300 DEFINE_REF(eDVBVideo);
302 eDVBVideo::eDVBVideo(eDVBDemux *demux, int dev)
303 :m_demux(demux), m_dev(dev), m_is_slow_motion(0), m_is_fast_forward(0), m_is_freezed(0)
306 #if HAVE_DVB_API_VERSION < 3
307 sprintf(filename, "/dev/dvb/card%d/video%d", demux->adapter, dev);
308 m_fd_video = ::open("/dev/video", O_RDWR);
310 eWarning("/dev/video: %m");
312 sprintf(filename, "/dev/dvb/adapter%d/video%d", demux->adapter, dev);
314 m_fd = ::open(filename, O_RDWR);
316 eWarning("%s: %m", filename);
319 m_sn = new eSocketNotifier(eApp, m_fd, eSocketNotifier::Priority);
320 CONNECT(m_sn->activated, eDVBVideo::video_event);
322 eDebug("Video Device: %s", filename);
323 #if HAVE_DVB_API_VERSION < 3
324 sprintf(filename, "/dev/dvb/card%d/demux%d", demux->adapter, demux->demux);
326 sprintf(filename, "/dev/dvb/adapter%d/demux%d", demux->adapter, demux->demux);
328 m_fd_demux = ::open(filename, O_RDWR);
330 eWarning("%s: %m", filename);
331 eDebug("demux device: %s", filename);
334 // not finally values i think.. !!
335 #define VIDEO_STREAMTYPE_MPEG2 0
336 #define VIDEO_STREAMTYPE_MPEG4_H264 1
338 #if HAVE_DVB_API_VERSION < 3
339 int eDVBVideo::setPid(int pid)
341 if ((m_fd < 0) || (m_fd_demux < 0))
343 dmx_pes_filter_params pes;
346 pes.input = DMX_IN_FRONTEND;
347 pes.output = DMX_OUT_DECODER;
348 pes.pes_type = m_dev ? DMX_PES_VIDEO1 : DMX_PES_VIDEO0; /* FIXME */
350 eDebugNoNewLine("DMX_SET_PES_FILTER(0x%02x) - video - ", pid);
351 if (::ioctl(m_fd_demux, DMX_SET_PES_FILTER, &pes) < 0)
353 eDebug("failed (%m)");
360 int eDVBVideo::startPid()
362 eDebugNoNewLine("DEMUX_START - video - ");
363 if (::ioctl(m_fd_demux, DMX_START) < 0)
365 eDebug("failed (%m)");
372 int eDVBVideo::start()
374 eDebugNoNewLine("VIDEO_PLAY - ");
375 if (::ioctl(m_fd, VIDEO_PLAY) < 0)
377 eDebug("failed (%m)");
384 int eDVBVideo::stopPid()
386 eDebugNoNewLine("DEMUX_STOP - video - ");
387 if (::ioctl(m_fd_demux, DMX_STOP) < 0)
389 eDebug("failed (%m)");
396 int eDVBVideo::startPid(int pid, int type)
398 if ((m_fd < 0) || (m_fd_demux < 0))
400 dmx_pes_filter_params pes;
402 eDebugNoNewLine("VIDEO_SET_STREAMTYPE %d - ",type == MPEG4_H264 ? VIDEO_STREAMTYPE_MPEG4_H264 : VIDEO_STREAMTYPE_MPEG2);
403 if (::ioctl(m_fd, VIDEO_SET_STREAMTYPE,
404 type == MPEG4_H264 ? VIDEO_STREAMTYPE_MPEG4_H264 : VIDEO_STREAMTYPE_MPEG2) < 0)
405 eDebug("failed (%m)");
410 pes.input = DMX_IN_FRONTEND;
411 pes.output = DMX_OUT_DECODER;
412 pes.pes_type = m_dev ? DMX_PES_VIDEO1 : DMX_PES_VIDEO0; /* FIXME */
414 eDebugNoNewLine("DMX_SET_PES_FILTER(0x%02x) - video - ", pid);
415 if (::ioctl(m_fd_demux, DMX_SET_PES_FILTER, &pes) < 0)
417 eDebug("failed (%m)");
421 eDebugNoNewLine("DEMUX_START - video - ");
422 if (::ioctl(m_fd_demux, DMX_START) < 0)
424 eDebug("failed (%m)");
429 eDebugNoNewLine("VIDEO_PLAY - ");
430 if (::ioctl(m_fd, VIDEO_PLAY) < 0)
431 eDebug("failed (%m)");
438 void eDVBVideo::stop()
440 #if HAVE_DVB_API_VERSION > 2
441 eDebugNoNewLine("DEMUX_STOP - video - ");
442 if (::ioctl(m_fd_demux, DMX_STOP) < 0)
443 eDebug("failed (%m)");
447 eDebugNoNewLine("VIDEO_STOP - ");
448 if (::ioctl(m_fd, VIDEO_STOP, 1) < 0)
449 eDebug("failed (%m)");
454 void eDVBVideo::flush()
456 eDebugNoNewLine("VIDEO_CLEAR_BUFFER - ");
457 if (::ioctl(m_fd, VIDEO_CLEAR_BUFFER) < 0)
458 eDebug("failed (%m)");
463 void eDVBVideo::freeze()
467 eDebugNoNewLine("VIDEO_FREEZE - ");
468 if (::ioctl(m_fd, VIDEO_FREEZE) < 0)
469 eDebug("failed (%m)");
476 void eDVBVideo::unfreeze()
480 eDebugNoNewLine("VIDEO_CONTINUE - ");
481 if (::ioctl(m_fd, VIDEO_CONTINUE) < 0)
482 eDebug("failed (%m)");
489 int eDVBVideo::setSlowMotion(int repeat)
491 eDebugNoNewLine("VIDEO_SLOWMOTION - ");
492 m_is_slow_motion = repeat;
493 int ret = ::ioctl(m_fd, VIDEO_SLOWMOTION, repeat);
495 eDebug("failed(%m)");
501 int eDVBVideo::setFastForward(int skip)
503 eDebugNoNewLine("VIDEO_FAST_FORWARD - ");
504 m_is_fast_forward = skip;
505 int ret = ::ioctl(m_fd, VIDEO_FAST_FORWARD, skip);
507 eDebug("failed(%m)");
513 int eDVBVideo::getPTS(pts_t &now)
515 #if HAVE_DVB_API_VERSION < 3
516 #define VIDEO_GET_PTS_OLD _IOR('o', 1, unsigned int*)
518 int ret = ::ioctl(m_fd_video, VIDEO_GET_PTS_OLD, &pts);
522 int ret = ::ioctl(m_fd, VIDEO_GET_PTS, &now);
525 eDebug("VIDEO_GET_PTS failed(%m)");
529 eDVBVideo::~eDVBVideo()
533 if (m_is_slow_motion)
535 if (m_is_fast_forward)
542 #if HAVE_DVB_API_VERSION < 3
548 void eDVBVideo::video_event(int)
550 #if HAVE_DVB_API_VERSION >= 3
551 struct video_event evt;
552 eDebugNoNewLine("VIDEO_GET_EVENT - ");
553 if (::ioctl(m_fd, VIDEO_GET_EVENT, &evt) < 0)
554 eDebug("failed (%m)");
558 if (evt.type == VIDEO_EVENT_SIZE_CHANGED)
560 struct iTSMPEGDecoder::videoEvent event;
561 event.type = iTSMPEGDecoder::videoEvent::eventSizeChanged;
562 event.aspect = evt.u.size.aspect_ratio;
563 event.height = evt.u.size.h;
564 event.width = evt.u.size.w;
565 /* emit */ m_event(event);
568 eDebug("unhandled DVBAPI Video Event %d", evt.type);
571 #warning "FIXMEE!! Video Events not implemented for old api"
575 RESULT eDVBVideo::connectEvent(const Slot1<void, struct iTSMPEGDecoder::videoEvent> &event, ePtr<eConnection> &conn)
577 conn = new eConnection(this, m_event.connect(event));
583 eDVBPCR::eDVBPCR(eDVBDemux *demux): m_demux(demux)
586 #if HAVE_DVB_API_VERSION < 3
587 sprintf(filename, "/dev/dvb/card%d/demux%d", demux->adapter, demux->demux);
589 sprintf(filename, "/dev/dvb/adapter%d/demux%d", demux->adapter, demux->demux);
591 m_fd_demux = ::open(filename, O_RDWR);
593 eWarning("%s: %m", filename);
596 #if HAVE_DVB_API_VERSION < 3
597 int eDVBPCR::setPid(int pid)
601 dmx_pes_filter_params pes;
604 pes.input = DMX_IN_FRONTEND;
605 pes.output = DMX_OUT_DECODER;
606 pes.pes_type = DMX_PES_PCR;
609 eDebugNoNewLine("DMX_SET_PES_FILTER(0x%02x) - pcr - ", pid);
610 if (::ioctl(m_fd_demux, DMX_SET_PES_FILTER, &pes) < 0)
612 eDebug("failed (%m)");
619 int eDVBPCR::startPid()
623 eDebugNoNewLine("DEMUX_START - pcr - ");
624 if (::ioctl(m_fd_demux, DMX_START) < 0)
626 eDebug("failed (%m)");
633 int eDVBPCR::startPid(int pid)
637 dmx_pes_filter_params pes;
640 pes.input = DMX_IN_FRONTEND;
641 pes.output = DMX_OUT_DECODER;
642 pes.pes_type = DMX_PES_PCR;
644 eDebugNoNewLine("DMX_SET_PES_FILTER(0x%02x) - pcr - ", pid);
645 if (::ioctl(m_fd_demux, DMX_SET_PES_FILTER, &pes) < 0)
647 eDebug("failed (%m)");
651 eDebugNoNewLine("DEMUX_START - pcr - ");
652 if (::ioctl(m_fd_demux, DMX_START) < 0)
654 eDebug("failed (%m)");
664 eDebugNoNewLine("DEMUX_STOP - pcr - ");
665 if (::ioctl(m_fd_demux, DMX_STOP) < 0)
666 eDebug("failed(%m)");
677 DEFINE_REF(eDVBTText);
679 eDVBTText::eDVBTText(eDVBDemux *demux): m_demux(demux)
682 #if HAVE_DVB_API_VERSION < 3
683 sprintf(filename, "/dev/dvb/card%d/demux%d", demux->adapter, demux->demux);
685 sprintf(filename, "/dev/dvb/adapter%d/demux%d", demux->adapter, demux->demux);
687 m_fd_demux = ::open(filename, O_RDWR);
689 eWarning("%s: %m", filename);
692 int eDVBTText::startPid(int pid)
696 dmx_pes_filter_params pes;
699 pes.input = DMX_IN_FRONTEND;
700 pes.output = DMX_OUT_DECODER;
701 pes.pes_type = DMX_PES_TELETEXT;
704 eDebugNoNewLine("DMX_SET_PES_FILTER(0x%02x) - ttx - ", pid);
705 if (::ioctl(m_fd_demux, DMX_SET_PES_FILTER, &pes) < 0)
707 eDebug("failed(%m)");
711 eDebugNoNewLine("DEMUX_START - pcr - ");
712 if (::ioctl(m_fd_demux, DMX_START) < 0)
714 eDebug("failed(%m)");
721 void eDVBTText::stop()
723 eDebugNoNewLine("DEMUX_STOP - ttx - ");
724 if (::ioctl(m_fd_demux, DMX_STOP) < 0)
725 eDebug("failed(%m)");
730 eDVBTText::~eDVBTText()
736 DEFINE_REF(eTSMPEGDecoder);
738 int eTSMPEGDecoder::setState()
742 int noaudio = m_is_sm || m_is_ff || m_is_trickmode;
743 int nott = noaudio; /* actually same conditions */
745 if ((noaudio && m_audio) || (!m_audio && !noaudio))
746 m_changed |= changeAudio;
748 if ((nott && m_text) || (!m_text && !nott))
749 m_changed |= changeText;
751 bool changed = !!m_changed;
752 #if HAVE_DVB_API_VERSION < 3
753 bool checkAVSync = m_changed & (changeAudio|changeVideo|changePCR);
754 if (m_changed & changeAudio && m_audio)
756 if (m_changed & changeVideo && m_video)
758 if (m_changed & changePCR && m_pcr)
762 if (!(m_pcrpid >= 0 && m_pcrpid < 0x1ff))
763 m_changed &= ~changePCR;
765 if (m_changed & changeAudio && m_audio)
769 if (!(m_apid >= 0 && m_apid < 0x1ff))
770 m_changed &= ~changeAudio;
772 if (m_changed & changeVideo && m_video)
776 m_video_event_conn=0;
777 if (!(m_vpid >= 0 && m_vpid < 0x1ff))
778 m_changed &= ~changeVideo;
780 if (m_changed & changeVideo)
782 m_video = new eDVBVideo(m_demux, m_decoder);
783 m_video->connectEvent(slot(*this, &eTSMPEGDecoder::video_event), m_video_event_conn);
784 if (m_video->setPid(m_vpid))
787 if (m_changed & changePCR)
789 m_pcr = new eDVBPCR(m_demux);
790 if (m_pcr->setPid(m_pcrpid))
793 if (m_changed & changeAudio)
795 m_audio = new eDVBAudio(m_demux, m_decoder);
796 if (m_audio->setPid(m_apid, m_atype))
799 if (m_changed & changePCR)
801 if (m_pcr->startPid())
803 m_changed &= ~changePCR;
805 else if (checkAVSync && m_audio && m_video)
807 if (m_audio->setAVSync(1))
810 if (m_changed & changeVideo)
812 if (m_video->startPid() || m_video->start())
814 m_changed &= ~changeVideo;
816 if (m_changed & changeAudio)
818 if (m_audio->start() || m_audio->startPid())
820 m_changed &= ~changeAudio;
823 if (m_changed & changePCR)
828 if ((m_pcrpid >= 0) && (m_pcrpid < 0x1FFF))
830 m_pcr = new eDVBPCR(m_demux);
831 if (m_pcr->startPid(m_pcrpid))
834 m_changed &= ~changePCR;
836 if (m_changed & changeVideo)
838 eDebug("VIDEO CHANGED (to %04x)", m_vpid);
843 m_video_event_conn = 0;
845 if ((m_vpid >= 0) && (m_vpid < 0x1FFF))
847 m_video = new eDVBVideo(m_demux, m_decoder);
848 m_video->connectEvent(slot(*this, &eTSMPEGDecoder::video_event), m_video_event_conn);
849 if (m_video->startPid(m_vpid, m_vtype))
852 m_changed &= ~changeVideo;
854 if (m_changed & changeAudio)
859 if ((m_apid >= 0) && (m_apid < 0x1FFF) && !noaudio)
861 m_audio = new eDVBAudio(m_demux, m_decoder);
862 if (m_audio->startPid(m_apid, m_atype))
865 m_changed &= ~changeAudio;
867 if (m_changed & changeText)
872 if ((m_textpid >= 0) && (m_textpid < 0x1FFF) && !nott)
874 m_text = new eDVBTText(m_demux);
875 if (m_text->startPid(m_textpid))
878 m_changed &= ~changeText;
881 if (changed && !m_video && m_audio && m_radio_pic.length())
882 showSinglePic(m_radio_pic.c_str());
887 int eTSMPEGDecoder::m_pcm_delay=-1,
888 eTSMPEGDecoder::m_ac3_delay=-1;
890 RESULT eTSMPEGDecoder::setPCMDelay(int delay)
892 if (m_decoder == 0 && delay != m_pcm_delay )
894 FILE *fp = fopen("/proc/stb/audio/audio_delay_pcm", "w");
897 fprintf(fp, "%x", delay*90);
906 RESULT eTSMPEGDecoder::setAC3Delay(int delay)
908 if ( m_decoder == 0 && delay != m_ac3_delay )
910 FILE *fp = fopen("/proc/stb/audio/audio_delay_bitstream", "w");
913 fprintf(fp, "%x", delay*90);
922 eTSMPEGDecoder::eTSMPEGDecoder(eDVBDemux *demux, int decoder): m_demux(demux), m_changed(0), m_decoder(decoder)
924 demux->connectEvent(slot(*this, &eTSMPEGDecoder::demux_event), m_demux_event_conn);
925 m_is_ff = m_is_sm = m_is_trickmode = 0;
928 eTSMPEGDecoder::~eTSMPEGDecoder()
930 m_vpid = m_apid = m_pcrpid = pidNone;
935 RESULT eTSMPEGDecoder::setVideoPID(int vpid, int type)
939 m_changed |= changeVideo;
946 RESULT eTSMPEGDecoder::setAudioPID(int apid, int type)
948 if ((m_apid != apid) || (m_atype != type))
950 m_changed |= changeAudio;
957 int eTSMPEGDecoder::m_audio_channel = -1;
959 RESULT eTSMPEGDecoder::setAudioChannel(int channel)
963 if (m_decoder == 0 && m_audio_channel != channel)
967 m_audio->setChannel(channel);
968 m_audio_channel=channel;
971 eDebug("eTSMPEGDecoder::setAudioChannel but no audio decoder exist");
976 int eTSMPEGDecoder::getAudioChannel()
978 return m_audio_channel == -1 ? ac_stereo : m_audio_channel;
981 RESULT eTSMPEGDecoder::setSyncPCR(int pcrpid)
983 if (m_pcrpid != pcrpid)
985 m_changed |= changePCR;
991 RESULT eTSMPEGDecoder::setTextPID(int textpid)
993 if (m_textpid != textpid)
995 m_changed |= changeText;
1001 RESULT eTSMPEGDecoder::setSyncMaster(int who)
1006 RESULT eTSMPEGDecoder::start()
1015 /* preroll is start in freezed mode. */
1016 RESULT eTSMPEGDecoder::preroll()
1021 RESULT eTSMPEGDecoder::freeze(int cont)
1032 RESULT eTSMPEGDecoder::unfreeze()
1035 m_video->unfreeze();
1038 m_audio->unfreeze();
1043 RESULT eTSMPEGDecoder::setSinglePictureMode(int when)
1048 RESULT eTSMPEGDecoder::setPictureSkipMode(int what)
1053 RESULT eTSMPEGDecoder::setFastForward(int frames_to_skip)
1055 m_is_ff = frames_to_skip != 0;
1060 return m_video->setFastForward(frames_to_skip);
1065 RESULT eTSMPEGDecoder::setSlowMotion(int repeat)
1067 m_is_sm = repeat != 0;
1072 return m_video->setSlowMotion(repeat);
1077 RESULT eTSMPEGDecoder::setZoom(int what)
1082 RESULT eTSMPEGDecoder::flush()
1091 void eTSMPEGDecoder::demux_event(int event)
1095 case eDVBDemux::evtFlush:
1103 RESULT eTSMPEGDecoder::setTrickmode(int what)
1105 m_is_trickmode = what;
1110 RESULT eTSMPEGDecoder::getPTS(int what, pts_t &pts)
1112 if (what == 0) /* auto */
1113 what = m_video ? 1 : 2;
1115 if (what == 1) /* video */
1118 return m_video->getPTS(pts);
1123 if (what == 2) /* audio */
1126 return m_audio->getPTS(pts);
1134 RESULT eTSMPEGDecoder::setRadioPic(const std::string &filename)
1136 m_radio_pic = filename;
1140 RESULT eTSMPEGDecoder::showSinglePic(const char *filename)
1144 FILE *f = fopen(filename, "r");
1147 int vfd = open("/dev/dvb/adapter0/video0", O_RDWR);
1150 fseek(f, 0, SEEK_END);
1151 int length = ftell(f);
1152 unsigned char *buffer = new unsigned char[length*2+9];
1153 if (ioctl(vfd, VIDEO_FAST_FORWARD, 1) < 0)
1154 eDebug("VIDEO_FAST_FORWARD failed (%m)");
1155 if (ioctl(vfd, VIDEO_SELECT_SOURCE, VIDEO_SOURCE_MEMORY) < 0)
1156 eDebug("VIDEO_SELECT_SOURCE MEMORY failed (%m)");
1157 if (ioctl(vfd, VIDEO_PLAY) < 0)
1158 eDebug("VIDEO_PLAY failed (%m)");
1159 if (::ioctl(vfd, VIDEO_CONTINUE) < 0)
1160 eDebug("video: VIDEO_CONTINUE: %m");
1166 fseek(f, 0, SEEK_SET);
1173 buffer[pos++]=(length*2)>>8;
1174 buffer[pos++]=(length*2)&0xFF;
1181 rd = fread(buffer+pos, 1, length, f);
1189 write(vfd, buffer, pos);
1190 usleep(75000); // i dont like this.. but i dont have a better solution :(
1191 if (ioctl(vfd, VIDEO_SELECT_SOURCE, VIDEO_SOURCE_DEMUX) < 0)
1192 eDebug("VIDEO_SELECT_SOURCE DEMUX failed (%m)");
1193 if (ioctl(vfd, VIDEO_FAST_FORWARD, 0) < 0)
1194 eDebug("VIDEO_FAST_FORWARD failed (%m)");
1202 eDebug("couldnt open %s", filename);
1208 eDebug("only show single pics on first decoder");
1214 RESULT eTSMPEGDecoder::connectVideoEvent(const Slot1<void, struct videoEvent> &event, ePtr<eConnection> &conn)
1216 conn = new eConnection(this, m_video_event.connect(event));
1220 void eTSMPEGDecoder::video_event(struct videoEvent event)
1222 /* emit */ m_video_event(event);