line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::SVT::Play::Video::Stream::HTTP; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Copyright (c) 2012 - Olof Johansson |
4
|
|
|
|
|
|
|
# All rights reserved. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or |
7
|
|
|
|
|
|
|
# modify it under the same terms as Perl itself. |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
WWW::SVT::Play::Video::Stream::HTTP, HTTP class representing a stream |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 SYNOPSIS |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use WWW::SVT::Play::Video; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my $svtp = WWW::SVT::Play::Video->new($url); |
18
|
|
|
|
|
|
|
my $stream = $svtp->stream(protocol => 'HTTP'); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 DESCRIPTION |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=cut |
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
1
|
|
5
|
use warnings FATAL => 'all'; |
|
1
|
|
|
|
|
18
|
|
|
1
|
|
|
|
|
39
|
|
25
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
26
|
1
|
|
|
1
|
|
5
|
use parent 'WWW::SVT::Play::Video::Stream'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
12
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
our $VERSION = 0.12; |
29
|
1
|
|
|
1
|
|
79
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
268
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head2 is_http |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Is stream using HTTP protocol? Yes. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
0
|
1
|
|
sub is_http { 1 } |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head2 download |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Download this stream using rtmpdump. This forks a new process and |
42
|
|
|
|
|
|
|
depends on the external program "rtmpdump". Takes the following |
43
|
|
|
|
|
|
|
named parameters: |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=over |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=item * output, filename to which the stream should be downloaded to |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=item * force, stream should be downloaded even if filename exists |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=back |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub download { |
56
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
57
|
0
|
|
|
|
|
|
my %args = @_; |
58
|
|
|
|
|
|
|
|
59
|
0
|
0
|
|
|
|
|
if (not defined $args{output}) { |
60
|
0
|
|
|
|
|
|
carp "No output filename specified. Can't download."; |
61
|
0
|
|
|
|
|
|
return; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
0
|
0
|
0
|
|
|
|
if (-e $args{output} and not $args{force}) { |
65
|
0
|
|
|
|
|
|
carp "Output file already exists"; |
66
|
0
|
|
|
|
|
|
return; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
0
|
0
|
|
|
|
|
if ($args{output} =~ /'/) { |
70
|
|
|
|
|
|
|
# FIXME: I'm lazy. The ' really should be treated correctly. |
71
|
|
|
|
|
|
|
# I think there is a CPAN module for this. |
72
|
0
|
|
|
|
|
|
carp "I hate ' characters in filenames. Try wihtout it."; |
73
|
0
|
|
|
|
|
|
return; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
system("curl -L -o '$args{output}' '$self->{url}'"); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head2 bitrate |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Get the bitrate information for this RTMP stream. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub bitrate { |
86
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
87
|
0
|
|
|
|
|
|
return $self->{bitrate}; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 COPYRIGHT |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Copyright (c) 2012 - Olof Johansson |
93
|
|
|
|
|
|
|
All rights reserved. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or |
96
|
|
|
|
|
|
|
modify it under the same terms as Perl itself. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
1; |