1 /* Quicktime muxer plugin for GStreamer
2 * Copyright (C) 2008 Thiago Sousa Santos <thiagoss@embedded.ufcg.edu.br>
3 * Copyright (C) 2008 Mark Nauwelaerts <mnauw@users.sf.net>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
21 * Unless otherwise indicated, Source Code is licensed under MIT license.
22 * See further explanation attached in License Statement (distributed in the file
25 * Permission is hereby granted, free of charge, to any person obtaining a copy of
26 * this software and associated documentation files (the "Software"), to deal in
27 * the Software without restriction, including without limitation the rights to
28 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
29 * of the Software, and to permit persons to whom the Software is furnished to do
30 * so, subject to the following conditions:
32 * The above copyright notice and this permission notice shall be included in all
33 * copies or substantial portions of the Software.
35 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
36 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
37 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
38 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
39 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
40 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
47 * @short_description: Muxer for quicktime(.mov) files
51 * This element merges streams (audio and video) into qt(.mov) files.
53 * <title>Example pipelines</title>
56 * gst-launch v4l2src num-buffers=500 ! video/x-raw-yuv,width=320,height=240 ! ffmpegcolorspace ! qtmux ! filesink location=video.mov
58 * Records a video stream captured from a v4l2 device and muxes it into a qt file.
62 * Last reviewed on 2008-08-27
73 #include <glib/gstdio.h>
76 #include <gst/base/gstcollectpads.h>
78 #include <sys/types.h>
80 #include <io.h> /* lseek, open, close, read */
82 #define lseek _lseeki64
93 GST_DEBUG_CATEGORY_STATIC (gst_qt_mux_debug);
94 #define GST_CAT_DEFAULT gst_qt_mux_debug
96 /* QTMux signals and args */
107 PROP_MOVIE_TIMESCALE,
111 PROP_FAST_START_TEMP_FILE
114 /* some spare for header size as well */
115 #define MDAT_LARGE_FILE_LIMIT ((guint64) 1024 * 1024 * 1024 * 2)
117 #define DEFAULT_LARGE_FILE FALSE
118 #define DEFAULT_MOVIE_TIMESCALE 1000
119 #define DEFAULT_DO_CTTS FALSE
120 #define DEFAULT_FAST_START FALSE
121 #define DEFAULT_FAST_START_TEMP_FILE NULL
123 static void gst_qt_mux_finalize (GObject * object);
125 static GstStateChangeReturn gst_qt_mux_change_state (GstElement * element,
126 GstStateChange transition);
128 /* property functions */
129 static void gst_qt_mux_set_property (GObject * object,
130 guint prop_id, const GValue * value, GParamSpec * pspec);
131 static void gst_qt_mux_get_property (GObject * object,
132 guint prop_id, GValue * value, GParamSpec * pspec);
135 static GstPad *gst_qt_mux_request_new_pad (GstElement * element,
136 GstPadTemplate * templ, const gchar * name);
137 static void gst_qt_mux_release_pad (GstElement * element, GstPad * pad);
140 static gboolean gst_qt_mux_sink_event (GstPad * pad, GstEvent * event);
142 static GstFlowReturn gst_qt_mux_collected (GstCollectPads * pads,
144 static GstFlowReturn gst_qt_mux_add_buffer (GstQTMux * qtmux, GstQTPad * pad,
147 static GstElementClass *parent_class = NULL;
150 gst_qt_mux_base_init (gpointer g_class)
152 GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
153 GstQTMuxClass *klass = (GstQTMuxClass *) g_class;
154 GstQTMuxClassParams *params;
155 GstElementDetails details;
156 GstPadTemplate *videosinktempl, *audiosinktempl, *srctempl;
159 (GstQTMuxClassParams *) g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
160 GST_QT_MUX_PARAMS_QDATA);
161 g_assert (params != NULL);
163 /* construct the element details struct */
164 details.longname = g_strdup_printf ("%s Muxer", params->prop->long_name);
165 details.klass = g_strdup ("Codec/Muxer");
166 details.description =
167 g_strdup_printf ("Multiplex audio and video into a %s file",
168 params->prop->long_name);
169 details.author = "Thiago Sousa Santos <thiagoss@embedded.ufcg.edu.br>";
170 gst_element_class_set_details (element_class, &details);
171 g_free (details.longname);
172 g_free (details.klass);
173 g_free (details.description);
176 srctempl = gst_pad_template_new ("src", GST_PAD_SRC,
177 GST_PAD_ALWAYS, params->src_caps);
178 gst_element_class_add_pad_template (element_class, srctempl);
180 if (params->audio_sink_caps) {
181 audiosinktempl = gst_pad_template_new ("audio_%d",
182 GST_PAD_SINK, GST_PAD_REQUEST, params->audio_sink_caps);
183 gst_element_class_add_pad_template (element_class, audiosinktempl);
186 if (params->video_sink_caps) {
187 videosinktempl = gst_pad_template_new ("video_%d",
188 GST_PAD_SINK, GST_PAD_REQUEST, params->video_sink_caps);
189 gst_element_class_add_pad_template (element_class, videosinktempl);
192 klass->format = params->prop->format;
196 gst_qt_mux_class_init (GstQTMuxClass * klass)
198 GObjectClass *gobject_class;
199 GstElementClass *gstelement_class;
201 gobject_class = (GObjectClass *) klass;
202 gstelement_class = (GstElementClass *) klass;
204 parent_class = g_type_class_peek_parent (klass);
206 gobject_class->finalize = gst_qt_mux_finalize;
207 gobject_class->get_property = gst_qt_mux_get_property;
208 gobject_class->set_property = gst_qt_mux_set_property;
210 g_object_class_install_property (gobject_class, PROP_LARGE_FILE,
211 g_param_spec_boolean ("large-file", "Support for large files",
212 "Uses 64bits to some fields instead of 32bits, "
213 "providing support for large files",
214 DEFAULT_LARGE_FILE, G_PARAM_READWRITE));
215 g_object_class_install_property (gobject_class, PROP_MOVIE_TIMESCALE,
216 g_param_spec_uint ("movie-timescale", "Movie timescale",
217 "Timescale to use in the movie (units per second)",
218 1, G_MAXUINT32, DEFAULT_MOVIE_TIMESCALE,
219 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
220 g_object_class_install_property (gobject_class, PROP_DO_CTTS,
221 g_param_spec_boolean ("presentation-time",
222 "Include presentation-time info",
223 "Calculate and include presentation/composition time (in addition to decoding time)"
224 " (use with caution)", DEFAULT_DO_CTTS,
225 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
226 g_object_class_install_property (gobject_class, PROP_FAST_START,
227 g_param_spec_boolean ("faststart", "Format file to faststart",
228 "If the file should be formated for faststart (headers first). ",
229 DEFAULT_FAST_START, G_PARAM_READWRITE));
230 g_object_class_install_property (gobject_class, PROP_FAST_START_TEMP_FILE,
231 g_param_spec_string ("faststart-file", "File to use for storing buffers",
232 "File that will be used temporarily to store data from the stream when "
233 "creating a faststart file. If null a filepath will be created automatically",
234 DEFAULT_FAST_START_TEMP_FILE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
236 gstelement_class->request_new_pad =
237 GST_DEBUG_FUNCPTR (gst_qt_mux_request_new_pad);
238 gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_qt_mux_change_state);
239 gstelement_class->release_pad = GST_DEBUG_FUNCPTR (gst_qt_mux_release_pad);
243 gst_qt_mux_pad_reset (GstQTPad * qtpad)
246 qtpad->is_out_of_order = FALSE;
247 qtpad->have_dts = FALSE;
248 qtpad->sample_size = 0;
253 gst_buffer_replace (&qtpad->last_buf, NULL);
255 /* reference owned elsewhere */
260 * Takes GstQTMux back to its initial state
263 gst_qt_mux_reset (GstQTMux * qtmux, gboolean alloc)
267 qtmux->state = GST_QT_MUX_STATE_NONE;
268 qtmux->header_size = 0;
269 qtmux->mdat_size = 0;
273 atom_ftyp_free (qtmux->ftyp);
277 atom_moov_free (qtmux->moov);
280 if (qtmux->fast_start_file) {
281 fclose (qtmux->fast_start_file);
282 qtmux->fast_start_file = NULL;
284 gst_tag_setter_reset_tags (GST_TAG_SETTER (qtmux));
287 for (walk = qtmux->collect->data; walk; walk = g_slist_next (walk)) {
288 GstQTPad *qtpad = (GstQTPad *) walk->data;
289 gst_qt_mux_pad_reset (qtpad);
291 /* hm, moov_free above yanked the traks away from us,
292 * so do not free, but do clear */
297 qtmux->moov = atom_moov_new (qtmux->context);
298 /* ensure all is as nice and fresh as request_new_pad would provide it */
299 for (walk = qtmux->collect->data; walk; walk = g_slist_next (walk)) {
300 GstQTPad *qtpad = (GstQTPad *) walk->data;
302 qtpad->trak = atom_trak_new (qtmux->context);
303 atom_moov_add_trak (qtmux->moov, qtpad->trak);
309 gst_qt_mux_init (GstQTMux * qtmux, GstQTMuxClass * qtmux_klass)
311 GstElementClass *klass = GST_ELEMENT_CLASS (qtmux_klass);
312 GstPadTemplate *templ;
315 templ = gst_element_class_get_pad_template (klass, "src");
316 qtmux->srcpad = gst_pad_new_from_template (templ, "src");
317 caps = gst_caps_copy (gst_pad_get_pad_template_caps (qtmux->srcpad));
318 gst_pad_set_caps (qtmux->srcpad, caps);
319 gst_caps_unref (caps);
320 gst_pad_use_fixed_caps (qtmux->srcpad);
321 gst_element_add_pad (GST_ELEMENT (qtmux), qtmux->srcpad);
323 qtmux->collect = gst_collect_pads_new ();
324 gst_collect_pads_set_function (qtmux->collect,
325 (GstCollectPadsFunction) GST_DEBUG_FUNCPTR (gst_qt_mux_collected), qtmux);
327 /* properties set to default upon construction */
329 /* always need this */
331 atoms_context_new (gst_qt_mux_map_format_to_flavor (qtmux_klass->format));
333 /* internals to initial state */
334 gst_qt_mux_reset (qtmux, TRUE);
339 gst_qt_mux_finalize (GObject * object)
341 GstQTMux *qtmux = GST_QT_MUX_CAST (object);
343 gst_qt_mux_reset (qtmux, FALSE);
345 if (qtmux->fast_start_file_path)
346 g_free (qtmux->fast_start_file_path);
348 atoms_context_free (qtmux->context);
349 gst_object_unref (qtmux->collect);
351 G_OBJECT_CLASS (parent_class)->finalize (object);
355 gst_qt_mux_add_mp4_tag (GstQTMux * qtmux, const GstTagList * list,
356 const char *tag, const char *tag2, guint32 fourcc)
358 switch (gst_tag_get_type (tag)) {
364 if (!gst_tag_list_get_string (list, tag, &str) || !str)
366 GST_DEBUG_OBJECT (qtmux, "Adding tag %" GST_FOURCC_FORMAT " -> %s",
367 GST_FOURCC_ARGS (fourcc), str);
368 atom_moov_add_str_tag (qtmux->moov, fourcc, str);
377 if (!gst_tag_list_get_double (list, tag, &value))
379 GST_DEBUG_OBJECT (qtmux, "Adding tag %" GST_FOURCC_FORMAT " -> %u",
380 GST_FOURCC_ARGS (fourcc), (gint) value);
381 atom_moov_add_uint_tag (qtmux->moov, fourcc, 21, (gint) value);
384 /* paired unsigned integers */
390 if (!gst_tag_list_get_uint (list, tag, &value) ||
391 !gst_tag_list_get_uint (list, tag2, &count))
393 GST_DEBUG_OBJECT (qtmux, "Adding tag %" GST_FOURCC_FORMAT " -> %u/%u",
394 GST_FOURCC_ARGS (fourcc), value, count);
395 atom_moov_add_uint_tag (qtmux->moov, fourcc, 0,
396 value << 16 | (count & 0xFFFF));
400 g_assert_not_reached ();
406 gst_qt_mux_add_mp4_date (GstQTMux * qtmux, const GstTagList * list,
407 const char *tag, const char *tag2, guint32 fourcc)
415 g_return_if_fail (gst_tag_get_type (tag) == GST_TYPE_DATE);
417 if (!gst_tag_list_get_date (list, tag, &date) || !date)
420 year = g_date_get_year (date);
421 month = g_date_get_month (date);
422 day = g_date_get_day (date);
424 if (year == G_DATE_BAD_YEAR && month == G_DATE_BAD_MONTH &&
425 day == G_DATE_BAD_DAY) {
426 GST_WARNING_OBJECT (qtmux, "invalid date in tag");
430 str = g_strdup_printf ("%u-%u-%u", year, month, day);
431 GST_DEBUG_OBJECT (qtmux, "Adding tag %" GST_FOURCC_FORMAT " -> %s",
432 GST_FOURCC_ARGS (fourcc), str);
433 atom_moov_add_str_tag (qtmux->moov, fourcc, str);
437 gst_qt_mux_add_mp4_cover (GstQTMux * qtmux, const GstTagList * list,
438 const char *tag, const char *tag2, guint32 fourcc)
440 GValue value = { 0, };
443 GstStructure *structure;
446 g_return_if_fail (gst_tag_get_type (tag) == GST_TYPE_BUFFER);
448 if (!gst_tag_list_copy_value (&value, list, tag))
451 buf = gst_value_get_buffer (&value);
455 caps = gst_buffer_get_caps (buf);
457 GST_WARNING_OBJECT (qtmux, "preview image without caps");
461 GST_DEBUG_OBJECT (qtmux, "preview image caps %" GST_PTR_FORMAT, caps);
463 structure = gst_caps_get_structure (caps, 0);
464 if (gst_structure_has_name (structure, "image/jpeg"))
466 else if (gst_structure_has_name (structure, "image/png"))
468 gst_caps_unref (caps);
471 GST_WARNING_OBJECT (qtmux, "preview image format not supported");
475 GST_DEBUG_OBJECT (qtmux, "Adding tag %" GST_FOURCC_FORMAT
476 " -> image size %d", GST_FOURCC_ARGS (fourcc), GST_BUFFER_SIZE (buf));
477 atom_moov_add_tag (qtmux->moov, fourcc, flags, GST_BUFFER_DATA (buf),
478 GST_BUFFER_SIZE (buf));
480 g_value_unset (&value);
484 gst_qt_mux_add_3gp_str (GstQTMux * qtmux, const GstTagList * list,
485 const char *tag, const char *tag2, guint32 fourcc)
490 g_return_if_fail (gst_tag_get_type (tag) == G_TYPE_STRING);
491 g_return_if_fail (!tag2 || gst_tag_get_type (tag2) == G_TYPE_UINT);
493 if (!gst_tag_list_get_string (list, tag, &str) || !str)
497 if (!gst_tag_list_get_uint (list, tag2, &number))
501 GST_DEBUG_OBJECT (qtmux, "Adding tag %" GST_FOURCC_FORMAT " -> %s",
502 GST_FOURCC_ARGS (fourcc), str);
503 atom_moov_add_3gp_str_tag (qtmux->moov, fourcc, str);
505 GST_DEBUG_OBJECT (qtmux, "Adding tag %" GST_FOURCC_FORMAT " -> %s/%d",
506 GST_FOURCC_ARGS (fourcc), str, number);
507 atom_moov_add_3gp_str_int_tag (qtmux->moov, fourcc, str, number);
514 gst_qt_mux_add_3gp_date (GstQTMux * qtmux, const GstTagList * list,
515 const char *tag, const char *tag2, guint32 fourcc)
520 g_return_if_fail (gst_tag_get_type (tag) == GST_TYPE_DATE);
522 if (!gst_tag_list_get_date (list, tag, &date) || !date)
525 year = g_date_get_year (date);
527 if (year == G_DATE_BAD_YEAR) {
528 GST_WARNING_OBJECT (qtmux, "invalid date in tag");
532 GST_DEBUG_OBJECT (qtmux, "Adding tag %" GST_FOURCC_FORMAT " -> %d",
533 GST_FOURCC_ARGS (fourcc), year);
534 atom_moov_add_3gp_uint_tag (qtmux->moov, fourcc, year);
538 gst_qt_mux_add_3gp_location (GstQTMux * qtmux, const GstTagList * list,
539 const char *tag, const char *tag2, guint32 fourcc)
541 gdouble latitude = -360, longitude = -360, altitude = 0;
542 gchar *location = NULL;
543 guint8 *data, *ddata;
544 gint size = 0, len = 0;
545 gboolean ret = FALSE;
547 g_return_if_fail (strcmp (tag, GST_TAG_GEO_LOCATION_NAME) == 0);
549 ret = gst_tag_list_get_string (list, tag, &location);
550 ret |= gst_tag_list_get_double (list, GST_TAG_GEO_LOCATION_LONGITUDE,
552 ret |= gst_tag_list_get_double (list, GST_TAG_GEO_LOCATION_LATITUDE,
554 ret |= gst_tag_list_get_double (list, GST_TAG_GEO_LOCATION_ELEVATION,
561 len = strlen (location);
564 /* role + (long, lat, alt) + body + notes */
565 size += 1 + 3 * 4 + 1 + 1;
567 data = ddata = g_malloc (size);
570 GST_WRITE_UINT16_BE (data, language_code (GST_QT_MUX_DEFAULT_TAG_LANGUAGE));
573 memcpy (data + 2, location, len);
574 GST_WRITE_UINT8 (data + 2 + len, 0);
577 GST_WRITE_UINT8 (data, 0);
579 GST_WRITE_UINT32_BE (data + 1, (guint32) (longitude * 65536.0));
580 GST_WRITE_UINT32_BE (data + 5, (guint32) (latitude * 65536.0));
581 GST_WRITE_UINT32_BE (data + 9, (guint32) (altitude * 65536.0));
582 /* neither astronomical body nor notes */
583 GST_WRITE_UINT16_BE (data + 13, 0);
585 GST_DEBUG_OBJECT (qtmux, "Adding tag 'loci'");
586 atom_moov_add_3gp_tag (qtmux->moov, fourcc, ddata, size);
591 gst_qt_mux_add_3gp_keywords (GstQTMux * qtmux, const GstTagList * list,
592 const char *tag, const char *tag2, guint32 fourcc)
594 gchar *keywords = NULL;
595 guint8 *data, *ddata;
599 g_return_if_fail (strcmp (tag, GST_TAG_KEYWORDS) == 0);
601 if (!gst_tag_list_get_string (list, tag, &keywords) || !keywords)
604 kwds = g_strsplit (keywords, ",", 0);
607 for (i = 0; kwds[i]; i++) {
608 /* size byte + null-terminator */
609 size += strlen (kwds[i]) + 1 + 1;
612 /* language tag + count + keywords */
615 data = ddata = g_malloc (size);
618 GST_WRITE_UINT16_BE (data, language_code (GST_QT_MUX_DEFAULT_TAG_LANGUAGE));
620 GST_WRITE_UINT8 (data + 2, i);
623 for (i = 0; kwds[i]; ++i) {
624 gint len = strlen (kwds[i]);
626 GST_DEBUG_OBJECT (qtmux, "Adding tag %" GST_FOURCC_FORMAT " -> %s",
627 GST_FOURCC_ARGS (fourcc), kwds[i]);
629 GST_WRITE_UINT8 (data, len + 1);
630 memcpy (data + 1, kwds[i], len + 1);
636 atom_moov_add_3gp_tag (qtmux->moov, fourcc, ddata, size);
641 typedef void (*GstQTMuxAddTagFunc) (GstQTMux * mux, const GstTagList * list,
642 const char *tag, const char *tag2, guint32 fourcc);
645 * Struct to record mappings from gstreamer tags to fourcc codes
647 typedef struct _GstTagToFourcc
651 const gchar *gsttag2;
652 const GstQTMuxAddTagFunc func;
655 /* tag list tags to fourcc matching */
656 static const GstTagToFourcc tag_matches_mp4[] = {
657 {FOURCC__alb, GST_TAG_ALBUM, NULL, gst_qt_mux_add_mp4_tag},
658 {FOURCC__ART, GST_TAG_ARTIST, NULL, gst_qt_mux_add_mp4_tag},
659 {FOURCC__cmt, GST_TAG_COMMENT, NULL, gst_qt_mux_add_mp4_tag},
660 {FOURCC__wrt, GST_TAG_COMPOSER, NULL, gst_qt_mux_add_mp4_tag},
661 {FOURCC__gen, GST_TAG_GENRE, NULL, gst_qt_mux_add_mp4_tag},
662 {FOURCC__nam, GST_TAG_TITLE, NULL, gst_qt_mux_add_mp4_tag},
663 {FOURCC__des, GST_TAG_DESCRIPTION, NULL, gst_qt_mux_add_mp4_tag},
664 {FOURCC__too, GST_TAG_ENCODER, NULL, gst_qt_mux_add_mp4_tag},
665 {FOURCC_cprt, GST_TAG_COPYRIGHT, NULL, gst_qt_mux_add_mp4_tag},
666 {FOURCC_keyw, GST_TAG_KEYWORDS, NULL, gst_qt_mux_add_mp4_tag},
667 {FOURCC__day, GST_TAG_DATE, NULL, gst_qt_mux_add_mp4_date},
668 {FOURCC_tmpo, GST_TAG_BEATS_PER_MINUTE, NULL, gst_qt_mux_add_mp4_tag},
669 {FOURCC_trkn, GST_TAG_TRACK_NUMBER, GST_TAG_TRACK_COUNT,
670 gst_qt_mux_add_mp4_tag},
671 {FOURCC_disk, GST_TAG_ALBUM_VOLUME_NUMBER, GST_TAG_ALBUM_VOLUME_COUNT,
672 gst_qt_mux_add_mp4_tag},
673 {FOURCC_covr, GST_TAG_PREVIEW_IMAGE, NULL, gst_qt_mux_add_mp4_cover},
677 static const GstTagToFourcc tag_matches_3gp[] = {
678 {FOURCC_titl, GST_TAG_TITLE, NULL, gst_qt_mux_add_3gp_str},
679 {FOURCC_dscp, GST_TAG_DESCRIPTION, NULL, gst_qt_mux_add_3gp_str},
680 {FOURCC_cprt, GST_TAG_COPYRIGHT, NULL, gst_qt_mux_add_3gp_str},
681 {FOURCC_perf, GST_TAG_ARTIST, NULL, gst_qt_mux_add_3gp_str},
682 {FOURCC_auth, GST_TAG_COMPOSER, NULL, gst_qt_mux_add_3gp_str},
683 {FOURCC_gnre, GST_TAG_GENRE, NULL, gst_qt_mux_add_3gp_str},
684 {FOURCC_kywd, GST_TAG_KEYWORDS, NULL, gst_qt_mux_add_3gp_keywords},
685 {FOURCC_yrrc, GST_TAG_DATE, NULL, gst_qt_mux_add_3gp_date},
686 {FOURCC_albm, GST_TAG_ALBUM, GST_TAG_TRACK_NUMBER, gst_qt_mux_add_3gp_str},
687 {FOURCC_loci, GST_TAG_GEO_LOCATION_NAME, NULL, gst_qt_mux_add_3gp_location},
691 /* qtdemux produces these for atoms it cannot parse */
692 #define GST_QT_DEMUX_PRIVATE_TAG "private-qt-tag"
695 gst_qt_mux_add_metadata_tags (GstQTMux * qtmux, const GstTagList * list)
697 GstQTMuxClass *qtmux_klass = (GstQTMuxClass *) (G_OBJECT_GET_CLASS (qtmux));
700 const gchar *tag, *tag2;
701 const GstTagToFourcc *tag_matches;
703 switch (qtmux_klass->format) {
704 case GST_QT_MUX_FORMAT_3GP:
705 tag_matches = tag_matches_3gp;
707 case GST_QT_MUX_FORMAT_MJ2:
711 /* sort of iTunes style for mp4 and QT (?) */
712 tag_matches = tag_matches_mp4;
719 for (i = 0; tag_matches[i].fourcc; i++) {
720 fourcc = tag_matches[i].fourcc;
721 tag = tag_matches[i].gsttag;
722 tag2 = tag_matches[i].gsttag2;
724 g_assert (tag_matches[i].func);
725 tag_matches[i].func (qtmux, list, tag, tag2, fourcc);
728 /* add unparsed blobs if present */
729 if (gst_tag_exists (GST_QT_DEMUX_PRIVATE_TAG)) {
732 num_tags = gst_tag_list_get_tag_size (list, GST_QT_DEMUX_PRIVATE_TAG);
733 for (i = 0; i < num_tags; ++i) {
736 GstCaps *caps = NULL;
738 val = gst_tag_list_get_value_index (list, GST_QT_DEMUX_PRIVATE_TAG, i);
739 buf = (GstBuffer *) gst_value_get_mini_object (val);
741 if (buf && (caps = gst_buffer_get_caps (buf))) {
743 const gchar *style = NULL;
745 GST_DEBUG_OBJECT (qtmux, "Found private tag %d/%d; size %d, caps %"
746 GST_PTR_FORMAT, i, num_tags, GST_BUFFER_SIZE (buf), caps);
747 s = gst_caps_get_structure (caps, 0);
748 if (s && (style = gst_structure_get_string (s, "style"))) {
749 /* try to prevent some style tag ending up into another variant
750 * (todo: make into a list if more cases) */
751 if ((strcmp (style, "itunes") == 0 &&
752 qtmux_klass->format == GST_QT_MUX_FORMAT_MP4) ||
753 (strcmp (style, "iso") == 0 &&
754 qtmux_klass->format == GST_QT_MUX_FORMAT_3GP)) {
755 GST_DEBUG_OBJECT (qtmux, "Adding private tag");
756 atom_moov_add_blob_tag (qtmux->moov, GST_BUFFER_DATA (buf),
757 GST_BUFFER_SIZE (buf));
760 gst_caps_unref (caps);
769 * Gets the tagsetter iface taglist and puts the known tags
770 * into the output stream
773 gst_qt_mux_setup_metadata (GstQTMux * qtmux)
775 const GstTagList *tags;
777 tags = gst_tag_setter_get_tag_list (GST_TAG_SETTER (qtmux));
779 GST_LOG_OBJECT (qtmux, "tags: %" GST_PTR_FORMAT, tags);
781 if (tags && !gst_tag_list_is_empty (tags)) {
782 GST_DEBUG_OBJECT (qtmux, "Formatting tags");
783 gst_qt_mux_add_metadata_tags (qtmux, tags);
785 GST_DEBUG_OBJECT (qtmux, "No tags received");
790 gst_qt_mux_send_buffer (GstQTMux * qtmux, GstBuffer * buf, guint64 * offset,
797 g_return_val_if_fail (buf != NULL, GST_FLOW_ERROR);
799 data = GST_BUFFER_DATA (buf);
800 size = GST_BUFFER_SIZE (buf);
802 GST_LOG_OBJECT (qtmux, "sending buffer size %d", size);
804 if (mind_fast && qtmux->fast_start_file) {
807 GST_LOG_OBJECT (qtmux, "to temporary file");
808 ret = fwrite (data, sizeof (guint8), size, qtmux->fast_start_file);
809 gst_buffer_unref (buf);
815 GST_LOG_OBJECT (qtmux, "downstream");
817 gst_buffer_set_caps (buf, GST_PAD_CAPS (qtmux->srcpad));
818 res = gst_pad_push (qtmux->srcpad, buf);
821 if (G_LIKELY (offset))
829 GST_ELEMENT_ERROR (qtmux, RESOURCE, WRITE,
830 ("Failed to write to temporary file"), GST_ERROR_SYSTEM);
831 return GST_FLOW_ERROR;
836 gst_qt_mux_send_buffered_data (GstQTMux * qtmux, guint64 * offset)
838 GstFlowReturn ret = GST_FLOW_OK;
839 GstBuffer *buf = NULL;
841 if (fflush (qtmux->fast_start_file))
845 if (fseeko (qtmux->fast_start_file, (off_t) 0, SEEK_SET) != 0)
847 #elif defined (G_OS_UNIX) || defined (G_OS_WIN32)
848 if (lseek (fileno (qtmux->fast_start_file), (off_t) 0,
849 SEEK_SET) == (off_t) - 1)
852 if (fseek (qtmux->fast_start_file, (long) 0, SEEK_SET) != 0)
856 /* hm, this could all take a really really long time,
857 * but there may not be another way to get moov atom first
858 * (somehow optimize copy?) */
859 GST_DEBUG_OBJECT (qtmux, "Sending buffered data");
860 while (ret == GST_FLOW_OK) {
862 const int bufsize = 4096;
864 buf = gst_buffer_new_and_alloc (bufsize);
865 r = fread (GST_BUFFER_DATA (buf), sizeof (guint8), bufsize,
866 qtmux->fast_start_file);
869 GST_BUFFER_SIZE (buf) = r;
870 GST_LOG_OBJECT (qtmux, "Pushing buffered buffer of size %d", r);
871 ret = gst_qt_mux_send_buffer (qtmux, buf, offset, FALSE);
875 gst_buffer_unref (buf);
878 /* best cleaning up effort, eat possible error */
879 fclose (qtmux->fast_start_file);
880 qtmux->fast_start_file = NULL;
882 /* FIXME maybe delete temporary file, or let the system handle that ? */
889 GST_ELEMENT_ERROR (qtmux, RESOURCE, WRITE,
890 ("Failed to flush temporary file"), GST_ERROR_SYSTEM);
891 ret = GST_FLOW_ERROR;
896 GST_ELEMENT_ERROR (qtmux, RESOURCE, SEEK,
897 ("Failed to seek temporary file"), GST_ERROR_SYSTEM);
898 ret = GST_FLOW_ERROR;
904 * Sends the initial mdat atom fields (size fields and fourcc type),
905 * the subsequent buffers are considered part of it's data.
906 * As we can't predict the amount of data that we are going to place in mdat
907 * we need to record the position of the size field in the stream so we can
908 * seek back to it later and update when the streams have finished.
911 gst_qt_mux_send_mdat_header (GstQTMux * qtmux, guint64 * off, guint64 size,
919 GST_DEBUG_OBJECT (qtmux, "Sending mdat's atom header, "
920 "size %" G_GUINT64_FORMAT, size);
922 node_header = g_malloc0 (sizeof (Atom));
923 node_header->type = FOURCC_mdat;
925 /* use extended size */
926 node_header->size = 1;
927 node_header->extended_size = 0;
929 node_header->extended_size = size + 16;
931 node_header->size = size + 8;
935 if (atom_copy_data (node_header, &data, &size, &offset) == 0)
936 goto serialize_error;
938 buf = gst_buffer_new ();
939 GST_BUFFER_DATA (buf) = GST_BUFFER_MALLOCDATA (buf) = data;
940 GST_BUFFER_SIZE (buf) = offset;
942 g_free (node_header);
944 GST_LOG_OBJECT (qtmux, "Pushing mdat start");
945 return gst_qt_mux_send_buffer (qtmux, buf, off, FALSE);
950 GST_ELEMENT_ERROR (qtmux, STREAM, MUX, (NULL),
951 ("Failed to serialize ftyp"));
952 return GST_FLOW_ERROR;
957 * We get the position of the mdat size field, seek back to it
958 * and overwrite with the real value
961 gst_qt_mux_update_mdat_size (GstQTMux * qtmux, guint64 mdat_pos,
962 guint64 mdat_size, guint64 * offset)
968 large_file = (mdat_size > MDAT_LARGE_FILE_LIMIT);
973 /* seek and rewrite the header */
974 event = gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_BYTES,
975 mdat_pos, GST_CLOCK_TIME_NONE, 0);
976 gst_pad_push_event (qtmux->srcpad, event);
979 buf = gst_buffer_new_and_alloc (sizeof (guint64));
980 GST_WRITE_UINT64_BE (GST_BUFFER_DATA (buf), mdat_size + 16);
984 buf = gst_buffer_new_and_alloc (16);
985 data = GST_BUFFER_DATA (buf);
986 GST_WRITE_UINT32_BE (data, 8);
987 GST_WRITE_UINT32_LE (data + 4, FOURCC_free);
988 GST_WRITE_UINT32_BE (data + 8, mdat_size + 8);
989 GST_WRITE_UINT32_LE (data + 12, FOURCC_mdat);
992 return gst_qt_mux_send_buffer (qtmux, buf, offset, FALSE);
996 gst_qt_mux_stop_file (GstQTMux * qtmux)
998 gboolean ret = GST_FLOW_OK;
999 GstBuffer *buffer = NULL;
1000 guint64 offset = 0, size = 0;
1003 gboolean large_file;
1006 GST_DEBUG_OBJECT (qtmux, "Updating remaining values and sending last data");
1008 /* pushing last buffers for each pad */
1009 for (walk = qtmux->collect->data; walk; walk = g_slist_next (walk)) {
1010 GstCollectData *cdata = (GstCollectData *) walk->data;
1011 GstQTPad *qtpad = (GstQTPad *) cdata;
1013 /* send last buffer */
1014 GST_DEBUG_OBJECT (qtmux, "Sending the last buffer for pad %s",
1015 GST_PAD_NAME (qtpad->collect.pad));
1016 ret = gst_qt_mux_add_buffer (qtmux, qtpad, NULL);
1017 if (ret != GST_FLOW_OK)
1018 GST_DEBUG_OBJECT (qtmux, "Failed to send last buffer for %s, "
1019 "flow return: %s", GST_PAD_NAME (qtpad->collect.pad),
1020 gst_flow_get_name (ret));
1023 GST_OBJECT_LOCK (qtmux);
1024 timescale = qtmux->timescale;
1025 large_file = qtmux->large_file;
1026 GST_OBJECT_UNLOCK (qtmux);
1028 /* inform lower layers of our property wishes, and determine duration.
1029 * Let moov take care of this using its list of traks;
1030 * so that released pads are also included */
1031 GST_DEBUG_OBJECT (qtmux, "Large file support: %d", large_file);
1032 GST_DEBUG_OBJECT (qtmux, "Updating timescale to %" G_GUINT32_FORMAT,
1034 atom_moov_update_timescale (qtmux->moov, timescale);
1035 atom_moov_set_64bits (qtmux->moov, large_file);
1036 atom_moov_update_duration (qtmux->moov);
1038 /* tags into file metadata */
1039 gst_qt_mux_setup_metadata (qtmux);
1041 large_file = (qtmux->mdat_size > MDAT_LARGE_FILE_LIMIT);
1042 /* if faststart, update the offset of the atoms in the movie with the offset
1043 * that the movie headers before mdat will cause */
1044 if (qtmux->fast_start_file) {
1045 /* copy into NULL to obtain size */
1047 if (!atom_moov_copy_data (qtmux->moov, NULL, &size, &offset))
1048 goto serialize_error;
1049 GST_DEBUG_OBJECT (qtmux, "calculated moov atom size %" G_GUINT64_FORMAT,
1051 offset += qtmux->header_size + (large_file ? 16 : 8);
1053 offset = qtmux->header_size;
1054 atom_moov_chunks_add_offset (qtmux->moov, offset);
1056 /* serialize moov */
1059 GST_LOG_OBJECT (qtmux, "Copying movie header into buffer");
1060 ret = atom_moov_copy_data (qtmux->moov, &data, &size, &offset);
1062 goto serialize_error;
1064 buffer = gst_buffer_new ();
1065 GST_BUFFER_DATA (buffer) = GST_BUFFER_MALLOCDATA (buffer) = data;
1066 GST_BUFFER_SIZE (buffer) = offset;
1067 /* note: as of this point, we no longer care about tracking written data size,
1068 * since there is no more use for it anyway */
1069 GST_DEBUG_OBJECT (qtmux, "Pushing movie atoms");
1070 gst_qt_mux_send_buffer (qtmux, buffer, NULL, FALSE);
1072 /* if needed, send mdat atom and move buffered data into it */
1073 if (qtmux->fast_start_file) {
1074 /* mdat size = accumulated (buffered data) + mdat atom header */
1075 ret = gst_qt_mux_send_mdat_header (qtmux, NULL, qtmux->mdat_size,
1077 if (ret != GST_FLOW_OK)
1079 ret = gst_qt_mux_send_buffered_data (qtmux, NULL);
1080 if (ret != GST_FLOW_OK)
1083 /* mdata needs update iff not using faststart */
1084 GST_DEBUG_OBJECT (qtmux, "updating mdata size");
1085 ret = gst_qt_mux_update_mdat_size (qtmux, qtmux->mdat_pos,
1086 qtmux->mdat_size, NULL);
1087 /* note; no seeking back to the end of file is done,
1088 * since we longer write anything anyway */
1096 gst_buffer_unref (buffer);
1097 GST_ELEMENT_ERROR (qtmux, STREAM, MUX, (NULL),
1098 ("Failed to serialize moov"));
1099 return GST_FLOW_ERROR;
1103 static GstFlowReturn
1104 gst_qt_mux_send_ftyp (GstQTMux * qtmux, guint64 * off)
1107 guint64 size = 0, offset = 0;
1108 guint8 *data = NULL;
1110 GST_DEBUG_OBJECT (qtmux, "Sending ftyp atom");
1112 if (!atom_ftyp_copy_data (qtmux->ftyp, &data, &size, &offset))
1113 goto serialize_error;
1115 buf = gst_buffer_new ();
1116 GST_BUFFER_DATA (buf) = GST_BUFFER_MALLOCDATA (buf) = data;
1117 GST_BUFFER_SIZE (buf) = offset;
1119 GST_LOG_OBJECT (qtmux, "Pushing ftyp");
1120 return gst_qt_mux_send_buffer (qtmux, buf, off, FALSE);
1125 GST_ELEMENT_ERROR (qtmux, STREAM, MUX, (NULL),
1126 ("Failed to serialize ftyp"));
1127 return GST_FLOW_ERROR;
1131 static GstFlowReturn
1132 gst_qt_mux_start_file (GstQTMux * qtmux)
1134 GstQTMuxClass *qtmux_klass = (GstQTMuxClass *) (G_OBJECT_GET_CLASS (qtmux));
1135 GstFlowReturn ret = GST_FLOW_OK;
1136 guint32 major, version;
1140 GST_DEBUG_OBJECT (qtmux, "starting file");
1142 /* let downstream know we think in BYTES and expect to do seeking later on */
1143 gst_pad_push_event (qtmux->srcpad,
1144 gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_BYTES, 0, -1, 0));
1146 /* init and send context and ftyp based on current property state */
1148 atom_ftyp_free (qtmux->ftyp);
1149 gst_qt_mux_map_format_to_header (qtmux_klass->format, &prefix, &major,
1150 &version, &comp, qtmux->moov);
1151 qtmux->ftyp = atom_ftyp_new (qtmux->context, major, version, comp);
1155 ret = gst_qt_mux_send_buffer (qtmux, prefix, &qtmux->header_size, FALSE);
1156 if (ret != GST_FLOW_OK)
1159 ret = gst_qt_mux_send_ftyp (qtmux, &qtmux->header_size);
1160 if (ret != GST_FLOW_OK)
1163 /* send mdat header if already needed, and mark position for later update */
1164 GST_OBJECT_LOCK (qtmux);
1165 if (qtmux->fast_start) {
1166 qtmux->fast_start_file = g_fopen (qtmux->fast_start_file_path, "wb+");
1167 if (!qtmux->fast_start_file)
1170 /* extended to ensure some spare space */
1171 qtmux->mdat_pos = qtmux->header_size;
1172 ret = gst_qt_mux_send_mdat_header (qtmux, &qtmux->header_size, 0, TRUE);
1174 GST_OBJECT_UNLOCK (qtmux);
1182 GST_ELEMENT_ERROR (qtmux, RESOURCE, OPEN_READ_WRITE,
1183 (("Could not open temporary file \"%s\""), qtmux->fast_start_file_path),
1185 GST_OBJECT_UNLOCK (qtmux);
1186 return GST_FLOW_ERROR;
1191 * Here we push the buffer and update the tables in the track atoms
1193 static GstFlowReturn
1194 gst_qt_mux_add_buffer (GstQTMux * qtmux, GstQTPad * pad, GstBuffer * buf)
1196 GstBuffer *last_buf = NULL;
1197 GstClockTime duration;
1198 guint nsamples, sample_size;
1199 guint64 scaled_duration, chunk_offset;
1201 gint64 pts_offset = 0;
1202 gboolean sync = FALSE, do_pts = FALSE;
1205 goto not_negotiated;
1207 last_buf = pad->last_buf;
1208 if (last_buf == NULL) {
1209 #ifndef GST_DISABLE_GST_DEBUG
1211 GST_DEBUG_OBJECT (qtmux, "Pad %s has no previous buffer stored and "
1212 "received NULL buffer, doing nothing",
1213 GST_PAD_NAME (pad->collect.pad));
1215 GST_LOG_OBJECT (qtmux,
1216 "Pad %s has no previous buffer stored, storing now",
1217 GST_PAD_NAME (pad->collect.pad));
1220 pad->last_buf = buf;
1223 gst_buffer_ref (last_buf);
1225 /* fall back to duration if:
1227 * - this format has out of order buffers (e.g. MPEG-4),
1228 * - lack of valid time forces fall back */
1229 if (buf == NULL || pad->is_out_of_order ||
1230 !GST_BUFFER_TIMESTAMP_IS_VALID (last_buf) ||
1231 !GST_BUFFER_TIMESTAMP_IS_VALID (buf)) {
1232 if (!GST_BUFFER_DURATION_IS_VALID (last_buf)) {
1233 /* be forgiving for some possibly last upstream flushed buffer */
1236 GST_WARNING_OBJECT (qtmux, "no duration for last buffer");
1237 /* iso spec recommends some small value, try 0 */
1240 duration = GST_BUFFER_DURATION (last_buf);
1243 duration = GST_BUFFER_TIMESTAMP (buf) - GST_BUFFER_TIMESTAMP (last_buf);
1246 gst_buffer_replace (&pad->last_buf, buf);
1248 last_dts = gst_util_uint64_scale (pad->last_dts,
1249 atom_trak_get_timescale (pad->trak), GST_SECOND);
1251 /* raw audio has many samples per buffer (= chunk) */
1252 if (pad->sample_size) {
1253 sample_size = pad->sample_size;
1254 if (GST_BUFFER_SIZE (last_buf) % sample_size != 0)
1255 goto fragmented_sample;
1256 /* note: qt raw audio storage warps it implicitly into a timewise
1257 * perfect stream, discarding buffer times */
1258 nsamples = GST_BUFFER_SIZE (last_buf) / sample_size;
1259 duration = GST_BUFFER_DURATION (last_buf) / nsamples;
1260 /* timescale = samplerate */
1261 scaled_duration = 1;
1262 pad->last_dts += duration * nsamples;
1265 sample_size = GST_BUFFER_SIZE (last_buf);
1266 if (pad->have_dts) {
1268 pad->last_dts = GST_BUFFER_OFFSET_END (last_buf);
1269 if ((gint64) (pad->last_dts) < 0) {
1270 scaled_dts = -gst_util_uint64_scale (-pad->last_dts,
1271 atom_trak_get_timescale (pad->trak), GST_SECOND);
1273 scaled_dts = gst_util_uint64_scale (pad->last_dts,
1274 atom_trak_get_timescale (pad->trak), GST_SECOND);
1276 scaled_duration = scaled_dts - last_dts;
1277 last_dts = scaled_dts;
1279 /* first convert intended timestamp (in GstClockTime resolution) to
1280 * trak timescale, then derive delta;
1281 * this ensures sums of (scale)delta add up to converted timestamp,
1282 * which only deviates at most 1/scale from timestamp itself */
1283 scaled_duration = gst_util_uint64_scale (pad->last_dts + duration,
1284 atom_trak_get_timescale (pad->trak), GST_SECOND) - last_dts;
1285 pad->last_dts += duration;
1288 chunk_offset = qtmux->mdat_size;
1290 GST_LOG_OBJECT (qtmux,
1291 "Pad (%s) dts updated to %" GST_TIME_FORMAT,
1292 GST_PAD_NAME (pad->collect.pad), GST_TIME_ARGS (pad->last_dts));
1293 GST_LOG_OBJECT (qtmux,
1294 "Adding %d samples to track, duration: %" G_GUINT64_FORMAT
1295 " size: %" G_GUINT32_FORMAT " chunk offset: %" G_GUINT64_FORMAT,
1296 nsamples, scaled_duration, sample_size, chunk_offset);
1298 /* might be a sync sample */
1300 !GST_BUFFER_FLAG_IS_SET (last_buf, GST_BUFFER_FLAG_DELTA_UNIT)) {
1301 GST_LOG_OBJECT (qtmux, "Adding new sync sample entry for track of pad %s",
1302 GST_PAD_NAME (pad->collect.pad));
1306 /* optionally calculate ctts entry values
1307 * (if composition-time expected different from decoding-time) */
1308 /* really not recommended:
1309 * - decoder typically takes care of dts/pts issues
1310 * - in case of out-of-order, dts may only be determined as above
1311 * (e.g. sum of duration), which may be totally different from
1312 * buffer timestamps in case of multiple segment, non-perfect streams
1313 * (and just perhaps maybe with some luck segment_to_running_time
1314 * or segment_to_media_time might get near to it) */
1315 if ((pad->have_dts || qtmux->guess_pts) && pad->is_out_of_order) {
1318 pts = gst_util_uint64_scale (GST_BUFFER_TIMESTAMP (last_buf),
1319 atom_trak_get_timescale (pad->trak), GST_SECOND);
1320 pts_offset = (gint64) (pts - last_dts);
1322 GST_LOG_OBJECT (qtmux, "Adding ctts entry for pad %s: %" G_GINT64_FORMAT,
1323 GST_PAD_NAME (pad->collect.pad), pts_offset);
1326 /* now we go and register this buffer/sample all over */
1327 /* note that a new chunk is started each time (not fancy but works) */
1328 atom_trak_add_samples (pad->trak, nsamples, scaled_duration, sample_size,
1329 chunk_offset, sync, do_pts, pts_offset);
1332 gst_buffer_unref (buf);
1334 return gst_qt_mux_send_buffer (qtmux, last_buf, &qtmux->mdat_size, TRUE);
1340 gst_buffer_unref (buf);
1341 gst_buffer_unref (last_buf);
1342 return GST_FLOW_ERROR;
1346 GST_ELEMENT_ERROR (qtmux, STREAM, MUX, (NULL),
1347 ("Received buffer without timestamp/duration."));
1352 GST_ELEMENT_ERROR (qtmux, STREAM, MUX, (NULL),
1353 ("Audio buffer contains fragmented sample."));
1358 GST_ELEMENT_ERROR (qtmux, CORE, NEGOTIATION, (NULL),
1359 ("format wasn't negotiated before buffer flow on pad %s",
1360 GST_PAD_NAME (pad->collect.pad)));
1361 gst_buffer_unref (buf);
1362 return GST_FLOW_NOT_NEGOTIATED;
1366 static GstFlowReturn
1367 gst_qt_mux_collected (GstCollectPads * pads, gpointer user_data)
1369 GstFlowReturn ret = GST_FLOW_OK;
1370 GstQTMux *qtmux = GST_QT_MUX_CAST (user_data);
1372 GstQTPad *best_pad = NULL;
1373 GstClockTime time, best_time = GST_CLOCK_TIME_NONE;
1376 if (G_UNLIKELY (qtmux->state == GST_QT_MUX_STATE_STARTED)) {
1377 if ((ret = gst_qt_mux_start_file (qtmux)) != GST_FLOW_OK)
1380 qtmux->state = GST_QT_MUX_STATE_DATA;
1383 if (G_UNLIKELY (qtmux->state == GST_QT_MUX_STATE_EOS))
1384 return GST_FLOW_UNEXPECTED;
1386 /* select the best buffer */
1387 walk = qtmux->collect->data;
1390 GstCollectData *data;
1392 data = (GstCollectData *) walk->data;
1393 pad = (GstQTPad *) data;
1395 walk = g_slist_next (walk);
1397 buf = gst_collect_pads_peek (pads, data);
1399 GST_LOG_OBJECT (qtmux, "Pad %s has no buffers",
1400 GST_PAD_NAME (pad->collect.pad));
1403 time = GST_BUFFER_TIMESTAMP (buf);
1404 gst_buffer_unref (buf);
1406 if (best_pad == NULL || !GST_CLOCK_TIME_IS_VALID (time) ||
1407 (GST_CLOCK_TIME_IS_VALID (best_time) && time < best_time)) {
1413 if (best_pad != NULL) {
1414 GST_LOG_OBJECT (qtmux, "selected pad %s with time %" GST_TIME_FORMAT,
1415 GST_PAD_NAME (best_pad->collect.pad), GST_TIME_ARGS (best_time));
1416 buf = gst_collect_pads_pop (pads, &best_pad->collect);
1417 ret = gst_qt_mux_add_buffer (qtmux, best_pad, buf);
1419 ret = gst_qt_mux_stop_file (qtmux);
1420 if (ret == GST_FLOW_OK) {
1421 gst_pad_push_event (qtmux->srcpad, gst_event_new_eos ());
1422 ret = GST_FLOW_UNEXPECTED;
1424 qtmux->state = GST_QT_MUX_STATE_EOS;
1431 gst_qt_mux_audio_sink_set_caps (GstPad * pad, GstCaps * caps)
1433 GstQTMux *qtmux = GST_QT_MUX_CAST (gst_pad_get_parent (pad));
1434 GstQTMuxClass *qtmux_klass = (GstQTMuxClass *) (G_OBJECT_GET_CLASS (qtmux));
1435 GstQTPad *qtpad = NULL;
1436 GstStructure *structure;
1437 const gchar *mimetype;
1438 gint rate, channels;
1439 const GValue *value = NULL;
1440 const GstBuffer *codec_data = NULL;
1441 GstQTMuxFormat format;
1442 AudioSampleEntry entry = { 0, };
1443 AtomInfo *ext_atom = NULL;
1444 gint constant_size = 0;
1446 /* find stream data */
1447 qtpad = (GstQTPad *) gst_pad_get_element_private (pad);
1450 /* does not go well to renegotiate stream mid-way */
1452 goto refuse_renegotiation;
1454 GST_DEBUG_OBJECT (qtmux, "%s:%s, caps=%" GST_PTR_FORMAT,
1455 GST_DEBUG_PAD_NAME (pad), caps);
1457 format = qtmux_klass->format;
1458 structure = gst_caps_get_structure (caps, 0);
1459 mimetype = gst_structure_get_name (structure);
1462 if (!gst_structure_get_int (structure, "channels", &channels) ||
1463 !gst_structure_get_int (structure, "rate", &rate)) {
1468 value = gst_structure_get_value (structure, "codec_data");
1470 codec_data = gst_value_get_buffer (value);
1472 qtpad->is_out_of_order = FALSE;
1473 qtpad->have_dts = FALSE;
1475 /* set common properties */
1476 entry.sample_rate = rate;
1477 entry.channels = channels;
1479 entry.sample_size = 16;
1480 /* this is the typical compressed case */
1481 if (format == GST_QT_MUX_FORMAT_QT) {
1483 entry.compression_id = -2;
1486 /* now map onto a fourcc, and some extra properties */
1487 if (strcmp (mimetype, "audio/mpeg") == 0) {
1488 gint mpegversion = 0;
1491 gst_structure_get_int (structure, "mpegversion", &mpegversion);
1492 switch (mpegversion) {
1494 gst_structure_get_int (structure, "layer", &layer);
1498 /* note: QuickTime player does not like mp3 either way in iso/mp4 */
1499 if (format == GST_QT_MUX_FORMAT_QT)
1500 entry.fourcc = FOURCC__mp3;
1502 entry.fourcc = FOURCC_mp4a;
1504 build_esds_extension (qtpad->trak, ESDS_OBJECT_TYPE_MPEG1_P3,
1505 ESDS_STREAM_TYPE_AUDIO, codec_data);
1507 entry.samples_per_packet = 1152;
1508 entry.bytes_per_sample = 2;
1514 entry.fourcc = FOURCC_mp4a;
1515 if (!codec_data || GST_BUFFER_SIZE (codec_data) < 2)
1516 GST_WARNING_OBJECT (qtmux, "no (valid) codec_data for AAC audio");
1518 guint8 profile = GST_READ_UINT8 (GST_BUFFER_DATA (codec_data));
1520 /* warn if not Low Complexity profile */
1523 GST_WARNING_OBJECT (qtmux,
1524 "non-LC AAC may not run well on (Apple) QuickTime/iTunes");
1526 if (format == GST_QT_MUX_FORMAT_QT)
1527 ext_atom = build_mov_aac_extension (qtpad->trak, codec_data);
1530 build_esds_extension (qtpad->trak, ESDS_OBJECT_TYPE_MPEG4_P3,
1531 ESDS_STREAM_TYPE_AUDIO, codec_data);
1536 } else if (strcmp (mimetype, "audio/AMR") == 0) {
1537 entry.fourcc = FOURCC_samr;
1538 entry.sample_size = 16;
1539 entry.samples_per_packet = 160;
1540 entry.bytes_per_sample = 2;
1541 ext_atom = build_amr_extension ();
1542 } else if (strcmp (mimetype, "audio/AMR-WB") == 0) {
1543 entry.fourcc = FOURCC_sawb;
1544 entry.sample_size = 16;
1545 entry.samples_per_packet = 320;
1546 entry.bytes_per_sample = 2;
1547 ext_atom = build_amr_extension ();
1548 } else if (strcmp (mimetype, "audio/x-raw-int") == 0) {
1554 if (!gst_structure_get_int (structure, "width", &width) ||
1555 !gst_structure_get_int (structure, "depth", &depth) ||
1556 !gst_structure_get_boolean (structure, "signed", &sign)) {
1557 GST_DEBUG_OBJECT (qtmux, "broken caps, width/depth/signed field missing");
1562 endianness = G_BYTE_ORDER;
1563 } else if (!gst_structure_get_boolean (structure,
1564 "endianness", &endianness)) {
1565 GST_DEBUG_OBJECT (qtmux, "broken caps, endianness field missing");
1569 /* spec has no place for a distinction in these */
1570 if (width != depth) {
1571 GST_DEBUG_OBJECT (qtmux, "width must be same as depth!");
1576 if (endianness == G_LITTLE_ENDIAN)
1577 entry.fourcc = FOURCC_sowt;
1578 else if (endianness == G_BIG_ENDIAN)
1579 entry.fourcc = FOURCC_twos;
1580 /* maximum backward compatibility; only new version for > 16 bit */
1583 /* not compressed in any case */
1584 entry.compression_id = 0;
1585 /* QT spec says: max at 16 bit even if sample size were actually larger,
1586 * however, most players (e.g. QuickTime!) seem to disagree, so ... */
1587 entry.sample_size = depth;
1588 entry.bytes_per_sample = depth / 8;
1589 entry.samples_per_packet = 1;
1590 entry.bytes_per_packet = depth / 8;
1591 entry.bytes_per_frame = entry.bytes_per_packet * channels;
1593 if (width == 8 && depth == 8) {
1594 /* fall back to old 8-bit version */
1595 entry.fourcc = FOURCC_raw_;
1597 entry.compression_id = 0;
1598 entry.sample_size = 8;
1600 GST_DEBUG_OBJECT (qtmux, "non 8-bit PCM must be signed");
1604 constant_size = (depth / 8) * channels;
1605 } else if (strcmp (mimetype, "audio/x-alaw") == 0) {
1606 entry.fourcc = FOURCC_alaw;
1607 entry.samples_per_packet = 1023;
1608 entry.bytes_per_sample = 2;
1609 } else if (strcmp (mimetype, "audio/x-mulaw") == 0) {
1610 entry.fourcc = FOURCC_ulaw;
1611 entry.samples_per_packet = 1023;
1612 entry.bytes_per_sample = 2;
1618 /* ok, set the pad info accordingly */
1619 qtpad->fourcc = entry.fourcc;
1620 qtpad->sample_size = constant_size;
1621 atom_trak_set_audio_type (qtpad->trak, qtmux->context, &entry,
1622 entry.sample_rate, ext_atom, constant_size);
1624 gst_object_unref (qtmux);
1630 GST_WARNING_OBJECT (qtmux, "pad %s refused caps %" GST_PTR_FORMAT,
1631 GST_PAD_NAME (pad), caps);
1632 gst_object_unref (qtmux);
1635 refuse_renegotiation:
1637 GST_WARNING_OBJECT (qtmux,
1638 "pad %s refused renegotiation to %" GST_PTR_FORMAT,
1639 GST_PAD_NAME (pad), caps);
1640 gst_object_unref (qtmux);
1645 /* scale rate up or down by factor of 10 to fit into [1000,10000] interval */
1647 adjust_rate (guint64 rate)
1649 while (rate >= 10000)
1655 return (guint32) rate;
1659 gst_qt_mux_video_sink_set_caps (GstPad * pad, GstCaps * caps)
1661 GstQTMux *qtmux = GST_QT_MUX_CAST (gst_pad_get_parent (pad));
1662 GstQTMuxClass *qtmux_klass = (GstQTMuxClass *) (G_OBJECT_GET_CLASS (qtmux));
1663 GstQTPad *qtpad = NULL;
1664 GstStructure *structure;
1665 const gchar *mimetype;
1666 gint width, height, depth = -1;
1667 gint framerate_num, framerate_den;
1669 const GValue *value = NULL;
1670 const GstBuffer *codec_data = NULL;
1671 VisualSampleEntry entry = { 0, };
1672 GstQTMuxFormat format;
1673 AtomInfo *ext_atom = NULL;
1674 gboolean sync = FALSE;
1675 int par_num, par_den;
1677 /* find stream data */
1678 qtpad = (GstQTPad *) gst_pad_get_element_private (pad);
1681 /* does not go well to renegotiate stream mid-way */
1683 goto refuse_renegotiation;
1685 GST_DEBUG_OBJECT (qtmux, "%s:%s, caps=%" GST_PTR_FORMAT,
1686 GST_DEBUG_PAD_NAME (pad), caps);
1688 format = qtmux_klass->format;
1689 structure = gst_caps_get_structure (caps, 0);
1690 mimetype = gst_structure_get_name (structure);
1692 /* required parts */
1693 if (!gst_structure_get_int (structure, "width", &width) ||
1694 !gst_structure_get_int (structure, "height", &height))
1699 /* works as a default timebase */
1700 framerate_num = 10000;
1702 gst_structure_get_fraction (structure, "framerate", &framerate_num,
1704 gst_structure_get_int (structure, "depth", &depth);
1705 value = gst_structure_get_value (structure, "codec_data");
1707 codec_data = gst_value_get_buffer (value);
1711 gst_structure_get_fraction (structure, "pixel-aspect-ratio", &par_num,
1714 qtpad->is_out_of_order = FALSE;
1716 /* bring frame numerator into a range that ensures both reasonable resolution
1717 * as well as a fair duration */
1718 rate = adjust_rate (framerate_num);
1719 GST_DEBUG_OBJECT (qtmux, "Rate of video track selected: %" G_GUINT32_FORMAT,
1722 /* set common properties */
1723 entry.width = width;
1724 entry.height = height;
1725 entry.par_n = par_num;
1726 entry.par_d = par_den;
1727 /* should be OK according to qt and iso spec, override if really needed */
1728 entry.color_table_id = -1;
1729 entry.frame_count = 1;
1732 /* sync entries by default */
1735 /* now map onto a fourcc, and some extra properties */
1736 if (strcmp (mimetype, "video/x-raw-rgb") == 0) {
1739 entry.fourcc = FOURCC_raw_;
1740 gst_structure_get_int (structure, "bpp", &bpp);
1743 } else if (strcmp (mimetype, "video/x-raw-yuv") == 0) {
1747 gst_structure_get_fourcc (structure, "format", &format);
1749 case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
1752 entry.fourcc = FOURCC_2vuy;
1753 entry.depth = depth;
1756 } else if (strcmp (mimetype, "video/x-h263") == 0) {
1757 if (format == GST_QT_MUX_FORMAT_QT)
1758 entry.fourcc = FOURCC_h263;
1760 entry.fourcc = FOURCC_s263;
1761 ext_atom = build_h263_extension ();
1762 } else if (strcmp (mimetype, "video/x-divx") == 0 ||
1763 strcmp (mimetype, "video/mpeg") == 0) {
1766 if (strcmp (mimetype, "video/x-divx") == 0) {
1767 gst_structure_get_int (structure, "divxversion", &version);
1768 version = version == 5 ? 1 : 0;
1770 gst_structure_get_int (structure, "mpegversion", &version);
1771 version = version == 4 ? 1 : 0;
1774 entry.fourcc = FOURCC_mp4v;
1776 build_esds_extension (qtpad->trak, ESDS_OBJECT_TYPE_MPEG4_P2,
1777 ESDS_STREAM_TYPE_VISUAL, codec_data);
1779 GST_WARNING_OBJECT (qtmux, "no codec_data for MPEG4 video; "
1780 "output might not play in Apple QuickTime (try global-headers?)");
1782 } else if (strcmp (mimetype, "video/x-h264") == 0) {
1783 entry.fourcc = FOURCC_avc1;
1784 qtpad->is_out_of_order = TRUE;
1786 GST_WARNING_OBJECT (qtmux, "no codec_data in h264 caps");
1787 ext_atom = build_codec_data_extension (FOURCC_avcC, codec_data);
1788 } else if (strcmp (mimetype, "video/x-dv") == 0) {
1790 gboolean pal = TRUE;
1793 if (framerate_num != 25 || framerate_den != 1)
1795 gst_structure_get_int (structure, "dvversion", &version);
1796 /* fall back to typical one */
1802 entry.fourcc = GST_MAKE_FOURCC ('d', 'v', 'c', 'p');
1804 entry.fourcc = GST_MAKE_FOURCC ('d', 'v', 'c', ' ');
1808 entry.fourcc = GST_MAKE_FOURCC ('d', 'v', '5', 'p');
1810 entry.fourcc = GST_MAKE_FOURCC ('d', 'v', '5', 'n');
1813 GST_WARNING_OBJECT (qtmux, "unrecognized dv version");
1816 } else if (strcmp (mimetype, "image/jpeg") == 0) {
1817 entry.fourcc = FOURCC_jpeg;
1819 } else if (strcmp (mimetype, "image/x-j2c") == 0) {
1822 entry.fourcc = FOURCC_mjp2;
1824 if (!gst_structure_get_fourcc (structure, "fourcc", &fourcc) ||
1826 build_jp2h_extension (qtpad->trak, width, height, fourcc))) {
1827 GST_DEBUG_OBJECT (qtmux, "missing or invalid fourcc in jp2 caps");
1830 } else if (strcmp (mimetype, "video/x-qt-part") == 0) {
1833 gst_structure_get_fourcc (structure, "format", &fourcc);
1834 entry.fourcc = fourcc;
1835 qtpad->is_out_of_order = TRUE;
1836 qtpad->have_dts = TRUE;
1837 } else if (strcmp (mimetype, "video/x-mp4-part") == 0) {
1840 gst_structure_get_fourcc (structure, "format", &fourcc);
1841 entry.fourcc = fourcc;
1842 qtpad->is_out_of_order = TRUE;
1843 qtpad->have_dts = TRUE;
1849 /* ok, set the pad info accordingly */
1850 qtpad->fourcc = entry.fourcc;
1852 atom_trak_set_video_type (qtpad->trak, qtmux->context, &entry, rate,
1855 gst_object_unref (qtmux);
1861 GST_WARNING_OBJECT (qtmux, "pad %s refused caps %" GST_PTR_FORMAT,
1862 GST_PAD_NAME (pad), caps);
1863 gst_object_unref (qtmux);
1866 refuse_renegotiation:
1868 GST_WARNING_OBJECT (qtmux,
1869 "pad %s refused renegotiation to %" GST_PTR_FORMAT " from %"
1870 GST_PTR_FORMAT, GST_PAD_NAME (pad), caps, GST_PAD_CAPS (pad));
1871 gst_object_unref (qtmux);
1877 gst_qt_mux_sink_event (GstPad * pad, GstEvent * event)
1882 qtmux = GST_QT_MUX_CAST (gst_pad_get_parent (pad));
1883 switch (GST_EVENT_TYPE (event)) {
1884 case GST_EVENT_TAG:{
1886 GstTagSetter *setter = GST_TAG_SETTER (qtmux);
1887 const GstTagMergeMode mode = gst_tag_setter_get_tag_merge_mode (setter);
1889 GST_DEBUG_OBJECT (qtmux, "received tag event");
1890 gst_event_parse_tag (event, &list);
1891 gst_tag_setter_merge_tags (setter, list, mode);
1898 ret = qtmux->collect_event (pad, event);
1899 gst_object_unref (qtmux);
1905 gst_qt_mux_release_pad (GstElement * element, GstPad * pad)
1907 GstQTMux *mux = GST_QT_MUX_CAST (element);
1909 /* let GstCollectPads complain if it is some unknown pad */
1910 if (gst_collect_pads_remove_pad (mux->collect, pad))
1911 gst_element_remove_pad (element, pad);
1915 gst_qt_mux_request_new_pad (GstElement * element,
1916 GstPadTemplate * templ, const gchar * name)
1918 GstElementClass *klass = GST_ELEMENT_GET_CLASS (element);
1919 GstQTMux *qtmux = GST_QT_MUX_CAST (element);
1920 GstQTPad *collect_pad;
1924 GST_DEBUG_OBJECT (qtmux, "Requested pad: %s", GST_STR_NULL (name));
1926 if (qtmux->state != GST_QT_MUX_STATE_NONE) {
1927 GST_WARNING_OBJECT (qtmux, "Not providing request pad after stream start.");
1931 if (templ == gst_element_class_get_pad_template (klass, "audio_%d")) {
1933 } else if (templ == gst_element_class_get_pad_template (klass, "video_%d")) {
1936 GST_WARNING_OBJECT (qtmux, "This is not our template!");
1940 /* add pad to collections */
1941 newpad = gst_pad_new_from_template (templ, name);
1942 collect_pad = (GstQTPad *)
1943 gst_collect_pads_add_pad_full (qtmux->collect, newpad, sizeof (GstQTPad),
1944 (GstCollectDataDestroyNotify) (gst_qt_mux_pad_reset));
1946 gst_qt_mux_pad_reset (collect_pad);
1947 collect_pad->trak = atom_trak_new (qtmux->context);
1948 atom_moov_add_trak (qtmux->moov, collect_pad->trak);
1950 /* set up pad functions */
1952 gst_pad_set_setcaps_function (newpad,
1953 GST_DEBUG_FUNCPTR (gst_qt_mux_audio_sink_set_caps));
1955 gst_pad_set_setcaps_function (newpad,
1956 GST_DEBUG_FUNCPTR (gst_qt_mux_video_sink_set_caps));
1958 /* FIXME: hacked way to override/extend the event function of
1959 * GstCollectPads; because it sets its own event function giving the
1960 * element no access to events.
1962 qtmux->collect_event = (GstPadEventFunction) GST_PAD_EVENTFUNC (newpad);
1963 gst_pad_set_event_function (newpad,
1964 GST_DEBUG_FUNCPTR (gst_qt_mux_sink_event));
1966 gst_pad_set_active (newpad, TRUE);
1967 gst_element_add_pad (element, newpad);
1973 gst_qt_mux_get_property (GObject * object,
1974 guint prop_id, GValue * value, GParamSpec * pspec)
1976 GstQTMux *qtmux = GST_QT_MUX_CAST (object);
1978 GST_OBJECT_LOCK (qtmux);
1980 case PROP_LARGE_FILE:
1981 g_value_set_boolean (value, qtmux->large_file);
1983 case PROP_MOVIE_TIMESCALE:
1984 g_value_set_uint (value, qtmux->timescale);
1987 g_value_set_boolean (value, qtmux->guess_pts);
1989 case PROP_FAST_START:
1990 g_value_set_boolean (value, qtmux->fast_start);
1992 case PROP_FAST_START_TEMP_FILE:
1993 g_value_set_string (value, qtmux->fast_start_file_path);
1996 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1999 GST_OBJECT_UNLOCK (qtmux);
2003 gst_qt_mux_generate_fast_start_file_path (GstQTMux * qtmux)
2007 if (qtmux->fast_start_file_path) {
2008 g_free (qtmux->fast_start_file_path);
2009 qtmux->fast_start_file_path = NULL;
2012 tmp = g_strdup_printf ("%s%d", "qtmux", g_random_int ());
2013 qtmux->fast_start_file_path = g_build_filename (g_get_tmp_dir (), tmp, NULL);
2018 gst_qt_mux_set_property (GObject * object,
2019 guint prop_id, const GValue * value, GParamSpec * pspec)
2021 GstQTMux *qtmux = GST_QT_MUX_CAST (object);
2023 GST_OBJECT_LOCK (qtmux);
2025 case PROP_LARGE_FILE:
2026 qtmux->large_file = g_value_get_boolean (value);
2028 case PROP_MOVIE_TIMESCALE:
2029 qtmux->timescale = g_value_get_uint (value);
2032 qtmux->guess_pts = g_value_get_boolean (value);
2034 case PROP_FAST_START:
2035 qtmux->fast_start = g_value_get_boolean (value);
2037 case PROP_FAST_START_TEMP_FILE:
2038 if (qtmux->fast_start_file_path) {
2039 g_free (qtmux->fast_start_file_path);
2041 qtmux->fast_start_file_path = g_value_dup_string (value);
2042 /* NULL means to generate a random one */
2043 if (!qtmux->fast_start_file_path) {
2044 gst_qt_mux_generate_fast_start_file_path (qtmux);
2048 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
2051 GST_OBJECT_UNLOCK (qtmux);
2054 static GstStateChangeReturn
2055 gst_qt_mux_change_state (GstElement * element, GstStateChange transition)
2057 GstStateChangeReturn ret;
2058 GstQTMux *qtmux = GST_QT_MUX_CAST (element);
2060 switch (transition) {
2061 case GST_STATE_CHANGE_NULL_TO_READY:
2063 case GST_STATE_CHANGE_READY_TO_PAUSED:
2064 gst_collect_pads_start (qtmux->collect);
2065 qtmux->state = GST_QT_MUX_STATE_STARTED;
2067 case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
2069 case GST_STATE_CHANGE_PAUSED_TO_READY:
2070 gst_collect_pads_stop (qtmux->collect);
2076 ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
2078 switch (transition) {
2079 case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
2081 case GST_STATE_CHANGE_PAUSED_TO_READY:
2082 gst_qt_mux_reset (qtmux, TRUE);
2084 case GST_STATE_CHANGE_READY_TO_NULL:
2095 gst_qt_mux_register (GstPlugin * plugin)
2097 GTypeInfo typeinfo = {
2098 sizeof (GstQTMuxClass),
2099 (GBaseInitFunc) gst_qt_mux_base_init,
2101 (GClassInitFunc) gst_qt_mux_class_init,
2106 (GInstanceInitFunc) gst_qt_mux_init,
2108 static const GInterfaceInfo tag_setter_info = {
2112 GstQTMuxFormat format;
2113 GstQTMuxClassParams *params;
2116 GST_LOG ("Registering muxers");
2119 GstQTMuxFormatProp *prop;
2121 prop = &gst_qt_mux_format_list[i];
2122 format = prop->format;
2123 if (format == GST_QT_MUX_FORMAT_NONE)
2126 /* create a cache for these properties */
2127 params = g_new0 (GstQTMuxClassParams, 1);
2128 params->prop = prop;
2129 params->src_caps = gst_static_caps_get (&prop->src_caps);
2130 params->video_sink_caps = gst_static_caps_get (&prop->video_sink_caps);
2131 params->audio_sink_caps = gst_static_caps_get (&prop->audio_sink_caps);
2133 /* create the type now */
2134 type = g_type_register_static (GST_TYPE_ELEMENT, prop->type_name, &typeinfo,
2136 g_type_set_qdata (type, GST_QT_MUX_PARAMS_QDATA, (gpointer) params);
2137 g_type_add_interface_static (type, GST_TYPE_TAG_SETTER, &tag_setter_info);
2139 if (!gst_element_register (plugin, prop->name, GST_RANK_PRIMARY, type))
2145 GST_LOG ("Finished registering muxers");
2151 gst_qt_mux_plugin_init (GstPlugin * plugin)
2153 GST_DEBUG_CATEGORY_INIT (gst_qt_mux_debug, "qtmux", 0, "QT Muxer");
2155 return gst_qt_mux_register (plugin);
2158 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
2161 "Quicktime Muxer plugin",
2162 gst_qt_mux_plugin_init, VERSION, "LGPL", "gsoc2008 package",
2163 "embedded.ufcg.edu.br")