Tizen 2.0 Release
[framework/multimedia/gst-plugins-good0.10.git] / gst / multipart / multipartmux.c
1 /* multipart muxer plugin for GStreamer
2  * Copyright (C) 2004 Wim Taymans <wim@fluendo.com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 /**
21  * SECTION:element-multipartmux
22  *
23  * MultipartMux uses the #GstCaps of the sink pad as the Content-type field for
24  * incoming buffers when muxing them to a multipart stream. Most of the time 
25  * multipart streams are sequential JPEG frames.
26  *
27  * <refsect2>
28  * <title>Sample pipelines</title>
29  * |[
30  * gst-launch videotestsrc ! video/x-raw-yuv, framerate='(fraction)'5/1 ! jpegenc ! multipartmux ! filesink location=/tmp/test.multipart
31  * ]| a pipeline to mux 5 JPEG frames per second into a multipart stream
32  * stored to a file.
33  * </refsect2>
34  */
35
36 #ifdef HAVE_CONFIG_H
37 #include "config.h"
38 #endif
39
40 #include "multipartmux.h"
41
42 GST_DEBUG_CATEGORY_STATIC (gst_multipart_mux_debug);
43 #define GST_CAT_DEFAULT gst_multipart_mux_debug
44
45 #define DEFAULT_BOUNDARY        "ThisRandomString"
46
47 enum
48 {
49   ARG_0,
50   ARG_BOUNDARY
51       /* FILL ME */
52 };
53
54 static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
55     GST_PAD_SRC,
56     GST_PAD_ALWAYS,
57     GST_STATIC_CAPS ("multipart/x-mixed-replace")
58     );
59
60 static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink_%d",
61     GST_PAD_SINK,
62     GST_PAD_REQUEST,
63     GST_STATIC_CAPS_ANY         /* we can take anything, really */
64     );
65
66 typedef struct
67 {
68   const gchar *key;
69   const gchar *val;
70 } MimeTypeMap;
71
72 /* convert from gst structure names to mime types. Add more when needed. */
73 static const MimeTypeMap mimetypes[] = {
74   {"audio/x-mulaw", "audio/basic"},
75   {NULL, NULL}
76 };
77
78 static void gst_multipart_mux_base_init (gpointer g_class);
79 static void gst_multipart_mux_class_init (GstMultipartMuxClass * klass);
80 static void gst_multipart_mux_init (GstMultipartMux * multipart_mux);
81
82 static void gst_multipart_mux_finalize (GObject * object);
83
84 static gboolean gst_multipart_mux_handle_src_event (GstPad * pad,
85     GstEvent * event);
86 static GstPad *gst_multipart_mux_request_new_pad (GstElement * element,
87     GstPadTemplate * templ, const gchar * name);
88 static GstStateChangeReturn gst_multipart_mux_change_state (GstElement *
89     element, GstStateChange transition);
90
91 static GstFlowReturn gst_multipart_mux_collected (GstCollectPads * pads,
92     GstMultipartMux * mux);
93
94 static void gst_multipart_mux_set_property (GObject * object, guint prop_id,
95     const GValue * value, GParamSpec * pspec);
96 static void gst_multipart_mux_get_property (GObject * object, guint prop_id,
97     GValue * value, GParamSpec * pspec);
98
99 static GstElementClass *parent_class = NULL;
100
101 GType
102 gst_multipart_mux_get_type (void)
103 {
104   static GType multipart_mux_type = 0;
105
106   if (!multipart_mux_type) {
107     static const GTypeInfo multipart_mux_info = {
108       sizeof (GstMultipartMuxClass),
109       gst_multipart_mux_base_init,
110       NULL,
111       (GClassInitFunc) gst_multipart_mux_class_init,
112       NULL,
113       NULL,
114       sizeof (GstMultipartMux),
115       0,
116       (GInstanceInitFunc) gst_multipart_mux_init,
117     };
118
119     multipart_mux_type =
120         g_type_register_static (GST_TYPE_ELEMENT, "GstMultipartMux",
121         &multipart_mux_info, 0);
122   }
123   return multipart_mux_type;
124 }
125
126 static void
127 gst_multipart_mux_base_init (gpointer g_class)
128 {
129   GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
130
131   gst_element_class_add_static_pad_template (element_class, &src_factory);
132   gst_element_class_add_static_pad_template (element_class, &sink_factory);
133
134   gst_element_class_set_details_simple (element_class, "Multipart muxer",
135       "Codec/Muxer", "mux multipart streams", "Wim Taymans <wim@fluendo.com>");
136 }
137
138 static void
139 gst_multipart_mux_class_init (GstMultipartMuxClass * klass)
140 {
141   GObjectClass *gobject_class;
142   GstElementClass *gstelement_class;
143   gint i;
144
145   gobject_class = (GObjectClass *) klass;
146   gstelement_class = (GstElementClass *) klass;
147
148   parent_class = g_type_class_peek_parent (klass);
149
150   gobject_class->finalize = gst_multipart_mux_finalize;
151   gobject_class->get_property = gst_multipart_mux_get_property;
152   gobject_class->set_property = gst_multipart_mux_set_property;
153
154   g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BOUNDARY,
155       g_param_spec_string ("boundary", "Boundary", "Boundary string",
156           DEFAULT_BOUNDARY, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
157
158   gstelement_class->request_new_pad = gst_multipart_mux_request_new_pad;
159   gstelement_class->change_state = gst_multipart_mux_change_state;
160
161   /* populate mime types */
162   klass->mimetypes = g_hash_table_new (g_str_hash, g_str_equal);
163   for (i = 0; mimetypes[i].key; i++) {
164     g_hash_table_insert (klass->mimetypes, (gpointer) mimetypes[i].key,
165         (gpointer) mimetypes[i].val);
166   }
167 }
168
169 static void
170 gst_multipart_mux_init (GstMultipartMux * multipart_mux)
171 {
172   GstElementClass *klass = GST_ELEMENT_GET_CLASS (multipart_mux);
173
174   multipart_mux->srcpad =
175       gst_pad_new_from_template (gst_element_class_get_pad_template (klass,
176           "src"), "src");
177   gst_pad_set_event_function (multipart_mux->srcpad,
178       gst_multipart_mux_handle_src_event);
179   gst_element_add_pad (GST_ELEMENT (multipart_mux), multipart_mux->srcpad);
180
181   multipart_mux->boundary = g_strdup (DEFAULT_BOUNDARY);
182
183   multipart_mux->collect = gst_collect_pads_new ();
184   gst_collect_pads_set_function (multipart_mux->collect,
185       (GstCollectPadsFunction) GST_DEBUG_FUNCPTR (gst_multipart_mux_collected),
186       multipart_mux);
187 }
188
189 static void
190 gst_multipart_mux_finalize (GObject * object)
191 {
192   GstMultipartMux *multipart_mux;
193
194   multipart_mux = GST_MULTIPART_MUX (object);
195
196   g_free (multipart_mux->boundary);
197
198   if (multipart_mux->collect)
199     gst_object_unref (multipart_mux->collect);
200
201   G_OBJECT_CLASS (parent_class)->finalize (object);
202 }
203
204 static GstPad *
205 gst_multipart_mux_request_new_pad (GstElement * element,
206     GstPadTemplate * templ, const gchar * req_name)
207 {
208   GstMultipartMux *multipart_mux;
209   GstPad *newpad;
210   GstElementClass *klass = GST_ELEMENT_GET_CLASS (element);
211   gchar *name;
212
213   if (templ != gst_element_class_get_pad_template (klass, "sink_%d"))
214     goto wrong_template;
215
216   multipart_mux = GST_MULTIPART_MUX (element);
217
218   /* create new pad with the name */
219   name = g_strdup_printf ("sink_%02d", multipart_mux->numpads);
220   newpad = gst_pad_new_from_template (templ, name);
221   g_free (name);
222
223   /* construct our own wrapper data structure for the pad to
224    * keep track of its status */
225   {
226     GstMultipartPadData *multipartpad;
227
228     multipartpad = (GstMultipartPadData *)
229         gst_collect_pads_add_pad (multipart_mux->collect, newpad,
230         sizeof (GstMultipartPadData));
231
232     /* save a pointer to our data in the pad */
233     gst_pad_set_element_private (newpad, multipartpad);
234     multipart_mux->numpads++;
235   }
236
237   /* add the pad to the element */
238   gst_element_add_pad (element, newpad);
239
240   return newpad;
241
242   /* ERRORS */
243 wrong_template:
244   {
245     g_warning ("multipart_mux: this is not our template!");
246     return NULL;
247   }
248 }
249
250 /* handle events */
251 static gboolean
252 gst_multipart_mux_handle_src_event (GstPad * pad, GstEvent * event)
253 {
254   GstMultipartMux *multipart_mux;
255   GstEventType type;
256
257   multipart_mux = GST_MULTIPART_MUX (gst_pad_get_parent (pad));
258
259   type = event ? GST_EVENT_TYPE (event) : GST_EVENT_UNKNOWN;
260
261   switch (type) {
262     case GST_EVENT_SEEK:
263       /* disable seeking for now */
264       return FALSE;
265     default:
266       break;
267   }
268
269   gst_object_unref (multipart_mux);
270
271   return gst_pad_event_default (pad, event);
272 }
273
274 static const gchar *
275 gst_multipart_mux_get_mime (GstMultipartMux * mux, GstStructure * s)
276 {
277   GstMultipartMuxClass *klass;
278   const gchar *mime;
279   const gchar *name;
280   gint rate;
281   gint channels;
282   gint bitrate = 0;
283
284   klass = GST_MULTIPART_MUX_GET_CLASS (mux);
285
286   name = gst_structure_get_name (s);
287
288   /* use hashtable to convert to mime type */
289   mime = g_hash_table_lookup (klass->mimetypes, name);
290   if (mime == NULL) {
291     if (!strcmp (name, "audio/x-adpcm"))
292       gst_structure_get_int (s, "bitrate", &bitrate);
293
294     switch (bitrate) {
295       case 16000:
296         mime = "audio/G726-16";
297         break;
298       case 24000:
299         mime = "audio/G726-24";
300         break;
301       case 32000:
302         mime = "audio/G726-32";
303         break;
304       case 40000:
305         mime = "audio/G726-40";
306         break;
307       default:
308         /* no mime type mapping, use name */
309         mime = name;
310         break;
311     }
312   }
313   /* RFC2046 requires audio/basic to be mulaw 8000Hz mono */
314   if (g_ascii_strcasecmp (mime, "audio/basic") == 0) {
315     if (gst_structure_get_int (s, "rate", &rate) &&
316         gst_structure_get_int (s, "channels", &channels)) {
317       if (rate != 8000 || channels != 1) {
318         mime = name;
319       }
320     } else {
321       mime = name;
322     }
323   }
324   return mime;
325 }
326
327 /*
328  * Given two pads, compare the buffers queued on it and return 0 if they have
329  * an equal priority, 1 if the new pad is better, -1 if the old pad is better 
330  */
331 static gint
332 gst_multipart_mux_compare_pads (GstMultipartMux * multipart_mux,
333     GstMultipartPadData * old, GstMultipartPadData * new)
334 {
335   guint64 oldtime, newtime;
336
337   /* if the old pad doesn't contain anything or is even NULL, return 
338    * the new pad as best candidate and vice versa */
339   if (old == NULL || old->buffer == NULL)
340     return 1;
341   if (new == NULL || new->buffer == NULL)
342     return -1;
343
344   /* no timestamp on old buffer, it must go first */
345   oldtime = old->timestamp;
346   if (oldtime == GST_CLOCK_TIME_NONE)
347     return -1;
348
349   /* no timestamp on new buffer, it must go first */
350   newtime = new->timestamp;
351   if (newtime == GST_CLOCK_TIME_NONE)
352     return 1;
353
354   /* old buffer has higher timestamp, new one should go first */
355   if (newtime < oldtime)
356     return 1;
357   /* new buffer has higher timestamp, old one should go first */
358   else if (newtime > oldtime)
359     return -1;
360
361   /* same priority if all of the above failed */
362   return 0;
363 }
364
365 /* make sure a buffer is queued on all pads, returns a pointer to an multipartpad
366  * that holds the best buffer or NULL when no pad was usable */
367 static GstMultipartPadData *
368 gst_multipart_mux_queue_pads (GstMultipartMux * mux)
369 {
370   GSList *walk = NULL;
371   GstMultipartPadData *bestpad = NULL;
372
373   g_return_val_if_fail (GST_IS_MULTIPART_MUX (mux), NULL);
374
375   /* try to make sure we have a buffer from each usable pad first */
376   walk = mux->collect->data;
377   while (walk) {
378     GstCollectData *data = (GstCollectData *) walk->data;
379     GstMultipartPadData *pad = (GstMultipartPadData *) data;
380
381     walk = g_slist_next (walk);
382
383     /* try to get a new buffer for this pad if needed and possible */
384     if (pad->buffer == NULL) {
385       GstBuffer *buf = NULL;
386
387       buf = gst_collect_pads_pop (mux->collect, data);
388
389       /* Store timestamp with segment_start and preroll */
390       if (buf && GST_BUFFER_TIMESTAMP_IS_VALID (buf)) {
391         pad->timestamp =
392             gst_segment_to_running_time (&data->segment, GST_FORMAT_TIME,
393             GST_BUFFER_TIMESTAMP (buf));
394       } else {
395         pad->timestamp = GST_CLOCK_TIME_NONE;
396       }
397
398       pad->buffer = buf;
399     }
400
401     /* we should have a buffer now, see if it is the best stream to
402      * pull on */
403     if (pad->buffer != NULL) {
404       if (gst_multipart_mux_compare_pads (mux, bestpad, pad) > 0) {
405         bestpad = pad;
406       }
407     }
408   }
409
410   return bestpad;
411 }
412
413 /* basic idea:
414  *
415  * 1) find a pad to pull on, this is done by pulling on all pads and
416  *    looking at the buffers to decide which one should be muxed first.
417  * 2) create a new buffer for the header
418  * 3) push both buffers on best pad, go to 1
419  */
420 static GstFlowReturn
421 gst_multipart_mux_collected (GstCollectPads * pads, GstMultipartMux * mux)
422 {
423   GstMultipartPadData *best;
424   GstFlowReturn ret = GST_FLOW_OK;
425   gchar *header = NULL;
426   size_t headerlen;
427   GstBuffer *headerbuf = NULL;
428   GstBuffer *footerbuf = NULL;
429   GstBuffer *databuf = NULL;
430   GstStructure *structure = NULL;
431   const gchar *mime;
432
433   GST_DEBUG_OBJECT (mux, "all pads are collected");
434
435   /* queue buffers on all pads; find a buffer with the lowest timestamp */
436   best = gst_multipart_mux_queue_pads (mux);
437   if (!best)
438     /* EOS */
439     goto eos;
440   else if (!best->buffer)
441     goto buffer_error;
442
443   /* If not negotiated yet set caps on src pad */
444   if (!mux->negotiated) {
445     GstCaps *newcaps;
446
447     newcaps = gst_caps_new_simple ("multipart/x-mixed-replace",
448         "boundary", G_TYPE_STRING, mux->boundary, NULL);
449
450     if (!gst_pad_set_caps (mux->srcpad, newcaps)) {
451       gst_caps_unref (newcaps);
452       goto nego_error;
453     }
454
455     gst_caps_unref (newcaps);
456     mux->negotiated = TRUE;
457   }
458
459   /* see if we need to push a segment */
460   if (mux->need_segment) {
461     GstEvent *event;
462     GstClockTime time;
463
464     if (best->timestamp != -1)
465       time = best->timestamp;
466     else
467       time = 0;
468
469     /* for the segment, we take the first timestamp we see, we don't know the
470      * length and the position is 0 */
471     event = gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME,
472         time, -1, 0);
473
474     gst_pad_push_event (mux->srcpad, event);
475
476     mux->need_segment = FALSE;
477   }
478
479   structure = gst_caps_get_structure (GST_BUFFER_CAPS (best->buffer), 0);
480   if (!structure)
481     goto no_caps;
482
483   /* get the mime type for the structure */
484   mime = gst_multipart_mux_get_mime (mux, structure);
485
486   header = g_strdup_printf ("--%s\r\nContent-Type: %s\r\n"
487       "Content-Length: %u\r\n\r\n",
488       mux->boundary, mime, GST_BUFFER_SIZE (best->buffer));
489   headerlen = strlen (header);
490
491   ret = gst_pad_alloc_buffer_and_set_caps (mux->srcpad, GST_BUFFER_OFFSET_NONE,
492       headerlen, GST_PAD_CAPS (mux->srcpad), &headerbuf);
493   if (ret != GST_FLOW_OK)
494     goto alloc_failed;
495
496   memcpy (GST_BUFFER_DATA (headerbuf), header, headerlen);
497   g_free (header);
498
499   /* the header has the same timestamp as the data buffer (which we will push
500    * below) and has a duration of 0 */
501   GST_BUFFER_TIMESTAMP (headerbuf) = best->timestamp;
502   GST_BUFFER_DURATION (headerbuf) = 0;
503   GST_BUFFER_OFFSET (headerbuf) = mux->offset;
504   mux->offset += headerlen;
505   GST_BUFFER_OFFSET_END (headerbuf) = mux->offset;
506
507   GST_DEBUG_OBJECT (mux, "pushing %" G_GSIZE_FORMAT " bytes header buffer",
508       headerlen);
509   ret = gst_pad_push (mux->srcpad, headerbuf);
510   if (ret != GST_FLOW_OK)
511     /* push always takes ownership of the buffer, even after an error, so we
512      * don't need to unref headerbuf here. */
513     goto beach;
514
515   /* take best->buffer, we don't need to unref it later as we will push it
516    * now. */
517   databuf = gst_buffer_make_metadata_writable (best->buffer);
518   best->buffer = NULL;
519
520   gst_buffer_set_caps (databuf, GST_PAD_CAPS (mux->srcpad));
521   /* we need to updated the timestamp to match the running_time */
522   GST_BUFFER_TIMESTAMP (databuf) = best->timestamp;
523   GST_BUFFER_OFFSET (databuf) = mux->offset;
524   mux->offset += GST_BUFFER_SIZE (databuf);
525   GST_BUFFER_OFFSET_END (databuf) = mux->offset;
526   GST_BUFFER_FLAG_SET (databuf, GST_BUFFER_FLAG_DELTA_UNIT);
527
528   GST_DEBUG_OBJECT (mux, "pushing %u bytes data buffer",
529       GST_BUFFER_SIZE (databuf));
530   ret = gst_pad_push (mux->srcpad, databuf);
531   if (ret != GST_FLOW_OK)
532     /* push always takes ownership of the buffer, even after an error, so we
533      * don't need to unref headerbuf here. */
534     goto beach;
535
536   ret = gst_pad_alloc_buffer_and_set_caps (mux->srcpad, GST_BUFFER_OFFSET_NONE,
537       2, GST_PAD_CAPS (mux->srcpad), &footerbuf);
538   if (ret != GST_FLOW_OK)
539     goto alloc_failed;
540
541   memcpy (GST_BUFFER_DATA (footerbuf), "\r\n", 2);
542
543   /* the footer has the same timestamp as the data buffer and has a
544    * duration of 0 */
545   GST_BUFFER_TIMESTAMP (footerbuf) = best->timestamp;
546   GST_BUFFER_DURATION (footerbuf) = 0;
547   GST_BUFFER_OFFSET (footerbuf) = mux->offset;
548   mux->offset += 2;
549   GST_BUFFER_OFFSET_END (footerbuf) = mux->offset;
550   GST_BUFFER_FLAG_SET (footerbuf, GST_BUFFER_FLAG_DELTA_UNIT);
551
552   GST_DEBUG_OBJECT (mux, "pushing 2 bytes footer buffer");
553   ret = gst_pad_push (mux->srcpad, footerbuf);
554
555 beach:
556   if (best && best->buffer) {
557     gst_buffer_unref (best->buffer);
558     best->buffer = NULL;
559   }
560   return ret;
561
562   /* ERRORS */
563 buffer_error:
564   {
565     /* There is a best but no buffer, this is not quite right.. */
566     GST_ELEMENT_ERROR (mux, STREAM, FAILED, (NULL), ("internal muxing error"));
567     ret = GST_FLOW_ERROR;
568     goto beach;
569   }
570 eos:
571   {
572     GST_DEBUG_OBJECT (mux, "Pushing EOS");
573     gst_pad_push_event (mux->srcpad, gst_event_new_eos ());
574     ret = GST_FLOW_UNEXPECTED;
575     goto beach;
576   }
577 nego_error:
578   {
579     GST_WARNING_OBJECT (mux, "failed to set caps");
580     GST_ELEMENT_ERROR (mux, CORE, NEGOTIATION, (NULL), (NULL));
581     ret = GST_FLOW_NOT_NEGOTIATED;
582     goto beach;
583   }
584 no_caps:
585   {
586     GST_WARNING_OBJECT (mux, "no caps on the incoming buffer %p", best->buffer);
587     GST_ELEMENT_ERROR (mux, CORE, NEGOTIATION, (NULL), (NULL));
588     ret = GST_FLOW_NOT_NEGOTIATED;
589     goto beach;
590   }
591 alloc_failed:
592   {
593     GST_WARNING_OBJECT (mux,
594         "failed allocating a %" G_GSIZE_FORMAT " bytes buffer", headerlen);
595     g_free (header);
596     goto beach;
597   }
598 }
599
600 static void
601 gst_multipart_mux_get_property (GObject * object,
602     guint prop_id, GValue * value, GParamSpec * pspec)
603 {
604   GstMultipartMux *mux;
605
606   mux = GST_MULTIPART_MUX (object);
607
608   switch (prop_id) {
609     case ARG_BOUNDARY:
610       g_value_set_string (value, mux->boundary);
611       break;
612     default:
613       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
614       break;
615   }
616 }
617
618 static void
619 gst_multipart_mux_set_property (GObject * object,
620     guint prop_id, const GValue * value, GParamSpec * pspec)
621 {
622   GstMultipartMux *mux;
623
624   mux = GST_MULTIPART_MUX (object);
625
626   switch (prop_id) {
627     case ARG_BOUNDARY:
628       g_free (mux->boundary);
629       mux->boundary = g_strdup (g_value_get_string (value));
630       break;
631     default:
632       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
633       break;
634   }
635 }
636
637 static GstStateChangeReturn
638 gst_multipart_mux_change_state (GstElement * element, GstStateChange transition)
639 {
640   GstMultipartMux *multipart_mux;
641   GstStateChangeReturn ret;
642
643   multipart_mux = GST_MULTIPART_MUX (element);
644
645   switch (transition) {
646     case GST_STATE_CHANGE_READY_TO_PAUSED:
647       multipart_mux->offset = 0;
648       multipart_mux->negotiated = FALSE;
649       multipart_mux->need_segment = TRUE;
650       GST_DEBUG_OBJECT (multipart_mux, "starting collect pads");
651       gst_collect_pads_start (multipart_mux->collect);
652       break;
653     case GST_STATE_CHANGE_PAUSED_TO_READY:
654       GST_DEBUG_OBJECT (multipart_mux, "stopping collect pads");
655       gst_collect_pads_stop (multipart_mux->collect);
656       break;
657     default:
658       break;
659   }
660
661   ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
662   if (ret == GST_STATE_CHANGE_FAILURE)
663     return ret;
664
665   switch (transition) {
666     default:
667       break;
668   }
669
670   return ret;
671 }
672
673 gboolean
674 gst_multipart_mux_plugin_init (GstPlugin * plugin)
675 {
676   GST_DEBUG_CATEGORY_INIT (gst_multipart_mux_debug, "multipartmux", 0,
677       "multipart muxer");
678
679   return gst_element_register (plugin, "multipartmux", GST_RANK_NONE,
680       GST_TYPE_MULTIPART_MUX);
681 }