Commit b25e39a3 authored by paalmm's avatar paalmm
Browse files

-test added and testsets for rtp and mpeg

parent 685f762c
......@@ -45,7 +45,7 @@ my ($rtmp,$period,$last,$debug,$swfurl,$pageurl,$flash_version,$reconnect);
require "";
@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','test','ipv6','p=s','name=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','test','ipv6','p=s','name=s','tcp_t');
&NGetOpt(@opts) || die pod2usage(1);
die pod2usage(1) if $opt_h;
......@@ -175,7 +175,14 @@ if ($opt_dump){
open DUMP, ">$opt_dump";
&unit_test if $opt_test;
if ($opt_test){
if($opt_mpeg || $opt_rtp || $opt_tcp_t){
else {
print "You need to choose a test. (mpeg, tcp or rtp) \n";
if ($opt_pcap || ($opt_tcp && !$opt_rtmp)){ # listen in parallell
alarm($opt_last) if $opt_last;
......@@ -214,9 +221,12 @@ exit(0);
sub unit_test {
my $test_data = shift;
#streams = "rtp_158.38.130.110_6711_1.pcap";
@streams = "testing/testdata_mpeg.pcap" if $opt_mpeg;
@streams = "testing/testdata_rtp.pcap" if $opt_rtp;
@streams = "testing/testdata_tcp.pcap" if $opt_tcp;
if ($opt_mpeg){
@streams = "testing/pcap/testdata_mpeg.pcap";
@filter = qw "video audio";
@streams = "testing/pcap/testdata_rtp.pcap" if $opt_rtp;
@streams = "testing/pcap/testdata_tcp.pcap" if $opt_tcp_t;
$opt_xml = "tmp_testdata.xml";
$opt_q = 1;
$opt_v = 1;
......@@ -225,25 +235,35 @@ sub unit_test {
sub unit_test_2{
#my ($orgnial_test) = &feed_data("file",rtp_file.xml);
my $test_data;
$test_data = "mpeg_testdata.xml" if $opt_mpeg;
$test_data = "rtp_testdata.xml" if $opt_rtp;
$test_data = "testing/xml/testdata_mpeg.xml" if $opt_mpeg;
$test_data = "testing/xml/testdata_rtp.xml" if $opt_rtp;
#$test_data = "udp_testdata" if $opt_net;
$test_data = "tcp_testdata.xml" if $opt_tcp;
$test_data = "testing/xml/testdata_tcp.xml" if $opt_tcp;
my ($orginal_test) = &xml_parser($test_data);
my ($new_test) = &xml_parser("tmp_testdata.xml");
print Dumper($orginal_test), "\n", Dumper($new_test)if $opt_debug;
my $ignore_pattern = "jitter"; #PCR jitter is based on delta local time.
my $ignore_pattern2 = "dwell";
my $ignore_pattern3 ="delay_factor";
my $ignore_pattern4 ="gap";
print "Checking values ....\n";
for my $k1(keys %$orginal_test){
if ($orginal_test->{ $k1} != $new_test->{ $k1} and $orginal_test->{ $k1} !~ m/HASH/) {
print "different value @ $k1, value: $orginal_test->{$k1}, differs from value: $new_test->{$k1}\n";
else {
printf "%2s %2s\n", "OK @ ", "$k1 ";
for my $k2 ( keys %{$orginal_test->{ $k1}} ) {
if ( ($orginal_test->{ $k1}{$k2} != $new_test->{ $k1}{$k2}) and ($k2 !~ m/$ignore_pattern/)){
if ( ($orginal_test->{ $k1}{$k2} != $new_test->{ $k1}{$k2}) and ($k2 !~ m/$ignore_pattern/) and ($k2 !~ m/$ignore_pattern2/) and ($k2 !~ m/$ignore_pattern3/) and ($k2 !~ m/$ignore_pattern4/)){
print "different value @ $k1-> $k2, value: $orginal_test->{$k1}{$k2} differs from, value: $new_test->{$k1}{$k2}\n";
print "Test complete \n";
sub xml_parser {
my $file = shift;
my $parser = new XML::DOM::Parser;
......@@ -268,7 +288,6 @@ foreach my $child ($node->getChildNodes()) {
foreach my $grandchild ($child->getChildNodes()){
if ($grandchild->getNodeType == ELEMENT_NODE){
#print $grandchild->getNodeName(), "\n";
eval {
$test_hash{$child->getNodeName().$dup}{$grandchild->getNodeName()}= $grandchild->getFirstChild()->getData();
......@@ -1148,7 +1167,7 @@ sub xml_dump {
my $dateXML = $doc->createElement('date');
my $timeXML = $doc->createElement('time');
my $spanXML = $doc->createElement('span');
my $pcr_jitter_parrent = $doc->createElement('pcr_jitter');
my $pcr_jitter_parrent = $doc->createElement('pcr_jitter') if $opt_mpeg;
my $network_info_parrent = $doc->createElement('network_info');
......@@ -1157,7 +1176,7 @@ sub xml_dump {
$flow->appendChild($pcr_jitter_parrent) if $opt_mpeg;
my $media="file";
$media = "host:port" if $opt_net;
my $id=$f;
......@@ -3861,6 +3880,10 @@ usage="$0 [option]... [file...|ip/|:port]...
=item B<-net> open network stream rather than file(s)
=item B<-ipv6> Listen to Ipv6 connections. Port needs to be defined with -p
=item B<-p> Set port.
=item B<-crude> the log is from crude
=item B<-bins> bins for gaps in ms : b1,b2,,,
......@@ -3897,6 +3920,8 @@ usage="$0 [option]... [file...|ip/|:port]...
=item B<-id name> - report name instead of flow_key in flows
=item B<-name name> - costume name for the tag flow_name in option -xml
=item B<-sum name> - make a summary of all flows to name rather than per flow
=item B<-ttl> - print ttl values for stream
......@@ -3913,6 +3938,8 @@ usage="$0 [option]... [file...|ip/|:port]...
=item B<-q> quiet, dont print anything to STDOUT.
=item B<-test> Run tests on different datasets. Needs to be used with option -rtp or -mpeg.
=head2 MPEG-TS
......@@ -4011,10 +4038,14 @@ Dwell time is for audio and video are measure seperatly.
see also, PCR
=item B<Stream id>
=item B<PID>
The program id (PID) for the transport stream.
The packet id (PID) for the transport stream.
=item B<Stream id/Stream id type>
The id that represent stream type.
=item B<MPEG TS packets>
......@@ -4091,6 +4122,17 @@ Listen to a TCP while running -RTMP option.
=head1 Test
mpeg test running: qstream testing/pcap/testdata_mpeg.pcap -mpeg -report audio,video -V
rtp tset running: qstream testing/pcap/testdata_rtp.pcap -rtp -V
Datasets for testing are found in testing/pcap and testing/xml.
=head1 Debian/Ubuntu dependecies
use strict;
use warnings;
#Test 1 -mpeg
system(".././ testdata.pcap -mpeg -packets 5000 -new -report video");
#Test 2 -rtp
#Test 3 -rtmp
#Test 4 -tcp
#Test 5 -udp
<?xml version="1.0"?>
<qstream version="1.0">
<?xml version="1.0"?>
<qstream version="1.0">
<?xml version="1.0"?>
<qstream version="1.0">
Supports Markdown
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