souphttpsrc: Fix keep-alive handling
[platform/upstream/gst-plugins-good.git] / ext / wavpack / gstwavpackenc.c
index 1f0f66e..5d6205c 100644 (file)
@@ -15,8 +15,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.
  */
 
 /**
  * <refsect2>
  * <title>Example launch line</title>
  * |[
- * gst-launch audiotestsrc num-buffers=500 ! audioconvert ! wavpackenc ! filesink location=sinewave.wv
+ * gst-launch-1.0 audiotestsrc num-buffers=500 ! audioconvert ! wavpackenc ! filesink location=sinewave.wv
  * ]| This pipeline encodes audio from audiotestsrc into a Wavpack file. The audioconvert element is needed
  * as the Wavpack encoder only accepts input with 32 bit width.
  * |[
- * gst-launch cdda://1 ! audioconvert ! wavpackenc ! filesink location=track1.wv
+ * gst-launch-1.0 cdda://1 ! audioconvert ! wavpackenc ! filesink location=track1.wv
  * ]| This pipeline encodes audio from an audio CD into a Wavpack file using
  * lossless encoding (the file output will be fairly large).
  * |[
- * gst-launch cdda://1 ! audioconvert ! wavpackenc bitrate=128000 ! filesink location=track1.wv
+ * gst-launch-1.0 cdda://1 ! audioconvert ! wavpackenc bitrate=128000 ! filesink location=track1.wv
  * ]| This pipeline encodes audio from an audio CD into a Wavpack file using
  * lossy encoding at a certain bitrate (the file will be fairly small).
  * </refsect2>
@@ -136,9 +136,7 @@ gst_wavpack_enc_mode_get_type (void)
       {GST_WAVPACK_ENC_MODE_FAST, "Fast Compression", "fast"},
       {GST_WAVPACK_ENC_MODE_DEFAULT, "Normal Compression", "normal"},
       {GST_WAVPACK_ENC_MODE_HIGH, "High Compression", "high"},
-#ifndef WAVPACK_OLD_API
       {GST_WAVPACK_ENC_MODE_VERY_HIGH, "Very High Compression", "veryhigh"},
-#endif
       {0, NULL, NULL}
     };
 
@@ -211,15 +209,12 @@ gst_wavpack_enc_class_init (GstWavpackEncClass * klass)
   GstAudioEncoderClass *base_class = (GstAudioEncoderClass *) (klass);
 
   /* add pad templates */
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&sink_factory));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&src_factory));
-  gst_element_class_add_pad_template (element_class,
-      gst_static_pad_template_get (&wvcsrc_factory));
+  gst_element_class_add_static_pad_template (element_class, &sink_factory);
+  gst_element_class_add_static_pad_template (element_class, &src_factory);
+  gst_element_class_add_static_pad_template (element_class, &wvcsrc_factory);
 
   /* set element details */
-  gst_element_class_set_details_simple (element_class, "Wavpack audio encoder",
+  gst_element_class_set_static_metadata (element_class, "Wavpack audio encoder",
       "Codec/Encoder/Audio",
       "Encodes audio with the Wavpack lossless/lossy audio codec",
       "Sebastian Dröge <slomo@circular-chaos.org>");
@@ -347,6 +342,8 @@ gst_wavpack_enc_init (GstWavpackEnc * enc)
 
   /* require perfect ts */
   gst_audio_encoder_set_perfect_timestamp (benc, TRUE);
+
+  GST_PAD_SET_ACCEPT_TEMPLATE (GST_AUDIO_ENCODER_SINK_PAD (enc));
 }
 
 
@@ -400,7 +397,7 @@ gst_wavpack_enc_set_format (GstAudioEncoder * benc, GstAudioInfo * info)
       enc->channel_mapping);
 
   /* wavpack caps hold gst mask, not wavpack mask */
-  gst_audio_channel_positions_to_mask (opos, enc->channels, &mask);
+  gst_audio_channel_positions_to_mask (opos, enc->channels, FALSE, &mask);
 
   /* set fixed src pad caps now that we know what we will get */
   caps = gst_caps_new_simple ("audio/x-wavpack",
@@ -466,12 +463,10 @@ gst_wavpack_enc_set_wp_config (GstWavpackEnc * enc)
     case GST_WAVPACK_ENC_MODE_HIGH:
       enc->wp_config->flags |= CONFIG_HIGH_FLAG;
       break;
-#ifndef WAVPACK_OLD_API
     case GST_WAVPACK_ENC_MODE_VERY_HIGH:
       enc->wp_config->flags |= CONFIG_HIGH_FLAG;
       enc->wp_config->flags |= CONFIG_VERY_HIGH_FLAG;
       break;
-#endif
   }
 
   /* Bitrate, enables lossy mode */
@@ -590,7 +585,9 @@ gst_wavpack_enc_push_block (void *id, void *data, int32_t count)
         enc->pending_offset = wph.block_index;
       }
 
-      if (!(wph.flags & FINAL_BLOCK))
+      /* Is this the not-final block of multi-channel data? If so, just
+       * accumulate and return here. */
+      if (!(wph.flags & FINAL_BLOCK) && ((block[32] & ID_OPTIONAL_DATA) == 0))
         return TRUE;
 
       buffer = enc->pending_buffer;
@@ -632,11 +629,11 @@ gst_wavpack_enc_push_block (void *id, void *data, int32_t count)
 
   if (wid->correction || wid->passthrough) {
     /* push the buffer and forward errors */
-    GST_DEBUG_OBJECT (enc, "pushing buffer with %d bytes",
+    GST_DEBUG_OBJECT (enc, "pushing buffer with %" G_GSIZE_FORMAT " bytes",
         gst_buffer_get_size (buffer));
     *flow = gst_pad_push (pad, buffer);
   } else {
-    GST_DEBUG_OBJECT (enc, "handing frame of %d bytes",
+    GST_DEBUG_OBJECT (enc, "handing frame of %" G_GSIZE_FORMAT " bytes",
         gst_buffer_get_size (buffer));
     *flow = gst_audio_encoder_finish_frame (GST_AUDIO_ENCODER (enc), buffer,
         samples);