kamaitachi - perl flash media server
YAPC::Asia 2009 Tokyo
Sep 11th, 2009
FMS
- Media player for Adobe Flash Player
- RTMP protocol
- AMF data format for RPC
FMS
- RPC (similar to XMLRPC/JSONRPC)
- Shared Object (share some flash objects in multiple client)
- Media Streaming
- Record Streaming
WebServices using FMS
- ustream.tv
- justin.tv
- ニコニコ動画 (生放送)
FMS implementations
- Adobe Flash Media Server
- wowza
- red5
- rubyizumi
- etc.. google code search: "RTMP"
All implementation sucks because it's not "Perl"
You should write ActionScript for Adobe's FMS
Java for red5
XML for wowza
Perl for kamaitachi
:)
with perl
- Code sharing with other perl application
- Much less bugs (maybe..)
kamaitachi supports
- RTMP only (not RTMPE/RTMPT)
- RPC
- Media streaming
- Media recording
RPC
- Remote Procedure Call like XMLRPC
- use AMF (Action Message Format)
package Service::Echo;
use Moose;
extends 'Kamaitachi::Service';
with 'Kamaitachi::Service::AutoConnect';
sub on_invoke_echo {
my ($self, $session, $req) = @_;
$req->response(@{ $req->args });
}
__PACKAGE__->meta->make_immutable;
my $kamaitachi = Kamaitachi->new;
$kamaitachi->register_services(
'rpc' => 'Service::Echo',
);
$kamaitachi->run;
nc = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS, status_handler);
nc.objectEncoding = ObjectEncoding.AMF0;
nc.connect("rtmp:/rpc");
// or
// nc.connect("rtmp://hostname/rpc");
nc.call("echo", new Responder(EchoResponseHandler), "foo bar");
Demo
RTMP Hacking tips
...
RTMP Hacking tips
- Read the source of other implementations
...
RTMP Hacking tips
- Read the source of other implementations
- Analyze packet stream by Sniffer::RTMP
...
RTMP Hacking tips
- Read the source of other implementations
- Analyze packet stream by Sniffer::RTMP
- Don't read adobe's RTMP spec! (fuking LICENSE)
Sniffer::RTMP
Sniffer::RTMP->new(
filter => "tcp port $port",
device => 'en1',
callbacks => {
notify => \&log_method,
invoke => \&log_method,
# ...
},
)->run;
Demo
Demo (FW--)
Demo
sudo ./script/rtmp_flvdump.pl en1 ustream.flv
and open ustream live in your browser
(the script is bundled in Sniffer::RTMP)
Future plan
- support SharedObject
- AnyEvent? (currently Danga::Socket)
- support streaming static media file. (lestrrat++ for perl bindings for libavcodec)
Thank you!