X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=SkypeAPI.pm;h=2b522ccce05974f14e8285545831b346b583ff23;hb=f513dc73d0a63af2547af4a2fd7a4e6bbebbd41f;hp=60aa30636ef2fc2361f3a840e158c90bbc43c549;hpb=3caa6f46f2f1a1f88e9aa47891ccab8ab2888b04;p=skype-conference-recorder.git diff --git a/SkypeAPI.pm b/SkypeAPI.pm index 60aa306..2b522cc 100644 --- a/SkypeAPI.pm +++ b/SkypeAPI.pm @@ -56,7 +56,17 @@ sub Notify { # only print to terminal. override this in a subclass for something # more useful. my ($self, $string) = @_; - print "-> $string\n"; + print "Notify <- $string\n"; + if ( $string =~ m{CHATMESSAGE (\d+) STATUS RECEIVED} ) { + my $id = $1; + my $body = $self->Invoke("GET CHATMESSAGE $id BODY"); + print "# $body\n"; + my $chat = $self->Invoke("GET CHATMESSAGE $id CHATNAME"); + my $o = $self->Invoke($body); + print "# $o\n"; + $self->Invoke("CHATMESSAGE $chat $o"); + } + # be careful with what you return here! DBus will try to serialize it, # returning it to skype. you should explicitely return something # simple to avoid to leak something unserializable, causing odd errors. @@ -67,7 +77,13 @@ sub Invoke { # this doesn't print $string, so that subclasses can call it without # that side effect. subclass it yourself if you want it to do that. my ($self, $string) = @_; - return $self->{invoker}->Invoke($string); + print "Invoke -> $string\n"; + my $response = $self->{invoker}->Invoke($string); + print "Invoke <- $response\n"; + if ( $string =~ s/^get //i ) { + $response =~ s/^\Q$string\E *//; + } + return $response; } package Example; # ------------------------------------------------------------ @@ -90,6 +106,37 @@ sub Notify { # away mode is no good! let's be not available $self->Invoke('SET USERSTATUS NA'); } + + if ( $string =~ m{CALL (\d+) STATUS RINGING} ) { + $self->Invoke("ALTER CALL $1 ANSWER"); + } elsif ( $string =~ m{CALL (\d+) STATUS INPROGRESS} ) { + my $call_id = $1; + my $port = 5000 + $call_id; + + my $gst = qq{ + gst-launch -v + tcpserversrc port=$port ! + "audio/x-raw-int,rate=16000,width=16,channels=1" ! + wavenc ! + filesink location=/tmp/$port.wav + }; + $gst =~ s{[\s\n\r]+}{ }gs; + + warn "# $gst\n"; + open(my $g, '-|', $gst) || die $!; + while(<$g>) { + warn "## $_"; + last if m/PREROLL/; + } + + $self->Invoke(qq|ALTER CALL $call_id set_output port="$port"|); + } elsif ( $string =~ m{CALL (\d+) STATUS FINISHED} ) { + my $port = $1 + 5000; + my $path = "/tmp/$port.wav"; + warn "# $path ", -s $path, " bytes\n"; +# } elsif ( $string =~ m{} ) { + } + return 0; }