summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>2009-03-31 16:07:46 +0200
committerMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>2009-03-31 16:18:00 +0200
commitad2c7bffe7d94c79184904b14101cbc93eeb9ebd (patch)
tree85462ced72694644022f71ac3d2daaa8f4483532
parentd2f954636997b16343b40dfefd3ffb0fb00895a1 (diff)
baseparse: Delay newsegment as long as possible.
If newsegment is sent (too) early, caps may not yet be fixed/set, and downstream may not have been linked.
-rw-r--r--gst/aacparse/gstbaseparse.c59
-rw-r--r--gst/amrparse/gstbaseparse.c59
2 files changed, 68 insertions, 50 deletions
diff --git a/gst/aacparse/gstbaseparse.c b/gst/aacparse/gstbaseparse.c
index 6d0e7f8d4..4940a8e49 100644
--- a/gst/aacparse/gstbaseparse.c
+++ b/gst/aacparse/gstbaseparse.c
@@ -748,8 +748,42 @@ gst_base_parse_handle_and_push_buffer (GstBaseParse * parse,
748 if (last_stop != GST_CLOCK_TIME_NONE && GST_BUFFER_DURATION_IS_VALID (buffer)) 748 if (last_stop != GST_CLOCK_TIME_NONE && GST_BUFFER_DURATION_IS_VALID (buffer))
749 last_stop += GST_BUFFER_DURATION (buffer); 749 last_stop += GST_BUFFER_DURATION (buffer);
750 750
751 /* should have caps by now */
752 g_return_val_if_fail (GST_PAD_CAPS (parse->srcpad), GST_FLOW_ERROR);
753
751 gst_buffer_set_caps (buffer, GST_PAD_CAPS (parse->srcpad)); 754 gst_buffer_set_caps (buffer, GST_PAD_CAPS (parse->srcpad));
752 755
756 /* and should then also be linked downstream, so safe to send some events */
757 if (parse->priv->pad_mode == GST_ACTIVATE_PULL) {
758 if (G_UNLIKELY (parse->close_segment)) {
759 GST_DEBUG_OBJECT (parse, "loop sending close segment");
760 gst_pad_push_event (parse->srcpad, parse->close_segment);
761 parse->close_segment = NULL;
762 }
763
764 if (G_UNLIKELY (parse->pending_segment)) {
765 GST_DEBUG_OBJECT (parse, "loop push pending segment");
766 gst_pad_push_event (parse->srcpad, parse->pending_segment);
767 parse->pending_segment = NULL;
768 }
769 } else {
770 if (G_UNLIKELY (parse->pending_segment)) {
771 GST_DEBUG_OBJECT (parse, "chain pushing a pending segment");
772 gst_pad_push_event (parse->srcpad, parse->pending_segment);
773 parse->pending_segment = NULL;
774 }
775 }
776
777 if (G_UNLIKELY (parse->priv->pending_events)) {
778 GList *l;
779
780 for (l = parse->priv->pending_events; l != NULL; l = l->next) {
781 gst_pad_push_event (parse->srcpad, GST_EVENT (l->data));
782 }
783 g_list_free (parse->priv->pending_events);
784 parse->priv->pending_events = NULL;
785 }
786
753 /* TODO: Add to seek table */ 787 /* TODO: Add to seek table */
754 788
755 if (ret == GST_FLOW_OK) { 789 if (ret == GST_FLOW_OK) {
@@ -839,9 +873,6 @@ gst_base_parse_chain (GstPad * pad, GstBuffer * buffer)
839 bclass = GST_BASE_PARSE_GET_CLASS (parse); 873 bclass = GST_BASE_PARSE_GET_CLASS (parse);
840 874
841 if (G_UNLIKELY (parse->pending_segment)) { 875 if (G_UNLIKELY (parse->pending_segment)) {
842 GST_DEBUG_OBJECT (parse, "chain pushing a pending segment");
843 gst_pad_push_event (parse->srcpad, parse->pending_segment);
844 parse->pending_segment = NULL;
845 parse->priv->offset = parse->priv->pending_offset; 876 parse->priv->offset = parse->priv->pending_offset;
846 877
847 /* Make sure that adapter doesn't have any old data after 878 /* Make sure that adapter doesn't have any old data after
@@ -854,16 +885,6 @@ gst_base_parse_chain (GstPad * pad, GstBuffer * buffer)
854 gst_adapter_clear (parse->adapter); 885 gst_adapter_clear (parse->adapter);
855 } 886 }
856 887
857 if (G_UNLIKELY (parse->priv->pending_events)) {
858 GList *l;
859
860 for (l = parse->priv->pending_events; l != NULL; l = l->next) {
861 gst_pad_push_event (parse->srcpad, GST_EVENT (l->data));
862 }
863 g_list_free (parse->priv->pending_events);
864 parse->priv->pending_events = NULL;
865 }
866
867 if (G_LIKELY (buffer)) { 888 if (G_LIKELY (buffer)) {
868 GST_LOG_OBJECT (parse, "buffer size: %d, offset = %lld", 889 GST_LOG_OBJECT (parse, "buffer size: %d, offset = %lld",
869 GST_BUFFER_SIZE (buffer), GST_BUFFER_OFFSET (buffer)); 890 GST_BUFFER_SIZE (buffer), GST_BUFFER_OFFSET (buffer));
@@ -1051,18 +1072,6 @@ gst_base_parse_loop (GstPad * pad)
1051 parse = GST_BASE_PARSE (gst_pad_get_parent (pad)); 1072 parse = GST_BASE_PARSE (gst_pad_get_parent (pad));
1052 klass = GST_BASE_PARSE_GET_CLASS (parse); 1073 klass = GST_BASE_PARSE_GET_CLASS (parse);
1053 1074
1054 if (parse->close_segment) {
1055 GST_DEBUG_OBJECT (parse, "loop sending close segment");
1056 gst_pad_push_event (parse->srcpad, parse->close_segment);
1057 parse->close_segment = NULL;
1058 }
1059
1060 if (parse->pending_segment) {
1061 GST_DEBUG_OBJECT (parse, "loop push pending segment");
1062 gst_pad_push_event (parse->srcpad, parse->pending_segment);
1063 parse->pending_segment = NULL;
1064 }
1065
1066 /* TODO: Check if we reach segment stop limit */ 1075 /* TODO: Check if we reach segment stop limit */
1067 1076
1068 while (TRUE) { 1077 while (TRUE) {
diff --git a/gst/amrparse/gstbaseparse.c b/gst/amrparse/gstbaseparse.c
index 673f7169c..b06b9becb 100644
--- a/gst/amrparse/gstbaseparse.c
+++ b/gst/amrparse/gstbaseparse.c
@@ -748,8 +748,42 @@ gst_base_parse_handle_and_push_buffer (GstBaseParse * parse,
748 if (last_stop != GST_CLOCK_TIME_NONE && GST_BUFFER_DURATION_IS_VALID (buffer)) 748 if (last_stop != GST_CLOCK_TIME_NONE && GST_BUFFER_DURATION_IS_VALID (buffer))
749 last_stop += GST_BUFFER_DURATION (buffer); 749 last_stop += GST_BUFFER_DURATION (buffer);
750 750
751 /* should have caps by now */
752 g_return_val_if_fail (GST_PAD_CAPS (parse->srcpad), GST_FLOW_ERROR);
753
751 gst_buffer_set_caps (buffer, GST_PAD_CAPS (parse->srcpad)); 754 gst_buffer_set_caps (buffer, GST_PAD_CAPS (parse->srcpad));
752 755
756 /* and should then also be linked downstream, so safe to send some events */
757 if (parse->priv->pad_mode == GST_ACTIVATE_PULL) {
758 if (G_UNLIKELY (parse->close_segment)) {
759 GST_DEBUG_OBJECT (parse, "loop sending close segment");
760 gst_pad_push_event (parse->srcpad, parse->close_segment);
761 parse->close_segment = NULL;
762 }
763
764 if (G_UNLIKELY (parse->pending_segment)) {
765 GST_DEBUG_OBJECT (parse, "loop push pending segment");
766 gst_pad_push_event (parse->srcpad, parse->pending_segment);
767 parse->pending_segment = NULL;
768 }
769 } else {
770 if (G_UNLIKELY (parse->pending_segment)) {
771 GST_DEBUG_OBJECT (parse, "chain pushing a pending segment");
772 gst_pad_push_event (parse->srcpad, parse->pending_segment);
773 parse->pending_segment = NULL;
774 }
775 }
776
777 if (G_UNLIKELY (parse->priv->pending_events)) {
778 GList *l;
779
780 for (l = parse->priv->pending_events; l != NULL; l = l->next) {
781 gst_pad_push_event (parse->srcpad, GST_EVENT (l->data));
782 }
783 g_list_free (parse->priv->pending_events);
784 parse->priv->pending_events = NULL;
785 }
786
753 /* TODO: Add to seek table */ 787 /* TODO: Add to seek table */
754 788
755 if (ret == GST_FLOW_OK) { 789 if (ret == GST_FLOW_OK) {
@@ -839,9 +873,6 @@ gst_base_parse_chain (GstPad * pad, GstBuffer * buffer)
839 bclass = GST_BASE_PARSE_GET_CLASS (parse); 873 bclass = GST_BASE_PARSE_GET_CLASS (parse);
840 874
841 if (G_UNLIKELY (parse->pending_segment)) { 875 if (G_UNLIKELY (parse->pending_segment)) {
842 GST_DEBUG_OBJECT (parse, "chain pushing a pending segment");
843 gst_pad_push_event (parse->srcpad, parse->pending_segment);
844 parse->pending_segment = NULL;
845 parse->priv->offset = parse->priv->pending_offset; 876 parse->priv->offset = parse->priv->pending_offset;
846 877
847 /* Make sure that adapter doesn't have any old data after 878 /* Make sure that adapter doesn't have any old data after
@@ -854,16 +885,6 @@ gst_base_parse_chain (GstPad * pad, GstBuffer * buffer)
854 gst_adapter_clear (parse->adapter); 885 gst_adapter_clear (parse->adapter);
855 } 886 }
856 887
857 if (G_UNLIKELY (parse->priv->pending_events)) {
858 GList *l;
859
860 for (l = parse->priv->pending_events; l != NULL; l = l->next) {
861 gst_pad_push_event (parse->srcpad, GST_EVENT (l->data));
862 }
863 g_list_free (parse->priv->pending_events);
864 parse->priv->pending_events = NULL;
865 }
866
867 if (G_LIKELY (buffer)) { 888 if (G_LIKELY (buffer)) {
868 GST_LOG_OBJECT (parse, "buffer size: %d, offset = %lld", 889 GST_LOG_OBJECT (parse, "buffer size: %d, offset = %lld",
869 GST_BUFFER_SIZE (buffer), GST_BUFFER_OFFSET (buffer)); 890 GST_BUFFER_SIZE (buffer), GST_BUFFER_OFFSET (buffer));
@@ -1051,18 +1072,6 @@ gst_base_parse_loop (GstPad * pad)
1051 parse = GST_BASE_PARSE (gst_pad_get_parent (pad)); 1072 parse = GST_BASE_PARSE (gst_pad_get_parent (pad));
1052 klass = GST_BASE_PARSE_GET_CLASS (parse); 1073 klass = GST_BASE_PARSE_GET_CLASS (parse);
1053 1074
1054 if (parse->close_segment) {
1055 GST_DEBUG_OBJECT (parse, "loop sending close segment");
1056 gst_pad_push_event (parse->srcpad, parse->close_segment);
1057 parse->close_segment = NULL;
1058 }
1059
1060 if (parse->pending_segment) {
1061 GST_DEBUG_OBJECT (parse, "loop push pending segment");
1062 gst_pad_push_event (parse->srcpad, parse->pending_segment);
1063 parse->pending_segment = NULL;
1064 }
1065
1066 /* TODO: Check if we reach segment stop limit */ 1075 /* TODO: Check if we reach segment stop limit */
1067 1076
1068 while (TRUE) { 1077 while (TRUE) {