[gst-devel] gstreamer gstbasetransform
Federico Paganini
black_eagle85 at hotmail.com
Mon Feb 1 11:51:59 CET 2010
Hi Micheal,
i am following your advice in order to allocate the output buffer. But
i have a problem, I insert my encryption plug-in in a pipeline and when
i try to run the pipeline i obtain a file with only audio track; video
track is disappeared. My pipeline is this:
-->queue--->decoder--->audioconverter-->encoder--->identity--->queue--- AUDIO
Filesrc-->avidemux----
---> mux-->filesink
-->queue--->DES
TOOL--->queue-------------------------------------------------------
VIDEO
I have annex in this mail my gst_destool_chain() function in which i
have inserted the buffer output allocation and the encryption plug-in:
Can you say to me if is correct? Thanks in advance!!!!!
/* chain function
* this function does the actual processing
*/
static GstFlowReturn
gst_destool_chain (GstPad * pad, GstBuffer * inbuf)
{
GstDesTool *filter;
GstBuffer *outbuf;
outbuf=NULL;
filter = GST_DESTOOL (GST_OBJECT_PARENT (pad));
if (filter->silent == FALSE)
{
//printf ("I'm plugged, therefore I'm in.\n");
//filter->process (filter, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
//Calculating the dimensione of the output buffer
guint padSize = (8 - inbuf->size % 8);
guint newSize = inbuf->size + padSize;
guint pad;
//Allocate output buffer
outbuf= gst_buffer_new_and_alloc (newSize);
GST_BUFFER_TIMESTAMP(outbuf)= GST_BUFFER_TIMESTAMP (inbuf);
GST_BUFFER_DURATION(outbuf)= GST_BUFFER_DURATION (inbuf);
gst_buffer_set_caps (outbuf, GST_PAD_CAPS (filter->srcpad));
guint8 startCode[3] = { 0x00, 0x00, 0x01 };
if ( (guint8*)memmem( inbuf->data, inbuf->size, startCode, 3 ) == inbuf->data )
{
memcpy( outbuf->data, inbuf->data, inbuf->size );
// Doing padding
for( pad = 0; pad < padSize; ++pad )
{
outbuf->data[ inbuf->size + pad ] = padSize;
}
// prepare des key
DES_key_schedule schedule;
DES_set_key ( (des_cblock*)filter->key, &schedule );
//do encryption
DES_ncbc_encrypt( inbuf->data + 4, outbuf->data + 4,
newSize - 4, &schedule, (des_cblock*)filter->iv, DES_ENCRYPT );
}
else
{
fprintf( stderr, "begin of frame is not expected start code, dropping\n");
}
}
/* just push out the incoming buffer without touching it */
gst_buffer_unref (inbuf);
return gst_pad_push (filter->srcpad, outbuf);
}
> Date: Sat, 30 Jan 2010 15:54:28 -0800
> From: msmith at xiph.org
> To: gstreamer-devel at lists.sourceforge.net
> Subject: Re: [gst-devel] gstreamer gstbasetransform
>
> On Sat, Jan 30, 2010 at 2:43 AM, Federico Paganini
> <black_eagle85 at hotmail.com> wrote:
> > Hi,
> >
> > I briefly explain to you my problem. For my thesis i am developing a
> > gstreamer plug-in that encrypt an mpeg4 video with DES in CBC mode. The
> > encryption is made frame by frame and because a frame doesn't contain an
> > exact number of DES BLOCK SIZE(64 bit) i must padding the final bytes of the
> > frame. Because i use padding the dimension of the frame in output is greater
> > than that in input. For this reason i must allocate an output buffer of a
> > precise size. So in the trasform function of my plug in i have tried to call
> > this function: gst_base_transform_prepare_output_buffer( base, inbuf,
> > newSize, inbuf->caps,&outbuf ); but when i try to compile i have this
> > error:error: implicit declaration of function
> > ‘gst_base_transform_prepare_output_buffer’ nevertheless i have done the
> > include of gstbasetransform.h.
> > I would be very happy if you can say to me how i must to allocate an output
> > buffer that is larger than input.
>
> For what you're doing, you probably don't want to make your element a
> subclass of GstBaseTransform at all - instead you should directly
> subclass GstElement. You can use gst_pad_alloc_buffer() or
> gst_buffer_new_and_alloc() to allocate your output buffer with any
> size you want.
>
> Mike
>
> ------------------------------------------------------------------------------
> The Planet: dedicated and managed hosting, cloud storage, colocation
> Stay online with enterprise data centers and the best network in the business
> Choose flexible plans and management services without long-term contracts
> Personal 24x7 support from experience hosting pros just a phone call away.
> http://p.sf.net/sfu/theplanet-com
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
_________________________________________________________________
Personalizza la tua vita digitale, scarica i nuovi gadget!
http://www.pimpit.it/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20100201/12094a63/attachment.htm>
More information about the gstreamer-devel
mailing list