Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[linux-dvb] Re: VDR remote control



Hi!

* Andreas 'Count' Kotes <count@flatline.de> [20010530 13:10]:
> is someone working on a 'remote control' via TCP for VDR? SVDRP does
> support everything needed, but kvdr isn't really up to the job - it does
> too much, and only works correctly when used on the same machine as VDR.
> 
> I'm thinking about the ability to do a TCP connection to a VDR anywhere,
> to be able to see the current EPG info and program timers for it
> remotely. No video display or audio needed, mainly, 'just' the OSD part
> of VDR would suffice.

hmm. SVDRP is missing some commands which allow to control recording,
playback, forwarding, etc, regardless of positions or menus. The format
of the LSTE-entries appears undocumented, how about some information
about that?

> anybody doing anything like this? a gtk application would be best.

I've appended what I did so far. Currently still blocking code, and
missing lots of things, but it can zap remotely. More things to come.

   Count

-- 
Andreas Kotes - UIN: 3741366 - The views expressed herein are (only) mine.
You don't have to change the world... to change the world. You're either part
of the problem, part of the solution, or part of the scenery. Only you decide.

#!/usr/bin/perl -w
# 
# SVDRP client, preliminary version
# usage: gvdr [host [port]]
#
# Author: Andreas Kotes <count@linux.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#

use strict;
use Gtk;
init Gtk;
use Gtk::CListModel;
use Socket;
use IO::Handle;

# the channellist
my $channels = tie my @channel, 'Gtk::CListModel', titles => ["Channum", "Name","Freq","Polarization","X","X","X","X","X","X","X"];

# setup SVDRP connection
my ($remote,$port, $iaddr, $paddr, $proto, $line);
$remote  = shift || 'localhost';
$port    = shift || 2001;  # random port
if ($port =~ /\D/) { $port = getservbyname($port, 'tcp') }
die "No port" unless $port;
$iaddr   = inet_aton($remote)               || die "no host: $remote";
$paddr   = sockaddr_in($port, $iaddr);
$proto   = getprotobyname('tcp');
socket(SOCK, PF_INET, SOCK_STREAM, $proto)  || die "socket: $!";
connect(SOCK, $paddr)    || die "connect: $!";
SOCK->autoflush(1);
$line = <SOCK>;
print $line;

# close VDR connection
sub closevdr {
   print SOCK "QUIT\r\n";
   $line = <SOCK>;
   print $line;
   close (SOCK)            || die "close: $!";
 }

# refresh/load channellist
sub getchanlist {
   print SOCK "LSTC\r\n";
   my $done = 0;
   @channel = ();
   while (!$done) {
      ##print $line;
      $line = <SOCK>;
      if ($line =~ /^250([- ])(\d+)\s([^:]+):(\d+):(\S):(\d+):(\d+):(\d+):(\d+):(\d+):(\d+):(\d+)\r\n$/) {
         push @channel, [$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12];
       } else {
         print "no match: $line";
       }
      if ($1 eq " ") { $done = 1; }
    }
 }

# fetch current channel number
sub getchan {
   print SOCK "CHAN\r\n";
   $line = <SOCK>;
   print $line;
   if ($line =~ /250 (\d+)\s/) {
      return $1;
    } else {
      return 0;
    }
 }

# avoid SVDRP timeouts
sub timeoutcommand {
   print SOCK "CHAN\r\n";
   $line = <SOCK>;
   print $line;
   return 1;
 }

# switch channel
sub vdrzap {
   my ($channel) = @_;
   print SOCK "CHAN $channel\r\n";
   $line = <SOCK>;
   print $line;
 }

# populate channellist
getchanlist;

# generate objects
my $channelwindow    = new Gtk::Window;
my $scroller  = new Gtk::ScrolledWindow;
my $container = new Gtk::VBox(0);
my $button    = new Gtk::Button("Quit");

# 250 1431 INT2/3 RADIO:12436:h:1:27500:8191:85:0:1:9
my $channellist = $channels->create_view('channels', titles => ['Channum', 'Name']);

# signal handling
my $timeout = Gtk->timeout_add(150000,\&timeoutcommand,0);
$channellist->signal_connect("select-row", sub {my ($object,$channel) = @_;$channel++;vdrzap($channel)});
$button->signal_connect("clicked", sub {closevdr;Gtk->main_quit});
$channelwindow->signal_connect('destroy', sub {closevdr;Gtk->main_quit});

# construct interface
$channelwindow->set_title("Channellist");
$channelwindow->set_default_size(200,420);
$scroller->set_usize(200,400);
$button->set_usize(200,20);
$scroller->add($channellist);
$container->add($scroller);
$container->add($button);
$channelwindow->add($container);

# startup interface
$channelwindow->show_all;
Gtk->main;


-- 
Info:
To unsubscribe send a mail to listar@linuxtv.org with "unsubscribe linux-dvb" as subject.



Home | Main Index | Thread Index