qtmux: fix subtitle buffer duration and strip null termination

Strip the \0 off the subtitle as we already know the size and also remember
to set the duration as buffer copying doesn't do it.

https://bugzilla.gnome.org/show_bug.cgi?id=737095
This commit is contained in:
Matej Knopp 2014-09-23 19:07:25 +02:00 committed by Thiago Santos
parent f57e9c4516
commit 6695341583

View file

@ -561,10 +561,11 @@ gst_qt_mux_prepare_tx3g_buffer (GstQTPad * qtpad, GstBuffer * buf,
if (buf == NULL) if (buf == NULL)
return NULL; return NULL;
size = gst_buffer_get_size (buf); gst_buffer_map (buf, &frommap, GST_MAP_READ);
size = (gint16) strnlen ((const char *) frommap.data, frommap.size);
newbuf = gst_buffer_new_and_alloc (size + 2); newbuf = gst_buffer_new_and_alloc (size + 2);
gst_buffer_map (buf, &frommap, GST_MAP_READ);
gst_buffer_map (newbuf, &tomap, GST_MAP_WRITE); gst_buffer_map (newbuf, &tomap, GST_MAP_WRITE);
GST_WRITE_UINT16_BE (tomap.data, size); GST_WRITE_UINT16_BE (tomap.data, size);
@ -575,6 +576,10 @@ gst_qt_mux_prepare_tx3g_buffer (GstQTPad * qtpad, GstBuffer * buf,
gst_buffer_copy_into (newbuf, buf, GST_BUFFER_COPY_METADATA, 0, size); gst_buffer_copy_into (newbuf, buf, GST_BUFFER_COPY_METADATA, 0, size);
/* gst_buffer_copy_into is trying to be too clever and
* won't copy duration when size is different */
GST_BUFFER_DURATION (newbuf) = GST_BUFFER_DURATION (buf);
gst_buffer_unref (buf); gst_buffer_unref (buf);
return newbuf; return newbuf;
@ -588,7 +593,7 @@ gst_qt_mux_create_empty_tx3g_buffer (GstQTPad * qtpad, gint64 duration)
data = g_malloc (2); data = g_malloc (2);
GST_WRITE_UINT16_BE (data, 0); GST_WRITE_UINT16_BE (data, 0);
return gst_buffer_new_wrapped (data, 2);; return gst_buffer_new_wrapped (data, 2);
} }
static void static void