Revision 90d13e30 libavformat/mpegts.c

View differences:

libavformat/mpegts.c
110 110
    /** list of PMTs in the last PAT seen                    */
111 111
    MpegTSService **services;
112 112

  
113
    /** MPEG program number of stream we want to decode      */
114
    int req_sid;
115 113

  
116 114
    /** filters for various streams specified by PMT + for the PAT and PMT */
117 115
    MpegTSFilter *pids[NB_PID_MAX];
......
441 439
    av_log(ts->stream, AV_LOG_DEBUG, "sid=0x%x sec_num=%d/%d\n",
442 440
           h->id, h->sec_num, h->last_sec_num);
443 441
#endif
444
    if (h->tid != PMT_TID || (ts->req_sid >= 0 && h->id != ts->req_sid) )
442
    if (h->tid != PMT_TID)
445 443
        return;
446 444

  
447 445
    pcr_pid = get16(&p, p_end) & 0x1fff;
......
538 536
        case STREAM_TYPE_AUDIO_AC3:
539 537
        case STREAM_TYPE_AUDIO_DTS:
540 538
        case STREAM_TYPE_SUBTITLE_DVB:
539
            if(ts->pids[pid]){
540
                assert(ts->pids[pid].type == MPEGTS_PES);
541
                pes= ts->pids[pid]->u.pes_filter.opaque;
542
                st= pes->st;
543
            }else{
541 544
            pes = add_pes_stream(ts, pid, stream_type);
542 545
            if (pes)
543 546
                st = new_pes_av_stream(pes, 0);
544 547
            break;
548
            }
545 549
        default:
546 550
            /* we ignore the other streams */
547 551
            break;
......
561 565
        }
562 566
    }
563 567
    /* all parameters are there */
564
    ts->stop_parse=1;
568
    ts->stop_parse++;
565 569
    mpegts_close_filter(ts, filter);
566 570
}
567 571

  
......
596 600
        if (sid == 0x0000) {
597 601
            /* NIT info */
598 602
        } else {
599
            if (ts->req_sid == sid) {
603
            ts->stop_parse--;
600 604
                mpegts_open_section_filter(ts, pmt_pid,
601 605
                                                            pmt_cb, ts, 1);
602
                goto found;
603
            }
604 606
        }
605 607
    }
606 608
    /* not found */
607
    ts->stop_parse=1;
609
    ts->stop_parse++;
608 610

  
609
 found:
610 611
    mpegts_close_filter(ts, filter);
611 612
}
612 613

  
......
651 652
    mpegts_close_filter(ts, filter);
652 653
}
653 654

  
654
static void mpegts_set_service(MpegTSContext *ts, int sid)
655
static void mpegts_set_service(MpegTSContext *ts)
655 656
{
656
    ts->req_sid = sid;
657 657
    mpegts_open_section_filter(ts, PAT_PID,
658 658
                                                pat_cb, ts, 1);
659 659
}
......
1098 1098
    ts->stop_parse = 0;
1099 1099
    packet_num = 0;
1100 1100
    for(;;) {
1101
        if (ts->stop_parse)
1101
        if (ts->stop_parse>0)
1102 1102
            break;
1103 1103
        packet_num++;
1104 1104
        if (nb_packets != 0 && packet_num >= nb_packets)
......
1218 1218
            goto do_pcr;
1219 1219
        }
1220 1220

  
1221
        /* tune to first service found */
1222
        for(i=0; i<ts->nb_services; i++){
1223
            service = ts->services[i];
1224
            sid = service->sid;
1225
#ifdef DEBUG_SI
1226
            av_log(ts->stream, AV_LOG_DEBUG, "tuning to '%s'\n", service->name);
1227
#endif
1228

  
1229
            /* now find the info for the first service if we found any,
1230
            otherwise try to filter all PATs */
1231

  
1232 1221
            url_fseek(pb, pos, SEEK_SET);
1233
            mpegts_set_service(ts, sid);
1222
            mpegts_set_service(ts);
1234 1223

  
1235 1224
            handle_packets(ts, s->probesize);
1236
        }
1237 1225
        /* if could not find service, enable auto_guess */
1238 1226

  
1239 1227
        ts->auto_guess = 1;
......
1464 1452
    ts->pkt = pkt;
1465 1453
    ts->stop_parse = 0;
1466 1454
    for(;;) {
1467
        if (ts->stop_parse)
1455
        if (ts->stop_parse>0)
1468 1456
            break;
1469 1457
        if (len < TS_PACKET_SIZE)
1470 1458
            return -1;

Also available in: Unified diff