| | 303 | static double |
|---|
| | 304 | ma_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 | |
|---|
| 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 | |
|---|
| | 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 | |
|---|