Brought all packages under eye of strict, warnings and love of Carp, For
[sdlgit/SDL_perl.git] / lib / SDL / MPEG.pm
CommitLineData
8fde61e3 1#
2# MPEG.pm
3#
4# A package for manipulating MPEG video
5#
6# Copyright (C) 2004 David J. Goehrig
7
8package SDL::MPEG;
9
10use strict;
084b921f 11use warnings;
12use Carp;
8fde61e3 13use SDL;
14
15sub 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
35sub DESTROY {
36 SDL::FreeSMPEGInfo(${$_[0]});
37}
38
39sub has_audio {
40 SDL::SMPEGInfoHasAudio(${$_[0]});
41}
42
43sub has_video {
44 SDL::SMPEGInfoHasVideo(${$_[0]});
45}
46
47sub width {
48 SDL::SMPEGInfoWidth(${$_[0]});
49}
50
51sub height {
52 SDL::SMPEGInfoHeight(${$_[0]});
53}
54
55sub size {
56 SDL::SMPEGInfoTotalSize(${$_[0]});
57}
58
59sub offset {
60 SDL::SMPEGInfoCurrentOffset(${$_[0]});
61}
62
63sub frame {
64 SDL::SMPEGInfoCurrentFrame(${$_[0]});
65}
66
67sub fps {
68 SDL::SMPEGInfoCurrentFPS(${$_[0]});
69}
70
71sub time {
72 SDL::SMPEGInfoCurrentTime(${$_[0]});
73}
74
75sub length {
76 SDL::SMPEGInfoTotalTime(${$_[0]});
77}
78
791;
80
81__END__;
82
83=pod
84
85
86=head1 NAME
87
88SDL::MPEG - a SDL perl extension
89
90=head1 SYNOPSIS
91
92 $info = new SDL::MPEG -from => $mpeg;
93
94=head1 DESCRIPTION
95
96C<SDL::MPEG> provides an interface to quering the status
97of a SMPEG stream.
98
99=head2 METHODS
100
101=over 4
102
103=item *
104
105C<SDL::MPEG::has_audio> returns true if it has audio track
106
107=item *
108
109C<SDL::MPEG::has_video> returns true if it has a video track
110
111=item *
112
113C<SDL::MPEG::width> returns the width of the video in pixels
114
115=item *
116
117C<SDL::MPEG::height> returns the height of the video in pixels
118
119=item *
120
121C<SDL::MPEG::size> returns the total size of the clip in bytes
122
123=item *
124
125C<SDL::MPEG::offset> returns the offset into the clip in bytes
126
127=item *
128
129C<SDL::MPEG::frame> returns the offset into the clip in fames
130
131=item *
132
133C<SDL::MPEG::fps> returns the play rate in frames per second
134
135=item *
136
137C<SDL::MPEG::time> returns the current play time in seconds
138
139=item *
140
141C<SDL::MPEG::length> returns the total play time in seconds
142
143=back
144
145=head1 AUTHOR
146
147David J. Goehrig
148
149=head1 SEE ALSO
150
151perl(1) SDL::Video(3)
152
153=cut
154