- Timestamp:
- 11/27/08 10:48:51 (5 years ago)
- Location:
- lang/perl/Video-LibAvformat/trunk
- Files:
-
- 2 added
- 1 removed
- 3 modified
- 3 moved
-
LibAvformat.xs (moved) (moved from lang/perl/Video-LibAvformat/trunk/Avcodec.xs) (1 diff)
-
Makefile.PL (modified) (8 diffs)
-
lib/Video/Avcodec (deleted)
-
lib/Video/LibAvcodec (added)
-
lib/Video/LibAvformat (added)
-
lib/Video/LibAvformat.pm (moved) (moved from lang/perl/Video-LibAvformat/trunk/lib/Video/Avcodec.pm) (4 diffs)
-
perl-avformat.h (moved) (moved from lang/perl/Video-LibAvformat/trunk/perl_avcodec.h) (1 diff)
-
t/00_compile.t (modified) (1 diff)
-
t/01_basic.t (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/Video-LibAvformat/trunk/LibAvformat.xs
r25030 r25037 3 3 #include "XSUB.h" 4 4 5 #include "perl _avcodec.h"5 #include "perl-avformat.h" 6 6 7 MODULE = Video:: Avcodec PACKAGE = Video::AvcodecPREFIX = av_7 MODULE = Video::LibAvformat PACKAGE = Video::LibAvformat PREFIX = av_ 8 8 9 9 PROTOTYPES: DISABLED 10 10 11 int 12 av_get_bits_per_sample_format(enum SampleFormat sample_fmt); 11 MODULE = Video::LibAvformat PACKAGE = Video::LibAvformat::Const 13 12 13 PROTOTYPES: ENABLED 14 14 15 MODULE = Video::Avcodec PACKAGE = Video::Avcodec::Const 15 INCLUDE: avformat-const.inc 16 17 MODULE = Video::LibAvformat PACKAGE = Video::LibAvcodec::Const 16 18 17 19 PROTOTYPES: ENABLED 18 20 19 21 INCLUDE: avcodec-const.inc 22 -
lang/perl/Video-LibAvformat/trunk/Makefile.PL
r25030 r25037 2 2 use ExtUtils::MakeMaker; 3 3 4 my $INCDIR; 5 my $HEADER; 6 my $CONSTFILE = 'avcodec-const.inc'; 7 my $CONSTPM = 'lib/Video/Avcodec/Const.pm'; 8 4 use File::Spec; 5 6 my %CONFIG = ( 7 avcodec => { 8 incdir => undef, 9 header => undef, 10 constfile => 'avcodec-const.inc', 11 constpm => File::Spec->catfile(qw(lib Video LibAvcodec Const.pm)), 12 }, 13 avformat => { 14 incdir => undef, 15 header => undef, 16 constfile => 'avformat-const.inc', 17 constpm => File::Spec->catfile(qw(lib Video LibAvformat Const.pm)), 18 }, 19 ); 9 20 10 21 print <<EOM; 11 22 12 This is the perl interface to libav codec, which comeswith ffmpeg.23 This is the perl interface to libavformat and libavcodec, which come with ffmpeg. 13 24 14 25 EOM … … 36 47 } 37 48 38 { # look for where avcodec.h is 39 print <<EOM; 40 Looking for avcodec.h... 41 42 EOM 43 my @dirs = qw(/usr/local/include /opt/local/include /usr/include); 44 unshift @dirs, $ENV{AVCODEC_INC} if $ENV{AVCODEC_INC}; 45 foreach my $dir (@dirs) { 46 if ( -f File::Spec->catfile($dir, 'libavcodec', 'avcodec.h')) { 47 $INCDIR = $dir; 48 last; 49 } 50 } 51 52 if (! $INCDIR || ! -d $INCDIR || ! -f ($HEADER = File::Spec->catfile($INCDIR, 'libavcodec', 'avcodec.h'))) { 53 print STDERR <<EOM; 54 Couldn't find avcodec.h. If you have installed it in an odd location, 55 please specify the directory in AVCODEC_INC dir 56 EOM 57 exit 1; 58 } 59 print <<EOM; 60 Found avcodec.h in $HEADER. 61 62 EOM 63 } 64 65 { # Check if we have const file 66 if (! -f $CONSTFILE) { 67 print <<EOM; 68 No const file ($CONSTFILE) found. We will generate one from avcodec.h. 69 70 EOM 71 gen_constfile(); 72 } 73 } 74 75 { # Finally create a Makefile 49 50 { 51 foreach my $type (keys %CONFIG) { 52 prepare($type); 53 } 54 76 55 print <<EOM; 77 56 Generating Makefile... … … 80 59 81 60 WriteMakefile( 82 INC => "-I$INCDIR",83 DISTNAME => 'Video- Avcodec',84 LIBS => [ '-lav codec' ],85 NAME => 'Video:: Avcodec',61 INC => join(' ', map { "-I$CONFIG{$_}{incdir}" } keys %CONFIG), 62 DISTNAME => 'Video-LibAvformat', 63 LIBS => [ '-lavformat -lavcodec' ], 64 NAME => 'Video::LibAvformat', 86 65 OBJECT => '$(O_FILES)', 87 VERSION_FROM => 'lib/Video/ Avcodec.pm',66 VERSION_FROM => 'lib/Video/LibAvformat.pm', 88 67 clean => { 89 FILES => "$CONSTFILE $CONSTPM"68 FILES => join(' ', map { "$CONFIG{$_}{constfile} $CONFIG{$_}{constpm}" } keys %CONFIG ) 90 69 } 91 70 ); … … 94 73 # Utilities 95 74 sub gen_constfile { 96 open(my $header, '<', $HEADER) or 97 die "Could not open $HEADER: $!"; 75 my $type = shift; 76 77 my $header = $CONFIG{$type}{header} or 78 die "Don't know where the header file is for $type"; 79 80 open(my $header, '<', $header) or 81 die "Could not open $header: $!"; 98 82 99 83 my %constants; … … 112 96 113 97 { # one big-ass constant file 114 open(my $fh, '>', $CONSTFILE) or 115 die "Could not open $CONSTFILE: $!"; 98 my $constfile = $CONFIG{$type}{constfile}; 99 open(my $fh, '>', $constfile) or 100 die "Could not open $constfile: $!"; 116 101 print $fh <<EOM; 117 102 # DO NOT EDIT! GENERATED BY $0 ON @{ [ scalar localtime() ] } … … 134 119 135 120 { # create perl wrapper 136 open(my $fh, '>', $CONSTPM) or 137 die "Could not open $CONSTPM: $!"; 121 my $constpm = $CONFIG{$type}{constpm}; 122 open(my $fh, '>', $constpm) or 123 die "Could not open $constpm: $!"; 138 124 print $fh <<EOM; 139 125 # DO NOT EDIT! GENERATED BY $0 ON @{ [ scalar localtime() ] } 140 126 141 package Video:: Avcodec::Const;127 package Video::Lib@{[ ucfirst $type ]}::Const; 142 128 use Exporter 'import'; 143 129 … … 168 154 =head1 NAME 169 155 170 Video:: Avcodec::Const - Constants for Video::Avcodec156 Video::Lib@{[ ucfirst $type ]}::Const - Constants for Video::Lib@{[ucfirst $type]} 171 157 172 158 =head1 SYNOPSIS 173 159 174 use Video:: Avcodec::Const;160 use Video::@{[ucfirst]}::Const; 175 161 176 162 =cut … … 179 165 } 180 166 } 167 168 sub prepare { 169 my $type = shift; 170 probe_header($type); 171 # Check if we have const file 172 my $constfile = $CONFIG{$type}{constfile}; 173 if (! -f $constfile) { 174 print <<EOM; 175 No const file ($constfile) found. We will generate one from $type.h. 176 177 EOM 178 gen_constfile($type); 179 } 180 } 181 182 sub probe_header { # look for where avformat.h/avcodec.h is 183 my $type = shift; 184 185 print <<EOM; 186 Looking for $type.h... 187 188 EOM 189 my @dirs = qw(/usr/local/include /opt/local/include /usr/include); 190 unshift @dirs, $ENV{uc "${type}_INC"} if $ENV{uc "${type}_INC"}; 191 192 my $incdir; 193 194 foreach my $dir (@dirs) { 195 if ( -f File::Spec->catfile($dir, "lib$type", "$type.h")) { 196 $incdir = $dir; 197 last; 198 } 199 } 200 201 my $header; 202 if (! $incdir || ! -d $incdir || ! -f ($header = File::Spec->catfile($incdir, "lib$type", "$type.h"))) { 203 print STDERR <<EOM; 204 Couldn't find $type.h. If you have installed it in an odd location, 205 please specify the directory in @{[uc $type]}_INC dir 206 EOM 207 exit 1; 208 } 209 print <<EOM; 210 Found $type.h in $header. 211 212 EOM 213 214 $CONFIG{$type}{incdir} = $incdir; 215 $CONFIG{$type}{header} = $header; 216 } 217 -
lang/perl/Video-LibAvformat/trunk/lib/Video/LibAvformat.pm
r25019 r25037 1 package Video:: Avcodec;1 package Video::LibAvformat; 2 2 use strict; 3 3 use warnings; … … 8 8 XSLoader::load(__PACKAGE__, $VERSION); 9 9 } 10 use Video:: Avcodec::Const;10 use Video::LibAvformat::Const; 11 11 12 12 1; … … 16 16 =head1 NAME 17 17 18 Video:: Avcodec- Interface To libavcodec18 Video::LibAvformat - Interface To libavcodec 19 19 20 20 =head1 SYNOPSIS 21 21 22 use Video:: Avcodec;22 use Video::LibAvformat; 23 23 24 24 =head1 SEE ALSO … … 26 26 =over 4 27 27 28 =item Video:: Avcodec::Const28 =item Video::LibAvformat::Const 29 29 30 30 Covers the constants defined in avcodec.h -
lang/perl/Video-LibAvformat/trunk/perl-avformat.h
r25030 r25037 1 1 /* Utility functions for Video::Avcodec */ 2 2 3 #include "libavformat/avformat.h" 3 4 #include "libavcodec/avcodec.h" 4 5 -
lang/perl/Video-LibAvformat/trunk/t/00_compile.t
r25019 r25037 2 2 use Test::More (tests => 1); 3 3 4 use_ok("Video:: Avcodec");4 use_ok("Video::LibAvformat"); -
lang/perl/Video-LibAvformat/trunk/t/01_basic.t
r25030 r25037 1 1 use strict; 2 use Test::More (tests => 1); 3 4 use Video::Avcodec; 5 6 { 7 my $bits = Video::Avcodec::get_bits_per_sample_format( 8 &Video::Avcodec::Const::SAMPLE_FMT_DBL 9 ); 10 11 # I have no idea if this is the right value, but bits should be 64 12 note("SAMPLE_FMT_DBL -> bits = $bits"); 13 ok($bits); 14 } 2 use Test::More (skip_all => "unimplemented");
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)