Permalink
Browse files

Added SMPEG priliminary support

  • Loading branch information...
1 parent 47f9909 commit 9cd8a1697d71b53f56fcf33b14d025ff4e84ec7a @kthakore kthakore committed Jan 5, 2011
Showing with 371 additions and 68 deletions.
  1. +14 −7 Build.PL
  2. +19 −16 lib/SDL/MPEG.pm
  3. +33 −26 lib/SDL/SMPEG.pm
  4. +3 −17 lib/SDLx/Surface.pm
  5. +296 −0 src/MPEG.xs
  6. +1 −1 src/SMPEG.xs
  7. +5 −1 t/smpeg.t
  8. BIN test/data/test-mpeg.mpg
View
@@ -392,13 +392,20 @@ my %subsystems = (
libraries => [qw( SDL SDL_image )],
},
- # SMPEG => {
- # file => {
- # from => 'src/SMPEG.xs',
- # to => 'lib/SDL/SMPEG.xs',
- # },
- # libraries => [qw( SDL smpeg)],
- # },
+ SMPEG => {
+ file => {
+ from => 'src/SMPEG.xs',
+ to => 'lib/SDL/SMPEG.xs',
+ },
+ libraries => [qw( SDL smpeg)],
+ },
+ MPEG => {
+ file => {
+ from => 'src/MPEG.xs',
+ to => 'lib/SDL/MPEG.xs',
+ },
+ libraries => [qw( SDL smpeg)],
+ },
Pango => {
file => {
from => 'src/Pango/Pango.xs',
View
@@ -34,6 +34,12 @@ use strict;
use warnings;
use Carp;
use SDL;
+our @ISA = qw(Exporter DynaLoader);
+
+use SDL::Internal::Loader;
+internal_load_dlls(__PACKAGE__);
+
+bootstrap SDL::MPEG;
sub new {
my $proto = shift;
@@ -42,59 +48,56 @@ sub new {
my $self;
if ( $options{-from} ) {
- Carp::confess "SDL::MPEG::new -from requires a SDL::Video object\n"
- unless $options{-from}->isa('SDL::Video');
-
- $self = \SDL::SMPEGGetInfo( ${ $options{-from} } );
+ $self = \SDL::MPEG::SMPEGGetInfo( ${ $options{-from} } );
} else {
- $self = \SDL::NewSMPEGInfo();
+ $self = \SDL::MPEG::NewSMPEGInfo();
}
bless $self, $class;
return $self;
}
sub DESTROY {
- SDL::FreeSMPEGInfo( ${ $_[0] } );
+ SDL::MPEG::FreeSMPEGInfo( ${ $_[0] } );
}
sub has_audio {
- SDL::SMPEGInfoHasAudio( ${ $_[0] } );
+ SDL::MPEG::SMPEGInfoHasAudio( ${ $_[0] } );
}
sub has_video {
- SDL::SMPEGInfoHasVideo( ${ $_[0] } );
+ SDL::MPEG::SMPEGInfoHasVideo( ${ $_[0] } );
}
sub width {
- SDL::SMPEGInfoWidth( ${ $_[0] } );
+ SDL::MPEG::SMPEGInfoWidth( ${ $_[0] } );
}
sub height {
- SDL::SMPEGInfoHeight( ${ $_[0] } );
+ SDL::MPEG::SMPEGInfoHeight( ${ $_[0] } );
}
sub size {
- SDL::SMPEGInfoTotalSize( ${ $_[0] } );
+ SDL::MPEG::SMPEGInfoTotalSize( ${ $_[0] } );
}
sub offset {
- SDL::SMPEGInfoCurrentOffset( ${ $_[0] } );
+ SDL::MPEG::SMPEGInfoCurrentOffset( ${ $_[0] } );
}
sub frame {
- SDL::SMPEGInfoCurrentFrame( ${ $_[0] } );
+ SDL::MPEG::SMPEGInfoCurrentFrame( ${ $_[0] } );
}
sub fps {
- SDL::SMPEGInfoCurrentFPS( ${ $_[0] } );
+ SDL::MPEG::SMPEGInfoCurrentFPS( ${ $_[0] } );
}
sub time {
- SDL::SMPEGInfoCurrentTime( ${ $_[0] } );
+ SDL::MPEG::SMPEGInfoCurrentTime( ${ $_[0] } );
}
sub length {
- SDL::SMPEGInfoTotalTime( ${ $_[0] } );
+ SDL::MPEG::SMPEGInfoTotalTime( ${ $_[0] } );
}
1;
View
@@ -7,6 +7,13 @@ use Carp;
use SDL;
use SDL::Surface;
use SDL::MPEG;
+our @ISA = qw(Exporter DynaLoader);
+
+use SDL::Internal::Loader;
+internal_load_dlls(__PACKAGE__);
+
+bootstrap SDL::SMPEG;
+
sub new {
my $proto = shift;
@@ -18,91 +25,91 @@ sub new {
my $a = $options{'-audio'} ? 1 : 0;
my $info = SDL::MPEG->new();
- my $self = \SDL::NewSMPEG( $n, $$info, $a );
- Carp::confess SDL::GetError() unless $$self;
+ my $self = \SDL::SMPEG::NewSMPEG( $n, $$info, $a );
+ Carp::confess SDL::get_error() unless $$self;
bless $self, $class;
$self->audio(1);
$self->video(1);
return $self, $info;
}
sub DESTROY {
- SDL::FreeSMPEG( ${ $_[0] } );
+ SDL::SMPEG::FreeSMPEG( ${ $_[0] } );
}
sub error {
- SDL::SMPEGError( ${ $_[0] } );
+ SDL::SMPEG::SMPEGError( ${ $_[0] } );
}
sub audio {
- SDL::SMPEGEnableAudio( ${ $_[0] }, $_[1] );
+ SDL::SMPEG::SMPEGEnableAudio( ${ $_[0] }, $_[1] );
}
sub video {
- SDL::SMPEGEnableSMPEG( ${ $_[0] }, $_[1] );
+ SDL::SMPEG::SMPEGEnableVideo( ${ $_[0] }, $_[1] );
}
sub volume {
- SDL::SMPEGSetVolume( ${ $_[0] }, $_[1] );
+ SDL::SMPEG::SMPEGSetVolume( ${ $_[0] }, $_[1] );
}
sub display {
- Carp::confess "SDL::SMPEG::Display requires a SDL::Surface\n"
- unless $_[1]->isa('SDL::Surface');
- SDL::SMPEGSetDisplay( ${ $_[0] }, ${ $_[1] }, 0 );
+ Carp::confess "SDL::SMPEG::SMPEG::Display requires a SDL::SMPEG::Surface\n"
+ unless $_[1]->isa('SDL::SMPEG::Surface');
+ SDL::SMPEG::SMPEGSetDisplay( ${ $_[0] }, ${ $_[1] }, 0 );
}
sub scale {
- return SDL::SMPEGScaleXY( ${ $_[0] }, $_[1], $_[2] ) if ( @_ == 3 );
- return SDL::SMPEGScaleXY( ${ $_[0] }, $_[1]->width(), $_[1]->height() )
- if $_[1]->isa('SDL::Surface');
- SDL::SMPEGScale( ${ $_[0] }, $_[1] );
+ return SDL::SMPEG::SMPEGScaleXY( ${ $_[0] }, $_[1], $_[2] ) if ( @_ == 3 );
+ return SDL::SMPEG::SMPEGScaleXY( ${ $_[0] }, $_[1]->width(), $_[1]->height() )
+ if $_[1]->isa('SDL::SMPEG::Surface');
+ SDL::SMPEG::SMPEGScale( ${ $_[0] }, $_[1] );
}
sub play {
- SDL::SMPEGPlay( ${ $_[0] } );
+ SDL::SMPEG::SMPEGPlay( ${ $_[0] } );
}
sub pause {
- SDL::SMPEGPause( ${ $_[0] } );
+ SDL::SMPEG::SMPEGPause( ${ $_[0] } );
}
sub stop {
- SDL::SMPEGStop( ${ $_[0] } );
+ SDL::SMPEG::SMPEGStop( ${ $_[0] } );
}
sub rewind {
- SDL::SMPEGRewind( ${ $_[0] } );
+ SDL::SMPEG::SMPEGRewind( ${ $_[0] } );
}
sub seek {
- SDL::SMPEGSeek( ${ $_[0] }, $_[1] );
+ SDL::SMPEG::SMPEGSeek( ${ $_[0] }, $_[1] );
}
sub skip {
- SDL::SMPEGSkip( ${ $_[0] }, $_[1] );
+ SDL::SMPEG::SMPEGSkip( ${ $_[0] }, $_[1] );
}
sub loop {
- SDL::SMPEGLoop( ${ $_[0] }, $_[1] );
+ SDL::SMPEG::SMPEGLoop( ${ $_[0] }, $_[1] );
}
sub region {
- Carp::confess "SDL::SMPEG::region requires a SDL::Rect\n"
- unless $_[1]->isa('SDL::Rect');
- SDL::SMPEGDisplayRegion( ${ $_[0] }, ${ $_[1] } );
+ Carp::confess "SDL::SMPEG::SMPEG::region requires a SDL::SMPEG::Rect\n"
+ unless $_[1]->isa('SDL::SMPEG::Rect');
+ SDL::SMPEG::SMPEGDisplayRegion( ${ $_[0] }, ${ $_[1] } );
}
sub frame {
- SDL::SMPEGRenderFrame( ${ $_[0] }, $_[1] );
+ SDL::SMPEG::SMPEGRenderFrame( ${ $_[0] }, $_[1] );
}
sub info {
new SDL::MPEG-from => $_[0];
}
sub status {
- SDL::SMPEGStatus( ${ $_[0] } );
+ SDL::SMPEG::SMPEGStatus( ${ $_[0] } );
}
1;
View
@@ -218,27 +218,13 @@ sub update {
my ( $surface, $rects ) = @_;
if ( !defined($rects) || ( ref($rects) eq 'ARRAY' && !ref( $rects->[0] ) ) ) {
- my @rect;
- @rect = @{$rects} if $rects;
+ my @rect;
+ @rect = @{$rects} if $rects;
$rect[0] ||= 0;
$rect[1] ||= 0;
$rect[2] ||= $surface->w;
$rect[3] ||= $surface->h;
-
- foreach(0..1)
- {
- $rect[$_] = 0 if $rect[$_] < 0;
- }
-
- foreach(0,2)
- {
- $rect[$_] = $surface->w if $rect[$_] > $surface->w;
- }
-
- foreach(1,3)
- {
- $rect[$_] = $surface->h if $rect[$_] > $surface->h;
- }
+
SDL::Video::update_rect( $surface, @rect );
} else {
SDL::Video::update_rects( $surface, map { SDLx::Validate::rect($_) } @{$rects} );
Oops, something went wrong.

0 comments on commit 9cd8a16

Please sign in to comment.