How to retrieve attached custom meta information on receiver side?

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

How to retrieve attached custom meta information on receiver side?

bronstein87
Hi. I added my custom meta data and can't retrieve it on receiver side
On sender side i have rtsp server and i'm adding meta info to frame buffers (i skip some of not important parts of code):

    buffer = gst_buffer_new_wrapped(frame.data, size);
...
        GST_BUFFER_PTS (buffer) = ts;
        GST_BUFFER_DTS (buffer) = ts;

        qint64 duration = ((double)1 / params.framerate) * GST_SECOND;
        GST_BUFFER_DURATION(buffer) = duration;
        GST_BUFFER_OFFSET(buffer) = currentFrameCount;

        // ADD META
        GstMetaMarking* meta = GST_META_MARKING_ADD(buffer);
        meta->in_timestamp = it->time;
        if (currentFrameCount >= needFrameCount)
        {
            meta->last = true;
        }
        else
        {
            meta->last = false;
        }
      // here i check that meta added correctly
        GstMetaMarking* metaCheck = GST_META_MARKING_GET(buffer);
        qDebug() << metaCheck->in_timestamp << metaCheck->last;
        g_signal_emit_by_name (appsrc, "push-buffer", buffer, &ret);
        gst_buffer_unref (buffer);

On receiver side i modified part where i retrieve frame:
...
sample = gst_app_sink_pull_sample(GST_APP_SINK(sink));
...
GstBuffer * buf = gst_sample_get_buffer(sample);
if (!buf)
        return false;

// RETRIEVE META
GstMetaMarking* meta = GST_META_MARKING_GET(buf);
if (meta)
{
CV_WARN("GStreamer: META EXISTS");
tsMeta = meta->in_timestamp;
isLastMeta = meta->last;
}
else
{
CV_WARN("GStreamer: META IS EMPTY"); // so i'm always here
}
    GstMapInfo info;
    if (!gst_buffer_map(buf, &info, GST_MAP_READ))
    {
        //something weird went wrong here. abort. abort.
        CV_WARN("Failed to map GStreamerbuffer to system memory");
        return false;
    }

    {
        Mat src;
        if (isOutputByteBuffer)
            src = Mat(Size(info.size, 1), CV_8UC1, info.data);
        else
            src = Mat(sz, CV_MAKETYPE(CV_8U, channels), info.data);
        CV_Assert(src.isContinuous());
        src.copyTo(dst);
    }
    gst_buffer_unmap(buf, &info);



So, here
  GstMetaMarking* meta = GST_META_MARKING_GET(buf); 

i always get empty pointer. What is wrong here? 

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

Re: How to retrieve attached custom meta information on receiver side?

Nicolas Dufresne-5
Le mercredi 18 mars 2020 à 14:54 +0300, Борис a écrit :
> Hi. I added my custom meta data and can't retrieve it on receiver side
> On sender side i have rtsp server and i'm adding meta info to frame buffers (i skip some of not important parts of code):

GstMeta are not generically serialized through RTP protocol. You have
to serialize / unserialize this through custom element or pad probes.
You can you the extension headers to store this information in the RTP
packet.

>
>     buffer = gst_buffer_new_wrapped(frame.data, size);
> ...
>         GST_BUFFER_PTS (buffer) = ts;
>         GST_BUFFER_DTS (buffer) = ts;
>
>         qint64 duration = ((double)1 / params.framerate) * GST_SECOND;
>         GST_BUFFER_DURATION(buffer) = duration;
>         GST_BUFFER_OFFSET(buffer) = currentFrameCount;
>
>         // ADD META
>         GstMetaMarking* meta = GST_META_MARKING_ADD(buffer);
>         meta->in_timestamp = it->time;
>         if (currentFrameCount >= needFrameCount)
>         {
>             meta->last = true;
>         }
>         else
>         {
>             meta->last = false;
>         }
>       // here i check that meta added correctly
>         GstMetaMarking* metaCheck = GST_META_MARKING_GET(buffer);
>         qDebug() << metaCheck->in_timestamp << metaCheck->last;
>         g_signal_emit_by_name (appsrc, "push-buffer", buffer, &ret);
>         gst_buffer_unref (buffer);
>
> On receiver side i modified part where i retrieve frame:
> ...
> sample = gst_app_sink_pull_sample(GST_APP_SINK(sink));
> ...
> GstBuffer * buf = gst_sample_get_buffer(sample);
> if (!buf)
>         return false;
>
> // RETRIEVE META
> GstMetaMarking* meta = GST_META_MARKING_GET(buf);
> if (meta)
> {
> CV_WARN("GStreamer: META EXISTS");
> tsMeta = meta->in_timestamp;
> isLastMeta = meta->last;
> }
> else
> {
> CV_WARN("GStreamer: META IS EMPTY"); // so i'm always here
> }
>     GstMapInfo info;
>     if (!gst_buffer_map(buf, &info, GST_MAP_READ))
>     {
>         //something weird went wrong here. abort. abort.
>         CV_WARN("Failed to map GStreamerbuffer to system memory");
>         return false;
>     }
>
>     {
>         Mat src;
>         if (isOutputByteBuffer)
>             src = Mat(Size(info.size, 1), CV_8UC1, info.data);
>         else
>             src = Mat(sz, CV_MAKETYPE(CV_8U, channels), info.data);
>         CV_Assert(src.isContinuous());
>         src.copyTo(dst);
>     }
>     gst_buffer_unmap(buf, &info);
>
>
>
> So, here
>   GstMetaMarking* meta = GST_META_MARKING_GET(buf);
>
> i always get empty pointer. What is wrong here?
> _______________________________________________
> 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: How to retrieve attached custom meta information on receiver side?

bronstein87
Hi. Thanks for your answer. I decided to add meta info to rtp header. So i
have  pipeline:

( appsrc name=vsrc ! nvvidconv ! video/x-raw(memory:NVMM),format=NV12 !
omxh265enc MeasureEncoderLatency=true bitrate=20000000 control-rate=2 !
rtph265pay name=pay0 pt=96 )
If i correctly understood i need to set a probe at rtph265pay 'src' pad and
change GstRtpBuffer header there. So i added test probe, but it never gets
inside

static GstPadProbeReturntest_probe (GstPad *pad, GstPadProbeInfo *info,
gpointer user_data)
{
GstBuffer *buffer;
buffer = GST_PAD_PROBE_INFO_BUFFER (info);
buffer = gst_buffer_make_writable (buffer);
qDebug() << "probe works" << buffer;
 return GST_PAD_PROBE_OK;
}
void mediaConfigure (GstRTSPMediaFactory* factory, GstRTSPMedia* media,
gpointer user_data)
{
GstElement *element, *rtph265pay; GstPad *pad;
element = gst_rtsp_media_get_element (media);
rtph265pay = gst_bin_get_by_name_recurse_up (GST_BIN (element), "pay0");
qDebug() << "GET PAY" << rtph265pay;
 pad = gst_element_get_static_pad (rtph265pay, "src");
qDebug() << "GET PAD" << pad;
qDebug() << gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_BUFFER,
(GstPadProbeCallback) test_probe, NULL, NULL);
gst_object_unref (pad);
}

If i set "sink" instead of "src", probe works, but i need "src", correct?
What is wrong here?



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel