[Bug] Problem with DVB-IP channels with changed SID or PID (1 Viewer)

Stepko

Retired Team Member
  • Premium Supporter
  • September 29, 2007
    186
    152
    Hamburg/Wolfsburg
    Home Country
    Germany Germany
    AW: Problem with DVB-IP channels with changed SID or PID

    Hi romka,

    can you please check which IDs changed? I think the relevant one is the serviceID, but it would be interesting to know what other ids were changed.
    Thx
     

    Andrusha777

    Portal Pro
    December 3, 2009
    132
    3
    Home Country
    Russian Federation Russian Federation
    Stepko, i get access to MP's mysql databace via ODBC and on example of those 2 channels in logs above, i have noticed, that changed values in fields ServiceID and PMTPid in my case.
     

    AlexPlas

    Portal Pro
    August 24, 2006
    231
    41
    Kyiv, Ukraine
    Home Country
    Ukraine Ukraine
    I have a problem related to this one. My ISP broadcast few channels with fully identical sets of IDs i.e. TSID, ONID and SID and PMT_PID are the same for two different channels. As a result I cannot scan all the channels because second channel in the pair with identical IDs always updates first in the pair.
     

    mm1352000

    Retired Team Member
  • Premium Supporter
  • September 1, 2008
    21,578
    8,228
    Home Country
    New Zealand New Zealand
    Hi everyone

    I don't know what you think Stepko, but after looking at the code I think the changes required to support proper handling of channels where the SID (or anything other than the PMT PID) are changing is *way* out of scope for 1.2.0b. We know that TV Server does not implement DVB-IP standards properly, and the problems are becoming more and more obvious with the increasing number of IP-TV services that are being offered. The major changes that are required to resolve this *properly* will have to wait for 1.3.0. I think the best that we can do for 1.2.0 is:

    1. Use the URL for identifying channels when scanning (ie. ignore TSID, ONID, SID, PMT PID... whatever) when scanning for DVB-IP channels *if the "provider doesn't uniquely identify channels..." option is ticked*.

    2. Accept channels where the service type is not set correctly. If video is detected then the channel should be treated as TV; if video is not detected then the channel should be treated as radio.

    3. Make a hack in TsWriter for people that have providers who change the SID (+ TSID... whatever). The first PMT would be used as the PMT for the channel. When only the PMT PID is changing, the debug option (see here) for looking up the PMT PID in the PAT should be used. This would only work as long as the URL doesn't change and only *one channel* is streamed from each URL. For this to work, you need to:

    - Delete all your DVB-IP channels.
    - Do a full rescan with the "provider doesn't uniquely identify channels..." option ticked.
    - Whenever you scan for channels, the "provider doesn't uniquely identify channels..." option must be ticked.

    This will ensure that all your channels have a service ID of zero, which is required for the hack to work.

    A patched version of 1.2.0b that does all of the above is attached. I can't test as I don't have access to any DVB-IP streams... ;)

    Instructions:
    1. Stop TV Server and close MediaPortal, TV Server configuration, and MediaPortal configuration if they are open.
    2. Take a backup of the following files in your TV Server install folder:
    - SetupControls.dll
    - SetupTv.exe
    - TvBusiness.dll
    - TVDatabase.dll
    - TVLibrary.dll
    - TsWriter.ax
    3. Download and extract the attached files from DVB-IP[1.2.0b_relax].zip into your TV Server install folder.
    4. Copy the TvBusinessLayer.dll and TvDatabase.dll into your MediaPortal client install folder.
    5. Start TV Server.
    6. Rescan your channels if necessary.

    Let me know if you have any problems...

    mm
     

    Attachments

    • DVB-IP[1.2.0b_relax].zip
      1 MB
    • Code_Changes.patch
      6.3 KB

    Stepko

    Retired Team Member
  • Premium Supporter
  • September 29, 2007
    186
    152
    Hamburg/Wolfsburg
    Home Country
    Germany Germany
    AW: Re: Problem with DVB-IP channels with changed SID or PID

    Hi mm1352000,

    wow, many thanks for the patch!! After having a look at the code on thursday I hoped to get a solution for this particular bug (sid changes) for 1.2.0 rc. There are a lot of other issues in the tv server to get a proper dvb-ip solution that are way out of scope for 1.2.0. Perhaps we won't even fix all of them for 1.3.0...
    I had an idea how to fix this bug, but no time to implement it, yet.

    1. Use the URL for identifying channels when scanning (ie. ignore TSID, ONID, SID, PMT PID... whatever) when scanning for DVB-IP channels *if the "provider doesn't uniquely identify channels..." option is ticked*.
    I don't think that scanning is the problem. As far as I understood the TV server finds all channels. In dvb-ip the channel can be identified by its name and the name of the provider, both as dns names (e.g. bbc1.bbc.co.uk). Identifying the channel by the url would not be correct in terms of dvb-ip standart. If we change anything, I think we should do it in a way to get closer to the standart. Thats why I would say not to change that.

    2. Accept channels where the service type is not set correctly. If video is detected then the channel should be treated as TV; if video is not detected then the channel should be treated as radio.
    I think this is done for dvb-ip by riks patch, isn't it? The patch will be applied for 1.2.0 rc.

    3. Make a hack in TsWriter for people that have providers who change the SID (+ TSID... whatever). The first PMT would be used as the PMT for the channel. When only the PMT PID is changing, the debug option (see here) for looking up the PMT PID in the PAT should be used. This would only work as long as the URL doesn't change and only *one channel* is streamed from each URL.
    When the pmt pid changes, TSWriter looks for the new pmt pid in pad. That works only if the sid stays the same - which doesn't in this case. My idea was to ignore the sid when there is only one channel found in the ts stream. More technically detailed:
    • Add a flag to TSWriter (boolean, lets call it "ignoreSID")
    • ignoreSID is set to false by default
    • Only the dvb-ip card sets this flag to true
    • In "PadParser" check how many channles are in ts stream (should be possible to calculate with the length of pad)
    • In "PadParser" check if "ignoreSID" is set and if only one channle is in stream. Then ignore SID and take the first pmt pid that is found in pad (is also the only pmt pid in pad)
    This way we can be sure that the changes only affects dvb-ip, and the changes are all in one place (apart from setting "ignoreSID"). I didn't have time to try this, so perhaps there is some bad mistake in it. Perhaps you can post some comments on this?

    I tried your patch on my system and had no problems with it. But my provider doesn't change any ids, so I cannot really say if it works.
    Again, many :D for the patch!!
    Stepko
     

    AlexPlas

    Portal Pro
    August 24, 2006
    231
    41
    Kyiv, Ukraine
    Home Country
    Ukraine Ukraine
    Re: AW: Re: Problem with DVB-IP channels with changed SID or PID

    Hi mm1352000,
    I don't think that scanning is the problem. As far as I understood the TV server finds all channels. In dvb-ip the channel can be identified by its name and the name of the provider, both as dns names (e.g. bbc1.bbc.co.uk). Identifying the channel by the url would not be correct in terms of dvb-ip standart. If we change anything, I think we should do it in a way to get closer to the standart. Thats why I would say not to change that.
    In my case scanning is the problem as well, I have few pairs of different channels with identical set of IDs. But I think identifying by name of the channel and name of the provider is much better then identifying by URL
     

    mm1352000

    Retired Team Member
  • Premium Supporter
  • September 1, 2008
    21,578
    8,228
    Home Country
    New Zealand New Zealand
    Re: AW: Re: Problem with DVB-IP channels with changed SID or PID

    Hi Stepko

    I don't think that scanning is the problem. As far as I understood the TV server finds all channels. In dvb-ip the channel can be identified by its name and the name of the provider, both as dns names (e.g. bbc1.bbc.co.uk). Identifying the channel by the url would not be correct in terms of dvb-ip standart. If we change anything, I think we should do it in a way to get closer to the standart. Thats why I would say not to change that.
    The same people that are affected by SID changing are the same people that would benefit from the first change. The URL that they're scanning isn't changing, but any or all of the other parameters are. Scanning would result in the TSID, ONID etc. being updated rather than creating a mess with a new channel and/or tuning detail. The only reason I have used the URL is that I didn't think that we always had access to the proper name and provider information from the stream itself. If we do then we can make a change easily. My patch is really only a starting point...

    I think this is done for dvb-ip by riks patch, isn't it? The patch will be applied for 1.2.0 rc.
    That is also my understanding, although Rik's patch is not committed if it has been written. This is meant to be a patch that tries to deal with all the DVB-IP issues that I am currently aware of. I don't like it when it feels like many users are unable to use a part of the TV Server - I was hoping this patch could be turned into something that will mostly work and give us the time to implement the standard (or a big chunk of it) for 1.3.0.

    When the pmt pid changes, TSWriter looks for the new pmt pid in pad. That works only if the sid stays the same - which doesn't in this case. My idea was to ignore the sid when there is only one channel found in the ts stream. More technically detailed:
    • Add a flag to TSWriter (boolean, lets call it "ignoreSID")
    • ignoreSID is set to false by default
    • Only the dvb-ip card sets this flag to true
    • In "PadParser" check how many channles are in ts stream (should be possible to calculate with the length of pad)
    • In "PadParser" check if "ignoreSID" is set and if only one channle is in stream. Then ignore SID and take the first pmt pid that is found in pad (is also the only pmt pid in pad)
    This way we can be sure that the changes only affects dvb-ip, and the changes are all in one place (apart from setting "ignoreSID"). I didn't have time to try this, so perhaps there is some bad mistake in it. Perhaps you can post some comments on this?
    That is basically what I've done (great minds think alike! :D), although I've done it without the check for only one channel (I made an assumption that the people who need this change only have one channel per URL - multiple channels that change IDs available from one URL would be chaos :p). The flag that I used was simply the SID and the PMT PID that are already passed to TsWriter. If they are both 0 then the first PMT that is received is accepted. My solution is a hack because I didn't think it was worth trying to pass this change through the rest of the team and get it into 1.2.0rc. The minimal changes that are required make it easy to maintain until 1.3.0. I'm very open to a less "hacky" patch if you want a change that will get into 1.2.0rc...

    Best regards,
    mm
    :)
     

    Andrusha777

    Portal Pro
    December 3, 2009
    132
    3
    Home Country
    Russian Federation Russian Federation
    Hi mm1352000! If I understand properly, each IPTV channel which has in sql server table field with SID=0 will be identified by URL. So if I have channel which previously was not working in MP because of changed SID, and I will manually set the SID of this channel to 0, so I do not need to rescan this previously not working channel? Every time when tvserver will try to show IPTV channel with SID=0 it would be try to find new SID for it (but may be MP need much more time for switching channels in this case)? If so, for dvb-ip we do not need to scan channel, simply to convert m3u playlist of URLS to tvserver? Do i understand correctly?
     

    mm1352000

    Retired Team Member
  • Premium Supporter
  • September 1, 2008
    21,578
    8,228
    Home Country
    New Zealand New Zealand
    Hi Andrusha777 :)

    If I understand properly, each IPTV channel which has in sql server table field with SID=0 will be identified by URL.
    The identification by URL is only important when scanning to avoid getting only one channel - it solves your problem with the channels that have identical ONID, TSID, and SID combinations. To activate this, simply tick the "provider does not uniquely..." option when you do a scan.

    So if I have channel which previously was not working in MP because of changed SID, and I will manually set the SID of this channel to 0, so I do not need to rescan this previously not working channel?
    Yes. You also need to make sure that you enable the "always lookup PMT in PAT" debug option or also set the PMT PID to 0.

    Every time when tvserver will try to show IPTV channel with SID=0 it would be try to find new SID for it (but may be MP need much more time for switching channels in this case)?
    Correct - MP will use the first channel that it finds in the stream. It will not be any slower. :)

    If so, for dvb-ip we do not need to scan channel, simply to convert m3u playlist of URLS to tvserver? Do i understand correctly?
    You understand very close to correctly. Just make sure that if you have cases where the SID (or ONID, or TSID...) change then you need to set *both* the SID and PMT PID to 0. That can be done by manually editing the database, however TV Server may overwrite the PMT PID automatically. That is why you need to use the debug option. The SID is not like the PMT PID - it will only be overwritten if you do a rescan. In that case, just tick the "provider does not..." option and that will set the SID to 0 when it inserts the channels.

    I'm sorry it is so complicated. Please feel free to ask more questions if you need to. :D
     

    Users who are viewing this thread

    Top Bottom