Req [Solved] mpegts, set program number
#1
Hi,
I liked kodi for connecting with emby and some iptv channels.
I have a enigma2 box, that I will like to use as a backend for kodi.
The vupvr addon is loading everything really good, but the reason I'm posting this is that some channels will not start. It must be the same problem I have playing the stream with vlc,
it need to set the program to start.

Now, I'm not a programmer and c++ is not easy for a non programmer, so will ask if this is possible, and easy to implement:
in the file DVDDemuxFFmpeg.cpp, in this part:
Code:
// in case of mpegts and we have not seen pat/pmt, defer creation of streams
  if (!skipCreateStreams || m_pFormatContext->nb_programs > 0)
  {
    unsigned int nProgram = UINT_MAX;
    if (m_pFormatContext->nb_programs > 0)
    {
      // select the corrrect program if requested
      CVariant programProp(pInput->GetProperty("program"));
      if (!programProp.isNull())
      {
        int programNumber = programProp.asInteger();

        for (unsigned int i = 0; i < m_pFormatContext->nb_programs; ++i)
        {
          if (m_pFormatContext->programs[i]->program_num == programNumber)
          {
            nProgram = i;
            break;
          }
        }
      }
      else if (m_pFormatContext->iformat && strcmp(m_pFormatContext->iformat->name, "hls,applehttp") == 0)
      {
        nProgram = HLSSelectProgram();
      }
    }
    CreateStreams(nProgram);
  }

I thought 2 ways to fix this:
1- One way, probably the best, would be for the vupvr addon set for each channel pInput->GetProperty("program"), but I imagine this will not be so easy.

2- Second way, patch the file DVDDemuxFFmpeg.cpp. Knowing the stream URL is always something like "http://192.168.1.22:8001/1:0:1:1F:10:10:CCD2000:0:0:0:" where 1F is the program
Code:
else if (m_pFormatContext->iformat && strcmp(m_pFormatContext->iformat->name, "hls,applehttp") == 0)
      {
        nProgram = HLSSelectProgram();
      }
      // ****** NOT CODE *********** :)
+      else if(StreamURL Match "/1:0:1:([0-9a-fA-F]+):")
+      {
+        nProgram = hextodec($1);
+      }

Is this possible and easy?
Need someone to code this to c++, if it's easy Smile
Reply
#2
I solved the enigma2 streams checking for empty streams, tested and working:

Code:
diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
index f182509296..79c4d8e102 100644
--- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
+++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
@@ -1281,9 +1281,15 @@ void CDVDDemuxFFmpeg::CreateStreams(unsigned int program)
     // look for first non empty stream and discard nonselected programs
     for (unsigned int i = 0; i < m_pFormatContext->nb_programs; i++)
     {
-      if(m_program == UINT_MAX && m_pFormatContext->programs[i]->nb_stream_indexes > 0)
+      for (unsigned int j = 0; m_program == UINT_MAX && j < m_pFormatContext->programs[i]->nb_stream_indexes; j++)
       {
-        m_program = i;
+        int idx = m_pFormatContext->programs[i]->stream_index[j];
+        AVStream *st = m_pFormatContext->streams[idx];
+        if ((st->codec->codec_type == AVMEDIA_TYPE_VIDEO && st->codec_info_nb_frames > 0) ||
+            (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->codec->sample_rate > 0))
+        {
+          m_program = i;
+        }
       }

       if(i != m_program)
Reply

Logout Mark Read Team Forum Stats Members Help
[Solved] mpegts, set program number0