It will take time to have a look at your code.
Just to let you know: The current pvrinput source allows to execute a script on every channel change. Have a look at "externchannelswitch" in http://projects.vdr-developer.org/repositories/entry/plg-pvrinput/README
We won't support the usage of lirc transmitters directly in the plugin, but you could do it with an own binary.
Greets, Martin