comparison rdt.c @ 6356:2048bf728893 libavformat

get ride of MAX_STREAMS limit in RDT
author aurel
date Mon, 09 Aug 2010 22:58:54 +0000
parents a036426dc8e6
children
comparison
equal deleted inserted replaced
6355:3aa7765383b5 6356:2048bf728893
84 av_free(s); 84 av_free(s);
85 } 85 }
86 86
87 struct PayloadContext { 87 struct PayloadContext {
88 AVFormatContext *rmctx; 88 AVFormatContext *rmctx;
89 RMStream *rmst[MAX_STREAMS]; 89 int nb_rmst;
90 RMStream **rmst;
90 uint8_t *mlti_data; 91 uint8_t *mlti_data;
91 unsigned int mlti_data_size; 92 unsigned int mlti_data_size;
92 char buffer[RTP_MAX_PACKET_LENGTH + FF_INPUT_BUFFER_PADDING_SIZE]; 93 char buffer[RTP_MAX_PACKET_LENGTH + FF_INPUT_BUFFER_PADDING_SIZE];
93 int audio_pkt_cnt; /**< remaining audio packets in rmdec */ 94 int audio_pkt_cnt; /**< remaining audio packets in rmdec */
94 }; 95 };
419 else if (av_strstart(p, "ASMRuleBook:string;", &p)) { 420 else if (av_strstart(p, "ASMRuleBook:string;", &p)) {
420 int n, first = -1; 421 int n, first = -1;
421 422
422 for (n = 0; n < s->nb_streams; n++) 423 for (n = 0; n < s->nb_streams; n++)
423 if (s->streams[n]->priv_data == stream->priv_data) { 424 if (s->streams[n]->priv_data == stream->priv_data) {
425 int count = s->streams[n]->index + 1;
424 if (first == -1) first = n; 426 if (first == -1) first = n;
427 if (rdt->nb_rmst < count) {
428 RMStream **rmst= av_realloc(rdt->rmst, count*sizeof(*rmst));
429 if (!rmst)
430 return AVERROR(ENOMEM);
431 memset(rmst + rdt->nb_rmst, 0,
432 (count - rdt->nb_rmst) * sizeof(*rmst));
433 rdt->rmst = rmst;
434 rdt->nb_rmst = count;
435 }
425 rdt->rmst[s->streams[n]->index] = ff_rm_alloc_rmstream(); 436 rdt->rmst[s->streams[n]->index] = ff_rm_alloc_rmstream();
426 rdt_load_mdpr(rdt, s->streams[n], (n - first) * 2); 437 rdt_load_mdpr(rdt, s->streams[n], (n - first) * 2);
427 438
428 if (s->streams[n]->codec->codec_id == CODEC_ID_AAC) 439 if (s->streams[n]->codec->codec_id == CODEC_ID_AAC)
429 s->streams[n]->codec->frame_size = 1; // FIXME 440 s->streams[n]->codec->frame_size = 1; // FIXME
463 static void 474 static void
464 real_parse_asm_rulebook(AVFormatContext *s, AVStream *orig_st, 475 real_parse_asm_rulebook(AVFormatContext *s, AVStream *orig_st,
465 const char *p) 476 const char *p)
466 { 477 {
467 const char *end; 478 const char *end;
468 int n_rules, odd = 0; 479 int n_rules = 0, odd = 0;
469 AVStream *st; 480 AVStream *st;
470 481
471 /** 482 /**
472 * The ASMRuleBook contains a list of comma-separated strings per rule, 483 * The ASMRuleBook contains a list of comma-separated strings per rule,
473 * and each rule is separated by a ;. The last one also has a ; at the 484 * and each rule is separated by a ;. The last one also has a ; at the
481 * so there are never multiple conditions spread out over separate 492 * so there are never multiple conditions spread out over separate
482 * statements. Generally, these conditions are bitrate limits (min/max) 493 * statements. Generally, these conditions are bitrate limits (min/max)
483 * for multi-bitrate streams. 494 * for multi-bitrate streams.
484 */ 495 */
485 if (*p == '\"') p++; 496 if (*p == '\"') p++;
486 for (n_rules = 0; s->nb_streams < MAX_STREAMS;) { 497 while (1) {
487 if (!(end = strchr(p, ';'))) 498 if (!(end = strchr(p, ';')))
488 break; 499 break;
489 if (!odd && end != p) { 500 if (!odd && end != p) {
490 if (n_rules > 0) 501 if (n_rules > 0)
491 st = add_dstream(s, orig_st); 502 st = add_dstream(s, orig_st);
492 else 503 else
493 st = orig_st; 504 st = orig_st;
505 if (!st)
506 break;
494 real_parse_asm_rule(st, p, end); 507 real_parse_asm_rule(st, p, end);
495 n_rules++; 508 n_rules++;
496 } 509 }
497 p = end + 1; 510 p = end + 1;
498 odd ^= 1; 511 odd ^= 1;
522 static void 535 static void
523 rdt_free_context (PayloadContext *rdt) 536 rdt_free_context (PayloadContext *rdt)
524 { 537 {
525 int i; 538 int i;
526 539
527 for (i = 0; i < MAX_STREAMS; i++) 540 for (i = 0; i < rdt->nb_rmst; i++)
528 if (rdt->rmst[i]) { 541 if (rdt->rmst[i]) {
529 ff_rm_free_rmstream(rdt->rmst[i]); 542 ff_rm_free_rmstream(rdt->rmst[i]);
530 av_freep(&rdt->rmst[i]); 543 av_freep(&rdt->rmst[i]);
531 } 544 }
532 if (rdt->rmctx) 545 if (rdt->rmctx)
533 av_close_input_stream(rdt->rmctx); 546 av_close_input_stream(rdt->rmctx);
534 av_freep(&rdt->mlti_data); 547 av_freep(&rdt->mlti_data);
548 av_freep(&rdt->rmst);
535 av_free(rdt); 549 av_free(rdt);
536 } 550 }
537 551
538 #define RDT_HANDLER(n, s, t) \ 552 #define RDT_HANDLER(n, s, t) \
539 static RTPDynamicProtocolHandler ff_rdt_ ## n ## _handler = { \ 553 static RTPDynamicProtocolHandler ff_rdt_ ## n ## _handler = { \