#!/usr/bin/perl # Andrew Daviel, TRIUMF, November 1997 # record_session for use with sdr, wrtp # based on an idea by Christoph Fleck which used rtpdump # This version uses CERN wrtp by Miguel.Chamochin # See http://csvod1.cern.ch/cgi-bin/nph-MBone-VCR # For use with sdr; this script must be called "record_session" and # must be on the user's PATH unless ($0 =~ /record_session$/) { print STDERR "For correct operation, this script must be named \"record_session\" not \"$0\"\n"; exit ; } if (!$ARGV[0]) { print <$ARGV[0].record") || die "Cannot create record script $ARGV[0].record" ; open (PLAY,">$ARGV[0].play") || die "Cannot create playbackscript $ARGV[0].play"; while () { $in .= $_ ; } $_ = $in ; #print $_ ; @line = (split("\012")) ; for ($i=0;$i<@line;$i++) { $_ = $line[$i] ; ($letter,$rest)=(/^(.)=(.+)/); if ($letter eq 'i') { # Info $description=$rest ; } elsif ($letter eq 's') { # Title $title=$rest ; } elsif ($letter eq 'u') { # URL $url=$rest; } elsif ($letter eq 'n') { # Announce # n=2358119139 2358119139 879461852 224.2.127.254 9875 ($ip1,$ip2,$annt,$anni,$nn) = split(/\s/,$rest); $ip1a = join(".",unpack("C4",pack("N",$ip1))) ; $ip2a = join(".",unpack("C4",pack("N",$ip2))) ; #print "ip1 $ip1a ip2 $ip2a\n" ; chop($annta = &main'ctime($annt)); } elsif ($letter eq 'o') { # Originator # o=kannan 3077640111 3078385359 IN IP4 128.9.160.67 #print "Created by $rest \n\n"; #print join(".",unpack("C4",pack("N",$ip1))),")\n\n"; } elsif ($letter eq 't') { # Time # t=3090267000 3090272400 ($tm1,$tm2) = split(/\s/,$rest); if ($tm1 && $tm2) { if ($tm1 > 0xffffffff) { # Probably got require 'bigint.pl'; # sign-extended by an # alpha running a buggy # version of sd. $tm1=&main'bmod($tm1,"4294967296"); $tm2=&main'bmod($tm2,"4294967296"); } $tm1 -= $sd_time; $tm2 -= $sd_time; $now = time ; if ($tm1 < $now) { $startnow++ ; $tm1 = $now ; } if ($tm2 < $now) { print STDERR "Too Late!\n" ; } chop($tm1a = &main'ctime($tm1)); chop($tm2a = &main'ctime($tm2)); $duration = $tm2 - $tm1 ; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($tm1) ; } } elsif ($letter eq 'a') { if ($media) { # print "$rest\n"; } else { # print "Session options: ",$rest,"\n\n"; } } elsif ($letter eq 'm') { # Media ($media,$port,$proto)=split(/\s/,$rest); $port{$media} = $port; $proto{$media} = $proto ; $_ = $line[$i+1] ; ($letter,$rest)=(/^(.)=(.+)/); if ($letter eq 'c') { # expect address info # c=IN IP4 224.2.253.119/191 ($in,$ip,$adrt) =split(/\s/,$rest); ($adrs{$media},$ttl{$media}) = split(/\//,$adrt) ; } else { print STDERR "ERROR - expect \"c=\" got $_\n"; } } } $name = $title ; $name =~ tr/A-Za-z0-9//cd ; print REC<