Hi,
Some friends asked me to modify vdr/write a plugin, because their boxes boot so fast that most of the hardware is not initialized by the time vdr can start. They had to delay it or had to restart vdr when they think the hardware is ready. But since some pci-cards are 'fast enough' they would like to attach the 'slow' cards later while using the 'fast' cards for watching, recording etc. as soon as possible. So 'dynamite' was born (just some kind of wordplay with 'dynamic' and it sounds more 'bombastic' and effective in advertising than 'dyndev' or whatever). :-)
It's clear that this can't be done without patching the device handling inside vdr, so attached is my patch against vdr 1.7.17. It is designed in such a way that the original behaviour of vdr is not changed if the dynamite plugin is not loaded. I know that it is pretty invasive but it is as small as I could to do it. My knowledge of the inner relations of the various classes is certainly limited but I spent hours and hours on reading the source. And it is tested by a brave crew of volunteers. Nonetheless I would like to hear some remarks from the vdr-experts out there.
In the following lines I will try to explain what this patch-plugin-combination is able to do and how it's done. It's a bit lengthy but it's important to me and I know it wouldn't get integrated at all if I don't give a wider overview about the concepts and ideas behind this.
Features: - attach/detach devices While vdr is running you can dynamically attach/detach (unused) receiving devices to/from it. This could be a DVB-USB-stick or a very slow initialising piece of hardware (firmware load etc.).
New devices are detected via udev, detaching should be made manually. If a frontend is in use udev is not sending a corresponding signal, there are just some messages from the usb subsystem, for example. The mapping to the right frontend and detaching it automatically is not trivial (in other words: it's on the TODO list). Also OSD integration is completely missing but will be added in the future.
For attaching/detaching there are SVDRP commands (and Service calls for other plugins): PLUG dynamite ATTD /dev/dvb/adapter0/frontend0 PLUG dynamite DETD /dev/dvb/adapter0/frontend0
For a complete list of commands please read the README[1].
- set device on idle You can set a device to 'idle' mode. It will be ignored by the EIT scanner and closes all its handles. This is handy if you have enough tuners and want so save some power or preserve some frontends from being 'always on'. This is also a 'manual' feature, some kind of automatism is planned (some kind of timeout or similar). Of course it will be 'reanimated' automatically if a recording is starting or someone wants to look live-tv.
- GetTSPacket timeout It is possible to set a 'GetTSPacket' timeout on the devices. If a device delivers no data for some time it can be automatically detached. This is intended for devices which has known unstable drivers. After detaching such a device a script is started so the driver can be reloaded and the device can be attached again to the vdr (this could happen on its own if the created frontend is signaled by udev). It avoids restarts of vdr and interrupting recordings on other devices.
How this all is achieved: The class cDevice is extended by two fields: parentDevice and subDevice. The dynamite plugin provides a class derived from cDevice which passes all calls to its methods to its subDevice if one is attached. Otherwise it returns the appropriate values so vdr does think it can't receive anything (like the dummydevice output-plugin which can play everything). On the other side there are some methods in cDevice which have to be "parentDevice-aware", since they are called from other derived devices or classes inside vdr. Since parentDevice (and subDevice) are always NULL if dynamite isn't loaded, it's easy to preserve the original behaviour.
To get the cDynamicDevice between the vdr and the device-creating plugins dynamite is doing two things: - it registers a cDvbDeviceProbe-object and moves it to the front of the list - the patch adds a second list 'cDynamicDeviceProbe' for 'dynamite-aware' plugins (like pvrinput as an example)
On startup when vdr iterates through the dvb-devices dynamite captures all devices and adds a cDynamicDevice for every one to the global vdr-device-array. It asks all other cDvbDeviceProbes if they would like to create a device and attaches this as a subDevice. If no cDvbDeviceProbe is left it creates a core cDvbDevice on its own. After this it creates enough cDynamicDevice objects to flood the vdr-device-array. This ensures that vdr and other plugins always communicate with the devices through dynamite (like CAM, CI etc.) and so there is enough room for devices which will be attached later. If you use plugins which create (non-dvb-)devices which can't be handled by dynamite (like xine, iptv, streamdev etc.) they have to be loaded *before* dynamite. Actually it's best to load dynamite as the *last* plugin because then it can ensure that its cDvbDeviceProbe will be the first one. The dirtiest part of the patch is the modification of the constructor of cDevice. If the new 'parentDevice' parameter would be made non-optional, I don't have to use this ugly global placeholder... If it really gets integrated in vdr (I don't abandon hope on this), that would definitly gets cleaned up. But that would force changes on many plugins so I chose 'the dirty way'.
Plugins which would like to use the functionallity of dynamite had to alter their device detection in their startup phase: - if dynamite is loaded just register a cDynamicDeviceProbe object and use the helper function QueueDynamicDeviceCommand from cDynamicDeviceProbe to queue the strings it needs to create the device objects. - if dynamite is not present create the devices like before - make sure you close all handles on destruction at the latest
Look at pvrinput[3] as an example (cPvrDevice::Initialize at device.c:269 and at the end of that file) pvrinput uses strings like '/dev/video0' to identify the device it has to create. But these 'attach'-strings doesn't necessarily need to be real device paths. It's just a parameter to the Attach method of your cDynamicDeviceProbe object - so your fantasy limits the possibilities. :-) In the dynamite source you'll find a cDynamiteDeviceProbe which reacts on strings like 'dummydevice0' or 'dummydevice1'. It helped me while developing the SVDRP commands since I had only one DVB-T stick at my dev-vdr. You can activate it with a commandline argument.
There are some caveats if you would like to use other patches together with dynamite if they also extend cDevice. Every new method has to be investigated if it should return its own value or the one of the parentDevice or subDevice (if it's present). And every new virtual method has to be added to cDynamicDevice at the dynamite plugin. If I had 'the power' I would integrate the functionality of cDynamicDevice completly into cDevice and leave the controlling at the plugin - but I'm realistic enough to know, that that would need a lot of convincing for my part... :-) As an example I added a reworked version of the lnb-sharing-patch to my repository[2]. Also I include some methods added by the patches yaVDR uses since this is my preferred distribution.
So, anything left to say? It took me a while to write all this stuff down so for now I don't know if I had forgotten something important or not. I'm looking forward for comments.
Of course I'm never responsible for broken or missed recordings (as no one is)! :-)
Thanks for reading!
Regards, Lars. -- P.S.: If you have a Sundtek stick and are interested in dynamite, please check out the sundtek-plugin[4]. It monitors devices via the libmedia/mediasrv and can even react on unplugging a device which is in use. -- [1] http://projects.vdr-developer.org/projects/plg-dynamite/repository/revisions... [2] git://projects.vdr-developer.org/vdr-plugin-dynamite.git [3] http://projects.vdr-developer.org/projects/plg-pvrinput [4] https://github.com/flensrocker/vdr-plugin-sundtek
"L. Hanisch" dvb@flensrocker.de writes:
Features:
- attach/detach devices
[...]
- set device on idle
[...]
- GetTSPacket timeout
It is possible to set a 'GetTSPacket' timeout on the devices. If a device delivers no data for some time it can be automatically detached. This is intended for devices which has known unstable drivers. After detaching such a device a script is started so the driver can be reloaded and the device can be attached again to the vdr (this could happen on its own if the created frontend is signaled by udev). It avoids restarts of vdr and interrupting recordings on other devices.
Thanks for that ! I'll be trying your patch this week end ! This is probably one of my most wanted vdr feature and it sounds like you've just implemented it :)
questions : - have you considered changing the way vdr detects adapter on startup ? for instance vdr won't detect /dev/dvb/adapter1 if /dev/dvb/adapter0 does not exist. this might happen when using udev rules and restarting vdr while a module isn't loaded
- what about being able to use aliases like /dev/dvb/dvb_s2_card_one with the -D arg ? (tho it's not really important)
- what about a github tree of vdr with your patch already applied ?
"L. Hanisch" dvb@flensrocker.de writes: questions :
- have you considered changing the way vdr detects adapter on startup ? for instance vdr won't detect /dev/dvb/adapter1 if /dev/dvb/adapter0 does not exist. this might happen when using udev rules and restarting vdr while a module isn't loaded
Not sure what you mean. There is no reason anymore to restart vdr, even not after resume from suspend2ram. Dynamite is signaled by udev that a new adapter is detected. So it is not important whether the vdr sees an adapter, or not.
- what about a github tree of vdr with your patch already applied ?
I know it is not what you asked for, but the vdr 1.7.17 in the unstable-vdr PPA from yaVDR uses the plugin already.
Gerald
Hi,
Am 24.03.2011 01:57, schrieb syrius.ml@no-log.org:
"L. Hanisch"dvb@flensrocker.de writes:
Features:
- attach/detach devices
[...]
- set device on idle
[...]
- GetTSPacket timeout
It is possible to set a 'GetTSPacket' timeout on the devices. If a device delivers no data for some time it can be automatically detached. This is intended for devices which has known unstable drivers. After detaching such a device a script is started so the driver can be reloaded and the device can be attached again to the vdr (this could happen on its own if the created frontend is signaled by udev). It avoids restarts of vdr and interrupting recordings on other devices.
Thanks for that ! I'll be trying your patch this week end ! This is probably one of my most wanted vdr feature and it sounds like you've just implemented it :)
Cool, nice to hear! :)
questions :
- have you considered changing the way vdr detects adapter on startup ? for instance vdr won't detect /dev/dvb/adapter1 if /dev/dvb/adapter0 does not exist. this might happen when using udev rules and restarting vdr while a module isn't loaded
If all devices are loaded after the start of vdr every device will be attached regardless of its adapter nr. But if it gets initialized before the startup it might get overseen (which might be intended by some users). I'll think about some kind of udev-device-enumration at startup. BTW the -D argument of vdr is ignored for now - have to implement that as well.
what about being able to use aliases like /dev/dvb/dvb_s2_card_one with the -D arg ? (tho it's not really important)
what about a github tree of vdr with your patch already applied ?
Maybe - shouldn't be too bad. :)
Thanks, Lars.
what about being able to use aliases like /dev/dvb/dvb_s2_card_one with the -D arg ? (tho it's not really important)
what about a github tree of vdr with your patch already applied ?
Maybe - shouldn't be too bad. :)
Maybe just adding a patch branch to http://projects.vdr-developer.org/git/?p=vdr.git;a=summary ? It could also contain some other known patches for 17.7, like the vdr-1.7.17-updatemarks-2.diff or vdr-1.7.17-updatemarks-3.diff...
Mika
Am Donnerstag, den 24.03.2011, 11:38 +0200 schrieb Mika Laitio:
what about being able to use aliases like /dev/dvb/dvb_s2_card_one with the -D arg ? (tho it's not really important)
what about a github tree of vdr with your patch already applied ?
Maybe - shouldn't be too bad. :)
Maybe just adding a patch branch to http://projects.vdr-developer.org/git/?p=vdr.git;a=summary ? It could also contain some other known patches for 17.7, like the vdr-1.7.17-updatemarks-2.diff or vdr-1.7.17-updatemarks-3.diff...
maybe kls adopts all this patches in vdr-1.7.18 ?
Mika
vdr mailing list vdr@linuxtv.org http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr
Hi
Am Donnerstag, 24. März 2011 schrieb Holger Schvestka:
Am Donnerstag, den 24.03.2011, 11:38 +0200 schrieb Mika Laitio:
[...] Maybe just adding a patch branch to http://projects.vdr-developer.org/git/?p=vdr.git;a=summary ? It could also contain some other known patches for 17.7, like the vdr-1.7.17-updatemarks-2.diff or vdr-1.7.17-updatemarks-3.diff...
maybe kls adopts all this patches in vdr-1.7.18 ?
Even if kls does not adopt this patch that fast, I will not add it to the above git repository. That GIT is maintained by me and it will contain only releases provided by kls. That is and will remain its intended purpose.
Of course one of the intentions of that GIT is it to be cloned :) Host the clone on http://projects.vdr-developer.org and and apply the patch you mentioned yourself.
The site projects.vdr-developer.org is open for everybody who want's to host a vdr related project ;)
Regards Tadi
Hi,
Am 24.03.2011 01:57, schrieb syrius.ml@no-log.org:
questions :
- have you considered changing the way vdr detects adapter on startup ? for instance vdr won't detect /dev/dvb/adapter1 if /dev/dvb/adapter0 does not exist. this might happen when using udev rules and restarting vdr while a module isn't loaded
dynamite 0.0.6 now uses udev device enumeration to detect all dvb frontends regardless of their numbering. If you would like to keep an adapter from being used by vdr you can set an udev environment property on that device.
The following would ensure that /dev/dvb/adapter2/frontend* is not attached:
ACTION=="add", SUBSYSTEM=="dvb", ENV{DVB_ADAPTER_NUM}=="2", ENV{dynamite_attach}="no"
This acts as an replacement for the "-D" option of the core vdr. Since the card index of dynamically attached devices are not necessarily related to their adapter number it wouldn't work as expected any more. (the -D option is only used in the vdr internal dvb device enumeration - if you add a device afterwards it would get attached even if it gets a "forbidden" adapter nr)
If you run multiple instances of vdr with different ids (option -i) you can associate the devices to the different vdrs with the property "dynamite_instanceid".
This attaches /dev/dvb/adapter2/frontend* to "vdr -i 1" and all other adapter to "vdr -i 0":
ACTION=="add", SUBSYSTEM=="dvb", ENV{DVB_ADAPTER_NUM}!="2", ENV{dynamite_instanceid}="0" ACTION=="add", SUBSYSTEM=="dvb", ENV{DVB_ADAPTER_NUM}=="2", ENV{dynamite_instanceid}="1"
Regards, Lars.
"L. Hanisch" dvb@flensrocker.de writes:
- have you considered changing the way vdr detects adapter on startup ? for instance vdr won't detect /dev/dvb/adapter1 if /dev/dvb/adapter0 does not exist. this might happen when using udev rules and restarting vdr while a module isn't loaded
dynamite 0.0.6 now uses udev device enumeration to detect all dvb frontends regardless of their numbering. If you would like to keep an adapter from being used by vdr you can set an udev environment property on that device.
Hi !
Thanks a lot ! I'm using 0.0.6b and the new udev rules. My setup is : - first vdr (the one in production that has to be working, especially when i'm not @home) genuine vdr 1.7.17, 2 dvb-s cards, diseqc
- 2nd vdr dynamite vdr 1.7.17, 1 dvb-s ff card which keeps crashing + 1 dvb-t usb stick
It is working perfectly, i haven't tried to remove/add adapter yet. I will do later today.
Just another question: When i decide to only use one vdr instance, i'll be needing the diseqc trick in diseqc.conf (the one that replaces the sourcecaps patch), how do you think it could work ? I guess the quickest workaround would be to add a new udev param to force the card index in vdr.
I've been having issues with udev rules to order dvb devices in the past, instead i'm using a simple simple script that gives vdr the correct card number. ex: vdr $(get-dvb-device.sh main) "get-dvb-devices.sh main" returns "-D 1 -D 4" for example. that way i'm sure my main vdr always uses my two stable dvb-s cards
Hi,
Am 28.03.2011 12:24, schrieb syrius.ml@no-log.org:
"L. Hanisch"dvb@flensrocker.de writes:
- have you considered changing the way vdr detects adapter on startup ? for instance vdr won't detect /dev/dvb/adapter1 if /dev/dvb/adapter0 does not exist. this might happen when using udev rules and restarting vdr while a module isn't loaded
dynamite 0.0.6 now uses udev device enumeration to detect all dvb frontends regardless of their numbering. If you would like to keep an adapter from being used by vdr you can set an udev environment property on that device.
Hi !
Thanks a lot ! I'm using 0.0.6b and the new udev rules. My setup is :
first vdr (the one in production that has to be working, especially when i'm not @home) genuine vdr 1.7.17, 2 dvb-s cards, diseqc
2nd vdr dynamite vdr 1.7.17, 1 dvb-s ff card which keeps crashing + 1 dvb-t usb stick
It is working perfectly, i haven't tried to remove/add adapter yet. I will do later today.
Thanks for testing this!
Just another question: When i decide to only use one vdr instance, i'll be needing the diseqc trick in diseqc.conf (the one that replaces the sourcecaps patch), how do you think it could work ? I guess the quickest workaround would be to add a new udev param to force the card index in vdr.
I only have DVB-C and only limited knowledge about DVB-S, Diseqc and all this stuff. But I found a description of the sourcecaps patch. When I have read and understood it, I'll get in touch with you. It seems possible to configure this via udev and solve it with a device hook. But I haven't tried it and don't know exactly how the device hooks works. (a little bit of brainstorming)
I've been having issues with udev rules to order dvb devices in the past, instead i'm using a simple simple script that gives vdr the correct card number. ex: vdr $(get-dvb-device.sh main) "get-dvb-devices.sh main" returns "-D 1 -D 4" for example. that way i'm sure my main vdr always uses my two stable dvb-s cards
Regards, Lars.
"L. Hanisch" dvb@flensrocker.de writes:
Hi,
It is working perfectly, i haven't tried to remove/add adapter yet. I will do later today.
Thanks for testing this!
No issues with detaching and reattaching, that's a very nice feature !
Just another question: When i decide to only use one vdr instance, i'll be needing the diseqc trick in diseqc.conf (the one that replaces the sourcecaps patch), how do you think it could work ? I guess the quickest workaround would be to add a new udev param to force the card index in vdr.
I only have DVB-C and only limited knowledge about DVB-S, Diseqc and all this stuff. But I found a description of the sourcecaps patch. When I have read and understood it, I'll get in touch with you. It seems possible to configure this via udev and solve it with a device hook. But I haven't tried it and don't know exactly how the device hooks works. (a little bit of brainstorming)
Ok, Thanks again for that. I wish i wasn't that clueless about c++ and vdr internals.