Mailing List Archive

Adding PLP support (DTV_STREAM_ID)
Hello.

i have a few questions but first some background.

several years ago i bought a usb based dvbt2 tuner with the intention to
replace my pcie card.
i picked a TT CT2-4650 since it was supposed to have linux support already.
turned out that was not true since i got a newer version of it with no linux
support, so with a bit of hacking on the drivers i was able to get it working
due to the similarities with other cards.

but i quickly realized i could not tune to any dvb-t2 mux, after a lot of
troubleshooting i gave up and forgot about it.

then a year or so later my dvb tv box broke down and i bought a new one (vu+
solo4k) and to my surprise it had the exact same issue.
after even more troubleshooting i found out i need to set PLP ID to 1 for
tuning to work on dvb-t2 muxes.

so then i realized that must be the same problem with my ct2-4650 and it was.
yesterday i got tvheadend working on the usb tuner successfully and thats the
first time i got the usb tuner to do something useful.

BUT channel scanning is not working, so mux must be setup manualy, that
includes PLP ID and other paramters.
so i think the drivers don't do auto detect like my pcie card does.
and the downside of missing autodetect of plp is that most software dont know
how to handle plp and this applies to mythtv too.



so for mythtv to work with this card i need to convince the backend to specify
plp when tuning.
so a new mux paramter need to be added to database and then used during tuning.
as i understand it this is done with a property called: DTV_STREAM_ID and i
need to try to understand better how libs/libmythtv/recorders/dvbchannel.cpp works.

can someone give me any pointers about this?
to start with i'm happy with a proof of concept hack that sets DTV_STREAM_ID to
1 on all dvb-t2 tuning attempts, then if it works i can try and get a proper
patch for it.

i probably wont be able to get the mux editor or settings working since i'm not
familiar with how the setup gui works.
but if i get a new optional mux setting for plp in place then i'm happy.

_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Adding PLP support (DTV_STREAM_ID) [ In reply to ]
On 01/28/2018 08:12 AM, Torbjorn Jansson wrote:
> Hello.
>
> i have a few questions but first some background.
>
> several years ago i bought a usb based dvbt2 tuner with the intention
> to replace my pcie card.
> i picked a TT CT2-4650 since it was supposed to have linux support
> already.
> turned out that was not true since i got a newer version of it with no
> linux support, so with a bit of hacking on the drivers i was able to
> get it working due to the similarities with other cards.
>
> but i quickly realized i could not tune to any dvb-t2 mux, after a lot
> of troubleshooting i gave up and forgot about it.
>
> then a year or so later my dvb tv box broke down and i bought a new
> one (vu+ solo4k) and to my surprise it had the exact same issue.
> after even more troubleshooting i found out i need to set PLP ID to 1
> for tuning to work on dvb-t2 muxes.
>
> so then i realized that must be the same problem with my ct2-4650 and
> it was.
> yesterday i got tvheadend working on the usb tuner successfully and
> thats the first time i got the usb tuner to do something useful.
>
> BUT channel scanning is not working, so mux must be setup manualy,
> that includes PLP ID and other paramters.
> so i think the drivers don't do auto detect like my pcie card does.
> and the downside of missing autodetect of plp is that most software
> dont know how to handle plp and this applies to mythtv too.
>
>
>
> so for mythtv to work with this card i need to convince the backend to
> specify plp when tuning.
> so a new mux paramter need to be added to database and then used
> during tuning.
> as i understand it this is done with a property called: DTV_STREAM_ID
> and i need to try to understand better how
> libs/libmythtv/recorders/dvbchannel.cpp works.
>
> can someone give me any pointers about this?
> to start with i'm happy with a proof of concept hack that sets
> DTV_STREAM_ID to 1 on all dvb-t2 tuning attempts, then if it works i
> can try and get a proper patch for it.
>
> i probably wont be able to get the mux editor or settings working
> since i'm not familiar with how the setup gui works.
> but if i get a new optional mux setting for plp in place then i'm happy.
>
> _______________________________________________

I cannot directly help since I am not familiar with DVB tuning and I am
in the USA where there is no DVB-T2. I think the best way to find out
how it is working is to use a debugger to stop at some point in the
code, examine backtraces and step through the code. You may want to set
up a separate development system for that.

Changing setup is easy but it may require an extra database column if
this is a new parameter for the channel. Is the PLP ID different for
each channel? Is there a database column for it already?

Setup is different in MythTV version 29. Are you using V29?

If you do not have the time or the interest in debugging and figuring
this out, please create a ticket so that somebody can look at it later.
However it may be a long time before that happens.

If you do want to debug it and have questions about debugging let me
know and I can try to help.

