Changeset 792

Show
Ignore:
Timestamp:
08/03/07 13:49:53 (10 years ago)
Author:
zaheer
Message:

Merge from trunk.
Most of the work done by Allesandro Decina.

Location:
branches/dvb-si-1
Files:
1 removed
17 modified

Legend:

Unmodified
Added
Removed
  • branches/dvb-si-1

    • Property svn:externals set to
  • branches/dvb-si-1/ChangeLog

    r637 r792  
     12007-08-03  Zaheer Abbas Merali  <zaheerabbas at merali dot org> 
     2 
     3        * src/flutspmtinfo.c (PROP_DESCRIPTORS, fluts_pmt_info_class_init, 
     4          fluts_pmt_info_init, fluts_pmt_info_finalize, 
     5          fluts_pmt_info_get_property, fluts_pmt_info_add_descriptor): 
     6        * src/flutspmtinfo.h (descriptors, streams, FluTsPmtInfo): 
     7        * src/flutspmtstreaminfo.c (PROP_LANGUAGES, PROP_STREAM_TYPE, 
     8          PROP_DESCRIPTORS, fluts_pmt_stream_info_class_init, 
     9          fluts_pmt_stream_info_init, fluts_pmt_stream_info_finalize, 
     10          fluts_pmt_stream_info_new, fluts_pmt_stream_info_add_language, 
     11          fluts_pmt_stream_info_add_descriptor, 
     12          fluts_pmt_stream_info_get_property): 
     13        * src/flutspmtstreaminfo.h (stream_type, descriptors, 
     14          FluTsPmtStreamInfo): 
     15        * src/gstdvbtables.c (gst_fluts_stream_parse_dvb_sdt, 
     16          gst_fluts_stream_parse_dvb_nit, gst_fluts_stream_parse_dvb_eit, 
     17          fluts_dvb_tables_build_si_info): 
     18        * src/gstmpegdefs.h (ID_RESERVED_STREAM_1, ID_RESERVED_STREAM_2, 
     19          ID_EXTENDED_METADATA, ID_EXTENDED_STREAM_ID, ID_RESERVED_STREAM_3): 
     20        * src/gstmpegdemux.c (video_template, audio_template, 
     21          gst_flups_demux_class_init, gst_flups_demux_init, 
     22          gst_flups_demux_send_data, gst_flups_demux_mark_discont, 
     23          gst_flups_demux_sink_event, gst_flups_demux_src_event, 
     24          gst_flups_demux_src_query, gst_flups_demux_parse_pack_start, 
     25          gst_flups_demux_data_cb, gst_flups_demux_chain): 
     26        * src/gstmpegdesc.c (gst_mpeg_descriptor_nth): 
     27        * src/gstmpegtsdemux.c (HAVE_ADAPTER_TAKE_BUF, video_template, 
     28          audio_template, private_template, gst_fluts_is_dirac_stream, 
     29          gst_fluts_stream_is_video, gst_fluts_demux_fill_stream, 
     30          gst_fluts_demux_send_new_segment, GST_FLOW_IS_SUCCESS, 
     31          gst_fluts_demux_data_cb, gst_fluts_demux_get_stream_for_PID, 
     32          gst_fluts_activate_pmt, gst_fluts_stream_parse_pmt, 
     33          gst_fluts_demux_parse_adaptation_field, gst_fluts_demux_parse_stream, 
     34          gst_fluts_demux_parse_transport_packet, gst_fluts_demux_sink_event, 
     35          GST_BUFFER_IS_DISCONT, fluts_demux_build_pmt_info): 
     36        * src/gstmpegtsdemux.h (FLUTS_STREAM_FLAG_PMT_VALID, 
     37          FLUTS_STREAM_FLAG_IS_VIDEO, last_PCR_difference, discont_PCR, 
     38          discont_difference, base_time, last_time, PMT_pid): 
     39        * src/gstpesfilter.c (gst_pes_filter_init, gst_pes_filter_is_sync, 
     40          gst_pes_filter_parse): 
     41        * src/gstpesfilter.h (gather_pes, allow_unbounded): 
     42        Merge from trunk. 
     43        Most of the work done by: Allesandro Decina. 
     44 
    1452007-02-11  Zaheer Abbas Merali  <zaheerabbas at merali dot org> 
    246 
  • branches/dvb-si-1/Makefile.am

    r412 r792  
    1 SUBDIRS = m4 src common 
     1SUBDIRS = src common 
    22 
    33EXTRA_DIST = autogen.sh gst-fluendo-mpegdemux.spec 
  • branches/dvb-si-1/autogen.sh

    r399 r792  
    4747# aclocal 
    4848if test -f acinclude.m4; then rm acinclude.m4; fi 
    49 tool_run "$aclocal" "-I m4 $ACLOCAL_FLAGS" 
     49tool_run "$aclocal" "-I common/m4 $ACLOCAL_FLAGS" 
    5050 
    5151tool_run "$libtoolize" "--copy --force" 
  • branches/dvb-si-1/configure.ac

    r564 r792  
    1 AC_INIT 
     1AC_PREREQ(2.52) 
    22 
    3 dnl the fourth (nano) number should be 0 for a release, 1 for trunk, 
     3dnl please read gstreamer/docs/random/autotools before changing this file 
     4 
     5dnl initialize autoconf 
     6dnl fill in your package name and version here 
     7dnl the fourth (nano) number should be 0 for a release, 1 for CVS, 
    48dnl and 2... for a prerelease 
    5 dnl releases only do Wall, cvs and prerelease does Werror too 
    6 AS_VERSION(gst-fluendo-mpegdemux, GST_PLUGIN_VERSION, 0, 10, 8, 1, 
    7     GST_PLUGIN_TRUNK="no", GST_PLUGIN_TRUNK="no") 
     9dnl releases only do -Wall, cvs and prerelease does -Werror too 
     10AC_INIT(GStreamer Fluendo MPEG Demuxer, 0.10.12.1,, 
     11    gst-fluendo-mpegdemux) 
    812 
    9 dnl AM_MAINTAINER_MODE provides the option to enable maintainer mode 
     13AG_GST_INIT 
     14 
     15dnl initialize automake 
     16AM_INIT_AUTOMAKE 
     17 
     18dnl define PACKAGE_VERSION_* variables 
     19AS_VERSION 
     20 
     21dnl check if this is a release version 
     22AS_NANO(GST_CVS="no", GST_CVS="yes") 
     23 
     24dnl define the output header for config 
     25AM_CONFIG_HEADER([config.h]) 
     26 
     27dnl AM_MAINTAINER_MODE only provides the option to configure to enable it 
    1028AM_MAINTAINER_MODE 
    1129 
    12 AM_INIT_AUTOMAKE($PACKAGE, $VERSION) 
    13  
    14 AM_CONFIG_HEADER(config.h) 
     30dnl sets host_* variables 
     31AC_CANONICAL_HOST 
    1532 
    1633dnl make aclocal work in maintainer mode 
    17 AC_SUBST(ACLOCAL_AMFLAGS, "-I m4") 
     34AC_SUBST(ACLOCAL_AMFLAGS, "-I common/m4") 
    1835 
    19 dnl check for tools 
     36dnl *** check for arguments to configure *** 
     37 
     38AG_GST_ARG_PROFILING 
     39AG_GST_ARG_VALGRIND 
     40AG_GST_ARG_GCOV 
     41 
     42dnl *** checks for programs *** 
     43 
    2044AC_PROG_CC 
    2145AC_PROG_LIBTOOL 
    2246 
    23 dnl decide on error flags 
    24 AS_COMPILER_FLAG(-Wall, GST_WALL="yes", GST_WALL="no") 
    25                                                                                  
    26 if test "x$GST_WALL" = "xyes"; then 
    27    GST_ERROR="$GST_ERROR -Wall" 
    28                                                                                  
    29    if test "x$GST_PLUGIN_TRUNK" = "xyes"; then 
    30      AS_COMPILER_FLAG(-Werror, 
    31          GST_ERROR="$GST_ERROR -Werror", 
    32          GST_ERROR="$GST_ERROR") 
    33    fi 
    34 fi 
     47AC_PATH_PROG(VALGRIND_PATH, valgrind, no) 
     48AM_CONDITIONAL(HAVE_VALGRIND, test ! "x$VALGRIND_PATH" = "xno") 
     49 
     50dnl define an ERROR_CFLAGS Makefile variable 
     51AG_GST_SET_ERROR_CFLAGS($GST_CVS) 
    3552 
    3653dnl Check for pkgconfig first 
     
    4562dnl And we can also ask for the right version of gstreamer 
    4663 
    47 GST_REQUIRED=0.10.5.1 
     64GST_REQ=0.10.3 
     65GSTPB_REQ=0.10.3 
    4866 
    4967GST_MAJORMINOR=0.10 
    50 PKG_CHECK_MODULES(GST, \ 
    51   gstreamer-$GST_MAJORMINOR >= $GST_REQUIRED, 
    52   HAVE_GST=yes,HAVE_GST=no) 
    5368 
    54 dnl Give error and exit if we don't have gstreamer 
    55 if test "x$HAVE_GST" = "xno"; then 
    56   AC_MSG_ERROR(you need gstreamer development packages installed !) 
    57 fi 
    58  
    59 PKG_CHECK_MODULES(GST_BASE, \ 
    60   gstreamer-base-$GST_MAJORMINOR >= $GST_REQUIRED, 
    61   HAVE_GST_BASE=yes,HAVE_GST_BASE=no) 
    62  
    63 dnl Give error and exit if we don't have gstreamer 
    64 if test "x$HAVE_GST_BASE" = "xno"; then 
    65   AC_MSG_ERROR(you need gstreamer base development packages installed !) 
    66 fi 
     69AG_GST_CHECK_GST($GST_MAJORMINOR, [$GST_REQ]) 
     70AG_GST_CHECK_GST_BASE($GST_MAJORMINOR, [$GST_REQ]) 
    6771 
    6872GST_CFLAGS="$GST_CFLAGS $GST_ERROR" 
     
    7680AC_SUBST(GST_MAJORMINOR) 
    7781 
    78 dnl set the plugindir where plugins should be installed 
    79 plugindir="\$(libdir)/gstreamer-$GST_MAJORMINOR" 
    80 AC_SUBST(plugindir) 
     82AG_GST_SET_PLUGINDIR 
    8183 
    8284dnl set proper LDFLAGS for plugins 
     
    8688AC_OUTPUT( 
    8789Makefile 
    88 m4/Makefile 
    8990src/Makefile 
    9091common/Makefile 
     92common/m4/Makefile 
    9193gst-fluendo-mpegdemux.spec 
    9294) 
  • branches/dvb-si-1/src/flutspmtinfo.c

    r585 r792  
    3333  PROP_VERSION_NO, 
    3434  PROP_PCR_PID, 
     35  PROP_DESCRIPTORS, 
    3536  PROP_STREAMINFO 
    3637}; 
     
    8182       "Version number of this program information", 0, G_MAXUINT8, 1, 
    8283       G_PARAM_READABLE)); 
     84   
     85  g_object_class_install_property (gobject_klass, PROP_DESCRIPTORS, 
     86    g_param_spec_value_array ("descriptors", 
     87      "Descriptors", 
     88      "Value array of strings containing program descriptors", 
     89      g_param_spec_boxed ("descriptor", 
     90        "descriptor", 
     91        "", 
     92        G_TYPE_GSTRING, 
     93        G_PARAM_READABLE), 
     94      G_PARAM_READABLE)); 
    8395} 
    8496 
     
    8799{ 
    88100  pmt_info->streams = g_value_array_new (0); 
     101  pmt_info->descriptors = g_value_array_new (0); 
    89102} 
    90103 
     
    109122 
    110123  g_value_array_free (info->streams); 
     124  g_value_array_free (info->descriptors); 
    111125 
    112126  G_OBJECT_CLASS (parent_class)->finalize (object); 
     
    144158      g_value_set_uint (value, pmt_info->version_no); 
    145159      break; 
     160    case PROP_DESCRIPTORS: 
     161      g_value_set_boxed (value, pmt_info->descriptors); 
     162      break; 
    146163    default: 
    147164      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, spec); 
    148165      break; 
    149166  } 
     167} 
     168 
     169void 
     170fluts_pmt_info_add_descriptor (FluTsPmtInfo *pmt_info, 
     171  const gchar *descriptor, guint length) 
     172{ 
     173  GValue value = {0}; 
     174  GString *string; 
     175 
     176  g_return_if_fail (FLUTS_IS_PMT_INFO (pmt_info)); 
     177 
     178  string = g_string_new_len (descriptor, length); 
     179 
     180  g_value_init (&value, G_TYPE_GSTRING); 
     181  g_value_take_boxed (&value, string); 
     182  g_value_array_append (pmt_info->descriptors, &value); 
     183  g_value_unset (&value); 
    150184} 
    151185 
  • branches/dvb-si-1/src/flutspmtinfo.h

    r585 r792  
    3939  guint8 version_no; 
    4040 
     41  GValueArray *descriptors; 
    4142  GValueArray *streams; 
    4243} FluTsPmtInfo; 
     
    4445FluTsPmtInfo *fluts_pmt_info_new (guint16 program_no, guint16 pcr_pid, guint8 version); 
    4546void fluts_pmt_info_add_stream (FluTsPmtInfo *pmt_info, FluTsPmtStreamInfo *stream); 
     47void fluts_pmt_info_add_descriptor (FluTsPmtInfo *pmt_info,      
     48  const gchar *descriptor, guint length); 
    4649 
    4750GType fluts_pmt_info_get_type (void); 
  • branches/dvb-si-1/src/flutspmtstreaminfo.c

    r598 r792  
    3131  PROP_0, 
    3232  PROP_PID, 
    33   PROP_LANGUAGES 
     33  PROP_LANGUAGES, 
     34  PROP_STREAM_TYPE, 
     35  PROP_DESCRIPTORS, 
    3436}; 
    3537 
     
    4143static void fluts_pmt_stream_info_get_property (GObject * object, guint prop_id, 
    4244    GValue * value, GParamSpec * spec); 
     45static void fluts_pmt_stream_info_finalize (GObject *object); 
    4346 
    4447static void 
     
    5457  gobject_klass->set_property = fluts_pmt_stream_info_set_property; 
    5558  gobject_klass->get_property = fluts_pmt_stream_info_get_property; 
     59  gobject_klass->finalize = fluts_pmt_stream_info_finalize; 
    5660 
    5761  g_object_class_install_property (gobject_klass, PROP_PID, 
     
    6367       "Value array of the languages of this stream",  
    6468         g_param_spec_string("language", "language", "language", "",  
    65            G_PARAM_READABLE), 
    66          G_PARAM_READABLE)); 
     69         G_PARAM_READABLE), 
     70         G_PARAM_READABLE)); 
     71   
     72  g_object_class_install_property (gobject_klass, PROP_STREAM_TYPE, 
     73    g_param_spec_uint ("stream-type", 
     74      "Stream type", 
     75      "Stream type", 
     76      0, 
     77      G_MAXUINT8, 
     78      0, 
     79      G_PARAM_READABLE)); 
     80   
     81  g_object_class_install_property (gobject_klass, PROP_DESCRIPTORS, 
     82    g_param_spec_value_array ("descriptors", 
     83      "Descriptors", 
     84      "Value array of strings containing stream descriptors", 
     85      g_param_spec_boxed ("descriptor", 
     86        "descriptor", 
     87        "", 
     88        G_TYPE_GSTRING, 
     89        G_PARAM_READABLE), 
     90      G_PARAM_READABLE)); 
    6791} 
    6892 
     
    7195{ 
    7296  pmt_stream_info->languages = g_value_array_new ( 0 ); 
     97  pmt_stream_info->descriptors = g_value_array_new (0); 
    7398} 
    7499 
    75 FluTsPmtStreamInfo *fluts_pmt_stream_info_new (guint16 pid) 
     100static void 
     101fluts_pmt_stream_info_finalize (GObject *object) 
     102{ 
     103  FluTsPmtStreamInfo *info = FLUTS_PMT_STREAM_INFO (object); 
     104 
     105  g_value_array_free (info->languages); 
     106  g_value_array_free (info->descriptors); 
     107} 
     108 
     109FluTsPmtStreamInfo *fluts_pmt_stream_info_new (guint16 pid, guint8 type) 
    76110{ 
    77111  FluTsPmtStreamInfo *info; 
     
    79113 
    80114  info->pid = pid; 
     115  info->stream_type = type; 
    81116  return info; 
    82117} 
     
    92127  g_value_take_string (&v, language); 
    93128  g_value_array_append (pmt_info->languages, &v); 
     129  g_value_unset (&v); 
     130} 
     131 
     132void 
     133fluts_pmt_stream_info_add_descriptor (FluTsPmtStreamInfo *pmt_info, 
     134  const gchar *descriptor, guint length) 
     135{ 
     136  GValue value = {0}; 
     137  GString *string; 
     138 
     139  g_return_if_fail (FLUTS_IS_PMT_STREAM_INFO (pmt_info)); 
     140 
     141  string = g_string_new_len (descriptor, length); 
     142 
     143  g_value_init (&value, G_TYPE_GSTRING); 
     144  g_value_take_boxed (&value, string); 
     145  g_value_array_append (pmt_info->descriptors, &value); 
     146  g_value_unset (&value); 
    94147} 
    95148 
     
    115168 
    116169  switch (prop_id) { 
     170    case PROP_STREAM_TYPE: 
     171      g_value_set_uint (value, si->stream_type); 
     172      break; 
    117173    case PROP_PID: 
    118174      g_value_set_uint (value, si->pid); 
     
    120176    case PROP_LANGUAGES: 
    121177      g_value_set_boxed (value, si->languages); 
     178      break; 
     179    case PROP_DESCRIPTORS: 
     180      g_value_set_boxed (value, si->descriptors); 
    122181      break; 
    123182    default: 
  • branches/dvb-si-1/src/flutspmtstreaminfo.h

    r598 r792  
    3636  guint16 pid; 
    3737  GValueArray *languages; /* null terminated 3 character ISO639 language code */ 
     38  guint8 stream_type; 
     39  GValueArray *descriptors; 
    3840} FluTsPmtStreamInfo; 
    3941 
    40 FluTsPmtStreamInfo *fluts_pmt_stream_info_new (guint16 pid); 
     42FluTsPmtStreamInfo *fluts_pmt_stream_info_new (guint16 pid, guint8 type); 
    4143void fluts_pmt_stream_info_add_language(FluTsPmtStreamInfo* si, gchar* language); 
    4244 
  • branches/dvb-si-1/src/gstdvbtables.c

    r635 r792  
    183183  } 
    184184  else { 
    185     GST_DEBUG("oi transport_stream_id: %d hash: %d", transport_stream_id, 
    186       g_direct_hash(transport_stream_id)); 
    187185    SDT = (GstFluTSDVBSDT*)g_hash_table_lookup(demux->dvb_tables->other_ts_sdt_tables, 
    188       transport_stream_id); 
     186      GINT_TO_POINTER ((gint) transport_stream_id)); 
    189187    if (SDT == NULL) { 
    190188      SDT = g_new0(GstFluTSDVBSDT, 1); 
    191189      new_sdt = TRUE; 
    192190      g_hash_table_insert (demux->dvb_tables->other_ts_sdt_tables,  
    193         (gpointer)(guint)transport_stream_id, SDT); 
     191        GINT_TO_POINTER ((gint) transport_stream_id), SDT); 
    194192    } 
    195193  } 
     
    369367  else { 
    370368    NIT = (GstFluTSDVBNIT*)g_hash_table_lookup(demux->dvb_tables->other_network_nit_tables, 
    371       (gpointer)(guint)network_id); 
     369      GINT_TO_POINTER ((gint) network_id)); 
    372370    if (NIT == NULL) { 
    373371      NIT = g_new(GstFluTSDVBNIT, 1); 
    374372      new_nit = TRUE; 
    375373      g_hash_table_insert (demux->dvb_tables->other_network_nit_tables,  
    376         (gpointer)(guint)network_id, NIT); 
     374        GINT_TO_POINTER ((gint) network_id), NIT); 
    377375    } 
    378376  } 
     
    557555  GST_DEBUG_OBJECT (demux, "EIT Tables: 0x%x service_id: %u", demux->dvb_tables->eit_tables, service_id); 
    558556  EIT = (GstFluTSDVBEIT*)g_hash_table_lookup(demux->dvb_tables->eit_tables, 
    559       (gpointer)service_id); 
     557      GINT_TO_POINTER ((gint) service_id)); 
    560558  if (EIT == NULL) { 
    561559    EIT = g_new0(GstFluTSDVBEIT, 1); 
    562560    new_eit = TRUE; 
    563561    g_hash_table_insert (demux->dvb_tables->eit_tables,  
    564       (gpointer)service_id, EIT); 
     562      GINT_TO_POINTER ((gint) service_id), EIT); 
    565563  } 
    566564  GST_DEBUG_OBJECT (demux, "EIT version_number: %d", version_number); 
     
    703701        /* go through EIT for this service */ 
    704702        EIT = (GstFluTSDVBEIT*)g_hash_table_lookup(demux->dvb_tables->eit_tables, 
    705           (gpointer)entry->service_id); 
     703          GINT_TO_POINTER ((gint) entry->service_id)); 
    706704        if (EIT) { 
    707705          guint j=0; 
     
    713711      GstFluTSDVBEITEventEntry*, j++)) != NULL) { 
    714712              GST_DEBUG_OBJECT(demux,"  EIT Event id: %u, start&duration: %" G_GUINT64_FORMAT, event->event_id, event->start_duration); 
    715               si_event = fluts_si_event_new(event->event_id, event->scrambled, event->start_duration); 
     713              si_event = fluts_si_event_new(event->event_id, event->scrambled, (guint8 *) event->start_duration); 
    716714              fluts_si_service_info_add_event(service, si_event); 
    717715            } 
  • branches/dvb-si-1/src/gstmpegdefs.h

    r613 r792  
    6464#define ID_ITU_TREC_H222_TYPE_E_STREAM          0x000001F8 
    6565#define ID_ANCILLARY_STREAM                     0x000001F9 
    66 #define ID_RESERVED_STREAM_START                0x000001FA 
    67 #define ID_RESERVED_STREAM_END                  0x000001FE 
     66#define ID_RESERVED_STREAM_1                    0x000001FA 
     67#define ID_RESERVED_STREAM_2                    0x000001FB 
     68#define ID_EXTENDED_METADATA                    0x000001FC 
     69#define ID_EXTENDED_STREAM_ID                   0x000001FD 
     70#define ID_RESERVED_STREAM_3                    0x000001FE 
    6871#define ID_PROGRAM_STREAM_DIRECTORY             0x000001FF 
    6972 
  • branches/dvb-si-1/src/gstmpegdemux.c

    r613 r792  
    9090 
    9191static GstStaticPadTemplate video_template = 
    92 GST_STATIC_PAD_TEMPLATE ("video_%02d", 
     92GST_STATIC_PAD_TEMPLATE ("video_%02x", 
    9393    GST_PAD_SRC, 
    9494    GST_PAD_SOMETIMES, 
     
    9898 
    9999static GstStaticPadTemplate audio_template = 
    100     GST_STATIC_PAD_TEMPLATE ("audio_%02d", 
     100    GST_STATIC_PAD_TEMPLATE ("audio_%02x", 
    101101    GST_PAD_SRC, 
    102102    GST_PAD_SOMETIMES, 
     
    203203      g_param_spec_enum ("sync", "Sync", "The synchronisation method", 
    204204          GST_TYPE_FLUPS_DEMUX_SYNC, 
    205           GST_FLUPS_DEMUX_SYNC_AUTO, G_PARAM_READWRITE)); 
     205          GST_FLUPS_DEMUX_SYNC_SCR, G_PARAM_READWRITE)); 
    206206 
    207207  gstelement_class->change_state = gst_flups_demux_change_state; 
     
    221221      g_malloc0 (sizeof (GstFluPSStream *) * (GST_FLUPS_DEMUX_MAX_STREAMS)); 
    222222 
    223   demux->cur_sync_method = GST_FLUPS_DEMUX_SYNC_AUTO; 
     223  demux->sync_method = demux->cur_sync_method = GST_FLUPS_DEMUX_SYNC_SCR; 
    224224} 
    225225 
     
    460460 
    461461    if (demux->cur_sync_method == GST_FLUPS_DEMUX_SYNC_AUTO) { 
    462       if (((demux->base_dts > demux->base_scr) &&  
    463            (demux->base_dts - demux->base_scr > CLOCK_FREQ)) || 
    464           (demux->base_scr - demux->base_dts > CLOCK_FREQ)) { 
     462      gint64 diff; 
     463      if (demux->base_dts > demux->base_scr) 
     464        diff = demux->base_dts - demux->base_scr; 
     465      else 
     466        diff = demux->base_scr - demux->base_dts; 
     467 
     468      if (diff > CLOCK_FREQ) { 
    465469        /* Use DTS as the sync method */ 
    466470        if (demux->cur_sync_method != GST_FLUPS_DEMUX_SYNC_DTS) { 
     
    530534  /* Set the buffer discont flag, and clear discont state on the stream */ 
    531535  if (stream->discont) { 
     536    GST_DEBUG_OBJECT (demux, "marking discont buffer"); 
    532537    GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DISCONT); 
    533538 
     
    553558    gst_buffer_unref (buf); 
    554559    return GST_FLOW_OK; 
     560  } 
     561} 
     562 
     563static void 
     564gst_flups_demux_mark_discont (GstFluPSDemux * demux) 
     565{ 
     566  gint id; 
     567 
     568  /* mark discont on all streams */ 
     569  for (id = 0; id < GST_FLUPS_DEMUX_MAX_STREAMS; id++) { 
     570    GstFluPSStream *stream = demux->streams[id]; 
     571 
     572    if (stream) { 
     573      GST_DEBUG_OBJECT (demux, "marking stream as discont"); 
     574      stream->discont = TRUE; 
     575    } 
    555576  } 
    556577} 
     
    674695 
    675696      gst_segment_init (&demux->sink_segment, GST_FORMAT_UNDEFINED); 
     697      gst_flups_demux_mark_discont (demux); 
    676698      gst_adapter_clear (demux->adapter); 
    677699      gst_pes_filter_drain (&demux->filter); 
     
    786808 
    787809      bcur = cur * demux->mux_rate / GST_SECOND; 
    788       bstop = stop * demux->mux_rate / GST_SECOND; 
     810      if (stop != -1) 
     811        bstop = stop * demux->mux_rate / GST_SECOND; 
     812      else 
     813        bstop = -1; 
    789814 
    790815      bevent = gst_event_new_seek (rate, GST_FORMAT_BYTES, flags, cur_type, 
     
    822847 
    823848  demux = GST_FLUPS_DEMUX (gst_pad_get_parent (pad)); 
     849 
     850  GST_LOG_OBJECT (demux, "Have query of type %d on pad %" GST_PTR_FORMAT, 
     851      GST_QUERY_TYPE (query), pad); 
    824852 
    825853  switch (GST_QUERY_TYPE (query)) { 
     
    855883      gst_query_parse_duration (query, &format, NULL); 
    856884 
     885      if ((peer = gst_pad_get_peer (demux->sinkpad)) == NULL) { 
     886        GST_DEBUG_OBJECT (demux, "duration not possible, no peer"); 
     887        goto not_supported; 
     888      } 
     889 
     890      /* For any format other than bytes, see if upstream knows first */ 
     891      if (format == GST_FORMAT_BYTES) { 
     892        GST_DEBUG_OBJECT (demux, "duration not supported for format %d", 
     893            format); 
     894        gst_object_unref (peer); 
     895        goto not_supported; 
     896      } 
     897 
     898      if (gst_pad_query (peer, query)) { 
     899        gst_object_unref (peer); 
     900        res = TRUE; 
     901        break; 
     902      } 
     903 
     904      /* Upstream didn't know, so we can only answer TIME queries from  
     905       * here on */ 
    857906      if (format != GST_FORMAT_TIME) { 
    858907        GST_DEBUG_OBJECT (demux, "duration not supported for format %d", 
    859908            format); 
     909        gst_object_unref (peer); 
    860910        goto not_supported; 
    861911      } 
     912 
    862913      if (demux->mux_rate == -1) { 
    863914        GST_DEBUG_OBJECT (demux, "duration not possible, no mux_rate"); 
    864         goto not_supported; 
    865       } 
    866  
    867       if ((peer = gst_pad_get_peer (demux->sinkpad)) == NULL) { 
    868         GST_DEBUG_OBJECT (demux, "duration not possible, no peer"); 
     915        gst_object_unref (peer); 
    869916        goto not_supported; 
    870917      } 
     
    888935    } 
    889936    default: 
     937      res = gst_pad_query_default (pad, query); 
    890938      break; 
    891939  } 
     
    10301078 
    10311079  if (demux->current_scr == G_MAXUINT64) { 
    1032     gint id; 
    1033  
    10341080    /* take new base_scr */ 
    10351081    demux->base_scr = scr; 
     
    10501096 
    10511097    /* mark discont on all streams */ 
    1052     for (id = 0; id < GST_FLUPS_DEMUX_MAX_STREAMS; id++) { 
    1053       GstFluPSStream *stream = demux->streams[id]; 
    1054  
    1055       if (stream) 
    1056         stream->discont = TRUE; 
    1057     } 
     1098    gst_flups_demux_mark_discont (demux); 
     1099 
    10581100    /* Reset the sync method, so that it will switch again 
    10591101     * if it's AUTO */ 
     
    13741416   * to send to it, unless we're processing a discont (which resets 
    13751417   * the not-linked status and tries again */ 
    1376   if (demux->current_stream->discont) 
     1418  if (demux->current_stream->discont) { 
     1419    GST_DEBUG_OBJECT (demux, "stream is discont"); 
    13771420    demux->current_stream->notlinked = FALSE; 
     1421  } 
    13781422 
    13791423  if (demux->current_stream->notlinked == FALSE) { 
     
    14701514 
    14711515    gst_pes_filter_drain (&demux->filter); 
     1516 
     1517    /* mark discont on all streams */ 
     1518    gst_flups_demux_mark_discont (demux); 
     1519 
    14721520    demux->current_scr = G_MAXUINT64; 
    14731521    demux->bytes_since_scr = 0; 
  • branches/dvb-si-1/src/gstmpegdesc.c

    r613 r792  
    164164  guint8 *current; 
    165165  guint size; 
    166   guint j = 0; 
    167166 
    168167  g_return_val_if_fail (desc != NULL, NULL); 
     
    174173  length = desc->data_length; 
    175174 
    176   while (TRUE) { 
    177     if (i == j) 
     175  while (length > 0) { 
     176    if (i == 0) 
    178177      return current; 
    179178 
     
    182181    current += size; 
    183182    length -= size; 
    184     j++; 
     183    i--; 
     184 
    185185  } 
    186186  return NULL; 
  • branches/dvb-si-1/src/gstmpegtsdemux.c

    r635 r792  
    2323#endif 
    2424 
     25#include <linux/dvb/ca.h> 
     26#include <sys/types.h> 
     27#include <sys/stat.h> 
     28#include <sys/ioctl.h> 
     29#include <fcntl.h> 
     30 
    2531#include <string.h> 
    2632#include <stdlib.h> 
     
    3238#include "flutssiinfo.h" 
    3339#include "gstdvbtables.h" 
     40 
     41#if ((GST_VERSION_MAJOR > 0) ||                                    \ 
     42     (GST_VERSION_MAJOR == 0 && GST_VERSION_MINOR > 10) ||         \ 
     43     (GST_VERSION_MAJOR == 0 && GST_VERSION_MINOR == 10 &&         \ 
     44      GST_VERSION_MICRO >= 6)) 
     45#define HAVE_ADAPTER_TAKE_BUF 
     46#endif 
    3447 
    3548GST_DEBUG_CATEGORY_STATIC (gstflutsdemux_debug); 
     
    100113 
    101114static GstStaticPadTemplate video_template = 
    102 GST_STATIC_PAD_TEMPLATE ("video_%02d", 
     115GST_STATIC_PAD_TEMPLATE ("video_%04x", 
    103116    GST_PAD_SRC, 
    104117    GST_PAD_SOMETIMES, 
     
    106119 
    107120static GstStaticPadTemplate audio_template = 
    108 GST_STATIC_PAD_TEMPLATE ("audio_%02d", 
     121GST_STATIC_PAD_TEMPLATE ("audio_%04x", 
    109122    GST_PAD_SRC, 
    110123    GST_PAD_SOMETIMES, 
     
    112125 
    113126static GstStaticPadTemplate private_template = 
    114 GST_STATIC_PAD_TEMPLATE ("private_%d", 
     127GST_STATIC_PAD_TEMPLATE ("private_%04x", 
    115128    GST_PAD_SRC, 
    116129    GST_PAD_SOMETIMES, 
     
    135148static GstStateChangeReturn gst_fluts_demux_change_state (GstElement * element, 
    136149    GstStateChange transition); 
     150 
     151static FluTsPmtInfo *fluts_demux_build_pmt_info (GstFluTSDemux *demux, 
     152  guint16 pmt_pid); 
    137153 
    138154static GstElementClass *parent_class = NULL; 
     
    412428 
    413429static gboolean 
     430gst_fluts_is_dirac_stream (GstFluTSStream * stream) 
     431{ 
     432  gboolean is_dirac = FALSE; 
     433 
     434  if (stream->stream_type != ST_VIDEO_DIRAC) 
     435    return FALSE; 
     436 
     437  if (stream->ES_info != NULL) { 
     438    guint8 *dirac_desc; 
     439    /* Check for a Registration Descriptor to confirm this is dirac */ 
     440    dirac_desc = gst_mpeg_descriptor_find (stream->ES_info, 
     441                     DESC_REGISTRATION); 
     442    if (dirac_desc != NULL && DESC_LENGTH (dirac_desc) >= 4) { 
     443      if (DESC_REGISTRATION_format_identifier (dirac_desc) == 
     444        0x64726163) /* 'drac' in hex */ { 
     445        is_dirac = TRUE; 
     446      } 
     447    } else { 
     448      /* Check for old mapping as originally specified too */ 
     449      dirac_desc = gst_mpeg_descriptor_find (stream->ES_info, 
     450                       DESC_DIRAC_TC_PRIVATE); 
     451      if (dirac_desc != NULL && DESC_LENGTH (dirac_desc) == 0) 
     452        is_dirac = TRUE; 
     453    } 
     454  } 
     455   
     456  return is_dirac; 
     457} 
     458 
     459static gboolean  
     460gst_fluts_stream_is_video (GstFluTSStream * stream) 
     461{ 
     462  switch (stream->stream_type) { 
     463    case ST_VIDEO_MPEG1: 
     464    case ST_VIDEO_MPEG2: 
     465    case ST_VIDEO_MPEG4: 
     466    case ST_VIDEO_H264: 
     467      return TRUE; 
     468    case ST_VIDEO_DIRAC: 
     469      return gst_fluts_is_dirac_stream (stream); 
     470  } 
     471 
     472  return FALSE; 
     473} 
     474 
     475static gboolean 
    414476gst_fluts_demux_fill_stream (GstFluTSStream * stream, guint8 id, 
    415477    guint8 stream_type) 
     
    469531      name = g_strdup_printf ("video_%04x", stream->PID); 
    470532      caps = gst_caps_new_simple ("video/x-h264", NULL); 
     533      break; 
    471534    case ST_VIDEO_DIRAC: 
    472       /* Check for the empty 0xAC descriptor to be sure */ 
    473       { 
    474         gboolean is_dirac = FALSE; 
    475  
    476         if (stream->ES_info != NULL) { 
    477           guint8 *dirac_desc; 
    478           dirac_desc = gst_mpeg_descriptor_find (stream->ES_info,  
    479                            DESC_DIRAC_TC_PRIVATE); 
    480           if (dirac_desc != NULL && DESC_LENGTH (dirac_desc) == 0) 
    481             is_dirac = TRUE; 
    482         } 
    483         if (is_dirac) { 
    484           template = klass->video_template; 
    485           name = g_strdup_printf ("video_%04x", stream->PID); 
    486           caps = gst_caps_new_simple ("video/x-dirac", NULL); 
    487         } 
     535      if (gst_fluts_is_dirac_stream (stream)) { 
     536        template = klass->video_template; 
     537        name = g_strdup_printf ("video_%04x", stream->PID); 
     538        caps = gst_caps_new_simple ("video/x-dirac", NULL); 
    488539      } 
    489540      break; 
     
    502553      name = g_strdup_printf ("audio_%04x", stream->PID); 
    503554      caps = gst_caps_new_simple ("audio/x-lpcm", NULL); 
     555      break; 
    504556    case ST_PS_DVD_SUBPICTURE: 
    505       break; 
    506     case ST_PS_TIMECODE: 
    507       /* Check for the 0xAC descriptor with video_PID */ 
    508       { 
    509         gboolean is_timecode = FALSE; 
    510         guint16 video_pid; 
    511         if (stream->ES_info != NULL) { 
    512           guint8 *desc; 
    513           desc = gst_mpeg_descriptor_find (stream->ES_info,  
    514                            DESC_DIRAC_TC_PRIVATE); 
    515           if (desc != NULL && DESC_LENGTH (desc) == 2) { 
    516             is_timecode = TRUE; 
    517             video_pid = DESC_TIMECODE_video_pid (desc); 
    518           } 
    519         } 
    520         if (is_timecode) { 
    521           template = klass->private_template; 
    522           name = g_strdup_printf ("private_%04x", stream->PID); 
    523           caps = gst_caps_new_simple ("application/x-mpeg-timecode",  
    524               "video-pid", video_pid, NULL); 
    525         } 
    526       } 
    527557      break; 
    528558    default: 
     
    639669} 
    640670 
     671#ifndef GST_FLOW_IS_SUCCESS 
     672#define GST_FLOW_IS_SUCCESS(ret) ((ret) >= GST_FLOW_OK) 
     673#endif 
     674 
    641675static GstFlowReturn 
    642676gst_fluts_demux_combine_flows (GstFluTSDemux * demux, GstFluTSStream * stream, 
     
    693727    pts = filter->pts; 
    694728    time = MPEGTIME_TO_GSTTIME (pts) + stream->base_time; 
    695  
    696     /* handle wrap arounds sanely */ 
    697     if (stream->last_time > 0 && time < stream->last_time &&   
    698         stream->last_time - time > MPEGTIME_TO_GSTTIME(G_MAXUINT32)) { 
    699       /* wrap around occurred */  
    700       stream->base_time = stream->base_time +  
    701                           MPEGTIME_TO_GSTTIME((guint64)(1) << 33); 
    702       time = MPEGTIME_TO_GSTTIME (pts) + stream->base_time; 
    703       GST_DEBUG_OBJECT (demux,  
    704          "timestamps wrapped around, compensating with new base time: %" 
    705                G_GUINT64_FORMAT "last time: %" G_GUINT64_FORMAT " time: %" 
    706          G_GUINT64_FORMAT, stream->base_time, stream->last_time, time); 
    707       g_signal_emit (demux, gst_fluts_demux_signals[SIGNAL_WRAPAROUND], 0); 
    708       stream->last_time = time; 
    709     } 
    710     else if (stream->last_time > 0 && time > stream->last_time && 
    711              time - stream->last_time > MPEGTIME_TO_GSTTIME(G_MAXUINT32) && 
    712              stream->base_time > 0) { 
    713       /* had a previous wrap around */ 
    714       time = time - MPEGTIME_TO_GSTTIME((guint64)(1) << 33); 
    715       GST_DEBUG_OBJECT (demux,  
    716         "timestamps wrapped around earlier but we have an out of pts: %" 
    717         G_GUINT64_FORMAT ", translated to: %" G_GUINT64_FORMAT, pts, time); 
    718       g_signal_emit (demux,  
    719         gst_fluts_demux_signals[SIGNAL_WRAPAROUND_OUTOFORDER], 0); 
    720     } 
     729    
     730    if ((stream->last_time > 0 && stream->last_time < time && 
     731         time - stream->last_time > GST_SECOND * 60 * 10) || ( 
     732         stream->last_time > time &&  
     733         stream->last_time - time > GST_SECOND * 60 * 10)) { 
     734      /* check first to see if we're in middle of detecting a discont in PCR. 
     735       * if we are we're not sure what timestamp the buffer should have, best 
     736       * to drop. */ 
     737      if (stream->PMT_pid <= FLUTS_MAX_PID && demux->streams[stream->PMT_pid] &&  
     738          demux->streams[demux->streams[stream->PMT_pid]->PMT.PCR_PID] && 
     739          demux->streams[demux->streams[stream->PMT_pid]->PMT.PCR_PID]->discont_PCR) { 
     740        GST_WARNING_OBJECT(demux, "middle of discont, dropping"); 
     741        goto bad_timestamp; 
     742      } 
     743      /* check for wraparounds */ 
     744      else if (stream->last_time > 0 && time < stream->last_time &&   
     745          stream->last_time - time > MPEGTIME_TO_GSTTIME(G_MAXUINT32)) { 
     746        /* wrap around occurred */  
     747        if (stream->base_time + MPEGTIME_TO_GSTTIME((guint64)(1) << 33) + 
     748            MPEGTIME_TO_GSTTIME(pts) > stream->last_time + GST_SECOND * 60 * 10) { 
     749          GST_DEBUG_OBJECT (demux, 
     750            "looks like we have a corrupt packet because its pts is a lot lower than" 
     751            " the previous pts but not a wraparound"); 
     752          goto bad_timestamp; 
     753        } 
     754        stream->base_time = stream->base_time +  
     755                            MPEGTIME_TO_GSTTIME((guint64)(1) << 33); 
     756        time = MPEGTIME_TO_GSTTIME (pts) + stream->base_time; 
     757        GST_DEBUG_OBJECT (demux,  
     758           "timestamps wrapped around, compensating with new base time: %" 
     759           GST_TIME_FORMAT "last time: %" GST_TIME_FORMAT " time: %" 
     760           GST_TIME_FORMAT, GST_TIME_ARGS(stream->base_time),  
     761           GST_TIME_ARGS(stream->last_time), GST_TIME_ARGS(time)); 
     762        stream->last_time = time; 
     763      }  
     764      else if (stream->last_time > 0 && time > stream->last_time && 
     765               time - stream->last_time > MPEGTIME_TO_GSTTIME(G_MAXUINT32) && 
     766               stream->base_time > 0) { 
     767        /* had a previous wrap around */ 
     768        if (time - MPEGTIME_TO_GSTTIME((guint64)(1) << 33) + GST_SECOND * 60 * 10  
     769            < stream->last_time) { 
     770          GST_DEBUG_OBJECT (demux, 
     771            "looks like we have a corrupt packet because its pts is a lot higher than" 
     772            " the previous pts but not because of a wraparound or pcr discont"); 
     773          goto bad_timestamp; 
     774        } 
     775        GST_DEBUG_OBJECT (demux,  
     776          "timestamps wrapped around earlier but we have an out of pts: %" 
     777          G_GUINT64_FORMAT ", as %" GST_TIME_FORMAT " translated to: %" GST_TIME_FORMAT " and last_time of %" 
     778          GST_TIME_FORMAT, pts, GST_TIME_ARGS(time), GST_TIME_ARGS(time - MPEGTIME_TO_GSTTIME((guint64)(1) << 33)), 
     779          GST_TIME_ARGS(stream->last_time)); 
     780        time = time - MPEGTIME_TO_GSTTIME((guint64)(1) << 33); 
     781      } 
     782      else { 
     783        /* we must have a corrupt packet */ 
     784        GST_WARNING_OBJECT (demux, "looks like we have a corrupt packet because" 
     785        " its timestamp is buggered timestamp: %" GST_TIME_FORMAT " compared to" 
     786        " last timestamp: %" GST_TIME_FORMAT, 
     787        GST_TIME_ARGS(time), GST_TIME_ARGS(stream->last_time)); 
     788        goto bad_timestamp; 
     789      } 
     790    }  
    721791    else { /* do not set last_time if a packet with pts from before wrap 
    722792    around arrived after the wrap around occured */ 
     
    729799 
    730800  GST_LOG_OBJECT (demux, "setting PTS to (%" G_GUINT64_FORMAT ") time: %" 
    731       G_GUINT64_FORMAT " on buffer 0x%x first buffer: %d", pts, time, buffer, 
    732       first); 
     801      GST_TIME_FORMAT " on buffer 0x%x first buffer: %d base_time: %" 
     802      GST_TIME_FORMAT, pts, GST_TIME_ARGS(time), buffer, first, GST_TIME_ARGS(stream->base_time)); 
    733803 
    734804  GST_BUFFER_TIMESTAMP (buffer) = time; 
     
    744814        stream->stream_type = ST_VIDEO_MPEG2; 
    745815        stream->flags &= ~FLUTS_STREAM_FLAG_STREAM_TYPE_UNKNOWN; 
     816        stream->flags |= FLUTS_STREAM_FLAG_IS_VIDEO; 
     817        GST_DEBUG_OBJECT (demux, "Found stream 0x%04x without PMT with video " 
     818            "start_code. Treating as video", stream->PID); 
    746819      } else if ((filter->start_code & 0xFFFFFFE0) == PACKET_AUDIO_START_CODE) { 
    747820        /* it is mpeg audio */ 
    748821        stream->stream_type = ST_AUDIO_MPEG2; 
    749822        stream->flags &= ~FLUTS_STREAM_FLAG_STREAM_TYPE_UNKNOWN; 
     823        GST_DEBUG_OBJECT (demux, "Found stream 0x%04x without PMT with audio " 
     824            "start_code. Treating as audio", stream->PID); 
    750825      } else { 
    751826        GST_LOG_OBJECT (demux, "Stream start code on pid 0x%04x is: 0x%x",  
     
    785860    return gst_fluts_demux_combine_flows (demux, stream, GST_FLOW_NOT_LINKED); 
    786861  } 
     862bad_timestamp: 
     863  { 
     864    gst_buffer_unref (buffer); 
     865    return gst_fluts_demux_combine_flows (demux, stream, GST_FLOW_OK); 
     866  } 
     867 
    787868} 
    788869 
     
    816897    stream->base_PCR = -1; 
    817898    stream->last_PCR = -1; 
     899    stream->last_PCR_difference = -1; 
    818900    stream->PMT.version_number = -1; 
    819901    stream->PAT.version_number = -1; 
     902    stream->PMT_pid = FLUTS_MAX_PID + 1; 
    820903    stream->flags |= FLUTS_STREAM_FLAG_STREAM_TYPE_UNKNOWN; 
    821904     
     
    901984gst_fluts_activate_pmt (GstFluTSDemux *demux, GstFluTSStream * stream) 
    902985{ 
     986        guint i; 
     987 
    903988  GST_DEBUG_OBJECT (demux, "activating PMT 0x%08x", stream->PID); 
    904989 
     
    10091094   * base_PCR. */ 
    10101095  gst_fluts_demux_get_stream_for_PID (demux, PMT->PCR_PID); 
    1011  
     1096   
    10121097  if ((data[0] & 0x0c) != 0x00) 
    10131098    goto wrong_pilen; 
     
    10651150      ES_stream->stream_type = stream_type; 
    10661151      ES_stream->flags &= ~FLUTS_STREAM_FLAG_STREAM_TYPE_UNKNOWN; 
     1152 
    10671153      /* init base and last time */ 
    10681154      ES_stream->base_time = 0; 
     
    10711157      /* parse descriptor */ 
    10721158      ES_stream->ES_info = gst_mpeg_descriptor_parse (data, ES_info_length); 
     1159 
     1160      /* Recognise video streams based on stream_type */ 
     1161      if (gst_fluts_stream_is_video (ES_stream)) 
     1162        ES_stream->flags |= FLUTS_STREAM_FLAG_IS_VIDEO; 
     1163 
    10731164      /* set adaptor */ 
    10741165      gst_pes_filter_init (&ES_stream->filter, NULL); 
     
    10761167          (GstPESFilterData) gst_fluts_demux_data_cb, 
    10771168          (GstPESFilterResync) gst_fluts_demux_resync_cb, ES_stream); 
     1169      if (ES_stream->flags & FLUTS_STREAM_FLAG_IS_VIDEO) 
     1170        ES_stream->filter.allow_unbounded = TRUE; 
     1171      ES_stream->PMT_pid = stream->PID; 
    10781172    } 
    10791173 
     
    12711365  guint8 length; 
    12721366  guint8 * data_end; 
     1367  gint i; 
     1368  GstFluTSStream *pmt_stream; 
    12731369 
    12741370  demux = stream->demux; 
     
    12861382 
    12871383    GST_DEBUG_OBJECT (demux, "flags 0x%02x", flags); 
    1288  
     1384    /* discontinuity flag */ 
     1385    if (flags & 0x80) { 
     1386      GST_DEBUG_OBJECT (demux, "discontinuity flag set"); 
     1387    } 
    12891388    /* PCR_flag */ 
    12901389    if (flags & 0x10) { 
     
    12921391      guint16 pcr2; 
    12931392      guint64 pcr, pcr_ext; 
    1294  
     1393      gboolean valid_pcr = TRUE; 
     1394       
    12951395      pcr1 = GST_READ_UINT32_BE (data); 
    12961396      pcr2 = GST_READ_UINT16_BE (data + 4); 
     
    13001400      if (pcr_ext) 
    13011401        pcr = (pcr * 300 + pcr_ext % 300) / 300; 
    1302       GST_DEBUG_OBJECT (demux, "have PCR %" G_GUINT64_FORMAT " on PID 0x%04x",  
    1303           pcr, stream->PID); 
    1304       stream->last_PCR = pcr; 
     1402      GST_DEBUG_OBJECT (demux, "have PCR %" G_GUINT64_FORMAT " on PID 0x%04x " 
     1403          "and last pcr is %" G_GUINT64_FORMAT,  
     1404          pcr, stream->PID, stream->last_PCR); 
     1405      /* pcr has been converted into units of 90Khz ticks  
     1406       * so assume discont if last pcr was > 900000 (10 second) lower */ 
     1407      if (stream->last_PCR != -1 && 
     1408          (pcr - stream->last_PCR > 900000 || 
     1409           pcr < stream->last_PCR)) { 
     1410        GstClockTimeDiff base_time_difference; 
     1411        GST_DEBUG_OBJECT (demux,  
     1412          "looks like we have a discont, this pcr should really be approx: %"  
     1413          G_GUINT64_FORMAT, stream->last_PCR + stream->last_PCR_difference); 
     1414        if (stream->discont_PCR == FALSE) { 
     1415          if (pcr > stream->last_PCR) { 
     1416            base_time_difference = -MPEGTIME_TO_GSTTIME((pcr -  
     1417              (stream->last_PCR + stream->last_PCR_difference))); 
     1418          } 
     1419          else { 
     1420            base_time_difference = MPEGTIME_TO_GSTTIME((stream->last_PCR + 
     1421              stream->last_PCR_difference) - pcr); 
     1422          } 
     1423          stream->discont_PCR = TRUE; 
     1424          stream->discont_difference = base_time_difference; 
     1425          valid_pcr = FALSE; 
     1426        } 
     1427        else { 
     1428          GstClockTimeDiff base_time_difference; 
     1429          /* need to check pmt pid in case this pcr is before it's  
     1430           * associated with a pmt */ 
     1431          if (stream->PMT_pid <= FLUTS_MAX_PID) { 
     1432            /* checking the pcr discont is similar this second time 
     1433             * if similar, update the es pids 
     1434             * if not, assume it's a false discont due to corruption 
     1435             * or other */ 
     1436            if (pcr > stream->last_PCR) { 
     1437              base_time_difference = -MPEGTIME_TO_GSTTIME((pcr -  
     1438                (stream->last_PCR + stream->last_PCR_difference))); 
     1439            } 
     1440            else { 
     1441              base_time_difference = MPEGTIME_TO_GSTTIME((stream->last_PCR + 
     1442                stream->last_PCR_difference) - pcr); 
     1443            } 
     1444            if ((base_time_difference - stream->discont_difference > 0 && 
     1445                base_time_difference - stream->discont_difference < GST_SECOND * 10) || 
     1446                (stream->discont_difference - base_time_difference > 0 && 
     1447                stream->discont_difference -base_time_difference < GST_SECOND * 10)) { 
     1448              GST_DEBUG_OBJECT (demux, "Updating base_time on all es pids belonging" 
     1449                " to PMT 0x%02x", stream->PMT_pid); 
     1450              pmt_stream = demux->streams[stream->PMT_pid]; 
     1451              for (i = 0; i <= pmt_stream->PMT.entries->len; i++) { 
     1452                GstFluTSPMTEntry *cur_entry =  
     1453                  &g_array_index(pmt_stream->PMT.entries, GstFluTSPMTEntry, i); 
     1454                GST_DEBUG_OBJECT (demux, "Updating base time on pid 0x%02x by %"  
     1455                  G_GINT64_FORMAT, cur_entry->PID, stream->discont_difference); 
     1456                 if (cur_entry->PID <= FLUTS_MAX_PID && demux->streams[cur_entry->PID]) { 
     1457                   demux->streams[cur_entry->PID]->base_time +=  
     1458                   stream->discont_difference; 
     1459                 }  
     1460              } 
     1461              stream->base_PCR = pcr; 
     1462            } 
     1463            else { 
     1464                GST_DEBUG_OBJECT(demux, "last PCR discont looked to be bogus: " 
     1465                  "previous discont difference %" G_GINT64_FORMAT " now %" G_GINT64_FORMAT,  
     1466                  stream->discont_difference, 
     1467                  base_time_difference); 
     1468                valid_pcr = FALSE; 
     1469            } 
     1470 
     1471          } 
     1472          stream->discont_PCR = FALSE; 
     1473          stream->discont_difference = 0; 
     1474        } 
     1475      } 
     1476      else if (stream->last_PCR != -1) stream->last_PCR_difference = pcr - stream->last_PCR; 
     1477      GST_DEBUG_OBJECT (demux, "last PCR difference: %" G_GUINT64_FORMAT, stream->last_PCR_difference); 
     1478      if (valid_pcr) stream->last_PCR = pcr; 
    13051479      data += 6; 
    13061480    } 
     
    16111785  adaptation_field_control = (data[2] & 0x30) >> 4; 
    16121786  continuity_counter = data[2] & 0x0f; 
     1787 
     1788  if (PID == 0xa2) { 
     1789    GST_DEBUG ("scrambling %d indicator %d", 
     1790      transport_scrambling_control, payload_unit_start_indicator); 
     1791     
     1792    if (payload_unit_start_indicator) { 
     1793      GST_DEBUG ("break"); 
     1794    } 
     1795  } 
    16131796 
    16141797  data += 3; 
     
    17481931 
    17491932        if (payload_unit_start_indicator) { 
     1933          if (PID == 0xa2) { 
     1934            GST_DEBUG ("asd"); 
     1935          } 
    17501936          GST_DEBUG_OBJECT (demux, "new PES start for PID 0x%04x", PID); 
    17511937          gst_pes_filter_drain (&stream->filter); 
     
    17531939        GST_LOG_OBJECT (demux, "Elementary packet of size %u for PID 0x%04x", 
    17541940            datalen, PID); 
     1941 
    17551942        if (datalen > 0) { 
    17561943          es_buf = gst_buffer_create_sub (buf, data - GST_BUFFER_DATA (buf),  
     
    18061993 
    18071994  /* we consumed the sync byte */ 
     1995#ifdef HAVE_ADAPTER_TAKE_BUF 
    18081996  buf = gst_adapter_take_buffer (demux->adapter, 187); 
    18091997  g_return_val_if_fail (buf != NULL, GST_FLOW_ERROR); 
     1998#else 
     1999  /* Compatibility path for GStreamer < 0.10.6 */ 
     2000  buf = gst_buffer_new_and_alloc (187); 
     2001  g_return_val_if_fail (buf != NULL, GST_FLOW_ERROR); 
     2002 
     2003  data = gst_adapter_peek (demux->adapter, 187); 
     2004  g_return_val_if_fail (data != NULL, GST_FLOW_ERROR); 
     2005  memcpy (GST_BUFFER_DATA (buf), data, 187); 
     2006#endif 
    18102007 
    18112008  data = GST_BUFFER_DATA (buf); 
     
    19332130  return TRUE; 
    19342131} 
     2132 
     2133#ifndef GST_BUFFER_IS_DISCONT 
     2134#define GST_BUFFER_IS_DISCONT(buffer)   (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DISCONT)) 
     2135#endif 
    19352136 
    19362137static GstFlowReturn 
     
    20452246 
    20462247  for (i = 0; i < PMT->entries->len; i++) { 
     2248    GstFluTSStream *stream; 
    20472249    FluTsPmtStreamInfo *stream_info; 
    20482250    GstFluTSPMTEntry *cur_entry =  
    20492251        &g_array_index(PMT->entries, GstFluTSPMTEntry, i); 
    20502252     
    2051     stream_info = fluts_pmt_stream_info_new (cur_entry->PID); 
    2052     if (demux->streams[cur_entry->PID]->ES_info) { 
     2253    stream = demux->streams [cur_entry->PID]; 
     2254    stream_info = fluts_pmt_stream_info_new (cur_entry->PID, stream->stream_type); 
     2255 
     2256    if (stream->ES_info) { 
    20532257      int i; 
    20542258      /* add languages */ 
    20552259      guint8 *iso639_languages = gst_mpeg_descriptor_find( 
    2056         demux->streams[cur_entry->PID]->ES_info, DESC_ISO_639_LANGUAGE); 
     2260        stream->ES_info, DESC_ISO_639_LANGUAGE); 
    20572261      if (iso639_languages) { 
    20582262        for(i=0;i<DESC_ISO_639_LANGUAGE_codes_n(iso639_languages);i++) { 
     
    20612265          fluts_pmt_stream_info_add_language(stream_info, g_strndup(language_n, 3)); 
    20622266        } 
     2267      } 
     2268 
     2269      for (i = 0; i < gst_mpeg_descriptor_n_desc (stream->ES_info); ++i) { 
     2270        guint8 *desc = gst_mpeg_descriptor_nth (stream->ES_info, i); 
     2271 
     2272        /* add the whole descriptor, tag + length + DESC_LENGTH bytes */ 
     2273        fluts_pmt_stream_info_add_descriptor (stream_info,  
     2274          desc, 2 + DESC_LENGTH (desc)); 
    20632275      } 
    20642276    } 
  • branches/dvb-si-1/src/gstmpegtsdemux.h

    r613 r792  
    8282typedef enum _FluTsStreamFlags { 
    8383  FLUTS_STREAM_FLAG_STREAM_TYPE_UNKNOWN = 0x01, 
    84   FLUTS_STREAM_FLAG_PMT_VALID = 0x02 
     84  FLUTS_STREAM_FLAG_PMT_VALID = 0x02, 
     85  FLUTS_STREAM_FLAG_IS_VIDEO  = 0x04 
    8586} FluTsStreamFlags; 
    8687 
     
    99100  guint64        base_PCR; 
    100101  guint64        last_OPCR; 
     102  guint64        last_PCR_difference; 
     103  gboolean       discont_PCR; 
     104  GstClockTimeDiff discont_difference; 
    101105 
    102106  /* for PAT streams */ 
     
    119123  GstMPEGDescriptor *ES_info; 
    120124  /* needed because 33bit mpeg timestamps wrap around every (approx) 26.5 hrs */ 
    121   GstClockTime  base_time; 
     125  GstClockTimeDiff base_time; 
    122126  GstClockTime   last_time; 
     127  /* pid of PMT that this stream belongs to */ 
     128  guint16        PMT_pid; 
    123129}; 
    124130#ifndef __GST_FLUTS_DEMUX_DVBTABLES_H__ 
  • branches/dvb-si-1/src/gstpesfilter.c

    r588 r792  
    4646  filter->state = STATE_HEADER_PARSE; 
    4747  filter->gather_pes = FALSE; 
     48  filter->allow_unbounded = FALSE; 
    4849} 
    4950 
     
    8586  return ((sync & 0xfffffffc) == 0x000001bc) || 
    8687      ((sync & 0xffffffe0) == 0x000001c0) || 
     88      ((sync & 0xfffffff0) == 0x000001f0) || 
    8789      ((sync & 0xfffffff0) == 0x000001e0); 
    8890} 
     
    127129   * streams, but actually a 0 sized packet in program streams or 
    128130   * for anything except video packets */ 
     131 
     132  /* FIXME: Remove this hack that is checking start_code. Instead, we need 
     133   * a callback that a start_code has been collected, giving the caller a chance 
     134   * to set the allow_unbounded flag if they want */ 
    129135  if (filter->length == 0 && 
    130       (filter->start_code & 0xFFFFFFF0) == PACKET_VIDEO_START_CODE) { 
     136      ((filter->start_code & 0xFFFFFFF0) == PACKET_VIDEO_START_CODE || 
     137      filter->allow_unbounded)) { 
    131138    GST_DEBUG ("id 0x%02x, unbounded length", filter->id); 
    132139    filter->unbounded_packet = TRUE; 
  • branches/dvb-si-1/src/gstpesfilter.h

    r588 r792  
    4646   * outputting */ 
    4747  gboolean           gather_pes; 
     48  /* Whether unbounded packets are allowed in this 
     49   * stream */ 
     50  gboolean           allow_unbounded; 
    4851 
    4952  gboolean           first;