static gboolean default_map (GstVideoMeta * meta, guint plane, GstMapInfo * info, gpointer * data, gint * stride, GstMapFlags flags) { guint idx, length; gsize offset, skip; GstBuffer *buffer = meta->buffer; offset = meta->offset[plane]; /* find the memory block for this plane, this is the memory block containing * the plane offset. FIXME use plane size */ if (!gst_buffer_find_memory (buffer, offset, 1, &idx, &length, &skip)) goto no_memory; if (!gst_buffer_map_range (buffer, idx, length, info, flags)) goto cannot_map; *stride = meta->stride[plane]; *data = (guint8 *) info->data + skip; return TRUE; /* ERRORS */ no_memory: { GST_DEBUG ("plane %u, no memory at offset %" G_GSIZE_FORMAT, plane, offset); return FALSE; } cannot_map: { GST_DEBUG ("cannot map memory range %u-%u", idx, length); return FALSE; } }
static GstFlowReturn gst_dtls_srtp_demux_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer) { GstDtlsSrtpDemux *self = GST_DTLS_SRTP_DEMUX (parent); GstMapInfo map; guint8 first_byte; if (!gst_buffer_map_range (buffer, 0, 1, &map, GST_MAP_READ)) { gst_buffer_unref (buffer); GST_ELEMENT_ERROR (self, STREAM, DEMUX, ("Could not map buffer"), ("Unable to map the first memory of buffer %p", buffer)); return GST_FLOW_ERROR; } if (map.size < 1) { gst_buffer_unmap (buffer, &map); GST_WARNING_OBJECT (self, "Buffer %p has a first GstMemory that's less than" " one bytes long, ignoring", buffer); goto done; } first_byte = map.data[0]; gst_buffer_unmap (buffer, &map); if (first_byte > 127 && first_byte < 192) { return gst_pad_push (self->srtp_srcpad, buffer); } else if (first_byte > 19 && first_byte < 64) { return gst_pad_push (self->dtls_srcpad, buffer); } GST_WARNING_OBJECT (self, "Buffer %p has first byte %d which is neither DTLS" " nor SRTP/RTP nor SRTCP/RTCP, ignoring it", buffer, first_byte); done: gst_buffer_unref (buffer); return GST_FLOW_OK; }