annotate mp4.t @ 1585:bff287fbf347

Tests: added proxy_cookie_domain/path tests with "off" parameter.
author Sergey Kandaurov <pluknet@nginx.com>
date Thu, 23 Jul 2020 12:17:39 +0300
parents 3ff92feb99d1
children 8659123d2d37
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
384
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1 #!/usr/bin/perl
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3 # (C) Sergey Kandaurov
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
4 # (C) Nginx, Inc.
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
5
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
6 # Tests for mp4 module.
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
7 # Ensures that requested stream duration is given with sane accuracy.
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
8
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
9 ###############################################################################
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
10
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
11 use warnings;
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
12 use strict;
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
13
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
14 use Test::More;
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
15
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
16 BEGIN { use FindBin; chdir($FindBin::Bin); }
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
17
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
18 use lib 'lib';
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
19 use Test::Nginx;
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
20
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
21 ###############################################################################
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
22
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
23 select STDERR; $| = 1;
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
24 select STDOUT; $| = 1;
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
25
389
c24d1c0b4c73 Tests: fixed invocation of has_daemon().
Sergey Kandaurov <pluknet@nginx.com>
parents: 388
diff changeset
26 my $t = Test::Nginx->new()->has(qw/http mp4/)->has_daemon('ffprobe')
c24d1c0b4c73 Tests: fixed invocation of has_daemon().
Sergey Kandaurov <pluknet@nginx.com>
parents: 388
diff changeset
27 ->has_daemon('ffmpeg')
390
7a65ebfdb02e Tests: skip mp4 if ffmpeg does not support lavfi format.
Sergey Kandaurov <pluknet@nginx.com>
parents: 389
diff changeset
28 ->write_file_expand('nginx.conf', <<'EOF');
384
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
29
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
30 %%TEST_GLOBALS%%
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
31
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
32 daemon off;
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
33
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
34 events {
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
35 }
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
36
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
37 http {
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
38 %%TEST_GLOBALS_HTTP%%
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
39
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
40 server {
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
41 listen 127.0.0.1:8080;
384
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
42 server_name localhost;
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
43
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
44 location / {
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
45 mp4;
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
46 }
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
47 }
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
48 }
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
49
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
50 EOF
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
51
390
7a65ebfdb02e Tests: skip mp4 if ffmpeg does not support lavfi format.
Sergey Kandaurov <pluknet@nginx.com>
parents: 389
diff changeset
52 plan(skip_all => 'no lavfi')
7a65ebfdb02e Tests: skip mp4 if ffmpeg does not support lavfi format.
Sergey Kandaurov <pluknet@nginx.com>
parents: 389
diff changeset
53 unless grep /lavfi/, `ffmpeg -loglevel quiet -formats`;
1268
1923461981c9 Tests: prevent broken terminal after tc[gs]etattr ffmpeg race.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
54 system('ffmpeg -nostdin -loglevel quiet -y '
384
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
55 . '-f lavfi -i testsrc=duration=10:size=320x200:rate=15 '
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
56 . '-f lavfi -i testsrc=duration=20:size=320x200:rate=15 '
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
57 . '-map 0:0 -map 1:0 -pix_fmt yuv420p -g 15 -c:v libx264 '
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
58 . "${\($t->testdir())}/test.mp4") == 0
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
59 or die "Can't create mp4 file: $!";
1268
1923461981c9 Tests: prevent broken terminal after tc[gs]etattr ffmpeg race.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
60 system('ffmpeg -nostdin -loglevel quiet -y '
1037
92479d9429ff Tests: added mp4 tests for moov atom before mdat atom.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
61 . '-f lavfi -i testsrc=duration=10:size=320x200:rate=15 '
92479d9429ff Tests: added mp4 tests for moov atom before mdat atom.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
62 . '-f lavfi -i testsrc=duration=20:size=320x200:rate=15 '
92479d9429ff Tests: added mp4 tests for moov atom before mdat atom.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
63 . '-map 0:0 -map 1:0 -pix_fmt yuv420p -g 15 -c:v libx264 '
92479d9429ff Tests: added mp4 tests for moov atom before mdat atom.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
64 . '-movflags +faststart '
92479d9429ff Tests: added mp4 tests for moov atom before mdat atom.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
65 . "${\($t->testdir())}/no_mdat.mp4") == 0
92479d9429ff Tests: added mp4 tests for moov atom before mdat atom.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
66 or die "Can't create mp4 file: $!";
384
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
67
1555
809d67d48d21 Tests: added mp4 test with chunk offset overflow.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1483
diff changeset
68 my $sbad = <<'EOF';
809d67d48d21 Tests: added mp4 test with chunk offset overflow.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1483
diff changeset
69 00000000: 00 00 00 1c 66 74 79 70 69 73 6f 6d 00 00 02 00 |....ftypisom....|
809d67d48d21 Tests: added mp4 test with chunk offset overflow.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1483
diff changeset
70 00000010: 69 73 6f 6d 69 73 6f 32 6d 70 34 31 00 00 00 09 |isomiso2mp41....|
809d67d48d21 Tests: added mp4 test with chunk offset overflow.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1483
diff changeset
71 00000020: 6d 64 61 74 00 00 00 00 94 6d 6f 6f 76 00 00 00 |mdat.....moov...|
809d67d48d21 Tests: added mp4 test with chunk offset overflow.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1483
diff changeset
72 00000030: 8c 74 72 61 6b 00 00 00 84 6d 64 69 61 00 00 00 |.trak....mdia...|
809d67d48d21 Tests: added mp4 test with chunk offset overflow.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1483
diff changeset
73 00000040: 7c 6d 69 6e 66 00 00 00 74 73 74 62 6c 00 00 00 ||minf...tstbl...|
809d67d48d21 Tests: added mp4 test with chunk offset overflow.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1483
diff changeset
74 00000050: 18 73 74 74 73 00 00 00 00 00 00 00 01 00 00 03 |.stts...........|
809d67d48d21 Tests: added mp4 test with chunk offset overflow.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1483
diff changeset
75 00000060: 3a 00 00 04 00 00 00 00 28 73 74 73 63 00 00 00 |:.......(stsc...|
809d67d48d21 Tests: added mp4 test with chunk offset overflow.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1483
diff changeset
76 00000070: 00 00 00 00 02 00 00 00 01 00 00 03 0f 00 00 00 |................|
809d67d48d21 Tests: added mp4 test with chunk offset overflow.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1483
diff changeset
77 00000080: 01 00 00 00 02 00 00 00 2b 00 00 00 01 00 00 00 |........+.......|
809d67d48d21 Tests: added mp4 test with chunk offset overflow.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1483
diff changeset
78 00000090: 14 73 74 73 7a 00 00 00 00 00 00 05 a9 00 00 03 |.stsz...........|
809d67d48d21 Tests: added mp4 test with chunk offset overflow.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1483
diff changeset
79 000000a0: 3b 00 00 00 18 63 6f 36 34 00 00 00 00 00 00 00 |;....co64.......|
809d67d48d21 Tests: added mp4 test with chunk offset overflow.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1483
diff changeset
80 000000b0: 01 ff ff ff ff f0 0f fb e7 |.........|
809d67d48d21 Tests: added mp4 test with chunk offset overflow.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1483
diff changeset
81 EOF
809d67d48d21 Tests: added mp4 test with chunk offset overflow.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1483
diff changeset
82
809d67d48d21 Tests: added mp4 test with chunk offset overflow.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1483
diff changeset
83 $t->write_file('bad.mp4', unhex($sbad));
809d67d48d21 Tests: added mp4 test with chunk offset overflow.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1483
diff changeset
84 $t->run()->plan(27);
384
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
85
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
86 ###############################################################################
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
87
1037
92479d9429ff Tests: added mp4 tests for moov atom before mdat atom.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
88 my $test_uri = '/test.mp4';
92479d9429ff Tests: added mp4 tests for moov atom before mdat atom.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
89
92479d9429ff Tests: added mp4 tests for moov atom before mdat atom.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
90 again:
92479d9429ff Tests: added mp4 tests for moov atom before mdat atom.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
91
384
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
92 is(durations($t, 0.0), '10.0 20.0', 'start zero');
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
93 is(durations($t, 2), '8.0 18.0', 'start integer');
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
94 is(durations($t, 7.1), '2.9 12.9', 'start float');
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
95
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
96 is(durations($t, 6, 9), '3.0 3.0', 'start end integer');
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
97 is(durations($t, 2.7, 5.6), '2.9 2.9', 'start end float');
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
98
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
99 is(durations($t, undef, 9), '9.0 9.0', 'end integer');
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
100 is(durations($t, undef, 5.6), '5.6 5.6', 'end float');
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
101
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
102 # invalid range results in ignoring end argument
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
103
1037
92479d9429ff Tests: added mp4 tests for moov atom before mdat atom.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
104 like(http_head("$test_uri?start=1&end=1"), qr/200 OK/, 'zero range');
92479d9429ff Tests: added mp4 tests for moov atom before mdat atom.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
105 like(http_head("$test_uri?start=1&end=0"), qr/200 OK/, 'negative range');
384
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
106
387
ff2e9afde90d Tests: adjusted mp4 test for end value beyond track duration.
Sergey Kandaurov <pluknet@nginx.com>
parents: 384
diff changeset
107 # start/end values exceeding track/file duration
384
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
108
1037
92479d9429ff Tests: added mp4 tests for moov atom before mdat atom.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
109 unlike(http_head("$test_uri?end=11"), qr!HTTP/1.1 500!,
387
ff2e9afde90d Tests: adjusted mp4 test for end value beyond track duration.
Sergey Kandaurov <pluknet@nginx.com>
parents: 384
diff changeset
110 'end beyond short track');
1037
92479d9429ff Tests: added mp4 tests for moov atom before mdat atom.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
111 unlike(http_head("$test_uri?end=21"), qr!HTTP/1.1 500!, 'end beyond EOF');
92479d9429ff Tests: added mp4 tests for moov atom before mdat atom.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
112 unlike(http_head("$test_uri?start=11"), qr!HTTP/1.1 500!,
388
3d4506565f43 Tests: more mp4 tests for exceeding start/end values.
Sergey Kandaurov <pluknet@nginx.com>
parents: 387
diff changeset
113 'start beyond short track');
1037
92479d9429ff Tests: added mp4 tests for moov atom before mdat atom.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
114 like(http_head("$test_uri?start=21"), qr!HTTP/1.1 500!, 'start beyond EOF');
92479d9429ff Tests: added mp4 tests for moov atom before mdat atom.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
115
92479d9429ff Tests: added mp4 tests for moov atom before mdat atom.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
116 $test_uri = '/no_mdat.mp4', goto again unless $test_uri eq '/no_mdat.mp4';
384
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
117
1555
809d67d48d21 Tests: added mp4 test with chunk offset overflow.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1483
diff changeset
118 # corrupted formats
809d67d48d21 Tests: added mp4 test with chunk offset overflow.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1483
diff changeset
119
809d67d48d21 Tests: added mp4 test with chunk offset overflow.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1483
diff changeset
120 TODO: {
809d67d48d21 Tests: added mp4 test with chunk offset overflow.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1483
diff changeset
121 local $TODO = 'not yet' unless $t->has_version('1.17.9');
809d67d48d21 Tests: added mp4 test with chunk offset overflow.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1483
diff changeset
122
809d67d48d21 Tests: added mp4 test with chunk offset overflow.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1483
diff changeset
123 like(http_get("/bad.mp4?start=0.5"), qr/500 Internal/, 'co64 chunk beyond EOF');
809d67d48d21 Tests: added mp4 test with chunk offset overflow.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1483
diff changeset
124
809d67d48d21 Tests: added mp4 test with chunk offset overflow.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1483
diff changeset
125 }
809d67d48d21 Tests: added mp4 test with chunk offset overflow.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1483
diff changeset
126
1556
3ff92feb99d1 Tests: todo_alerts() with sendfile for added mp4 overflow test.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1555
diff changeset
127 $t->todo_alerts() if $t->read_file('nginx.conf') =~ /sendfile on/
3ff92feb99d1 Tests: todo_alerts() with sendfile for added mp4 overflow test.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1555
diff changeset
128 and !$t->has_version('1.17.9');
3ff92feb99d1 Tests: todo_alerts() with sendfile for added mp4 overflow test.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1555
diff changeset
129
384
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
130 ###############################################################################
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
131
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
132 sub durations {
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
133 my ($t, $start, $end) = @_;
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
134 my $path = $t->{_testdir} . '/frag.mp4';
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
135
1037
92479d9429ff Tests: added mp4 tests for moov atom before mdat atom.
Sergey Kandaurov <pluknet@nginx.com>
parents: 974
diff changeset
136 my $uri = $test_uri;
384
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
137 if (defined $start) {
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
138 $uri .= "?start=$start";
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
139 if (defined $end) {
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
140 $uri .= "&end=$end";
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
141 }
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
142
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
143 } elsif (defined $end) {
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
144 $uri .= "?end=$end";
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
145 }
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
146
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
147 $t->write_file('frag.mp4', Test::Nginx::http_content(http_get($uri)));
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
148
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
149 my $r = `ffprobe -show_streams $path 2>/dev/null`;
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
150 Test::Nginx::log_core('||', $r);
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
151 sprintf "%.1f %.1f", $r =~ /duration=(\d+\.\d+)/g;
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
152 }
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
153
1555
809d67d48d21 Tests: added mp4 test with chunk offset overflow.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1483
diff changeset
154 sub unhex {
809d67d48d21 Tests: added mp4 test with chunk offset overflow.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1483
diff changeset
155 my ($input) = @_;
809d67d48d21 Tests: added mp4 test with chunk offset overflow.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1483
diff changeset
156 my $buffer = '';
809d67d48d21 Tests: added mp4 test with chunk offset overflow.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1483
diff changeset
157
809d67d48d21 Tests: added mp4 test with chunk offset overflow.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1483
diff changeset
158 for my $l ($input =~ m/: +((?:[0-9a-f]{2,4} +)+) /gms) {
809d67d48d21 Tests: added mp4 test with chunk offset overflow.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1483
diff changeset
159 for my $v ($l =~ m/[0-9a-f]{2}/g) {
809d67d48d21 Tests: added mp4 test with chunk offset overflow.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1483
diff changeset
160 $buffer .= chr(hex($v));
809d67d48d21 Tests: added mp4 test with chunk offset overflow.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1483
diff changeset
161 }
809d67d48d21 Tests: added mp4 test with chunk offset overflow.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1483
diff changeset
162 }
809d67d48d21 Tests: added mp4 test with chunk offset overflow.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1483
diff changeset
163
809d67d48d21 Tests: added mp4 test with chunk offset overflow.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1483
diff changeset
164 return $buffer;
809d67d48d21 Tests: added mp4 test with chunk offset overflow.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1483
diff changeset
165 }
809d67d48d21 Tests: added mp4 test with chunk offset overflow.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1483
diff changeset
166
384
1d67bc8fa680 Tests: mp4 tests added.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
167 ###############################################################################