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