Commit | Line | Data |
8fde61e3 |
1 | # |
2 | # MPEG.pm |
3 | # |
4 | # A package for manipulating MPEG video |
5 | # |
6 | # Copyright (C) 2004 David J. Goehrig |
7 | |
8 | package SDL::MPEG; |
9 | |
10 | use strict; |
084b921f |
11 | use warnings; |
12 | use Carp; |
8fde61e3 |
13 | use SDL; |
14 | |
15 | sub new { |
16 | my $proto = shift; |
17 | my $class = ref($proto) || $proto; |
18 | my %options = @_; |
19 | |
20 | verify (%options, qw/ -from / ) if $SDL::DEBUG; |
21 | |
22 | my $self; |
23 | if ( $options{-from} ) { |
084b921f |
24 | croak "SDL::MPEG::new -from requires a SDL::Video object\n" |
8fde61e3 |
25 | unless $options{-from}->isa('SDL::Video'); |
26 | |
27 | $self = \SDL::SMPEGGetInfo(${$options{-from}}); |
28 | } else { |
29 | $self = \SDL::NewSMPEGInfo(); |
30 | } |
31 | bless $self,$class; |
32 | return $self; |
33 | } |
34 | |
35 | sub DESTROY { |
36 | SDL::FreeSMPEGInfo(${$_[0]}); |
37 | } |
38 | |
39 | sub has_audio { |
40 | SDL::SMPEGInfoHasAudio(${$_[0]}); |
41 | } |
42 | |
43 | sub has_video { |
44 | SDL::SMPEGInfoHasVideo(${$_[0]}); |
45 | } |
46 | |
47 | sub width { |
48 | SDL::SMPEGInfoWidth(${$_[0]}); |
49 | } |
50 | |
51 | sub height { |
52 | SDL::SMPEGInfoHeight(${$_[0]}); |
53 | } |
54 | |
55 | sub size { |
56 | SDL::SMPEGInfoTotalSize(${$_[0]}); |
57 | } |
58 | |
59 | sub offset { |
60 | SDL::SMPEGInfoCurrentOffset(${$_[0]}); |
61 | } |
62 | |
63 | sub frame { |
64 | SDL::SMPEGInfoCurrentFrame(${$_[0]}); |
65 | } |
66 | |
67 | sub fps { |
68 | SDL::SMPEGInfoCurrentFPS(${$_[0]}); |
69 | } |
70 | |
71 | sub time { |
72 | SDL::SMPEGInfoCurrentTime(${$_[0]}); |
73 | } |
74 | |
75 | sub length { |
76 | SDL::SMPEGInfoTotalTime(${$_[0]}); |
77 | } |
78 | |
79 | 1; |
80 | |
81 | __END__; |
82 | |
83 | =pod |
84 | |
85 | |
86 | =head1 NAME |
87 | |
88 | SDL::MPEG - a SDL perl extension |
89 | |
90 | =head1 SYNOPSIS |
91 | |
92 | $info = new SDL::MPEG -from => $mpeg; |
93 | |
94 | =head1 DESCRIPTION |
95 | |
96 | C<SDL::MPEG> provides an interface to quering the status |
97 | of a SMPEG stream. |
98 | |
99 | =head2 METHODS |
100 | |
101 | =over 4 |
102 | |
103 | =item * |
104 | |
105 | C<SDL::MPEG::has_audio> returns true if it has audio track |
106 | |
107 | =item * |
108 | |
109 | C<SDL::MPEG::has_video> returns true if it has a video track |
110 | |
111 | =item * |
112 | |
113 | C<SDL::MPEG::width> returns the width of the video in pixels |
114 | |
115 | =item * |
116 | |
117 | C<SDL::MPEG::height> returns the height of the video in pixels |
118 | |
119 | =item * |
120 | |
121 | C<SDL::MPEG::size> returns the total size of the clip in bytes |
122 | |
123 | =item * |
124 | |
125 | C<SDL::MPEG::offset> returns the offset into the clip in bytes |
126 | |
127 | =item * |
128 | |
129 | C<SDL::MPEG::frame> returns the offset into the clip in fames |
130 | |
131 | =item * |
132 | |
133 | C<SDL::MPEG::fps> returns the play rate in frames per second |
134 | |
135 | =item * |
136 | |
137 | C<SDL::MPEG::time> returns the current play time in seconds |
138 | |
139 | =item * |
140 | |
141 | C<SDL::MPEG::length> returns the total play time in seconds |
142 | |
143 | =back |
144 | |
145 | =head1 AUTHOR |
146 | |
147 | David J. Goehrig |
148 | |
149 | =head1 SEE ALSO |
150 | |
151 | perl(1) SDL::Video(3) |
152 | |
153 | =cut |
154 | |