Commit 1bf1e733 authored by paalmm's avatar paalmm

release av qstream 2011-11-09

parent 56c18552
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
# Base Olav Kvittem # Base Olav Kvittem
# Mpeg support Odd Rune Mykkeltveit Lykkbo, 2009-2010 # Mpeg support Odd Rune Mykkeltveit Lykkbo, 2009-2010
# Mos values computation Gurvinder Singh, 2010-05-07 # Mos values computation Gurvinder Singh, 2010-05-07
# XML, RTMP, TCP support, Pål Moen Møst, 2011.
# use Socket; # use Socket;
use IO::Socket qw(:DEFAULT :crlf); use IO::Socket qw(:DEFAULT :crlf);
...@@ -42,7 +43,7 @@ my ($rtmp,$period,$last,$debug,$swfurl,$pageurl,$flash_version,$reconnect); ...@@ -42,7 +43,7 @@ my ($rtmp,$period,$last,$debug,$swfurl,$pageurl,$flash_version,$reconnect);
require "newgetopt.pl"; require "newgetopt.pl";
@opts=('list', 'man','fullformat', 'net', 'rtp', 'mpeg', 'pcap', 'crude', 'bins=s', 'log', 'nperiod=s', 'period=s', 'last=s', 'packets=s', 'src=s', 'flow_key=s', 'flow_no=s', 'flow_min=s', 'nohead', 'dump=s', 'format=s', 'id=s', 'sum=s', 'ttl', 'rtt=s', 'codec=s', 'log', 'verbose', 'v', 'h', 'debug', 'av','xml=s', 'rtmp','tcp', 'port=s','swfurl=s','pageurl=s','flashversion=s','new','q','exclude=s','report=s'); @opts=('list', 'man','fullformat', 'net', 'rtp', 'mpeg', 'pcap', 'crude', 'bins=s', 'log', 'nperiod=s', 'period=s', 'last=s', 'packets=s', 'src=s', 'flow_key=s', 'flow_no=s', 'flow_min=s', 'nohead', 'dump=s', 'format=s', 'id=s', 'sum=s', 'ttl', 'rtt=s', 'codec=s', 'log', 'verbose', 'v', 'h', 'debug', 'av','xml=s', 'rtmp','tcp', 'port=s','swfurl=s','pageurl=s','flashversion=s','new','q','exclude=s','report=s', 'filename');
&NGetOpt(@opts) || die pod2usage(1); &NGetOpt(@opts) || die pod2usage(1);
die pod2usage(1) if $opt_h; die pod2usage(1) if $opt_h;
...@@ -137,6 +138,8 @@ my %dist2 = (); ...@@ -137,6 +138,8 @@ my %dist2 = ();
$opt_period = $opt_last if not $opt_period; $opt_period = $opt_last if not $opt_period;
$file_flag = 1 if $opt_filename;
#MPEG-TS END #MPEG-TS END
...@@ -196,6 +199,7 @@ if ($opt_pcap || ($opt_tcp && !$opt_rtmp)){ # listen in parallell ...@@ -196,6 +199,7 @@ if ($opt_pcap || ($opt_tcp && !$opt_rtmp)){ # listen in parallell
&end_xml() if $opt_xml; &end_xml() if $opt_xml;
exit(0); exit(0);
sub http_stream_client { sub http_stream_client {
my $f = shift; my $f = shift;
my $playlist = get("$f"); my $playlist = get("$f");
...@@ -205,33 +209,34 @@ sub http_stream_client { ...@@ -205,33 +209,34 @@ sub http_stream_client {
my $regex = "http://"; my $regex = "http://";
my $p_chunk; my $p_chunk;
while(1){ while(1){
foreach my $item (@list_items){ foreach my $item (@list_items){
my @tmp_streams= get("$item"); my @tmp_streams= get("$item");
if ($item=~ /$regex/g){ if ($item=~ /$regex/g){
foreach my $stream (@tmp_streams){ foreach my $stream (@tmp_streams){
if ($stream =~ /EXT-X-TARGETDURATION/){ if ($stream =~ /EXT-X-TARGETDURATION/){
my @temp = split(/:/,$stream); my @temp = split(/:/,$stream);
$duration = $temp[1]; $duration = $temp[1];
} }
if($stream !~ /#/g){ if($stream !~ /#/g){
push(@streams,$stream); push(@streams,$stream);
my $l = @streams; my $l = @streams;
my $current_chunk = $streams[$l-1]; my $current_chunk = $streams[$l-1];
if ($current_chunk ne $p_chunk){ if ($current_chunk ne $p_chunk){
my $data = get("$current_chunk"); my $data = get("$current_chunk");
$p_chunk = $current_chunk; $p_chunk = $current_chunk;
sleep(9); sleep(9);
}
} }
} }
} }
} }
} }
} }
}
sub get_stream { sub get_stream {
my $uri = shift; my $uri = shift;
my $data = get("$uri"); my $data = get("$uri");
} }
##TCP impl. -PMM ##TCP impl. -PMM
sub handle_threads { sub handle_threads {
$tcp_stop = 1; $tcp_stop = 1;
...@@ -660,7 +665,7 @@ sub eat_stream { ...@@ -660,7 +665,7 @@ sub eat_stream {
# my $select=IO::Select->new(Net::Pcap::fileno($pcap)); # my $select=IO::Select->new(Net::Pcap::fileno($pcap));
until ( ! $uninterrupted || $endstream || ($opt_packets && $n_packets > $opt_packets) until ( ! $uninterrupted || $endstream || ($opt_packets && $n_packets > $opt_packets)
|| ! (my $pkt=Net::Pcap::next($pcap, \%hdr) ) ) { || ! (my $pkt=Net::Pcap::next($pcap, \%hdr) ) ) {
$file_flag =1; #$file_flag =1;
eat_pcap($f, $pcap, $pkt); eat_pcap($f, $pcap, $pkt);
$n_packets++; $n_packets++;
} }
...@@ -1236,7 +1241,7 @@ sub xml_dump { ...@@ -1236,7 +1241,7 @@ sub xml_dump {
$stream_id_type_XML->addText($pts_stats{$f}{$pid}{'stream_id_type'}); $stream_id_type_XML->addText($pts_stats{$f}{$pid}{'stream_id_type'});
#mpeg #mpeg
$num_packets_XML->addText($mpeg_stats{$f}{$pid}{'num'}); $num_packets_XML->addText($mpeg_stats{$f}{$pid}{'num'});
$lost_packets_XML->addText($mpeg_stats{$f}{$pid}{'lost_packets'}); $lost_packets_XML->addText(&format_numbers($mpeg_stats{$f}{$pid}{'lost_packets'}));
$media_loss_rate_XML->addText($mpeg_stats{$f}{$pid}{'media_loss_rate'}); $media_loss_rate_XML->addText($mpeg_stats{$f}{$pid}{'media_loss_rate'});
$delay_factor_XML->addText(&format_numbers($mpeg_stats{$f}{$pid}{'delay_factor'})); $delay_factor_XML->addText(&format_numbers($mpeg_stats{$f}{$pid}{'delay_factor'}));
$media_bandwidth_XML->addText($mpeg_stats{$f}{$pid}{'media_bandwidth'}); $media_bandwidth_XML->addText($mpeg_stats{$f}{$pid}{'media_bandwidth'});
...@@ -2111,9 +2116,6 @@ sub mpeg_stats ...@@ -2111,9 +2116,6 @@ sub mpeg_stats
if ($tspack->is_valid() != 1) { if ($tspack->is_valid() != 1) {
print "not valid $j offsett: $offset reading: $var \n\n";
print "off @ret ...$n \n";
print "@hex_string \n\n";
next; } next; }
...@@ -2194,7 +2196,6 @@ sub pcr_update_stats ...@@ -2194,7 +2196,6 @@ sub pcr_update_stats
$tm2 = $pcr_stats{$f}{'running_dpcr_mean'}; $tm2 = $pcr_stats{$f}{'running_dpcr_mean'};
$pcr_stats{$f}{'running_dpcr_std'} = $ts + (($sample - $tm)*($sample - $tm2)); $pcr_stats{$f}{'running_dpcr_std'} = $ts + (($sample - $tm)*($sample - $tm2));
#Max/Min-checks for delta-PCR #Max/Min-checks for delta-PCR
if ($sample > $pcr_stats{$f}{'max_dpcr'}) { if ($sample > $pcr_stats{$f}{'max_dpcr'}) {
$pcr_stats{$f}{'max_dpcr'} = $sample; $pcr_stats{$f}{'max_dpcr'} = $sample;
...@@ -2364,6 +2365,9 @@ sub init_dwell{ ...@@ -2364,6 +2365,9 @@ sub init_dwell{
sub check_continuity sub check_continuity
{ {
my ($f,$pid, $cc, $discont, $payload) = @_; my ($f,$pid, $cc, $discont, $payload) = @_;
if (!exists $mpeg_stats{$f}{$pid}{'lost_packets'}){
$mpeg_stats{$f}{$pid}{'lost_packets'} = 0;
}
if (not exists $last_ccs{$pid}) { if (not exists $last_ccs{$pid}) {
return; return;
...@@ -3705,6 +3709,8 @@ usage="$0 [option]... [file...|ip/|:port]... ...@@ -3705,6 +3709,8 @@ usage="$0 [option]... [file...|ip/|:port]...
=item B<-pcap> listen to all multicast groups with pcap at the same time. =item B<-pcap> listen to all multicast groups with pcap at the same time.
=item B<-filename> print filename as source.
=item B<-period> seconds - period in seconds between stats output =item B<-period> seconds - period in seconds between stats output
=item B<-nperiod> number of periodes =item B<-nperiod> number of periodes
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment