comparison libmpdemux/demux_ts.c @ 20485:8fb92804c652

ts_parse() move section handling after stream_read() rather than repeating it
author nicodvb
date Sun, 29 Oct 2006 10:23:15 +0000
parents d8dc67f94d5e
children 0cc36dd385ec
comparison
equal deleted inserted replaced
20484:50c4d39b6943 20485:8fb92804c652
2675 2675
2676 2676
2677 //TABLE PARSING 2677 //TABLE PARSING
2678 2678
2679 base = priv->ts.packet_size - buf_size; 2679 base = priv->ts.packet_size - buf_size;
2680 if(pid == 0)
2681 {
2682 stream_read(stream,&packet[base], buf_size);
2683 stream_skip(stream, junk);
2684 parse_pat(priv, is_start, &packet[base], buf_size);
2685 continue;
2686 }
2687 else if((tss->type == SL_SECTION) && pmt)
2688 {
2689 int k, ok=0, mp4_es_id = -1;
2690 ts_section_t *section;
2691 for(k = 0; k < pmt->mp4es_cnt; k++)
2692 {
2693 if(pmt->mp4es[k].decoder.object_type == MP4_OD && pmt->mp4es[k].decoder.stream_type == MP4_OD)
2694 mp4_es_id = pmt->mp4es[k].id;
2695 }
2696 mp_msg(MSGT_DEMUX, MSGL_DBG2, "MP4ESID: %d\n", mp4_es_id);
2697 for(k = 0; k < pmt->es_cnt; k++)
2698 {
2699 if(pmt->es[k].mp4_es_id == mp4_es_id)
2700 ok = 1;
2701 }
2702 stream_read(stream,&packet[base], buf_size);
2703 stream_skip(stream, junk);
2704 if(ok)
2705 {
2706 section = &(tss->section);
2707 parse_sl_section(pmt, section, progid, pid, is_start, &packet[base], buf_size);
2708 }
2709 continue;
2710 }
2711 else
2712 {
2713 progid = prog_id_in_pat(priv, pid);
2714 if(progid != -1)
2715 {
2716 if(pid != demuxer->video->id && pid != demuxer->audio->id && pid != demuxer->sub->id)
2717 {
2718 stream_read(stream,&packet[base], buf_size);
2719 stream_skip(stream, junk);
2720 parse_pmt(priv, progid, pid, is_start, &packet[base], buf_size);
2721 continue;
2722 }
2723 else
2724 mp_msg(MSGT_DEMUX, MSGL_ERR, "Argh! Data pid %d used in the PMT, Skipping PMT parsing!\n", pid);
2725 }
2726 }
2727
2728 2680
2729 priv->last_pid = pid; 2681 priv->last_pid = pid;
2730 2682
2731 is_video = IS_VIDEO(tss->type) || (tss->type==SL_PES_STREAM && IS_VIDEO(tss->subtype)); 2683 is_video = IS_VIDEO(tss->type) || (tss->type==SL_PES_STREAM && IS_VIDEO(tss->subtype));
2732 is_audio = IS_AUDIO(tss->type) || (tss->type==SL_PES_STREAM && IS_AUDIO(tss->subtype)) || (tss->type == PES_PRIVATE1); 2684 is_audio = IS_AUDIO(tss->type) || (tss->type==SL_PES_STREAM && IS_AUDIO(tss->subtype)) || (tss->type == PES_PRIVATE1);
2859 2811
2860 mp_msg(MSGT_DEMUX, MSGL_DBG2, "NOW PACKET_SIZE = %d, DP_OFFSET = %d\n", *buffer_size, *dp_offset); 2812 mp_msg(MSGT_DEMUX, MSGL_DBG2, "NOW PACKET_SIZE = %d, DP_OFFSET = %d\n", *buffer_size, *dp_offset);
2861 } 2813 }
2862 2814
2863 2815
2864 if(probe) 2816 if(probe || !dp) //dp is NULL for tables and sections
2865 { 2817 {
2866 p = &packet[base]; 2818 p = &packet[base];
2867 } 2819 }
2868 else //feeding 2820 else //feeding
2869 { 2821 {
2880 { 2832 {
2881 mp_msg(MSGT_DEMUX, MSGL_DBG2, "\r\nts_parse() couldn't read data\r\n"); 2833 mp_msg(MSGT_DEMUX, MSGL_DBG2, "\r\nts_parse() couldn't read data\r\n");
2882 continue; 2834 continue;
2883 } 2835 }
2884 stream_skip(stream, junk); 2836 stream_skip(stream, junk);
2837
2838 if(pid == 0)
2839 {
2840 parse_pat(priv, is_start, p, buf_size);
2841 continue;
2842 }
2843 else if((tss->type == SL_SECTION) && pmt)
2844 {
2845 int k, mp4_es_id = -1;
2846 ts_section_t *section;
2847 for(k = 0; k < pmt->mp4es_cnt; k++)
2848 {
2849 if(pmt->mp4es[k].decoder.object_type == MP4_OD && pmt->mp4es[k].decoder.stream_type == MP4_OD)
2850 mp4_es_id = pmt->mp4es[k].id;
2851 }
2852 mp_msg(MSGT_DEMUX, MSGL_DBG2, "MP4ESID: %d\n", mp4_es_id);
2853 for(k = 0; k < pmt->es_cnt; k++)
2854 {
2855 if(pmt->es[k].mp4_es_id == mp4_es_id)
2856 {
2857 section = &(tss->section);
2858 parse_sl_section(pmt, section, progid, pid, is_start, &packet[base], buf_size);
2859 }
2860 }
2861 continue;
2862 }
2863 else
2864 {
2865 progid = prog_id_in_pat(priv, pid);
2866 if(progid != -1)
2867 {
2868 if(pid != demuxer->video->id && pid != demuxer->audio->id && pid != demuxer->sub->id)
2869 {
2870 parse_pmt(priv, progid, pid, is_start, &packet[base], buf_size);
2871 continue;
2872 }
2873 else
2874 mp_msg(MSGT_DEMUX, MSGL_ERR, "Argh! Data pid %d used in the PMT, Skipping PMT parsing!\n", pid);
2875 }
2876 }
2885 2877
2886 if(is_start) 2878 if(is_start)
2887 { 2879 {
2888 uint8_t *lang = NULL; 2880 uint8_t *lang = NULL;
2889 2881