add possibility to show iframes (not bugfree yet)
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Sun, 25 Jun 2006 22:14:53 +0000 (22:14 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Sun, 25 Jun 2006 22:14:53 +0000 (22:14 +0000)
lib/dvb/decoder.cpp
lib/dvb/decoder.h
lib/dvb/idvb.h
lib/service/servicedvb.cpp
mytest.py

index a05c837..8e172c8 100644 (file)
@@ -405,7 +405,8 @@ int eTSMPEGDecoder::setState()
        
        if ((nott && m_text) || (!m_text && !nott))
                m_changed |= changeText;
-       
+
+       bool changed = !!m_changed;
 #if HAVE_DVB_API_VERSION < 3
        if (m_changed & changeAudio && m_audio)
                m_audio->stopPid();
@@ -477,7 +478,7 @@ int eTSMPEGDecoder::setState()
        {
                eDebug("VIDEO CHANGED (to %04x)", m_vpid);
                if (m_video)
-               {       
+               {
                        eDebug("STOP");
                        m_video->stop();
                }
@@ -527,6 +528,9 @@ int eTSMPEGDecoder::setState()
                m_changed &= ~changeText;
        }
 #endif
+       if (changed && !m_video && m_audio && m_radio_pic.length())
+               showSinglePic(m_radio_pic.c_str());
+
        return res;
 }
 
@@ -762,3 +766,79 @@ RESULT eTSMPEGDecoder::getPTS(int what, pts_t &pts)
 
        return -1;
 }
+
+RESULT eTSMPEGDecoder::setRadioPic(const std::string &filename)
+{
+       m_radio_pic = filename;
+}
+
+RESULT eTSMPEGDecoder::showSinglePic(const char *filename)
+{
+       if (m_decoder == 0)
+       {
+               FILE *f = fopen(filename, "r");
+               if (f)
+               {
+                       int vfd = open("/dev/dvb/adapter0/video0", O_RDWR);
+                       if (vfd > 0)
+                       {
+                               int length = fseek(f, 0, SEEK_END);
+                               unsigned char *buffer = new unsigned char[length*3+9];
+                               if (ioctl(vfd, VIDEO_FAST_FORWARD, 1) < 0)
+                                       eDebug("VIDEO_FAST_FORWARD failed (%m)");
+                               if (ioctl(vfd, VIDEO_SELECT_SOURCE, VIDEO_SOURCE_MEMORY) < 0)
+                                       eDebug("VIDEO_SELECT_SOURCE MEMORY failed (%m)");
+                               if (ioctl(vfd, VIDEO_PLAY) < 0)
+                                       eDebug("VIDEO_PLAY failed (%m)");
+                               int cnt=0;
+                               int pos=0;
+                               while(cnt<3)
+                               {
+                                       int rd;
+                                       fseek(f, 0, SEEK_SET);
+                                       while(1)
+                                       {
+                                               if (!cnt)
+                                               {
+                                                       buffer[pos++]=0;
+                                                       buffer[pos++]=0;
+                                                       buffer[pos++]=1;
+                                                       buffer[pos++]=0xE0;
+                                                       buffer[pos++]=(length*3)>>8;
+                                                       buffer[pos++]=(length*3)&0xFF;
+                                                       buffer[pos++]=0x80;
+                                                       buffer[pos++]=0;
+                                                       buffer[pos++]=0;
+                                               }
+                                               rd = fread(buffer+pos, 1, length, f);
+                                               if (rd > 0)
+                                                       pos += rd;
+                                               else
+                                                       break;
+                                       }
+                                       ++cnt;
+                               }
+                               write(vfd, buffer, pos);
+                               usleep(50000);
+                               if (ioctl(vfd, VIDEO_SELECT_SOURCE, VIDEO_SOURCE_DEMUX) < 0)
+                                       eDebug("VIDEO_SELECT_SOURCE DEMUX failed (%m)");
+                               if (ioctl(vfd, VIDEO_FAST_FORWARD, 0) < 0)
+                                       eDebug("VIDEO_FAST_FORWARD failed (%m)");
+                               close(vfd);
+                               delete [] buffer;
+                       }
+                       fclose(f);
+               }
+               else
+               {
+                       eDebug("couldnt open %s", filename);
+                       return -1;
+               }
+       }
+       else
+       {
+               eDebug("only show single pics on first decoder");
+               return -1;
+       }
+       return 0;
+}
index b50a605..8e8f65a 100644 (file)
@@ -86,6 +86,7 @@ class eTSMPEGDecoder: public Object, public iTSMPEGDecoder
        static int m_ac3_delay;
        static int m_audio_channel;
 DECLARE_REF(eTSMPEGDecoder);
+       std::string m_radio_pic;
 private:
        ePtr<eDVBDemux> m_demux;
        ePtr<eDVBAudio> m_audio;
@@ -131,7 +132,8 @@ public:
        RESULT setZoom(int what);
        RESULT flush();
        RESULT setTrickmode(int what);
-       
+       RESULT showSinglePic(const char *filename);
+       RESULT setRadioPic(const std::string &filename);
                /* what 0=auto, 1=video, 2=audio. */
        RESULT getPTS(int what, pts_t &pts);
 };
index 6934271..2c80a9b 100644 (file)
@@ -641,6 +641,10 @@ public:
        virtual RESULT setTrickmode(int what) = 0;
        
        virtual RESULT getPTS(int what, pts_t &pts) = 0;
+
+       virtual RESULT showSinglePic(const char *filename) = 0;
+
+       virtual RESULT setRadioPic(const std::string &filename) = 0;
 };
 
 #endif //SWIG
index 8f58cde..b7acd1f 100644 (file)
@@ -1734,6 +1734,15 @@ void eDVBServicePlay::updateDecoder()
 
                m_decoder->start();
 
+               if (vpid > 0 && vpid < 0x2000)
+                       ;
+               else
+               {
+                       std::string radio_pic;
+                       if (!ePythonConfigQuery::getConfigValue("config.misc.radiopic", radio_pic))
+                               m_decoder->setRadioPic(radio_pic);
+               }
+
                m_decoder->setAudioChannel(achannel);
 
 // how we can do this better?
index 0ad6e24..db720a6 100644 (file)
--- a/mytest.py
+++ b/mytest.py
@@ -23,11 +23,13 @@ from Navigation import Navigation
 
 from skin import readSkin, applyAllAttributes
 
-from Components.config import configfile
-from Tools.Directories import InitFallbackFiles, resolveFilename, SCOPE_PLUGINS
+from Tools.Directories import InitFallbackFiles, resolveFilename, SCOPE_PLUGINS, SCOPE_SKIN_IMAGE
+from Components.config import configfile, configElement, configText, ConfigSubsection, config, configSequence, configsequencearg
 InitFallbackFiles()
 eDVBDB.getInstance().reloadBouquets()
 
+config.misc.radiopic = configElement("config.misc.radiopic", configText, resolveFilename(SCOPE_SKIN_IMAGE)+"radio.mvi", 0)
+
 try:
        import e2reactor
        e2reactor.install()
@@ -302,7 +304,6 @@ class Session:
 from Screens.Volume import Volume
 from Screens.Mute import Mute
 from GlobalActions import globalActionMap
-from Components.config import ConfigSubsection, configSequence, configElement, configsequencearg
 
 #TODO .. move this to a own .py file
 class VolumeControl: