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