gst/elements/gstbufferstore.c: fix bug where buffer was not assembled correctly
authorBenjamin Otte <otte@gnome.org>
Sun, 25 Jan 2004 02:50:09 +0000 (02:50 +0000)
committerBenjamin Otte <otte@gnome.org>
Sun, 25 Jan 2004 02:50:09 +0000 (02:50 +0000)
Original commit message from CVS:
2004-01-25  Benjamin Otte  <in7y118@public.uni-hamburg.de>

* gst/elements/gstbufferstore.c: (gst_buffer_store_get_buffer):
fix bug where buffer was not assembled correctly
* gst/elements/gsttee.c: (gst_tee_class_init), (gst_tee_init):
silence by default
* gst/elements/gsttypefind.c: (gst_type_find_element_chain):
only seek if there's no more buffers that could work without seeking

ChangeLog
gst/elements/gstbufferstore.c
gst/elements/gsttee.c
gst/elements/gsttypefind.c
plugins/elements/gstbufferstore.c
plugins/elements/gsttee.c
plugins/elements/gsttypefind.c

index 8fb829637473dce1e82ffe89502ea274e89be1c8..9e3e5d97adb300acd52b353e274a2a14a1190122 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2004-01-25  Benjamin Otte  <in7y118@public.uni-hamburg.de>
+
+       * gst/elements/gstbufferstore.c: (gst_buffer_store_get_buffer):
+         fix bug where buffer was not assembled correctly
+       * gst/elements/gsttee.c: (gst_tee_class_init), (gst_tee_init):
+         silence by default
+       * gst/elements/gsttypefind.c: (gst_type_find_element_chain):
+         only seek if there's no more buffers that could work without seeking
+
 2004-01-23  Ronald Bultje  <rbultje@ronald.bitfreak.net>
 
        * gst/gsttag.c: (_gst_tag_initialize):
index 71d652af365944c429bd16233d3a1e5cd0a2655b..cb433f41b2737cc1b9003a234b9da5ed59dcae8d 100644 (file)
@@ -364,6 +364,7 @@ gst_buffer_store_get_buffer (GstBufferStore *store, guint64 offset, guint size)
        walk = g_list_next (walk);
        tmp = MIN (GST_BUFFER_SIZE (current), size);
        memcpy (data, GST_BUFFER_DATA (current), tmp);
+       data += tmp;
        size -= tmp;
       }
     }
index a7a45520dcaa187297ea128f29f21ed869ec9b85..0fc41588b5fe2007a0a6a43a5cb81c088dd4344a 100644 (file)
@@ -99,7 +99,7 @@ gst_tee_class_init (GstTeeClass *klass)
                       0, G_MAXINT, 0, G_PARAM_READABLE)); 
   g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
     g_param_spec_boolean ("silent", "silent", "silent",
-                      FALSE, G_PARAM_READWRITE));
+                      TRUE, G_PARAM_CONSTRUCT | G_PARAM_READWRITE));
   g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE,
     g_param_spec_string ("last_message", "last_message", "last_message",
                         NULL, G_PARAM_READABLE));
@@ -120,7 +120,6 @@ gst_tee_init (GstTee *tee)
   gst_pad_set_link_function (tee->sinkpad, GST_DEBUG_FUNCPTR (gst_pad_proxy_pad_link));
   gst_pad_set_getcaps_function (tee->sinkpad, GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
 
-  tee->silent = FALSE;
   tee->last_message = NULL;
 }
 
