Changeset 1745
- Timestamp:
- 2006-01-04 15:32:07 (3 years ago)
- Files:
-
- phpannodex/trunk/phpsrc/CGI/nph-mod_annodex.php (modified) (5 diffs)
- phpannodex/trunk/phpsrc/Classes/Annodex.php (modified) (3 diffs)
- phpannodex/trunk/phpsrc/Classes/AnnodexWriter.php (modified) (2 diffs)
- phpannodex/trunk/phpsrc/Exceptions/AnxBadFormatException.php (modified) (2 diffs)
- phpannodex/trunk/phpsrc/Exceptions/AnxFileNotFoundException.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
phpannodex/trunk/phpsrc/CGI/nph-mod_annodex.php
r1743 r1745 4 4 require_once("../AnxInterval/AnxInterval.php"); 5 5 require_once("../Classes/AnnodexWriter.php"); 6 7 define( "ANX_BUFFER_SIZE", 1024);8 6 9 7 /* Attempt to stop browsers caching the output of the script. */ … … 68 66 function start_headers() { 69 67 echo $_SERVER['SERVER_PROTOCOL'], ' 200 OK', "\n"; 68 //header( $_SERVER['SERVER_PROTOCOL'] . ' 200 OK'); 70 69 echo 'Server: ', $_SERVER['SERVER_SOFTWARE'], "\n"; 71 70 return; … … 94 93 95 94 $filename = $filename_root . ".anx"; 96 $anx = new AnnodexWriter(); 97 95 try { 96 $anx = new AnnodexWriter(); 97 } catch( Exception $e ) { 98 echo $e; 99 die( "Failed to create Annodex." ); 100 } 101 98 102 start_headers(); 99 echo "Content-Type: ", $anx::MIME_TYPE, "\n"; 100 101 103 echo "Content-Type: ", AnnodexWriter::MIME_TYPE, "\n"; 102 104 103 105 parse_str( $_SERVER['QUERY_STRING'], $query_array ); … … 110 112 $clip = $query_array['clip']; 111 113 112 $anx->import( $filename, $id, $content_type, $interval->get_start(), 57113 (int) $flags);114 $anx->import( $filename, $id, $content_type, $interval->get_start(), 115 $interval->get_end()); 114 116 115 117 /* Output bitrate and duration information to the headers. */ … … 129 131 return; 130 132 } 131 ?> 133 ?> phpannodex/trunk/phpsrc/Classes/Annodex.php
r1744 r1745 1 1 <?php 2 2 3 require_once("../Exceptions/ FileNotFoundException.php");3 require_once("../Exceptions/AnxFileNotFoundException.php"); 4 4 5 5 abstract class Annodex { … … 13 13 public function __construct( $type = ANX_WRITE, $filename = NULL ) { 14 14 15 if( $type != READ && $type !=WRITE ) {15 if( $type != self::READ && $type != self::WRITE ) { 16 16 throw new Exception("Unknown Annodex type."); 17 17 } … … 19 19 if( $filename ) { 20 20 21 if( $ anx_handle = anx_open( $filename, $type ) ) {21 if( $this->anx_handle = anx_open( $filename, $type ) ) { 22 22 return; 23 23 } else { 24 throw new FileNotFoundException("Couldn't open" 25 ." specified file."); 24 throw new AnxFileNotFoundException("Couldn't " 25 ."open specified file."); 26 } 26 27 } else { 27 $ anx_handle = anx_new( $type );28 $this->anx_handle = anx_new( $type ); 28 29 } 29 30 phpannodex/trunk/phpsrc/Classes/AnnodexWriter.php
r1743 r1745 5 5 class AnnodexWriter extends Annodex { 6 6 7 private buffer_size;8 const DEFAULT_BUFFER_SIZE = 1024 ;7 private $buffer_size; 8 const DEFAULT_BUFFER_SIZE = 10240; 9 9 10 10 public function __construct() { 11 11 12 12 parent::__construct( ANX_WRITE ); 13 init_importers("*/*");14 $this->buffer_size = DEFAULT_BUFFER_SIZE;13 anx_init_importers("*/*"); 14 $this->buffer_size = self::DEFAULT_BUFFER_SIZE; 15 15 16 16 return; 17 17 } 18 18 19 public function import( $filename, $id , $content_type, $start, $end,20 $ flags) {19 public function import( $filename, $id=NULL, $content_type=NULL, 20 $start=0, $end=-1, $flags=0 ) { 21 21 22 22 /* Returns true for success */ … … 28 28 29 29 /* Returns false on failure */ 30 return anx_write_output( $this->get_anx_handle(), buffer_size ); 30 return anx_write_output( $this->get_anx_handle(), 31 $this->buffer_size ); 31 32 32 33 } 33 34 public function close() { 34 35 35 anx_close( $this->get_anx_handle );36 anx_close( $this->get_anx_handle() ); 36 37 return; 37 38 phpannodex/trunk/phpsrc/Exceptions/AnxBadFormatException.php
r1739 r1745 1 1 <?php 2 2 3 class BadFormatException extends Exception {3 class AnxBadFormatException extends Exception { 4 4 5 5 function __construct( $error_string ) { … … 7 7 } 8 8 } 9 ?>phpannodex/trunk/phpsrc/Exceptions/AnxFileNotFoundException.php
r1739 r1745 1 1 <?php 2 2 3 class FileNotFoundException extends Exception {3 class AnxFileNotFoundException extends Exception { 4 4 5 5 function __construct( $error_string ) { … … 7 7 } 8 8 } 9 ?>10