Changeset 1173

Show
Ignore:
Timestamp:
2005-03-21 19:08:13 (4 years ago)
Author:
conrad
Message:

mod_annodex-ap13: add named offset handling (ticket:79)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • mod_annodex-ap13/trunk/mod_annodex.c

    r1168 r1173  
    301301} 
    302302 
     303static double 
     304ma_anxenc_clip_time (char * filename, char * content_type, char * id) 
     305{ 
     306  ANNODEX * anx; 
     307  int ret; 
     308  unsigned char buf[1024]; 
     309  long n = 1024; 
     310  double clip_offset; 
     311 
     312  anx = anx_new (ANX_WRITE); 
     313  ret = anx_write_import (anx, filename, NULL, content_type, 0.0, -1.0, 0); 
     314 
     315  /* Only spin through the file if the requested clip has not yet been 
     316   * inserted; avoid scanning media if 'filename' is a cmml file. */ 
     317  if ((clip_offset = anx_get_clip_time_by_id (anx, id)) == -1.0) { 
     318    while ((n = anx_write_output (anx, buf, 1024)) > 0); 
     319 
     320    if ((clip_offset = anx_get_clip_time_by_id (anx, id)) == -1.0) { 
     321      clip_offset = 0.0; 
     322    } 
     323  } 
     324 
     325  if (anx_close (anx) != NULL) { 
     326  } 
     327 
     328  return clip_offset; 
     329} 
     330 
    303331static int 
    304332ma_anxenc (request_rec * r, char * filename, char * mime_type, 
     
    307335  ANNODEX * anx; 
    308336  int ret; 
    309   char * val
     337  char * val, * id = NULL
    310338  double seek_offset = 0.0, seek_end = -1.0; 
    311339  char buf[1024]; 
     
    319347  /*anx_init_importers (ANX_MIME_TYPE);*/ 
    320348  anx_init_importers ("*/*"); 
    321    
    322   val = (char *)table_get (cgi_table, "t"); 
    323   if (val) { 
    324     ma_parse_time (val, &seek_offset, &seek_end); 
    325   } 
    326  
    327 #ifdef DEBUG 
    328     ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, 
    329                   "ma_anxenc: t=%s (%f/%f)", val, seek_offset, seek_end); 
    330 #endif 
    331  
    332   anx_set_presentation_time (anx, seek_offset); 
    333   anx_set_basetime (anx, 0.0); 
    334    
     349 
    335350  /* Retrieve the current working directory */ 
    336351  getcwd (olddir, PATH_MAX); 
     
    342357  chdir (newdir); 
    343358 
     359  /* Get the start/end times or id */   
     360  val = (char *)table_get (cgi_table, "t"); 
     361  id = (char *)table_get (cgi_table, "id"); 
     362  if (val) { 
     363    ma_parse_time (val, &seek_offset, &seek_end); 
     364  } else if (id) { 
     365    seek_offset = ma_anxenc_clip_time (filename, mime_type, id); 
     366  } 
     367 
     368#ifdef DEBUG 
     369    ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, 
     370                  "ma_anxenc: t=%s id=%s (%f/%f)", 
     371                  val, id, seek_offset, seek_end); 
     372#endif 
     373 
     374  anx_set_presentation_time (anx, seek_offset); 
     375  anx_set_basetime (anx, 0.0); 
     376   
    344377  ret = anx_write_import (anx, filename, NULL, mime_type, 
    345378                          seek_offset, seek_end, 0);