#include <string.h>
#include "gstflvmux.h"
+#include "amfdefs.h"
GST_DEBUG_CATEGORY_STATIC (flvmux_debug);
#define GST_CAT_DEFAULT flvmux_debug
static GstFlowReturn
gst_flv_mux_collected (GstCollectPads * pads, gpointer user_data);
-static gboolean gst_flv_mux_handle_src_event (GstPad * pad, GstEvent * event);
+static gboolean gst_flv_mux_handle_src_event (GstPad * pad, GstObject * parent,
+ GstEvent * event);
static GstPad *gst_flv_mux_request_new_pad (GstElement * element,
GstPadTemplate * templ, const gchar * req_name, const GstCaps * caps);
static void gst_flv_mux_release_pad (GstElement * element, GstPad * pad);
}
static gboolean
-gst_flv_mux_handle_src_event (GstPad * pad, GstEvent * event)
+gst_flv_mux_handle_src_event (GstPad * pad, GstObject * parent,
+ GstEvent * event)
{
GstEventType type;
break;
}
- return gst_pad_event_default (pad, event);
+ return gst_pad_event_default (pad, parent, event);
}
static gboolean
-gst_flv_mux_handle_sink_event (GstPad * pad, GstEvent * event)
+gst_flv_mux_handle_sink_event (GstPad * pad, GstObject * parent,
+ GstEvent * event)
{
- GstFlvMux *mux = GST_FLV_MUX (gst_pad_get_parent (pad));
+ GstFlvMux *mux = GST_FLV_MUX (parent);
gboolean ret = TRUE;
switch (GST_EVENT_TYPE (event)) {
/* now GstCollectPads can take care of the rest, e.g. EOS */
if (ret)
- ret = mux->collect_event (pad, event);
- gst_object_unref (mux);
+ ret = mux->collect_event (pad, parent, event);
return ret;
}
pad = gst_pad_new_from_template (templ, name);
cpad = (GstFlvPad *)
- gst_collect_pads_add_pad (mux->collect, pad, sizeof (GstFlvPad));
+ gst_collect_pads_add_pad (mux->collect, pad, sizeof (GstFlvPad), NULL);
cpad->audio_codec_data = NULL;
cpad->video_codec_data = NULL;
/* prefill the space with a gstfiller: <spaces> script tag variable */
GST_WRITE_UINT16_BE (data, 9); /* 9 characters */
memcpy (data + 2, "gstfiller", 9);
- GST_WRITE_UINT8 (data + 11, 2); /* a string value */
+ GST_WRITE_UINT8 (data + 11, AMF0_STRING_MARKER); /* a string value */
GST_WRITE_UINT16_BE (data + 12, preallocate_size - 14);
memset (data + 14, ' ', preallocate_size - 14); /* the rest is spaces */
return tmp;
{
GstBuffer *tmp;
guint8 *data;
+ gsize len = strlen (name);
- _gst_buffer_new_and_alloc (2 + strlen (name) + 1 + 8, &tmp, &data);
+ _gst_buffer_new_and_alloc (2 + len + 1 + 8, &tmp, &data);
- GST_WRITE_UINT16_BE (data, strlen (name)); /* name length */
- memcpy (&data[2], name, strlen (name));
- data[2 + strlen (name)] = 0; /* double */
- GST_WRITE_DOUBLE_BE (data + 2 + strlen (name) + 1, value);
+ GST_WRITE_UINT16_BE (data, len);
+ data += 2; /* name length */
+ memcpy (data, name, len);
+ data += len;
+ *data++ = AMF0_NUMBER_MARKER; /* double type */
+ GST_WRITE_DOUBLE_BE (data, value);
return tmp;
}
data[8] = data[9] = data[10] = 0;
_gst_buffer_new_and_alloc (13, &tmp, &data);
- data[0] = 2; /* string */
+ data[0] = AMF0_STRING_MARKER; /* string */
data[1] = 0;
data[2] = 10; /* length 10 */
memcpy (&data[3], "onMetaData", 10);
tmp = gst_flv_mux_create_number_script_value ("duration", 86400);
script_tag = gst_buffer_join (script_tag, tmp);
tags_written++;
- }
- /* Sometimes the information about the total file size is useful for the
- player. It will be filled later, after getting EOS */
- if (!mux->streamable) {
+ /* Sometimes the information about the total file size is useful for the
+ player. It will be filled later, after getting EOS */
tmp = gst_flv_mux_create_number_script_value ("filesize", 0);
script_tag = gst_buffer_join (script_tag, tmp);
tags_written++;
- }
- if (!mux->streamable) {
+ /* Preallocate space for the index to be written at EOS */
tmp = gst_flv_mux_preallocate_index (mux);
script_tag = gst_buffer_join (script_tag, tmp);
} else {
for (l = mux->collect->data; l; l = l->next) {
GstCollectData *cdata = l->data;
- if (gst_pad_query_peer_duration (cdata->pad, GST_FORMAT_TIME,
+ if (gst_pad_peer_query_duration (cdata->pad, GST_FORMAT_TIME,
(gint64 *) & dur) && dur != GST_CLOCK_TIME_NONE) {
if (mux->duration == GST_CLOCK_TIME_NONE)
mux->duration = dur;
gst_flv_mux_put_buffer_in_streamheader (&streamheader, audio_codec_data);
/* create the caps and put the streamheader in them */
- caps = gst_caps_new_simple ("video/x-flv", NULL);
- caps = gst_caps_make_writable (caps);
+ caps = gst_caps_new_empty_simple ("video/x-flv");
structure = gst_caps_get_structure (caps, 0);
gst_structure_set_value (structure, "streamheader", &streamheader);
g_value_unset (&streamheader);