Peter
_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Adding PLP support (DTV_STREAM_ID) [ In reply to ]
On 2018-01-28 16:42, Peter Bennett wrote:
>
>
> On 01/28/2018 08:12 AM, Torbjorn Jansson wrote:
>> Hello.
>>
>> i have a few questions but first some background.
>>
>> several years ago i bought a usb based dvbt2 tuner with the intention to
>> replace my pcie card.
>> i picked a TT CT2-4650 since it was supposed to have linux support already.
>> turned out that was not true since i got a newer version of it with no linux
>> support, so with a bit of hacking on the drivers i was able to get it working
>> due to the similarities with other cards.
>>
>> but i quickly realized i could not tune to any dvb-t2 mux, after a lot of
>> troubleshooting i gave up and forgot about it.
>>
>> then a year or so later my dvb tv box broke down and i bought a new one (vu+
>> solo4k) and to my surprise it had the exact same issue.
>> after even more troubleshooting i found out i need to set PLP ID to 1 for
>> tuning to work on dvb-t2 muxes.
>>
>> so then i realized that must be the same problem with my ct2-4650 and it was.
>> yesterday i got tvheadend working on the usb tuner successfully and thats the
>> first time i got the usb tuner to do something useful.
>>
>> BUT channel scanning is not working, so mux must be setup manualy, that
>> includes PLP ID and other paramters.
>> so i think the drivers don't do auto detect like my pcie card does.
>> and the downside of missing autodetect of plp is that most software dont know
>> how to handle plp and this applies to mythtv too.
>>
>>
>>
>> so for mythtv to work with this card i need to convince the backend to
>> specify plp when tuning.
>> so a new mux paramter need to be added to database and then used during tuning.
>> as i understand it this is done with a property called: DTV_STREAM_ID and i
>> need to try to understand better how libs/libmythtv/recorders/dvbchannel.cpp
>> works.
>>
>> can someone give me any pointers about this?
>> to start with i'm happy with a proof of concept hack that sets DTV_STREAM_ID
>> to 1 on all dvb-t2 tuning attempts, then if it works i can try and get a
>> proper patch for it.
>>
>> i probably wont be able to get the mux editor or settings working since i'm
>> not familiar with how the setup gui works.
>> but if i get a new optional mux setting for plp in place then i'm happy.
>>
>> _______________________________________________
>
> I cannot directly help since I am not familiar with DVB tuning and I am in the
> USA where there is no DVB-T2. I think the best way to find out how it is
> working is to use a debugger to stop at some point in the code, examine
> backtraces and step through the code. You may want to set up a separate
> development system for that.
>

i already have a dev system system, it is a vm with the usb tuner attached and
appears to work (can see the non dvb-t2 channels and frontend works)

> Changing setup is easy but it may require an extra database column if this is a
> new parameter for the channel. Is the PLP ID different for each channel? Is
> there a database column for it already?

PLP is per mux so yes a new column in dtv_multiplex table is needed.
adding another column is easy but im not yet familiar with the db update code
and i know you need to be careful with it so you don't screw up the schema numbers.


> Setup is different in MythTV version 29. Are you using V29?

yes i noticed, i upgrded my dev box from 28 to 29 and yes i partly like the new
setup but it gets very confusing with the options that is both a dropdown AND a
sub menu.
this is not intuitive at all, so that part i dislike.


> If you do not have the time or the interest in debugging and figuring this out,
> please create a ticket so that somebody can look at it later. However it may be
> a long time before that happens.
>
> If you do want to debug it and have questions about debugging let me know and I
> can try to help.

i'll start reading up on dvbchannel.cpp and see if i can stick in a new
property for this and hardcode plp (or stream id) to 1 for dvb-t2 muxes to see
if it works.

a few things i know from tvheadend that i got working:
channel scanning don't detect the mux if PLP is wrong, this is exactly
identical on my vu+4k box, wrong plp results in no signal and mux being skipped.
because of this, in tvheadend i had to specify the mux manually including all
other parameters (qam and so on, think it was 3 parameters that was important)


but when i scanned yesterday and setup muxes manually in mythtv 29 i was able
to define mux manually and make it scan and find the channels.
but actually tuning to one of those channels fails, and this i think is where
the plp comes into play.
anyway, more testing is needed and some hacking on the code.


also i read from the dvb api documentation (
https://www.kernel.org/doc/html/v4.14/media/uapi/dvb/fe_property_parameters.html#dtv-stream-id
) that apparently both dvb-t2 and dvb-s2 uses plp.

