Mercurial > hg > nginx
comparison src/http/modules/ngx_http_mp4_module.c @ 4727:1c7616100797 stable-1.2
Merge of r4688, r4689, r4706:
*) 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.
*) Mp4: fixed streaming if moov atom is at buffer edge.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 02 Jul 2012 16:56:53 +0000 |
parents | f12d474f0d5e |
children | 2bdb94e65a4c |
comparison
equal
deleted
inserted
replaced
4726:dad38cdaf496 | 4727:1c7616100797 |
---|---|
1022 | 1022 |
1023 mp4->buffer_size = (size_t) atom_data_size | 1023 mp4->buffer_size = (size_t) atom_data_size |
1024 + NGX_HTTP_MP4_MOOV_BUFFER_EXCESS * no_mdat; | 1024 + NGX_HTTP_MP4_MOOV_BUFFER_EXCESS * no_mdat; |
1025 } | 1025 } |
1026 | 1026 |
1027 if (ngx_http_mp4_read(mp4, (size_t) atom_data_size) != NGX_OK) { | |
1028 return NGX_ERROR; | |
1029 } | |
1030 | |
1027 mp4->trak.elts = &mp4->traks; | 1031 mp4->trak.elts = &mp4->traks; |
1028 mp4->trak.size = sizeof(ngx_http_mp4_trak_t); | 1032 mp4->trak.size = sizeof(ngx_http_mp4_trak_t); |
1029 mp4->trak.nalloc = 2; | 1033 mp4->trak.nalloc = 2; |
1030 mp4->trak.pool = mp4->request->pool; | 1034 mp4->trak.pool = mp4->request->pool; |
1031 | 1035 |
1041 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, mp4->file.log, 0, "mp4 moov atom done"); | 1045 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, mp4->file.log, 0, "mp4 moov atom done"); |
1042 | 1046 |
1043 if (no_mdat) { | 1047 if (no_mdat) { |
1044 mp4->buffer_start = mp4->buffer_pos; | 1048 mp4->buffer_start = mp4->buffer_pos; |
1045 mp4->buffer_size = NGX_HTTP_MP4_MOOV_BUFFER_EXCESS; | 1049 mp4->buffer_size = NGX_HTTP_MP4_MOOV_BUFFER_EXCESS; |
1050 | |
1051 if (mp4->buffer_start + mp4->buffer_size > mp4->buffer_end) { | |
1052 mp4->buffer = NULL; | |
1053 mp4->buffer_pos = NULL; | |
1054 mp4->buffer_end = NULL; | |
1055 } | |
1046 | 1056 |
1047 } else { | 1057 } else { |
1048 /* skip atoms after moov atom */ | 1058 /* skip atoms after moov atom */ |
1049 mp4->offset = mp4->end; | 1059 mp4->offset = mp4->end; |
1050 } | 1060 } |
2486 data->pos = (u_char *) entry; | 2496 data->pos = (u_char *) entry; |
2487 atom_size = sizeof(ngx_mp4_stsc_atom_t) + (data->last - data->pos); | 2497 atom_size = sizeof(ngx_mp4_stsc_atom_t) + (data->last - data->pos); |
2488 | 2498 |
2489 ngx_mp4_set_32value(entry->chunk, 1); | 2499 ngx_mp4_set_32value(entry->chunk, 1); |
2490 | 2500 |
2491 if (trak->chunk_samples) { | 2501 if (trak->chunk_samples && next_chunk - trak->start_chunk == 2) { |
2502 | |
2503 /* last chunk in the entry */ | |
2504 | |
2505 ngx_mp4_set_32value(entry->samples, samples - trak->chunk_samples); | |
2506 | |
2507 } else if (trak->chunk_samples) { | |
2492 | 2508 |
2493 first = &trak->stsc_chunk_entry; | 2509 first = &trak->stsc_chunk_entry; |
2494 ngx_mp4_set_32value(first->chunk, 1); | 2510 ngx_mp4_set_32value(first->chunk, 1); |
2495 ngx_mp4_set_32value(first->samples, samples - trak->chunk_samples); | 2511 ngx_mp4_set_32value(first->samples, samples - trak->chunk_samples); |
2496 ngx_mp4_set_32value(first->id, id); | 2512 ngx_mp4_set_32value(first->id, id); |
2502 | 2518 |
2503 trak->out[NGX_HTTP_MP4_STSC_CHUNK].buf = buf; | 2519 trak->out[NGX_HTTP_MP4_STSC_CHUNK].buf = buf; |
2504 | 2520 |
2505 ngx_mp4_set_32value(entry->chunk, 2); | 2521 ngx_mp4_set_32value(entry->chunk, 2); |
2506 | 2522 |
2523 entries++; | |
2507 atom_size += sizeof(ngx_mp4_stsc_entry_t); | 2524 atom_size += sizeof(ngx_mp4_stsc_entry_t); |
2508 } | 2525 } |
2509 | 2526 |
2510 while (++entry < end) { | 2527 while (++entry < end) { |
2511 chunk = ngx_mp4_get_32value(entry->chunk); | 2528 chunk = ngx_mp4_get_32value(entry->chunk); |