index 4b93849b3c94d5505ef3b392dc842f4005da879a..0dcce58eef3b62b2dec54d879b69bd7328772260 100644 (file)
@@ -490,7 +490,12 @@ gst_type_find_element_chain (GstPad *pad, GstData *data)
       gst_pad_push (typefind->src, data);
       return;
     case MODE_TYPEFIND: {
+      guint64 current_offset;
+      
       gst_buffer_store_add_buffer (typefind->store, GST_BUFFER (data));
+      current_offset = GST_BUFFER_OFFSET_IS_VALID (data) ? 
+         GST_BUFFER_OFFSET (data) + GST_BUFFER_SIZE (data) : 
+         gst_buffer_store_get_size (typefind->store, 0);
       gst_data_unref (data);
       if (typefind->possibilities == NULL) {
        /* not yet started, get all typefinding functions into our "queue" */
@@ -563,30 +568,38 @@ gst_type_find_element_chain (GstPad *pad, GstData *data)
        /* set up typefind element for next iteration */
        typefind->possibilities = g_list_sort (typefind->possibilities, compare_type_find_entry);
        
-       walk = typefind->possibilities;
-       while (walk) {
+       /* look for typefind functions that require data without seeking */
+       for (walk = typefind->possibilities; walk; walk = g_list_next (walk)) {
          entry = (TypeFindEntry *) walk->data;
-         walk = g_list_next (walk);
-         if (entry->requested_size > 0) {
-           /* FIXME: need heuristic to find out if we should seek */
-           gint64 seek_offset;
-           GstEvent *event;
-
-           seek_offset = entry->requested_offset > 0 ? entry->requested_offset : 
-                         find_element_get_length (entry) + entry->requested_offset;
-           seek_offset += gst_buffer_store_get_size (typefind->store, seek_offset);
-           event = gst_event_new_seek (GST_FORMAT_BYTES | GST_SEEK_METHOD_SET, seek_offset);
-           if (gst_pad_send_event (GST_PAD_PEER (typefind->sink), event)) {
-             /* done seeking */
-             GST_DEBUG_OBJECT (typefind, "'%s' was reset - seeked to %"G_GINT64_FORMAT, 
-                     GST_PLUGIN_FEATURE_NAME (entry->factory), seek_offset);
-             break;
-           } else if (entry->requested_offset < 0) {
-             /* impossible to seek */
-             GST_DEBUG_OBJECT (typefind, "'%s' was reset - couldn't seek to %"G_GINT64_FORMAT, 
-                     GST_PLUGIN_FEATURE_NAME (entry->factory), seek_offset);
-             entry->requested_size = 0;
-             entry->requested_offset = 0;
+         if (entry->requested_offset <= current_offset &&
+             entry->requested_offset + entry->requested_size > current_offset)
+           break;
+       }
+       if (!walk) {
+         /* find out if we should seek */
+         for (walk = typefind->possibilities; walk; walk = g_list_next (walk)) {
+           entry = (TypeFindEntry *) walk->data;
+           if (entry->requested_size > 0) {
+             /* FIXME: need heuristic to find out if we should seek */
+             gint64 seek_offset;
+             GstEvent *event;
+
+             seek_offset = entry->requested_offset > 0 ? entry->requested_offset : 
+                           find_element_get_length (entry) + entry->requested_offset;
+             seek_offset += gst_buffer_store_get_size (typefind->store, seek_offset);
+             event = gst_event_new_seek (GST_FORMAT_BYTES | GST_SEEK_METHOD_SET, seek_offset);
+             if (gst_pad_send_event (GST_PAD_PEER (typefind->sink), event)) {
+               /* done seeking */
+               GST_DEBUG_OBJECT (typefind, "'%s' was reset - seeked to %"G_GINT64_FORMAT, 
+                       GST_PLUGIN_FEATURE_NAME (entry->factory), seek_offset);
+               break;
+             } else if (entry->requested_offset < 0) {
+               /* impossible to seek */
+               GST_DEBUG_OBJECT (typefind, "'%s' was reset - couldn't seek to %"G_GINT64_FORMAT, 
+                       GST_PLUGIN_FEATURE_NAME (entry->factory), seek_offset);
+               entry->requested_size = 0;
+               entry->requested_offset = 0;
+             }
            }
          }
        }
index 71d652af365944c429bd16233d3a1e5cd0a2655b..cb433f41b2737cc1b9003a234b9da5ed59dcae8d 100644 (file)
@@ -364,6 +364,7 @@ gst_buffer_store_get_buffer (GstBufferStore *store, guint64 offset, guint size)
        walk = g_list_next (walk);
        tmp = MIN (GST_BUFFER_SIZE (current), size);
        memcpy (data, GST_BUFFER_DATA (current), tmp);
+       data += tmp;
        size -= tmp;
       }
     }
index a7a45520dcaa187297ea128f29f21ed869ec9b85..0fc41588b5fe2007a0a6a43a5cb81c088dd4344a 100644 (file)
@@ -99,7 +99,7 @@ gst_tee_class_init (GstTeeClass *klass)
                       0, G_MAXINT, 0, G_PARAM_READABLE)); 
   g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT,
     g_param_spec_boolean ("silent", "silent", "silent",
-                      FALSE, G_PARAM_READWRITE));
+                      TRUE, G_PARAM_CONSTRUCT | G_PARAM_READWRITE));
   g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE,
     g_param_spec_string ("last_message", "last_message", "last_message",
                         NULL, G_PARAM_READABLE));
