static GstFlowReturn gst_mms_create (GstPushSrc * psrc, GstBuffer ** buf) { GstMMS *mmssrc; guint8 *data; guint blocksize; gint result; mms_off_t offset; *buf = NULL; mmssrc = GST_MMS (psrc); offset = mmsx_get_current_pos (mmssrc->connection); /* Check if a seek perhaps has wrecked our connection */ if (offset == -1) { GST_DEBUG_OBJECT (mmssrc, "connection broken (probably an error during mmsx_seek_time during a convert query) returning FLOW_ERROR"); return GST_FLOW_ERROR; } /* Choose blocksize best for optimum performance */ if (offset == 0) blocksize = mmsx_get_asf_header_len (mmssrc->connection); else blocksize = mmsx_get_asf_packet_len (mmssrc->connection); *buf = gst_buffer_new_and_alloc (blocksize); data = GST_BUFFER_DATA (*buf); GST_BUFFER_SIZE (*buf) = 0; GST_LOG_OBJECT (mmssrc, "reading %d bytes", blocksize); result = mmsx_read (NULL, mmssrc->connection, (char *) data, blocksize); /* EOS? */ if (result == 0) goto eos; GST_BUFFER_OFFSET (*buf) = offset; GST_BUFFER_SIZE (*buf) = result; GST_LOG_OBJECT (mmssrc, "Returning buffer with offset %" G_GINT64_FORMAT " and size %u", GST_BUFFER_OFFSET (*buf), GST_BUFFER_SIZE (*buf)); gst_buffer_set_caps (*buf, GST_PAD_CAPS (GST_BASE_SRC_PAD (mmssrc))); return GST_FLOW_OK; eos: { GST_DEBUG_OBJECT (mmssrc, "EOS"); gst_buffer_unref (*buf); *buf = NULL; return GST_FLOW_UNEXPECTED; } }
static GstFlowReturn gst_mms_create (GstPushSrc * psrc, GstBuffer ** buf) { GstMMS *mmssrc = GST_MMS (psrc); guint8 *data; guint blocksize; gint result; mms_off_t offset; *buf = NULL; offset = mmsx_get_current_pos (mmssrc->connection); /* Check if a seek perhaps has wrecked our connection */ if (offset == -1) { GST_ERROR_OBJECT (mmssrc, "connection broken (probably an error during mmsx_seek_time during a convert query) returning FLOW_ERROR"); return GST_FLOW_ERROR; } /* Choose blocksize best for optimum performance */ if (offset == 0) blocksize = mmsx_get_asf_header_len (mmssrc->connection); else blocksize = mmsx_get_asf_packet_len (mmssrc->connection); data = g_try_malloc (blocksize); if (!data) { GST_ERROR_OBJECT (mmssrc, "Failed to allocate %u bytes", blocksize); return GST_FLOW_ERROR; } GST_LOG_OBJECT (mmssrc, "reading %d bytes", blocksize); result = mmsx_read (NULL, mmssrc->connection, (char *) data, blocksize); /* EOS? */ if (result == 0) goto eos; *buf = gst_buffer_new_wrapped (data, result); GST_BUFFER_OFFSET (*buf) = offset; GST_LOG_OBJECT (mmssrc, "Returning buffer with offset %" G_GINT64_FORMAT " and size %u", offset, result); return GST_FLOW_OK; eos: { GST_DEBUG_OBJECT (mmssrc, "EOS"); g_free (data); *buf = NULL; return GST_FLOW_EOS; } }