Changeset 1745

Show
Ignore:
Timestamp:
2006-01-04 15:32:07 (3 years ago)
Author:
ctford
Message:

"header output already started" bug fixed.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • phpannodex/trunk/phpsrc/CGI/nph-mod_annodex.php

    r1743 r1745  
    44        require_once("../AnxInterval/AnxInterval.php"); 
    55        require_once("../Classes/AnnodexWriter.php"); 
    6          
    7         define( "ANX_BUFFER_SIZE",  1024); 
    86         
    97        /* Attempt to stop browsers caching the output of the script. */ 
     
    6866function start_headers() { 
    6967        echo $_SERVER['SERVER_PROTOCOL'],  ' 200 OK', "\n"; 
     68        //header( $_SERVER['SERVER_PROTOCOL'] .  ' 200 OK'); 
    7069        echo 'Server: ', $_SERVER['SERVER_SOFTWARE'], "\n"; 
    7170        return; 
     
    9493 
    9594        $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 
    98102        start_headers(); 
    99         echo "Content-Type: ", $anx::MIME_TYPE, "\n"; 
    100  
    101  
     103        echo "Content-Type: ", AnnodexWriter::MIME_TYPE, "\n"; 
    102104 
    103105        parse_str( $_SERVER['QUERY_STRING'], $query_array ); 
     
    110112        $clip = $query_array['clip']; 
    111113 
    112         $anx->import( $filename, $id, $content_type, $interval->get_start(), 57 
    113                 (int) $flags ); 
     114        $anx->import( $filename, $id, $content_type, $interval->get_start(),  
     115                $interval->get_end()); 
    114116 
    115117        /* Output bitrate and duration information to the headers. */ 
     
    129131        return; 
    130132} 
    131 ?>      
     133?> 
  • phpannodex/trunk/phpsrc/Classes/Annodex.php

    r1744 r1745  
    11<?php 
    22 
    3 require_once("../Exceptions/FileNotFoundException.php"); 
     3require_once("../Exceptions/AnxFileNotFoundException.php"); 
    44 
    55abstract class Annodex { 
     
    1313        public function __construct( $type = ANX_WRITE, $filename = NULL ) { 
    1414 
    15                 if( $type != READ && $type != WRITE ) { 
     15                if( $type != self::READ && $type != self::WRITE ) { 
    1616                        throw new Exception("Unknown Annodex type."); 
    1717                } 
     
    1919                if( $filename ) { 
    2020                         
    21                         if( $anx_handle = anx_open( $filename, $type ) ) { 
     21                        if( $this->anx_handle = anx_open( $filename, $type ) ) { 
    2222                                return; 
    2323                        } else { 
    24                                 throw new FileNotFoundException("Couldn't open" 
    25                                         ." specified file."); 
     24                                throw new AnxFileNotFoundException("Couldn't " 
     25                                ."open specified file."); 
     26                        } 
    2627                } else { 
    27                         $anx_handle = anx_new( $type ); 
     28                        $this->anx_handle = anx_new( $type ); 
    2829                } 
    2930 
  • phpannodex/trunk/phpsrc/Classes/AnnodexWriter.php

    r1743 r1745  
    55class AnnodexWriter extends Annodex { 
    66 
    7         private buffer_size; 
    8         const DEFAULT_BUFFER_SIZE = 1024
     7        private $buffer_size; 
     8        const DEFAULT_BUFFER_SIZE = 10240
    99 
    1010        public function __construct() { 
    1111         
    1212                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; 
    1515 
    1616                return; 
    1717        } 
    1818 
    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 ) { 
    2121 
    2222                /* Returns true for success */ 
     
    2828 
    2929                /* 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 ); 
    3132 
    3233        } 
    3334        public function close() { 
    3435 
    35                 anx_close( $this->get_anx_handle ); 
     36                anx_close( $this->get_anx_handle() ); 
    3637                return; 
    3738 
  • phpannodex/trunk/phpsrc/Exceptions/AnxBadFormatException.php

    r1739 r1745  
    11<?php 
    22 
    3 class BadFormatException extends Exception { 
     3class AnxBadFormatException extends Exception { 
    44 
    55        function __construct( $error_string ) { 
     
    77        } 
    88} 
    9 ?> 
  • phpannodex/trunk/phpsrc/Exceptions/AnxFileNotFoundException.php

    r1739 r1745  
    11<?php 
    22 
    3 class FileNotFoundException extends Exception { 
     3class AnxFileNotFoundException extends Exception { 
    44 
    55        function __construct( $error_string ) { 
     
    77        } 
    88} 
    9 ?> 
    10