Transform plugin outbuf - plugin write problem

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

Transform plugin outbuf - plugin write problem

张若
Hi,

I am now writing a transform plugin for video stream.

When I use GstFlowReturn (*transform_ip) (GstBaseTransform *trans, GstBuffer *buf), it works fine. Inside the function I do nothing to the buffer. The ximagesink display is the camera capture.

Because of what I need is to change the buffer size, I come to GstFlowReturn (*transform) (GstBaseTransform *trans, GstBuffer *inbuf, GstBuffer *outbuf).
In this function, I first do a simple test with copying inbuf to outbuf. I check the data in outbuf which seems to be changed with camera captures. However, the ximagesink display is always black. I don't know why. It should be same to what I did in (*transform_ip), but not.

Thanks in advance!

Best regards

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Transform plugin outbuf - plugin write problem

Nicolas Dufresne-5
Le lundi 15 mai 2017 à 16:04 +0200, 张若 a écrit :

> When I use GstFlowReturn (*transform_ip) (GstBaseTransform *trans,
> GstBuffer *buf), it works fine. Inside the function I do nothing to
> the buffer. The ximagesink display is the camera capture.
>
> Because of what I need is to change the buffer size, I come
> to GstFlowReturn (*transform) (GstBaseTransform *trans, GstBuffer
> *inbuf, GstBuffer *outbuf).
> In this function, I first do a simple test with copying inbuf to
> outbuf. I check the data in outbuf which seems to be changed with
> camera captures. However, the ximagesink display is always black. I
> don't know why. It should be same to what I did in (*transform_ip),
> but not.
This is most likely a bug in your code, which isn't visible to us.

regards,
Nicolas
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (188 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Transform plugin outbuf - plugin write problem

张若
Actually, I just write based on the gsttransform.c/h in gst-template.
I only modify the part with transform_ip () to transform ().
In details:
1. Change the definition to:
    static GstFlowReturn gst_plugin_template_transform (GstBaseTransform * base, GstBuffer *inbuf,
    GstBuffer * outbuf);
2. Change class init to:
   GST_BASE_TRANSFORM_CLASS (klass)->transform =
      GST_DEBUG_FUNCPTR (gst_plugin_template_transform);
3. Change the main flow to:
    static GstFlowReturn
gst_plugin_template_transform (GstBaseTransform * base, GstBuffer *inbuf, GstBuffer * outbuf)
{
   GstMapInfo map_in; 
   GstMapInfo map_out;
   gst_buffer_map (inbuf, &map_in, GST_MAP_READ); 
   gst_buffer_map (outbuf, &map_out, GST_MAP_WRITE);
   gst_buffer_unmap (inbuf, &map_in);
   gst_buffer_unmap (outbuf, &map_out);
  return GST_FLOW_OK;
}

The other parts are remained. However, it only displays black, and when i check the outbuf, it has camera capture data.

Best regards,

Ruo


2017-05-15 16:48 GMT+02:00 Nicolas Dufresne <[hidden email]>:
Le lundi 15 mai 2017 à 16:04 +0200, 张若 a écrit :
> When I use GstFlowReturn (*transform_ip) (GstBaseTransform *trans,
> GstBuffer *buf), it works fine. Inside the function I do nothing to
> the buffer. The ximagesink display is the camera capture.
>
> Because of what I need is to change the buffer size, I come
> to GstFlowReturn (*transform) (GstBaseTransform *trans, GstBuffer
> *inbuf, GstBuffer *outbuf).
> In this function, I first do a simple test with copying inbuf to
> outbuf. I check the data in outbuf which seems to be changed with
> camera captures. However, the ximagesink display is always black. I
> don't know why. It should be same to what I did in (*transform_ip),
> but not.

This is most likely a bug in your code, which isn't visible to us.

regards,
Nicolas
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel



_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Transform plugin outbuf - plugin write problem

张若
In 3, I forget to put 1 line while writing the email:
gst_plugin_template_transform (GstBaseTransform * base, GstBuffer *inbuf, GstBuffer * outbuf)
{
   GstMapInfo map_in; 
   GstMapInfo map_out;
   gst_buffer_map (inbuf, &map_in, GST_MAP_READ); 
   gst_buffer_map (outbuf, &map_out, GST_MAP_WRITE);
   map_out.data = map_in.data;
   gst_buffer_unmap (inbuf, &map_in);
   gst_buffer_unmap (outbuf, &map_out);
  return GST_FLOW_OK;
}

2017-05-16 9:03 GMT+02:00 张若 <[hidden email]>:
Actually, I just write based on the gsttransform.c/h in gst-template.
I only modify the part with transform_ip () to transform ().
In details:
1. Change the definition to:
    static GstFlowReturn gst_plugin_template_transform (GstBaseTransform * base, GstBuffer *inbuf,
    GstBuffer * outbuf);
2. Change class init to:
   GST_BASE_TRANSFORM_CLASS (klass)->transform =
      GST_DEBUG_FUNCPTR (gst_plugin_template_transform);
3. Change the main flow to:
    static GstFlowReturn
gst_plugin_template_transform (GstBaseTransform * base, GstBuffer *inbuf, GstBuffer * outbuf)
{
   GstMapInfo map_in; 
   GstMapInfo map_out;
   gst_buffer_map (inbuf, &map_in, GST_MAP_READ); 
   gst_buffer_map (outbuf, &map_out, GST_MAP_WRITE);
   gst_buffer_unmap (inbuf, &map_in);
   gst_buffer_unmap (outbuf, &map_out);
  return GST_FLOW_OK;
}

The other parts are remained. However, it only displays black, and when i check the outbuf, it has camera capture data.

Best regards,

Ruo


2017-05-15 16:48 GMT+02:00 Nicolas Dufresne <[hidden email]>:
Le lundi 15 mai 2017 à 16:04 +0200, 张若 a écrit :
> When I use GstFlowReturn (*transform_ip) (GstBaseTransform *trans,
> GstBuffer *buf), it works fine. Inside the function I do nothing to
> the buffer. The ximagesink display is the camera capture.
>
> Because of what I need is to change the buffer size, I come
> to GstFlowReturn (*transform) (GstBaseTransform *trans, GstBuffer
> *inbuf, GstBuffer *outbuf).
> In this function, I first do a simple test with copying inbuf to
> outbuf. I check the data in outbuf which seems to be changed with
> camera captures. However, the ximagesink display is always black. I
> don't know why. It should be same to what I did in (*transform_ip),
> but not.

This is most likely a bug in your code, which isn't visible to us.

regards,
Nicolas
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel




_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Transform plugin outbuf - plugin write problem

Yasushi SHOJI-2
Hi,

On Tue, May 16, 2017 at 5:46 PM, 张若 <[hidden email]> wrote:
>
> In 3, I forget to put 1 line while writing the email:
> gst_plugin_template_transform (GstBaseTransform * base, GstBuffer *inbuf, GstBuffer * outbuf)
> {
>    GstMapInfo map_in;
>    GstMapInfo map_out;
>    gst_buffer_map (inbuf, &map_in, GST_MAP_READ);
>    gst_buffer_map (outbuf, &map_out, GST_MAP_WRITE);
>    map_out.data = map_in.data;

This won't work.  memcpy() it for test.  If you wanna play with GstBuffer and GstMemory, 
here is links:

>    gst_buffer_unmap (inbuf, &map_in);
>    gst_buffer_unmap (outbuf, &map_out);
>   return GST_FLOW_OK;
> }
-- 
            yashi


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel