add support for rds data on own pids (i.e. hitradio ffh, harmony fm)
[enigma2.git] / lib / service / servicedvb.cpp
index 5166414f82b727eac56ef0f5e485262407a96656..d04039dfba8ec3a7973fc6de60c1e08574012048 100644 (file)
@@ -1758,21 +1758,26 @@ int eDVBServicePlay::selectAudioStream(int i)
                return -4;
        }
 
+       int rdsPid = apid;
+
                /* if we are not in PVR mode, timeshift is not active and we are not in pip mode, check if we need to enable the rds reader */
        if (!(m_is_pvr || m_timeshift_active || !m_is_primary))
-               if (!m_rds_decoder)
+       {
+               int different_pid = program.videoStreams.empty() && program.audioStreams.size() == 1 && program.audioStreams[stream].rdsPid != -1;
+               if (different_pid)
+                       rdsPid = program.audioStreams[stream].rdsPid;
+               if (!m_rds_decoder || m_rds_decoder->getPid() != rdsPid)
                {
+                       m_rds_decoder = 0;
                        ePtr<iDVBDemux> data_demux;
                        if (!h.getDataDemux(data_demux))
                        {
-                               m_rds_decoder = new eDVBRdsDecoder(data_demux);
+                               m_rds_decoder = new eDVBRdsDecoder(data_demux, different_pid);
                                m_rds_decoder->connectEvent(slot(*this, &eDVBServicePlay::rdsDecoderEvent), m_rds_decoder_event_connection);
+                               m_rds_decoder->start(rdsPid);
                        }
                }
-
-               /* if we decided that we need one, update the pid */
-       if (m_rds_decoder)
-               m_rds_decoder->start(apid);
+       }
 
                        /* store new pid as default only when:
                                a.) we have an entry in the service db for the current service,
@@ -2329,23 +2334,24 @@ void eDVBServicePlay::updateDecoder()
                                m_decoder->connectVideoEvent(slot(*this, &eDVBServicePlay::video_event), m_video_event_connection);
                        if (m_is_primary)
                        {
-                               ePyObject subs;
-                               if (m_timeshift_changed)
-                                       subs = getCachedSubtitle();
                                m_teletext_parser = new eDVBTeletextParser(m_decode_demux);
                                m_teletext_parser->connectNewPage(slot(*this, &eDVBServicePlay::newSubtitlePage), m_new_subtitle_page_connection);
                                m_subtitle_parser = new eDVBSubtitleParser(m_decode_demux);
                                m_subtitle_parser->connectNewPage(slot(*this, &eDVBServicePlay::newDVBSubtitlePage), m_new_dvb_subtitle_page_connection);
-                               if (subs)
+                               if (m_timeshift_changed)
                                {
-                                       int type = PyInt_AsLong(PyTuple_GET_ITEM(subs, 0)),
-                                           pid = PyInt_AsLong(PyTuple_GET_ITEM(subs, 1)),
-                                           comp_page = PyInt_AsLong(PyTuple_GET_ITEM(subs, 2)), // ttx page
-                                           anc_page = PyInt_AsLong(PyTuple_GET_ITEM(subs, 3)); // ttx magazine
-                                       if (type == 0) // dvb
-                                               m_subtitle_parser->start(pid, comp_page, anc_page);
-                                       else if (type == 1) // ttx
-                                               m_teletext_parser->setPageAndMagazine(comp_page, anc_page);
+                                       ePyObject subs = getCachedSubtitle();
+                                       if (subs != Py_None)
+                                       {
+                                               int type = PyInt_AsLong(PyTuple_GET_ITEM(subs, 0)),
+                                                   pid = PyInt_AsLong(PyTuple_GET_ITEM(subs, 1)),
+                                                   comp_page = PyInt_AsLong(PyTuple_GET_ITEM(subs, 2)), // ttx page
+                                                   anc_page = PyInt_AsLong(PyTuple_GET_ITEM(subs, 3)); // ttx magazine
+                                               if (type == 0) // dvb
+                                                       m_subtitle_parser->start(pid, comp_page, anc_page);
+                                               else if (type == 1) // ttx
+                                                       m_teletext_parser->setPageAndMagazine(comp_page, anc_page);
+                                       }
                                        Py_DECREF(subs);
                                }
                        }