_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Adding PLP support (DTV_STREAM_ID) [ In reply to ]
On 28/01/2018 17:49, Torbjorn Jansson wrote:
> On 2018-01-28 16:42, Peter Bennett wrote:
>>
>>
>> On 01/28/2018 08:12 AM, Torbjorn Jansson wrote:
>>> Hello.
>>>
>>> i have a few questions but first some background.
>>>
>>> several years ago i bought a usb based dvbt2 tuner with the intention
>>> to replace my pcie card.
>>> i picked a TT CT2-4650 since it was supposed to have linux support
>>> already.
>>> turned out that was not true since i got a newer version of it with
>>> no linux support, so with a bit of hacking on the drivers i was able
>>> to get it working due to the similarities with other cards.
>>>
>>> but i quickly realized i could not tune to any dvb-t2 mux, after a
>>> lot of troubleshooting i gave up and forgot about it.
>>>
>>> then a year or so later my dvb tv box broke down and i bought a new
>>> one (vu+ solo4k) and to my surprise it had the exact same issue.
>>> after even more troubleshooting i found out i need to set PLP ID to 1
>>> for tuning to work on dvb-t2 muxes.
>>>
>>> so then i realized that must be the same problem with my ct2-4650 and
>>> it was.
>>> yesterday i got tvheadend working on the usb tuner successfully and
>>> thats the first time i got the usb tuner to do something useful.
>>>
>>> BUT channel scanning is not working, so mux must be setup manualy,
>>> that includes PLP ID and other paramters.
>>> so i think the drivers don't do auto detect like my pcie card does.
>>> and the downside of missing autodetect of plp is that most software
>>> dont know how to handle plp and this applies to mythtv too.
>>>
>>>
>>>
>>> so for mythtv to work with this card i need to convince the backend
>>> to specify plp when tuning.
>>> so a new mux paramter need to be added to database and then used
>>> during tuning.
>>> as i understand it this is done with a property called: DTV_STREAM_ID
>>> and i need to try to understand better how
>>> libs/libmythtv/recorders/dvbchannel.cpp works.
>>>
>>> can someone give me any pointers about this?
>>> to start with i'm happy with a proof of concept hack that sets
>>> DTV_STREAM_ID to 1 on all dvb-t2 tuning attempts, then if it works i
>>> can try and get a proper patch for it.
>>>
>>> i probably wont be able to get the mux editor or settings working
>>> since i'm not familiar with how the setup gui works.
>>> but if i get a new optional mux setting for plp in place then i'm happy.
>>>

I wrote the original patch to add support for DVB-T2
https://code.mythtv.org/trac/ticket/12342 . In the UK we don't use PLP
or it may have been that the tuner I had auto-detected but either way
there was no need to add PLP support at the time. If you follow that
link it should indicate roughly where to add the DTV_STREAM_ID property.
It's a long time since I looked at this but let me know if I can help.

David

_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Adding PLP support (DTV_STREAM_ID) [ In reply to ]
On 2018-01-29 19:39, David Matthews wrote:
> On 28/01/2018 17:49, Torbjorn Jansson wrote:
>> On 2018-01-28 16:42, Peter Bennett wrote:
>>>
>>>
>>> On 01/28/2018 08:12 AM, Torbjorn Jansson wrote:
>>>> Hello.
>>>>
>>>> i have a few questions but first some background.
>>>>
>>>> several years ago i bought a usb based dvbt2 tuner with the intention to
>>>> replace my pcie card.
>>>> i picked a TT CT2-4650 since it was supposed to have linux support already.
>>>> turned out that was not true since i got a newer version of it with no
>>>> linux support, so with a bit of hacking on the drivers i was able to get it
>>>> working due to the similarities with other cards.
>>>>
>>>> but i quickly realized i could not tune to any dvb-t2 mux, after a lot of
>>>> troubleshooting i gave up and forgot about it.
>>>>
>>>> then a year or so later my dvb tv box broke down and i bought a new one
>>>> (vu+ solo4k) and to my surprise it had the exact same issue.
>>>> after even more troubleshooting i found out i need to set PLP ID to 1 for
>>>> tuning to work on dvb-t2 muxes.
>>>>
>>>> so then i realized that must be the same problem with my ct2-4650 and it was.
>>>> yesterday i got tvheadend working on the usb tuner successfully and thats
>>>> the first time i got the usb tuner to do something useful.
>>>>
>>>> BUT channel scanning is not working, so mux must be setup manualy, that
>>>> includes PLP ID and other paramters.
>>>> so i think the drivers don't do auto detect like my pcie card does.
>>>> and the downside of missing autodetect of plp is that most software dont
>>>> know how to handle plp and this applies to mythtv too.
>>>>
>>>>
>>>>
>>>> so for mythtv to work with this card i need to convince the backend to
>>>> specify plp when tuning.
>>>> so a new mux paramter need to be added to database and then used during
>>>> tuning.
>>>> as i understand it this is done with a property called: DTV_STREAM_ID and i
>>>> need to try to understand better how
>>>> libs/libmythtv/recorders/dvbchannel.cpp works.
>>>>
>>>> can someone give me any pointers about this?
>>>> to start with i'm happy with a proof of concept hack that sets
>>>> DTV_STREAM_ID to 1 on all dvb-t2 tuning attempts, then if it works i can
>>>> try and get a proper patch for it.
>>>>
>>>> i probably wont be able to get the mux editor or settings working since i'm
>>>> not familiar with how the setup gui works.
>>>> but if i get a new optional mux setting for plp in place then i'm happy.
>>>>
>
> I wrote the original patch to add support for DVB-T2
> https://code.mythtv.org/trac/ticket/12342 .  In the UK we don't use PLP or it
> may have been that the tuner I had auto-detected but either way there was no
> need to add PLP support at the time.  If you follow that link it should
> indicate roughly where to add the DTV_STREAM_ID property.  It's a long time
> since I looked at this but let me know if I can help.
>
> David