@@ -120,7 +120,6 @@ gst_tee_init (GstTee *tee)
   gst_pad_set_link_function (tee->sinkpad, GST_DEBUG_FUNCPTR (gst_pad_proxy_pad_link));
   gst_pad_set_getcaps_function (tee->sinkpad, GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps));
 
-  tee->silent = FALSE;
   tee->last_message = NULL;
 }
 
index 4b93849b3c94d5505ef3b392dc842f4005da879a..0dcce58eef3b62b2dec54d879b69bd7328772260 100644 (file)
@@ -490,7 +490,12 @@ gst_type_find_element_chain (GstPad *pad, GstData *data)
       gst_pad_push (typefind->src, data);
       return;
     case MODE_TYPEFIND: {
+      guint64 current_offset;
+      
       gst_buffer_store_add_buffer (typefind->store, GST_BUFFER (data));
+      current_offset = GST_BUFFER_OFFSET_IS_VALID (data) ? 
+         GST_BUFFER_OFFSET (data) + GST_BUFFER_SIZE (data) : 
+         gst_buffer_store_get_size (typefind->store, 0);
       gst_data_unref (data);
       if (typefind->possibilities == NULL) {
        /* not yet started, get all typefinding functions into our "queue" */
@@ -563,30 +568,38 @@ gst_type_find_element_chain (GstPad *pad, GstData *data)
        /* set up typefind element for next iteration */
        typefind->possibilities = g_list_sort (typefind->possibilities, compare_type_find_entry);
        
-       walk = typefind->possibilities;
-       while (walk) {
+       /* look for typefind functions that require data without seeking */
+       for (walk = typefind->possibilities; walk; walk = g_list_next (walk)) {
          entry = (TypeFindEntry *) walk->data;
-         walk = g_list_next (walk);
-         if (entry->requested_size > 0) {
-           /* FIXME: need heuristic to find out if we should seek */
-           gint64 seek_offset;
-           GstEvent *event;
-
-           seek_offset = entry->requested_offset > 0 ? entry->requested_offset : 
-                         find_element_get_length (entry) + entry->requested_offset;
-           seek_offset += gst_buffer_store_get_size (typefind->store, seek_offset);
-           event = gst_event_new_seek (GST_FORMAT_BYTES | GST_SEEK_METHOD_SET, seek_offset);
-           if (gst_pad_send_event (GST_PAD_PEER (typefind->sink), event)) {
-             /* done seeking */
-             GST_DEBUG_OBJECT (typefind, "'%s' was reset - seeked to %"G_GINT64_FORMAT, 
-                     GST_PLUGIN_FEATURE_NAME (entry->factory), seek_offset);
-             break;
-           } else if (entry->requested_offset < 0) {
-             /* impossible to seek */
-             GST_DEBUG_OBJECT (typefind, "'%s' was reset - couldn't seek to %"G_GINT64_FORMAT, 
-                     GST_PLUGIN_FEATURE_NAME (entry->factory), seek_offset);
-             entry->requested_size = 0;
-             entry->requested_offset = 0;
+         if (entry->requested_offset <= current_offset &&
+             entry->requested_offset + entry->requested_size > current_offset)
+           break;
+       }
+       if (!walk) {
+         /* find out if we should seek */
+         for (walk = typefind->possibilities; walk; walk = g_list_next (walk)) {
+           entry = (TypeFindEntry *) walk->data;
+           if (entry->requested_size > 0) {
+             /* FIXME: need heuristic to find out if we should seek */
+             gint64 seek_offset;
+             GstEvent *event;
+
+             seek_offset = entry->requested_offset > 0 ? entry->requested_offset : 
+                           find_element_get_length (entry) + entry->requested_offset;
+             seek_offset += gst_buffer_store_get_size (typefind->store, seek_offset);
+             event = gst_event_new_seek (GST_FORMAT_BYTES | GST_SEEK_METHOD_SET, seek_offset);
+             if (gst_pad_send_event (GST_PAD_PEER (typefind->sink), event)) {
+               /* done seeking */
+               GST_DEBUG_OBJECT (typefind, "'%s' was reset - seeked to %"G_GINT64_FORMAT, 
+                       GST_PLUGIN_FEATURE_NAME (entry->factory), seek_offset);
+               break;
+             } else if (entry->requested_offset < 0) {
+               /* impossible to seek */
+               GST_DEBUG_OBJECT (typefind, "'%s' was reset - couldn't seek to %"G_GINT64_FORMAT, 
+                       GST_PLUGIN_FEATURE_NAME (entry->factory), seek_offset);
+               entry->requested_size = 0;
+               entry->requested_offset = 0;
+             }
            }
          }
        }