comparison src/http/modules/ngx_http_mp4_module.c @ 5202:322434f13bd8

Mp4: indentation and style, no functional changes.
author Maxim Dounin <mdounin@mdounin.ru>
date Sat, 11 May 2013 18:49:49 +0400
parents 37671d0042b7
children 670ceaba03d8
comparison
equal deleted inserted replaced
5201:06fbbde04098 5202:322434f13bd8
199 ((u_char *) (p))[7] = (u_char) (n) 199 ((u_char *) (p))[7] = (u_char) (n)
200 200
201 #define ngx_mp4_last_trak(mp4) \ 201 #define ngx_mp4_last_trak(mp4) \
202 &((ngx_http_mp4_trak_t *) mp4->trak.elts)[mp4->trak.nelts - 1] 202 &((ngx_http_mp4_trak_t *) mp4->trak.elts)[mp4->trak.nelts - 1]
203 203
204
205 static ngx_int_t ngx_http_mp4_handler(ngx_http_request_t *r);
204 206
205 static ngx_int_t ngx_http_mp4_process(ngx_http_mp4_file_t *mp4); 207 static ngx_int_t ngx_http_mp4_process(ngx_http_mp4_file_t *mp4);
206 static ngx_int_t ngx_http_mp4_read_atom(ngx_http_mp4_file_t *mp4, 208 static ngx_int_t ngx_http_mp4_read_atom(ngx_http_mp4_file_t *mp4,
207 ngx_http_mp4_atom_handler_t *atom, uint64_t atom_data_size); 209 ngx_http_mp4_atom_handler_t *atom, uint64_t atom_data_size);
208 static ngx_int_t ngx_http_mp4_read(ngx_http_mp4_file_t *mp4, size_t size); 210 static ngx_int_t ngx_http_mp4_read(ngx_http_mp4_file_t *mp4, size_t size);
278 uint64_t atom_data_size); 280 uint64_t atom_data_size);
279 static ngx_int_t ngx_http_mp4_update_co64_atom(ngx_http_mp4_file_t *mp4, 281 static ngx_int_t ngx_http_mp4_update_co64_atom(ngx_http_mp4_file_t *mp4,
280 ngx_http_mp4_trak_t *trak); 282 ngx_http_mp4_trak_t *trak);
281 static void ngx_http_mp4_adjust_co64_atom(ngx_http_mp4_file_t *mp4, 283 static void ngx_http_mp4_adjust_co64_atom(ngx_http_mp4_file_t *mp4,
282 ngx_http_mp4_trak_t *trak, off_t adjustment); 284 ngx_http_mp4_trak_t *trak, off_t adjustment);
285
283 static char *ngx_http_mp4(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); 286 static char *ngx_http_mp4(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
284 static void *ngx_http_mp4_create_conf(ngx_conf_t *cf); 287 static void *ngx_http_mp4_create_conf(ngx_conf_t *cf);
285 static char *ngx_http_mp4_merge_conf(ngx_conf_t *cf, void *parent, void *child); 288 static char *ngx_http_mp4_merge_conf(ngx_conf_t *cf, void *parent, void *child);
289
286 290
287 static ngx_command_t ngx_http_mp4_commands[] = { 291 static ngx_command_t ngx_http_mp4_commands[] = {
288 292
289 { ngx_string("mp4"), 293 { ngx_string("mp4"),
290 NGX_HTTP_LOC_CONF|NGX_CONF_NOARGS, 294 NGX_HTTP_LOC_CONF|NGX_CONF_NOARGS,
516 */ 520 */
517 521
518 ngx_set_errno(0); 522 ngx_set_errno(0);
519 start = (int) (strtod((char *) value.data, NULL) * 1000); 523 start = (int) (strtod((char *) value.data, NULL) * 1000);
520 524
521 if (ngx_errno == 0 && start >= 0) { 525 if (ngx_errno != 0) {
522 r->allow_ranges = 0; 526 start = -1;
523
524 mp4 = ngx_pcalloc(r->pool, sizeof(ngx_http_mp4_file_t));
525 if (mp4 == NULL) {
526 return NGX_HTTP_INTERNAL_SERVER_ERROR;
527 }
528
529 mp4->file.fd = of.fd;
530 mp4->file.name = path;
531 mp4->file.log = r->connection->log;;
532 mp4->end = of.size;
533 mp4->start = (ngx_uint_t) start;
534 mp4->request = r;
535
536 switch (ngx_http_mp4_process(mp4)) {
537
538 case NGX_DECLINED:
539 if (mp4->buffer) {
540 ngx_pfree(r->pool, mp4->buffer);
541 }
542
543 ngx_pfree(r->pool, mp4);
544 mp4 = NULL;
545
546 break;
547
548 case NGX_OK:
549 r->headers_out.content_length_n = mp4->content_length;
550 break;
551
552 default: /* NGX_ERROR */
553 if (mp4->buffer) {
554 ngx_pfree(r->pool, mp4->buffer);
555 }
556
557 ngx_pfree(r->pool, mp4);
558
559 return NGX_HTTP_INTERNAL_SERVER_ERROR;
560 }
561 } 527 }
528 }
529 }
530
531 if (start >= 0) {
532 r->allow_ranges = 0;
533
534 mp4 = ngx_pcalloc(r->pool, sizeof(ngx_http_mp4_file_t));
535 if (mp4 == NULL) {
536 return NGX_HTTP_INTERNAL_SERVER_ERROR;
537 }
538
539 mp4->file.fd = of.fd;
540 mp4->file.name = path;
541 mp4->file.log = r->connection->log;;
542 mp4->end = of.size;
543 mp4->start = (ngx_uint_t) start;
544 mp4->request = r;
545
546 switch (ngx_http_mp4_process(mp4)) {
547
548 case NGX_DECLINED:
549 if (mp4->buffer) {
550 ngx_pfree(r->pool, mp4->buffer);
551 }
552
553 ngx_pfree(r->pool, mp4);
554 mp4 = NULL;
555
556 break;
557
558 case NGX_OK:
559 r->headers_out.content_length_n = mp4->content_length;
560 break;
561
562 default: /* NGX_ERROR */
563 if (mp4->buffer) {
564 ngx_pfree(r->pool, mp4->buffer);
565 }
566
567 ngx_pfree(r->pool, mp4);
568
569 return NGX_HTTP_INTERNAL_SERVER_ERROR;
562 } 570 }
563 } 571 }
564 572
565 log->action = "sending mp4 to client"; 573 log->action = "sending mp4 to client";
566 574