<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
Hi Micheal,<br>
<br>
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:<br>
<br>
-->queue--->decoder--->audioconverter-->encoder--->identity--->queue--- AUDIO<br>
Filesrc-->avidemux----
---> mux-->filesink<br>
-->queue--->DES
TOOL--->queue-------------------------------------------------------
VIDEO<br><br>
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: <br>
Can you say to me if is correct? Thanks in advance!!!!!<br>
<br>
/* chain function
<br>
* this function does the actual processing
<br>
*/
<br>
static GstFlowReturn
<br>
gst_destool_chain (GstPad * pad, GstBuffer * inbuf)
<br>
{
<br>
GstDesTool *filter;
<br>
GstBuffer *outbuf;<br>
outbuf=NULL;<br>
filter = GST_DESTOOL (GST_OBJECT_PARENT (pad));
<br>
if (filter->silent == FALSE)
<br>
{
<br>
//printf ("I'm plugged, therefore I'm in.\n");
<br>
//filter->process (filter, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));<br>
<br>
//Calculating the dimensione of the output buffer <br>
guint padSize = (8 - inbuf->size % 8);<br>
guint newSize = inbuf->size + padSize;<br>
guint pad;<br>
<br>
//Allocate output buffer<br>
outbuf= gst_buffer_new_and_alloc (newSize);<br>
GST_BUFFER_TIMESTAMP(outbuf)= GST_BUFFER_TIMESTAMP (inbuf);<br>
GST_BUFFER_DURATION(outbuf)= GST_BUFFER_DURATION (inbuf);<br>
gst_buffer_set_caps (outbuf, GST_PAD_CAPS (filter->srcpad));<br>
<br>
<br>
guint8 startCode[3] = { 0x00, 0x00, 0x01 };<br>
<br>
if ( (guint8*)memmem( inbuf->data, inbuf->size, startCode, 3 ) == inbuf->data ) <br>
{<br>
memcpy( outbuf->data, inbuf->data, inbuf->size );<br>
<br>
// Doing padding <br>
for( pad = 0; pad < padSize; ++pad )<br>
{<br>
outbuf->data[ inbuf->size + pad ] = padSize;<br>
}<br>
// prepare des key <br>
DES_key_schedule schedule;<br>
DES_set_key ( (des_cblock*)filter->key, &schedule );<br>
//do encryption<br>
DES_ncbc_encrypt( inbuf->data + 4, outbuf->data + 4,
newSize - 4, &schedule, (des_cblock*)filter->iv, DES_ENCRYPT );<br>
}<br>
else<br>
{<br>
fprintf( stderr, "begin of frame is not expected start code, dropping\n");<br>
}<br>
<br>
}
<br>
<br>
/* just push out the incoming buffer without touching it */
<br>
gst_buffer_unref (inbuf);<br>
return gst_pad_push (filter->srcpad, outbuf);
<br>
}<br><br>> Date: Sat, 30 Jan 2010 15:54:28 -0800<br>> From: msmith@xiph.org<br>> To: gstreamer-devel@lists.sourceforge.net<br>> Subject: Re: [gst-devel] gstreamer gstbasetransform<br>> <br>> On Sat, Jan 30, 2010 at 2:43 AM, Federico Paganini<br>> <black_eagle85@hotmail.com> wrote:<br>> > Hi,<br>> ><br>> > I briefly explain to you my problem. For my thesis i am developing a<br>> > gstreamer plug-in that encrypt an mpeg4 video with DES in CBC mode. The<br>> > encryption is made frame by frame and because a frame doesn't contain an<br>> > exact number of DES BLOCK SIZE(64 bit) i must padding the final bytes of the<br>> > frame. Because i use padding the dimension of the frame in output is greater<br>> > than that in input. For this reason i must allocate an output buffer of a<br>> > precise size. So in the trasform function of my plug in i have tried to call<br>> > this function: gst_base_transform_prepare_output_buffer( base, inbuf,<br>> > newSize, inbuf->caps,&outbuf ); but when i try to compile i have this<br>> > error:error: implicit declaration of function<br>> > ‘gst_base_transform_prepare_output_buffer’ nevertheless i have done the<br>> > include of gstbasetransform.h.<br>> > I would be very happy if you can say to me how i must to allocate an output<br>> > buffer that is larger than input.<br>> <br>> For what you're doing, you probably don't want to make your element a<br>> subclass of GstBaseTransform at all - instead you should directly<br>> subclass GstElement. You can use gst_pad_alloc_buffer() or<br>> gst_buffer_new_and_alloc() to allocate your output buffer with any<br>> size you want.<br>> <br>> Mike<br>> <br>> ------------------------------------------------------------------------------<br>> The Planet: dedicated and managed hosting, cloud storage, colocation<br>> Stay online with enterprise data centers and the best network in the business<br>> Choose flexible plans and management services without long-term contracts<br>> Personal 24x7 support from experience hosting pros just a phone call away.<br>> http://p.sf.net/sfu/theplanet-com<br>> _______________________________________________<br>> gstreamer-devel mailing list<br>> gstreamer-devel@lists.sourceforge.net<br>> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel<br>                                            <br /><hr />Non sei a casa? <a href='http://www.messenger.it/web/default.aspx' target='_new'>Accedi a Messenger dal Web!</a></body>
</html>