comparison src/http/modules/ngx_http_mp4_module.c @ 4687:7f50a4063100

Mp4: fixed non-keyframe seeks in some cases (ticket #175). Number of entries in stsc atom was wrong if we've added an entry to split a chunk. Additionally, there is no need to add an entry if we are going to split last chunk in an entry, it's enough to update the entry we already have. Previously new entry was added and old one was left as is, resulting in incorrect entry with zero chunks which might confuse some software.
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 18 Jun 2012 14:01:18 +0000
parents 2b6cb7528409
children 5fedb27c3e36
comparison
equal deleted inserted replaced
4686:631eff4a0188 4687:7f50a4063100
2486 data->pos = (u_char *) entry; 2486 data->pos = (u_char *) entry;
2487 atom_size = sizeof(ngx_mp4_stsc_atom_t) + (data->last - data->pos); 2487 atom_size = sizeof(ngx_mp4_stsc_atom_t) + (data->last - data->pos);
2488 2488
2489 ngx_mp4_set_32value(entry->chunk, 1); 2489 ngx_mp4_set_32value(entry->chunk, 1);
2490 2490
2491 if (trak->chunk_samples) { 2491 if (trak->chunk_samples && next_chunk - trak->start_chunk == 2) {
2492
2493 /* last chunk in the entry */
2494
2495 ngx_mp4_set_32value(entry->samples, samples - trak->chunk_samples);
2496
2497 } else if (trak->chunk_samples) {
2492 2498
2493 first = &trak->stsc_chunk_entry; 2499 first = &trak->stsc_chunk_entry;
2494 ngx_mp4_set_32value(first->chunk, 1); 2500 ngx_mp4_set_32value(first->chunk, 1);
2495 ngx_mp4_set_32value(first->samples, samples - trak->chunk_samples); 2501 ngx_mp4_set_32value(first->samples, samples - trak->chunk_samples);
2496 ngx_mp4_set_32value(first->id, id); 2502 ngx_mp4_set_32value(first->id, id);
2502 2508
2503 trak->out[NGX_HTTP_MP4_STSC_CHUNK].buf = buf; 2509 trak->out[NGX_HTTP_MP4_STSC_CHUNK].buf = buf;
2504 2510
2505 ngx_mp4_set_32value(entry->chunk, 2); 2511 ngx_mp4_set_32value(entry->chunk, 2);
2506 2512
2513 entries++;
2507 atom_size += sizeof(ngx_mp4_stsc_entry_t); 2514 atom_size += sizeof(ngx_mp4_stsc_entry_t);
2508 } 2515 }
2509 2516
2510 while (++entry < end) { 2517 while (++entry < end) {
2511 chunk = ngx_mp4_get_32value(entry->chunk); 2518 chunk = ngx_mp4_get_32value(entry->chunk);