GStreamer Source Element for Proprietary Security Device

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

GStreamer Source Element for Proprietary Security Device

Mandar Joshi
Hello,
I have the task of developing a GStreamer source element for a proprietary security device. The SDK is Linux based and I have the SDK linked with the GStreamer element. Currently, the element is GstPushSrc based, and in its very basic form can write data received from the security device to a FILE using fwrite and this file is playable using mpv. No GstBuffers or filesink yet.

Here's what I need/want to do and in the remainder of the email, it'll hopefully become clear on which areas I'm seeking inputs.

The SDK has a callback that allows data from the security device to be retrieved in a callback. It's not pull-based or something I can read some 1000 bytes at a time and then fill into a GstBuffer in the _fill function of a GstPushSrc based element. Now, I need to push it out of the source element and have to processed/dumped to file by various GStreamer elements. I'm seeking some assistance on this.

Is it possible to store whatever is read in the proprietary SDK callback in say a buffer and then fill it into the GstBuffer in the _fill function?

I've attached the progress I've made with this email. Names changed for obvious reasons as there is an NDA involved.

Given the problems I'm facing, I'm even considering if an appsrc based solution would better. I would prefer a source element as the solution becomes elegant this way but I'm still open to suggestions.

Guys, any suggestions appreciated.

Being under an NDA, I'm not allowed to disclose all the details but I'll reveal as much as I can. Could you guys have a look at sourcelement.cpp and sourcelement.h to see what I'm trying to achieve?

Regards,
Mandar Joshi
Czar Softech

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

sourceelement.h (1K) Download Attachment
sourceelement.cpp (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: GStreamer Source Element for Proprietary Security Device

Nicolas Dufresne-5


Le dim. 5 juill. 2020 14 h 45, Mandar Joshi <[hidden email]> a écrit :
Hello,
I have the task of developing a GStreamer source element for a proprietary security device. The SDK is Linux based and I have the SDK linked with the GStreamer element. Currently, the element is GstPushSrc based, and in its very basic form can write data received from the security device to a FILE using fwrite and this file is playable using mpv. No GstBuffers or filesink yet.

Here's what I need/want to do and in the remainder of the email, it'll hopefully become clear on which areas I'm seeking inputs.

The SDK has a callback that allows data from the security device to be retrieved in a callback. It's not pull-based or something I can read some 1000 bytes at a time and then fill into a GstBuffer in the _fill function of a GstPushSrc based element. Now, I need to push it out of the source element and have to processed/dumped to file by various GStreamer elements. I'm seeking some assistance on this.

Is it possible to store whatever is read in the proprietary SDK callback in say a buffer and then fill it into the GstBuffer in the _fill function?

I've attached the progress I've made with this email. Names changed for obvious reasons as there is an NDA involved.

Given the problems I'm facing, I'm even considering if an appsrc based solution would better. I would prefer a source element as the solution becomes elegant this way but I'm still open to suggestions.

Guys, any suggestions appreciated.

This is quite common. What we usually do is queue the called back buffer, and send them using the create() virtual function. If the queue is empty, we wait.


Being under an NDA, I'm not allowed to disclose all the details but I'll reveal as much as I can. Could you guys have a look at sourcelement.cpp and sourcelement.h to see what I'm trying to achieve?

Regards,
Mandar Joshi
Czar Softech
_______________________________________________
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: GStreamer Source Element for Proprietary Security Device

Mandar Joshi

This is quite common. What we usually do is queue the called back buffer, and send them using the create() virtual function. If the queue is empty, we wait.

Thank You so much Nicolas for the input. I was overriding just the _fill virtual function and that was leading to unimaginably large files and unplayable files with filesink.

I'm at a bit of a loss here on how to go about writing the element. I found Stirling Westrup's notes here http://gstreamer-devel.966125.n4.nabble.com/Writing-Source-Help-td4667076.html although I feel referring to a similar source element would be largely helpful. Is there such an element I can refer to?

The neonhttpsrc and frei0r elements are there but I don't think they are quite like what I want to do, are they?

Regards
Mandar Joshi
Czar Softech

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

Re: GStreamer Source Element for Proprietary Security Device

Josh Doe
On Sun, Jul 5, 2020 at 10:58 PM Mandar Joshi <[hidden email]> wrote:

This is quite common. What we usually do is queue the called back buffer, and send them using the create() virtual function. If the queue is empty, we wait.

Thank You so much Nicolas for the input. I was overriding just the _fill virtual function and that was leading to unimaginably large files and unplayable files with filesink. 

I've done this several times in various ways, to share a buffer created in a callback with create() or fill(). For matroxsrc[0] I used a single mutex protected buffer, and for kayasrc[1] I've used GAsyncQueue.


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

Re: GStreamer Source Element for Proprietary Security Device

Nicolas Dufresne-5
Le lundi 06 juillet 2020 à 08:13 -0400, Josh Doe a écrit :

> On Sun, Jul 5, 2020 at 10:58 PM Mandar Joshi <[hidden email]> wrote:
> > > This is quite common. What we usually do is queue the called back buffer, and send them using the create() virtual function. If the queue is empty, we wait.
> > >
> > >
> >
> > Thank You so much Nicolas for the input. I was overriding just the _fill virtual function and that was leading to unimaginably large files and unplayable files with filesink.
> >
>
> I've done this several times in various ways, to share a buffer created in a callback with create() or fill(). For matroxsrc[0] I used a single mutex protected buffer, and for kayasrc[1] I've used GAsyncQueue.
>
> [0]: https://github.com/joshdoe/gst-plugins-vision/blob/master/sys/matrox/gstmatroxsrc.c
> [1]: https://github.com/joshdoe/gst-plugins-vision/blob/master/sys/kaya/gstkayasrc.c

And some more (they are a bit countless):

https://git.linuxtv.org/libcamera.git/tree/src/gstreamer/gstlibcamerasrc.cpp
https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/blob/master/sys/v4l2/gstv4l2src.c
https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/blob/master/sys/winks/gstksvideosrc.c

> _______________________________________________
> 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: GStreamer Source Element for Proprietary Security Device

Mandar Joshi
Hello guys,
> I've done this several times in various ways, to share a buffer created in a callback with create() or fill(). For matroxsrc[0] I used a single mutex protected buffer, and for kayasrc[1] I've used GAsyncQueue.
>
> [0]: https://github.com/joshdoe/gst-plugins-vision/blob/master/sys/matrox/gstmatroxsrc.c
> [1]: https://github.com/joshdoe/gst-plugins-vision/blob/master/sys/kaya/gstkayasrc.c

John, the matrox example especially is going to be really useful.

And some more (they are a bit countless):

https://git.linuxtv.org/libcamera.git/tree/src/gstreamer/gstlibcamerasrc.cpp
https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/blob/master/sys/v4l2/gstv4l2src.c
https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/blob/master/sys/winks/gstksvideosrc.c


Thank You so much Nicolas for the examples. They are certainly going to be useful. 

My schedule os packed for a few days but I'll certainly make sure whatever the result is of my experiments, it gets documented to whatever extent possible.

Warm regards,
Mandar Joshi
Czar Softech

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

Re: GStreamer Source Element for Proprietary Security Device

Mandar Joshi
Hello Nicolas & Josh,
Thank You so much. GAsyncQueue seems to have worked. I've been able to get the data out of the device. Not able to get it into an MP4 container but this is a start. I think the codec data is missing. The goal is WebRTC or RTSP or some live streaming mechanism. Have to work on that.

Sorry I referred to Josh as John. My mistake. Honestly, it was a typing error.

Warm regards,
Mandar Joshi
Czar Softech

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