thanks.
see below for a quick proof of concept patch that's mostly a hack to check that
it works.
with this i can get the hd channels to work.

now i need to make this into a proper patch by adding a new column to
dtv_multiplext table and reading that value in.
plus make sure it defaults to off, for example by using -1 to indicate it
should not be used.


---
diff --git a/mythtv/libs/libmythtv/recorders/dvbchannel.cpp
b/mythtv/libs/libmythtv/recorders/dvbchannel.cpp
index dbdf7adc11..f327cc3750 100644
--- a/mythtv/libs/libmythtv/recorders/dvbchannel.cpp
+++ b/mythtv/libs/libmythtv/recorders/dvbchannel.cpp
@@ -553,7 +553,7 @@ static struct dtv_properties *dtvmultiplex_to_dtvproperties(
if (!cmdseq)
return NULL;

- cmdseq->props = (struct dtv_property*) calloc(12, sizeof(*(cmdseq->props)));
+ cmdseq->props = (struct dtv_property*) calloc(13, sizeof(*(cmdseq->props)));
if (!(cmdseq->props))
{
free(cmdseq);
@@ -609,6 +609,12 @@ static struct dtv_properties *dtvmultiplex_to_dtvproperties(
cmdseq->props[c].cmd = DTV_HIERARCHY;
cmdseq->props[c++].u.data = tuning.hierarchy;
}
+ //PLP test
+ if (tuner_type == DTVTunerType::kTunerTypeDVBT2)
+ {
+ cmdseq->props[c].cmd = DTV_STREAM_ID;
+ cmdseq->props[c++].u.data = 1;
+ }

if (tuning.mod_sys == DTVModulationSystem::kModulationSystem_DVBS2)
{
--

_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Adding PLP support (DTV_STREAM_ID) [ In reply to ]
On 2018-02-03 16:55, Torbjorn Jansson wrote:
> On 2018-01-29 19:39, David Matthews wrote:
>> On 28/01/2018 17:49, Torbjorn Jansson wrote:
>>> On 2018-01-28 16:42, Peter Bennett wrote:
>>>>
>>>>
>>>> On 01/28/2018 08:12 AM, Torbjorn Jansson wrote:
>>>>> Hello.
>>>>>
>>>>> i have a few questions but first some background.
>>>>>
>>>>> several years ago i bought a usb based dvbt2 tuner with the intention to
>>>>> replace my pcie card.
>>>>> i picked a TT CT2-4650 since it was supposed to have linux support already.
>>>>> turned out that was not true since i got a newer version of it with no
>>>>> linux support, so with a bit of hacking on the drivers i was able to get
>>>>> it working due to the similarities with other cards.
>>>>>
>>>>> but i quickly realized i could not tune to any dvb-t2 mux, after a lot of
>>>>> troubleshooting i gave up and forgot about it.
>>>>>
>>>>> then a year or so later my dvb tv box broke down and i bought a new one
>>>>> (vu+ solo4k) and to my surprise it had the exact same issue.
>>>>> after even more troubleshooting i found out i need to set PLP ID to 1 for
>>>>> tuning to work on dvb-t2 muxes.
>>>>>
>>>>> so then i realized that must be the same problem with my ct2-4650 and it was.
>>>>> yesterday i got tvheadend working on the usb tuner successfully and thats
>>>>> the first time i got the usb tuner to do something useful.
>>>>>
>>>>> BUT channel scanning is not working, so mux must be setup manualy, that
>>>>> includes PLP ID and other paramters.
>>>>> so i think the drivers don't do auto detect like my pcie card does.
>>>>> and the downside of missing autodetect of plp is that most software dont
>>>>> know how to handle plp and this applies to mythtv too.
>>>>>
>>>>>
>>>>>
>>>>> so for mythtv to work with this card i need to convince the backend to
>>>>> specify plp when tuning.
>>>>> so a new mux paramter need to be added to database and then used during
>>>>> tuning.
>>>>> as i understand it this is done with a property called: DTV_STREAM_ID and
>>>>> i need to try to understand better how
>>>>> libs/libmythtv/recorders/dvbchannel.cpp works.
>>>>>
>>>>> can someone give me any pointers about this?
>>>>> to start with i'm happy with a proof of concept hack that sets
>>>>> DTV_STREAM_ID to 1 on all dvb-t2 tuning attempts, then if it works i can
>>>>> try and get a proper patch for it.
>>>>>
>>>>> i probably wont be able to get the mux editor or settings working since
>>>>> i'm not familiar with how the setup gui works.
>>>>> but if i get a new optional mux setting for plp in place then i'm happy.
>>>>>
>>
>> I wrote the original patch to add support for DVB-T2
>> https://code.mythtv.org/trac/ticket/12342 .  In the UK we don't use PLP or it
>> may have been that the tuner I had auto-detected but either way there was no
>> need to add PLP support at the time.  If you follow that link it should
>> indicate roughly where to add the DTV_STREAM_ID property.  It's a long time
>> since I looked at this but let me know if I can help.
>>
>> David
>
> thanks.
> see below for a quick proof of concept patch that's mostly a hack to check that
> it works.
> with this i can get the hd channels to work.
>
> now i need to make this into a proper patch by adding a new column to
> dtv_multiplext table and reading that value in.
> plus make sure it defaults to off, for example by using -1 to indicate it
> should not be used.
>

attached is my first version of adding plp support.
currently it is in a "works for me" state, a few things that is missing:
channel scanning is not adjusted, mux editor don't know about this new setting
and i haven't added the db update code needed.

so to test this you need to manually run:
ALTER TABLE dtv_multiplex ADD COLUMN plp_id SMALLINT;

the gui parts is not done because i haven't (yet) figured out how the settings
and gui work.

at a minimum the mux editor should have an option to set plp.
it should default to not setting plp by either leaving the column to NULL or
set it to -1
plp is only valid for dvb-t2 so maybe this gui setting should be hidden if it
is anything other than dvb-t2

according to the dvb api documentation apparently dvb-s2 also can use plp.
i have no way of testing this so it is not taken into account.


would be nice if someone can have a look at this patch because there are areas
i'm a little unsure of.
and also would be nice if someone else can test it to make sure i haven't
broken anything.
Re: Adding PLP support (DTV_STREAM_ID) [ In reply to ]
On 04/02/18 12:35, Torbjorn Jansson wrote:
>
> attached is my first version of adding plp support.
> currently it is in a "works for me" state, a few things that is missing:
> channel scanning is not adjusted, mux editor don't know about this new
> setting and i haven't added the db update code needed.
>
> so to test this you need to manually run:
> ALTER TABLE dtv_multiplex ADD COLUMN plp_id SMALLINT;
>
> the gui parts is not done because i haven't (yet) figured out how the
> settings and gui work.
>
> at a minimum the mux editor should have an option to set plp.
> it should default to not setting plp by either leaving the column to
> NULL or set it to -1
> plp is only valid for dvb-t2 so maybe this gui setting should be hidden
> if it is anything other than dvb-t2
>
> according to the dvb api documentation apparently dvb-s2 also can use plp.
> i have no way of testing this so it is not taken into account.
>
>
> would be nice if someone can have a look at this patch because there are
> areas i'm a little unsure of.
> and also would be nice if someone else can test it to make sure i
> haven't broken anything.
>

You need to make this part of the code conditional on the PLP ID being
set. You've initialized it to -1, and that's what should be checked
to verify that you need to send this option to the dvb card.

+ //PLP
+ if (tuner_type == DTVTunerType::kTunerTypeDVBT2)
+ {
+ cmdseq->props[c].cmd = DTV_STREAM_ID;
+ cmdseq->props[c++].u.data = tuning.plp_id >255 ||
tuning.plp_id<0 ? NO_STREAM_ID_FILTER : tuning.plp_id;
+ }



Regards
Stuart Auchterlonie
_______________________________________________
mythtv-dev mailing list
mythtv-dev@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-dev
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org