commit dbdabca06c6cc82a0801062008177f2848096ee8
Author: Stas Sergeev <stsp@users.sourceforge.net>
Date:   Mon Oct 10 20:12:58 2011 +0400

    Remove MpegTsMux arg from prepare functions to re-use them with other plugins

diff --git a/gst/mpegtsmux/mpegtsmux.c b/gst/mpegtsmux/mpegtsmux.c
index f59a5f7..a7d0582 100644
--- a/gst/mpegtsmux/mpegtsmux.c
+++ b/gst/mpegtsmux/mpegtsmux.c
@@ -515,6 +515,7 @@ mpegtsmux_create_streams (MpegTsMux * mux)
 
     walk = g_slist_next (walk);
 
+    ts_data->obj = G_OBJECT (mux);
     if (ts_data->prog_id == -1) {
       name = GST_PAD_NAME (c_data->pad);
       if (mux->prog_map != NULL && gst_structure_has_field (mux->prog_map,
@@ -585,7 +586,7 @@ mpegtsmux_choose_best_stream (MpegTsMux * mux)
 
         if (buf != NULL) {
           if (ts_data->prepare_func) {
-            buf = ts_data->prepare_func (buf, ts_data, mux);
+            buf = ts_data->prepare_func (buf, ts_data);
             if (buf) {          /* Take the prepared buffer instead */
               gst_buffer_unref (ts_data->queued_buf);
               ts_data->queued_buf = buf;
diff --git a/gst/mpegtsmux/mpegtsmux.h b/gst/mpegtsmux/mpegtsmux.h
index b45dd34..aeeeb5c 100644
--- a/gst/mpegtsmux/mpegtsmux.h
+++ b/gst/mpegtsmux/mpegtsmux.h
@@ -99,7 +99,7 @@ typedef struct MpegTsMuxClass MpegTsMuxClass;
 typedef struct MpegTsPadData MpegTsPadData;
 
 typedef GstBuffer * (*MpegTsPadDataPrepareFunction) (GstBuffer * buf,
-    MpegTsPadData * data, MpegTsMux * mux);
+    MpegTsPadData * data);
 
 typedef void (*MpegTsPadDataFreePrepareDataFunction) (gpointer prepare_data);
 
@@ -138,6 +138,7 @@ struct MpegTsMuxClass  {
 
 struct MpegTsPadData {
   GstCollectData collect; /* Parent */
+  GObject *obj;
 
   gint pid;
   TsMuxStream *stream;
diff --git a/gst/mpegtsmux/mpegtsmux_aac.c b/gst/mpegtsmux/mpegtsmux_aac.c
index c97b99e..59c7f1c 100644
--- a/gst/mpegtsmux/mpegtsmux_aac.c
+++ b/gst/mpegtsmux/mpegtsmux_aac.c
@@ -88,14 +88,14 @@
 #include <string.h>
 
 GstBuffer *
-mpegtsmux_prepare_aac (GstBuffer * buf, MpegTsPadData * data, MpegTsMux * mux)
+mpegtsmux_prepare_aac (GstBuffer * buf, MpegTsPadData * data)
 {
   guint8 adts_header[7] = { 0, };
   GstBuffer *out_buf = gst_buffer_new_and_alloc (GST_BUFFER_SIZE (buf) + 7);
   gsize out_offset = 0;
   guint8 rate_idx = 0, channels = 0, obj_type = 0;
 
-  GST_DEBUG_OBJECT (mux, "Preparing AAC buffer for output");
+  GST_DEBUG_OBJECT (data->obj, "Preparing AAC buffer for output");
 
   /* We want the same metadata */
   gst_buffer_copy_metadata (out_buf, buf, GST_BUFFER_COPY_ALL);
@@ -108,8 +108,8 @@ mpegtsmux_prepare_aac (GstBuffer * buf, MpegTsPadData * data, MpegTsMux * mux)
       (GST_READ_UINT8 (GST_BUFFER_DATA (data->codec_data) + 1) & 0x80) >> 7;
   channels =
       (GST_READ_UINT8 (GST_BUFFER_DATA (data->codec_data) + 1) & 0x78) >> 3;
-  GST_DEBUG_OBJECT (mux, "Rate index %u, channels %u, object type %u", rate_idx,
-      channels, obj_type);
+  GST_DEBUG_OBJECT (data->obj, "Rate index %u, channels %u, object type %u",
+      rate_idx, channels, obj_type);
   /* Sync point over a full byte */
   adts_header[0] = 0xFF;
   /* Sync point continued over first 4 bits + static 4 bits
diff --git a/gst/mpegtsmux/mpegtsmux_aac.h b/gst/mpegtsmux/mpegtsmux_aac.h
index 1e898b7..4e265b1 100644
--- a/gst/mpegtsmux/mpegtsmux_aac.h
+++ b/gst/mpegtsmux/mpegtsmux_aac.h
@@ -1,4 +1,4 @@
-/* 
+/*
  * Copyright 2006, 2007, 2008 Fluendo S.A. 
  *  Authors: Jan Schmidt <jan@fluendo.com>
  *           Kapil Agrawal <kapil@fluendo.com>
@@ -10,7 +10,7 @@
  * license.
  *
  * MPL:
- * 
+ *
  * The contents of this file are subject to the Mozilla Public License
  * Version 1.1 (the "License"); you may not use this file except in
  * compliance with the License. You may obtain a copy of the License at
@@ -59,17 +59,17 @@
  * Unless otherwise indicated, Source Code is licensed under MIT license.
  * See further explanation attached in License Statement (distributed in the file
  * LICENSE).
- * 
+ *
  * Permission is hereby granted, free of charge, to any person obtaining a copy of
  * this software and associated documentation files (the "Software"), to deal in
  * the Software without restriction, including without limitation the rights to
  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  * of the Software, and to permit persons to whom the Software is furnished to do
  * so, subject to the following conditions:
- * 
+ *
  * The above copyright notice and this permission notice shall be included in all
  * copies or substantial portions of the Software.
- * 
+ *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -79,13 +79,12 @@
  * SOFTWARE.
  *
  */
- 
+
 #ifndef __MPEGTSMUX_AAC_H__
 #define __MPEGTSMUX_AAC_H__
- 
+
 #include "mpegtsmux.h"
 
-GstBuffer * mpegtsmux_prepare_aac (GstBuffer * buf, MpegTsPadData * data,
-    MpegTsMux * mux);
- 
+GstBuffer * mpegtsmux_prepare_aac (GstBuffer * buf, MpegTsPadData * data);
+
 #endif /* __MPEGTSMUX_AAC_H__ */
diff --git a/gst/mpegtsmux/mpegtsmux_h264.c b/gst/mpegtsmux/mpegtsmux_h264.c
index 2c165e0..aea5e15 100644
--- a/gst/mpegtsmux/mpegtsmux_h264.c
+++ b/gst/mpegtsmux/mpegtsmux_h264.c
@@ -111,7 +111,7 @@ mpegtsmux_free_h264 (gpointer prepare_data)
 }
 
 static inline gboolean
-mpegtsmux_process_codec_data_h264 (MpegTsPadData * data, MpegTsMux * mux)
+mpegtsmux_process_codec_data_h264 (MpegTsPadData * data)
 {
   PrivDataH264 *h264_data;
   gboolean ret = FALSE;
@@ -147,14 +147,14 @@ mpegtsmux_process_codec_data_h264 (MpegTsPadData * data, MpegTsMux * mux)
     h264_data->nal_length_size =
         (GST_READ_UINT8 (GST_BUFFER_DATA (data->codec_data) + offset) & 0x03) +
         1;
-    GST_LOG_OBJECT (mux, "NAL length will be coded on %u bytes",
+    GST_LOG_OBJECT (data->obj, "NAL length will be coded on %u bytes",
         h264_data->nal_length_size);
     offset++;
 
     /* How many SPS */
     nb_sps =
         GST_READ_UINT8 (GST_BUFFER_DATA (data->codec_data) + offset) & 0x1f;
-    GST_DEBUG_OBJECT (mux, "we have %d Sequence Parameter Set", nb_sps);
+    GST_DEBUG_OBJECT (data->obj, "we have %d Sequence Parameter Set", nb_sps);
     offset++;
 
     /* For each SPS */
@@ -162,7 +162,8 @@ mpegtsmux_process_codec_data_h264 (MpegTsPadData * data, MpegTsMux * mux)
       guint16 sps_size =
           GST_READ_UINT16_BE (GST_BUFFER_DATA (data->codec_data) + offset);
 
-      GST_LOG_OBJECT (mux, "Sequence Parameter Set is %d bytes", sps_size);
+      GST_LOG_OBJECT (data->obj, "Sequence Parameter Set is %d bytes",
+          sps_size);
 
       /* Jump over SPS size */
       offset += 2;
@@ -181,7 +182,7 @@ mpegtsmux_process_codec_data_h264 (MpegTsPadData * data, MpegTsMux * mux)
 
     /* How many PPS */
     nb_pps = GST_READ_UINT8 (GST_BUFFER_DATA (data->codec_data) + offset);
-    GST_LOG_OBJECT (mux, "we have %d Picture Parameter Set", nb_sps);
+    GST_LOG_OBJECT (data->obj, "we have %d Picture Parameter Set", nb_sps);
     offset++;
 
     /* For each PPS */
@@ -189,7 +190,7 @@ mpegtsmux_process_codec_data_h264 (MpegTsPadData * data, MpegTsMux * mux)
       gint pps_size =
           GST_READ_UINT16_BE (GST_BUFFER_DATA (data->codec_data) + offset);
 
-      GST_LOG_OBJECT (mux, "Picture Parameter Set is %d bytes", pps_size);
+      GST_LOG_OBJECT (data->obj, "Picture Parameter Set is %d bytes", pps_size);
 
       /* Jump over PPS size */
       offset += 2;
@@ -206,14 +207,14 @@ mpegtsmux_process_codec_data_h264 (MpegTsPadData * data, MpegTsMux * mux)
       offset += pps_size;
     }
     GST_BUFFER_SIZE (h264_data->cached_es) = out_offset;
-    GST_DEBUG_OBJECT (mux, "generated a %" G_GSIZE_FORMAT
+    GST_DEBUG_OBJECT (data->obj, "generated a %" G_GSIZE_FORMAT
         " bytes SPS/PPS header", out_offset);
   }
   return ret;
 }
 
 GstBuffer *
-mpegtsmux_prepare_h264 (GstBuffer * buf, MpegTsPadData * data, MpegTsMux * mux)
+mpegtsmux_prepare_h264 (GstBuffer * buf, MpegTsPadData * data)
 {
   guint8 startcode[4] = { 0x00, 0x00, 0x00, 0x01 };
   gsize out_offset = 0, in_offset = 0;
@@ -222,9 +223,9 @@ mpegtsmux_prepare_h264 (GstBuffer * buf, MpegTsPadData * data, MpegTsMux * mux)
   PrivDataH264 *h264_data;
   GstClockTimeDiff diff = GST_CLOCK_TIME_NONE;
 
-  GST_DEBUG_OBJECT (mux, "Preparing H264 buffer for output");
+  GST_DEBUG_OBJECT (data->obj, "Preparing H264 buffer for output");
 
-  changed = mpegtsmux_process_codec_data_h264 (data, mux);
+  changed = mpegtsmux_process_codec_data_h264 (data);
   h264_data = (PrivDataH264 *) data->prepare_data;
 
   if (GST_CLOCK_TIME_IS_VALID (h264_data->last_resync_ts) &&
@@ -240,7 +241,8 @@ mpegtsmux_prepare_h264 (GstBuffer * buf, MpegTsPadData * data, MpegTsMux * mux)
     memcpy (GST_BUFFER_DATA (out_buf), GST_BUFFER_DATA (h264_data->cached_es),
         GST_BUFFER_SIZE (h264_data->cached_es));
     out_offset = GST_BUFFER_SIZE (h264_data->cached_es);
-    GST_DEBUG_OBJECT (mux, "prepending SPS/PPS information to that packet");
+    GST_DEBUG_OBJECT (data->obj,
+        "prepending SPS/PPS information to that packet");
   } else {
     out_buf = gst_buffer_new_and_alloc (GST_BUFFER_SIZE (buf) * 2);
   }
@@ -263,7 +265,7 @@ mpegtsmux_prepare_h264 (GstBuffer * buf, MpegTsPadData * data, MpegTsMux * mux)
         nal_size = GST_READ_UINT32_BE (GST_BUFFER_DATA (buf) + in_offset);
         break;
       default:
-        GST_WARNING_OBJECT (mux, "unsupported NAL length size %u",
+        GST_WARNING_OBJECT (data->obj, "unsupported NAL length size %u",
             h264_data->nal_length_size);
     }
     in_offset += h264_data->nal_length_size;
@@ -279,7 +281,7 @@ mpegtsmux_prepare_h264 (GstBuffer * buf, MpegTsPadData * data, MpegTsMux * mux)
   }
 
   if (out_offset > GST_BUFFER_SIZE (out_buf)) {
-    GST_WARNING_OBJECT (mux, "Calculated buffer size %" G_GSIZE_FORMAT
+    GST_WARNING_OBJECT (data->obj, "Calculated buffer size %" G_GSIZE_FORMAT
         " is greater than max expected size %u, "
         "using max expected size (Input might not be in "
         "avc format", out_offset, GST_BUFFER_SIZE (out_buf));
diff --git a/gst/mpegtsmux/mpegtsmux_h264.h b/gst/mpegtsmux/mpegtsmux_h264.h
index 3a9bccb..c6f401b 100644
--- a/gst/mpegtsmux/mpegtsmux_h264.h
+++ b/gst/mpegtsmux/mpegtsmux_h264.h
@@ -1,4 +1,4 @@
-/* 
+/*
  * Copyright 2006, 2007, 2008, 2009, 2010 Fluendo S.A. 
  *  Authors: Jan Schmidt <jan@fluendo.com>
  *           Kapil Agrawal <kapil@fluendo.com>
@@ -10,7 +10,7 @@
  * license.
  *
  * MPL:
- * 
+ *
  * The contents of this file are subject to the Mozilla Public License
  * Version 1.1 (the "License"); you may not use this file except in
  * compliance with the License. You may obtain a copy of the License at
@@ -59,17 +59,17 @@
  * Unless otherwise indicated, Source Code is licensed under MIT license.
  * See further explanation attached in License Statement (distributed in the file
  * LICENSE).
- * 
+ *
  * Permission is hereby granted, free of charge, to any person obtaining a copy of
  * this software and associated documentation files (the "Software"), to deal in
  * the Software without restriction, including without limitation the rights to
  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  * of the Software, and to permit persons to whom the Software is furnished to do
  * so, subject to the following conditions:
- * 
+ *
  * The above copyright notice and this permission notice shall be included in all
  * copies or substantial portions of the Software.
- * 
+ *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -79,15 +79,14 @@
  * SOFTWARE.
  *
  */
- 
+
 #ifndef __MPEGTSMUX_H264_H__
 #define __MPEGTSMUX_H264_H__
- 
+
 #include "mpegtsmux.h"
 
-GstBuffer * mpegtsmux_prepare_h264 (GstBuffer * buf, MpegTsPadData * data,
-    MpegTsMux * mux);
- 
+GstBuffer * mpegtsmux_prepare_h264 (GstBuffer * buf, MpegTsPadData * data);
+
 void mpegtsmux_free_h264 (gpointer prepare_data);
 
 #endif /* __MPEGTSMUX_H264_H__ */
