rtpsource: Add more information to probation warning
[platform/upstream/gst-plugins-good.git] / gst / auparse / gstauparse.c
index 7c1734b..b814ad8 100644 (file)
@@ -14,8 +14,8 @@
  *
  * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
  */
 
 /**
@@ -49,7 +49,16 @@ static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
                        "S32LE, S32BE, F32LE, F32BE, "        \
                        "F64LE, F64BE }, " \
     "rate = (int) [ 8000, 192000 ], "       \
-    "channels = (int) [ 1, 2 ]"
+    "channels = (int) 1, "                  \
+    "layout = (string) interleaved;"        \
+    "audio/x-raw, "                         \
+    "format= (string) { S8, S16LE, S16BE, S24LE, S24BE, "  \
+                       "S32LE, S32BE, F32LE, F32BE, "        \
+                       "F64LE, F64BE }, " \
+    "rate = (int) [ 8000, 192000 ], "       \
+    "channels = (int) 2, "                  \
+    "channel-mask = (bitmask) 0x3,"         \
+    "layout = (string) interleaved"
 
 #define GST_AU_PARSE_ALAW_PAD_TEMPLATE_CAPS \
     "audio/x-alaw, "                        \
@@ -109,11 +118,9 @@ gst_au_parse_class_init (GstAuParseClass * klass)
 
   gstelement_class->change_state =
       GST_DEBUG_FUNCPTR (gst_au_parse_change_state);
-  gst_element_class_add_pad_template (gstelement_class,
-      gst_static_pad_template_get (&sink_template));
-  gst_element_class_add_pad_template (gstelement_class,
-      gst_static_pad_template_get (&src_template));
-  gst_element_class_set_details_simple (gstelement_class,
+  gst_element_class_add_static_pad_template (gstelement_class, &sink_template);
+  gst_element_class_add_static_pad_template (gstelement_class, &src_template);
+  gst_element_class_set_static_metadata (gstelement_class,
       "AU audio demuxer",
       "Codec/Demuxer/Audio",
       "Parse an .au file into raw audio",
@@ -165,6 +172,8 @@ gst_au_parse_reset (GstAuParse * auparse)
 
   gst_adapter_clear (auparse->adapter);
 
+  gst_caps_replace (&auparse->src_caps, NULL);
+
   /* gst_segment_init (&auparse->segment, GST_FORMAT_TIME); */
 }
 
@@ -339,10 +348,18 @@ gst_au_parse_parse_header (GstAuParse * auparse)
         "channels", G_TYPE_INT, auparse->channels, NULL);
     auparse->sample_size = auparse->channels;
   } else if (format != GST_AUDIO_FORMAT_UNKNOWN) {
+    GstCaps *templ_caps = gst_pad_get_pad_template_caps (auparse->srcpad);
+    GstCaps *intersection;
+
     tempcaps = gst_caps_new_simple ("audio/x-raw",
         "format", G_TYPE_STRING, gst_audio_format_to_string (format),
         "rate", G_TYPE_INT, auparse->samplerate,
         "channels", G_TYPE_INT, auparse->channels, NULL);
+
+    intersection = gst_caps_intersect (tempcaps, templ_caps);
+    gst_caps_unref (tempcaps);
+    gst_caps_unref (templ_caps);
+    tempcaps = intersection;
   } else if (layout[0]) {
     tempcaps = gst_caps_new_simple ("audio/x-adpcm",
         "layout", G_TYPE_STRING, layout, NULL);
@@ -402,7 +419,6 @@ gst_au_parse_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
   gint64 timestamp;
   gint64 duration;
   gint64 offset;
-  GstSegment segment;
 
   auparse = GST_AU_PARSE (parent);
 
@@ -424,8 +440,11 @@ gst_au_parse_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
     if (ret != GST_FLOW_OK)
       goto out;
 
-    gst_segment_init (&segment, GST_FORMAT_TIME);
-    gst_pad_push_event (auparse->srcpad, gst_event_new_segment (&segment));
+    if (auparse->need_segment) {
+      gst_pad_push_event (auparse->srcpad,
+          gst_event_new_segment (&auparse->segment));
+      auparse->need_segment = FALSE;
+    }
   }
 
   avail = gst_adapter_available (auparse->adapter);
@@ -671,7 +690,6 @@ gst_au_parse_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
     {
       gint64 start, stop, offset = 0;
       GstSegment segment;
-      GstEvent *new_event = NULL;
 
       /* some debug output */
       gst_event_copy_segment (event, &segment);
@@ -703,9 +721,17 @@ gst_au_parse_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
       gst_segment_init (&segment, GST_FORMAT_TIME);
       segment.start = segment.time = start;
       segment.stop = stop;
-      new_event = gst_event_new_segment (&segment);
 
-      ret = gst_pad_push_event (auparse->srcpad, new_event);
+      gst_segment_copy_into (&segment, &auparse->segment);
+
+      if (!gst_pad_has_current_caps (auparse->srcpad)) {
+        auparse->need_segment = TRUE;
+        ret = TRUE;
+      } else {
+        auparse->need_segment = FALSE;
+        ret = gst_pad_push_event (auparse->srcpad,
+            gst_event_new_segment (&segment));
+      }
 
       auparse->buffer_offset = offset;
 
@@ -737,6 +763,7 @@ gst_au_parse_src_event (GstPad * pad, GstObject * parent, GstEvent * event)
   switch (GST_EVENT_TYPE (event)) {
     case GST_EVENT_SEEK:
       ret = gst_au_parse_handle_seek (auparse, event);
+      gst_event_unref (event);
       break;
     default:
       ret = gst_pad_event_default (pad, parent, event);
@@ -779,6 +806,6 @@ plugin_init (GstPlugin * plugin)
 
 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
     GST_VERSION_MINOR,
-    "auparse",
+    auparse,
     "parses au streams", plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME,
     GST_PACKAGE_ORIGIN)