AW: AW: video play fast with gst new buffer allocation

Thornton, Keith keith.thornton at zeiss.com
Fri Mar 5 06:04:39 UTC 2021


Hi
Just as an example you might like to look at the following


        GstSample* pSample = gst_app_sink_pull_sample(appsink);
        if (!pSample) {
            MULTIMEDIA_ERROR << " sample == nullptr";
            return GST_FLOW_ERROR;
        }

        GstBuffer* pBuffer = gst_sample_get_buffer(pSample);
        if (!pBuffer) {
            MULTIMEDIA_ERROR << "failed to get buffer from sample";
            gst_sample_unref(pSample);
            return GST_FLOW_ERROR;
        }

        GstBuffer* pNewBuffer = gst_buffer_copy_deep(pBuffer);
        if (!pNewBuffer) {
            MULTIMEDIA_ERROR << "failed to create new buffer for streaming";
            return GST_FLOW_ERROR;
        }

        GstCaps* pNewCaps = gst_sample_get_caps(pSample);
        GstSegment* pSegment = gst_sample_get_segment(pSample);
        GstSample* pNewSample = gst_sample_new(pNewBuffer, pNewCaps, pSegment, nullptr);
        gst_sample_unref(pSample);

        if (! pNewSample) {
            MULTIMEDIA_ERROR << "failed to get buffer from sample";
            gst_buffer_unref(pNewBuffer);
            return GST_FLOW_ERROR;
        }


        GstFlowReturn ret = gst_app_src_push_sample(appSrc, pNewSample);
        if (ret == GST_FLOW_OK) {
            MULTIMEDIA_TRACE << "PTS=" << GST_BUFFER_PTS(pNewBuffer) << ", DTS=" << GST_BUFFER_DTS(pNewBuffer) << ", DURATION=" << GST_BUFFER_DURATION(pNewBuffer);
        }
        else {
            MULTIMEDIA_ERROR << "failed to push the buffer downstream, error code = " << ret;
            gst_buffer_unref(pNewBuffer);
            gst_sample_unref(pNewSample);
            return GST_FLOW_OK;
        }
        //        g_signal_emit_by_name(appsrc, "push-buffer", buffer, &ret);

        gst_buffer_unref(pNewBuffer);
        gst_sample_unref(pNewSample);
        return ret;
    }

-----Ursprüngliche Nachricht-----
Von: gstreamer-devel <gstreamer-devel-bounces at lists.freedesktop.org> Im Auftrag von anil0407
Gesendet: Donnerstag, 4. März 2021 12:46
An: gstreamer-devel at lists.freedesktop.org
Betreff: Re: AW: video play fast with gst new buffer allocation

Hi,

After adding PTS, DURATION and OFFSET stuff...small video is playing good but longer video getting hang.


Here the snippet code:
        buf = gst_buffer_make_writable (buf);
       
        buf_size = gst_buffer_get_size (buf);
        n_buf = gst_buffer_new_allocate (NULL, buf_size, NULL);
        gst_buffer_map (n_buf, &n_map, GST_MAP_WRITE);

        if (gst_buffer_map (buf, &map, GST_MAP_WRITE)) {
                ptr = (guint16 *) map.data;

                GST_BUFFER_DURATION (n_buf) = GST_BUFFER_DURATION (buf);
		GST_BUFFER_PTS (n_buf) = GST_BUFFER_PTS (buf);
		GST_BUFFER_OFFSET(n_buf) = GST_BUFFER_OFFSET(buf);

                memcpy((guint16 *)n_map.data, (guint16 *)ptr, buf_size);
                gst_buffer_unmap (buf, &map);
                gst_buffer_unmap (n_buf, &n_map);
                return gst_pad_push (filter->srcpad, n_buf);
        } 

Thanks,
Anil



--
Sent from: https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgstreamer-devel.966125.n4.nabble.com%2F&data=04%7C01%7C%7C24ac24cc2a714dd7d77908d8df205ed6%7C28042244bb514cd680347776fa3703e8%7C1%7C1%7C637504677425205352%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=OUFd3lMBycgau%2B1AwMh43nFOhJXnJpgyyWETk0arEcs%3D&reserved=0
_______________________________________________
gstreamer-devel mailing list
gstreamer-devel at lists.freedesktop.org
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Fgstreamer-devel&data=04%7C01%7C%7C24ac24cc2a714dd7d77908d8df205ed6%7C28042244bb514cd680347776fa3703e8%7C1%7C1%7C637504677425215306%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=JwuxvprEHMH5Tqf79Ax8VBxcC4Ut1krEk5ln%2F6etqbc%3D&reserved=0


More information about the gstreamer-devel mailing list