querry : copying an ordinary buffer to GstBuffer

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

querry : copying an ordinary buffer to GstBuffer

arnabsamanta
 Hi ,
        how can i copy the contents of an ordinary buffer created in C++ to the
GstBuffer buffer.
        i have the following.... can any body tell me if its correct

        get_data(void *buffer, size_t frame)
        {
                GstBuffer *gst_buffer ;
                gst_buffer =  gst_buffer_new_and_alloc (frame);
                memcpy(gst_buffer , buffer, frame);
        }

        where buffer is the memory segment created by the previous function by
"new"


        i did so as i guess ,
                        gst_buffer = GST_BUFFER_CAST(buffer);
                                 or
                    gst_buffer = GST_BUFFER_DATA(buffer)

        wont work because "buffer" is not a n GST type buffer.

        is my understanding as stated above is correct ?
        if wrong , can any body tell me the correct way ?

 regards,
        ~Arnab


The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments contained in it.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: querry : copying an ordinary buffer to GstBuffer

Sudarshan Bisht
 
Hi ,
         Try following , would work   ,
 
       get_data(void *buffer, size_t frame)
       {
               GstBuffer *gst_buffer ;
               gst_buffer =  gst_buffer_new_and_alloc (frame);
               memcpy(GST_BUFFER_DATA(gst_buffer) , buffer, frame);
       }


 
On Mon, Sep 22, 2008 at 3:57 PM, arnabsamanta <[hidden email]> wrote:
 Hi ,
       how can i copy the contents of an ordinary buffer created in C++ to the
GstBuffer buffer.
       i have the following.... can any body tell me if its correct

       get_data(void *buffer, size_t frame)
       {
               GstBuffer *gst_buffer ;
               gst_buffer =  gst_buffer_new_and_alloc (frame);
               memcpy(gst_buffer , buffer, frame);
       }

       where buffer is the memory segment created by the previous function by
"new"


       i did so as i guess ,
                       gst_buffer = GST_BUFFER_CAST(buffer);
                                or
                   gst_buffer = GST_BUFFER_DATA(buffer)

       wont work because "buffer" is not a n GST type buffer.

       is my understanding as stated above is correct ?
       if wrong , can any body tell me the correct way ?

 regards,
       ~Arnab


The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments contained in it.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel



--
Regards,

Sudarshan Bisht

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: querry : copying an ordinary buffer to GstBuffer

Stefan Sauer
hi,

sudarshan bisht schrieb:

>  
> Hi ,
>          Try following , would work   ,
>  
>        get_data(void *buffer, size_t frame)
>        {
>                GstBuffer *gst_buffer ;
>                gst_buffer =  gst_buffer_new_and_alloc (frame);
>                memcpy(GST_BUFFER_DATA(gst_buffer) , buffer, frame);
>        }
you should also try to avoid the copy if you can (if you can take
ownership and if the buffer can be freed with g_free()):

gst_buffer =  gst_buffer_new()
GST_BUFFER_MALLOCDATA(gst_buffer) = GST_BUFFER_DATA(gst_buffer) = buffer;
GST_BUFFER_SIZE(gst_buffer) = frame;

Stefan

>
>
>  
> On Mon, Sep 22, 2008 at 3:57 PM, arnabsamanta
> <[hidden email] <mailto:[hidden email]>>
> wrote:
>
>      Hi ,
>            how can i copy the contents of an ordinary buffer created
>     in C++ to the
>     GstBuffer buffer.
>            i have the following.... can any body tell me if its correct
>
>            get_data(void *buffer, size_t frame)
>            {
>                    GstBuffer *gst_buffer ;
>                    gst_buffer =  gst_buffer_new_and_alloc (frame);
>                    memcpy(gst_buffer , buffer, frame);
>            }
>
>            where buffer is the memory segment created by the previous
>     function by
>     "new"
>
>
>            i did so as i guess ,
>                            gst_buffer = GST_BUFFER_CAST(buffer);
>                                     or
>                        gst_buffer = GST_BUFFER_DATA(buffer)
>
>            wont work because "buffer" is not a n GST type buffer.
>
>            is my understanding as stated above is correct ?
>            if wrong , can any body tell me the correct way ?
>
>      regards,
>            ~Arnab
>
>
>     The information contained in this electronic message and any
>     attachments to this message are intended for the exclusive use of
>     the addressee(s) and may contain proprietary, confidential or
>     privileged information. If you are not the intended recipient, you
>     should not disseminate, distribute or copy this e-mail. Please
>     notify the sender immediately and destroy all copies of this
>     message and any attachments contained in it.
>
>     -------------------------------------------------------------------------
>     This SF.Net email is sponsored by the Moblin Your Move Developer's
>     challenge
>     Build the coolest Linux based applications with Moblin SDK & win
>     great prizes
>     Grand prize is a trip for two to an Open Source event anywhere in
>     the world
>     http://moblin-contest.org/redirect.php?banner_id=100&url=/
>     <http://moblin-contest.org/redirect.php?banner_id=100&url=/>
>     _______________________________________________
>     gstreamer-devel mailing list
>     [hidden email]
>     <mailto:[hidden email]>
>     https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>
>
>
>
> --
> Regards,
>
> Sudarshan Bisht
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> ------------------------------------------------------------------------
>
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>  


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel