How to implement a pull-based sink?

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

How to implement a pull-based sink?

Hsu France
Hi!

I'm a newbie for gstreamer and  working on a sink that I wish it would provide buffer for source. I think it would be a pull-based sink.

The GStreamer I used is gstreamer-0.10.25, gst-plugin-base-0.10.25, and gst-plaugin-good-0.10.17.

I implemented this sink based on base-sink, and added the virtual function: buffer_alloc() (gst_my_sink_buffer_alloc) and render() (gst_my_sink_render).

After trying:
GST_DEBUG=basesink:7,mysink:7 gst-launch fakesrc can-activate-pull=1 ! mysink

I found gstbasesink.c had set DEFAULT_CAN_ACTIVATE_PULL to FALSE, so I set it to TRUE, and get the follow log. It seems pull mode is enabled, but gst_my_sink_buffer_alloc and gst_my_sink_render are not called.

Does I make something wrong, or which sink can I use as reference?
Besides fakesrc, is there any pull-source for me to do test with gst-launch?

Thanks,

France Hsu

gst_my_sink_change_state: null to  ready
|
gst_my_sink_start
|
gst_my_sink_change_state: ready to pause
|
gst_base_sink_pad_activate
   |
   gst_base_sink_negotiate_pull
   |
   gst_base_sink_pad_activate_pull
|
gst_base_sink_loop
|
gst_my_sink_change_state: pause to playing
|
[ gst_base_sink_loop: pulling 0, 4096 ]*

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to implement a pull-based sink?

Tim-Philipp Müller-2
On Thu, 2010-02-04 at 11:49 +0800, Hsu France wrote:

Hi,

> I'm a newbie for gstreamer and  working on a sink that I wish it would
> provide buffer for source. I think it would be a pull-based sink.
>  (...)
> I implemented this sink based on base-sink, and added the virtual
> function: buffer_alloc() (gst_my_sink_buffer_alloc) and render()
> (gst_my_sink_render).

What kind of sink is this?

There's no need for the sink to operate in pull mode to be able to
provide buffers to upstream. It should be sufficient to implement a
buffer alloc function.

Take for example:

 $ GST_DEBUG=*src:5,*sink:5 videotestsrc num-buffers=2 ! ximagesink

This will operate in push mode, but videotestsrc will call
gst_pad_alloc_buffer() to get a buffer from ximagesink and then fill
that with data and push it back to ximagesink.

Pull mode for sinks is something that's not really used much in practice
and is rarely useful. Maybe you could provide some more details of what
you're trying to do?

 Cheers
  -Tim



------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to implement a pull-based sink?

Hsu France
In reply to this post by Hsu France
Hi! Tim,

Thanks for your reply.
I would misunderstand the meaning of "pull-mode sink".
You mean, pull-mode and buffer allocated by sink are two different things, right?

In the fact, my sink is for a HW device, so I want the source to use the HW buffer (allocated in sink) for data flow, not to allocate by source itself.

I wish to use udpsrc for the pipeline, and found it is based on GstPushSrc. (Therefore, I thought I should implement a pull-based sink, and find a pull-based source)
$ gst-launch udpsrc udp://IP:PORT ! mysink

However, my buffer_alloc function is not called.

France Hsu


Hi,

> I'm a newbie for gstreamer and  working on a sink that I wish it would
> provide buffer for source. I think it would be a pull-based sink.
>  (...)
> I implemented this sink based on base-sink, and added the virtual
> function: buffer_alloc() (gst_my_sink_buffer_alloc) and render()
> (gst_my_sink_render).

What kind of sink is this?

There's no need for the sink to operate in pull mode to be able to
provide buffers to upstream. It should be sufficient to implement a
buffer alloc function.

Take for example:

 $ GST_DEBUG=*src:5,*sink:5 videotestsrc num-buffers=2 ! ximagesink

This will operate in push mode, but videotestsrc will call
gst_pad_alloc_buffer() to get a buffer from ximagesink and then fill
that with data and push it back to ximagesink.

Pull mode for sinks is something that's not really used much in practice
and is rarely useful. Maybe you could provide some more details of what
you're trying to do?

 Cheers
 -Tim





------------------------------

Message: 3
Date: Thu, 4 Feb 2010 08:51:07 -0800 (PST)
From: na <[hidden email]>
Subject: [gst-devel] h264 playback, qtdemux issue
To: [hidden email]
Message-ID: <[hidden email]>
Content-Type: text/plain; charset=us-ascii


Hello,

I am new to gstreamer and I wanted to setup a pipeline that can playback an
h.264 video that is encapsulated within an MP4 container.

I am using the following command:

gst-launch -v --gst-debug-level=2 filesrc
location=hdv_0015_480p_384kbps_20fps.mp4 ! qtdemux ! ffdec_h264 ! ximagesink

I have attached the console output below.  Any help is greatly appreciated.
Thanks.

Best regards,

Nadeem

----------------------

gst-launch -v --gst-debug-level=2 filesrc
location=hdv_0015_480p_384kbps_20fps.mp4 ! qtdemux ! ffdec_h264 ! ximagesink
Setting pipeline to PAUSED ...
0:00:00.128491689  2421  0x91fcb78 WARN                 qtdemux
qtdemux_types.c:154:qtdemux_type_get: unknown QuickTime node type avc1
0:00:00.128991982  2421  0x91fcb78 WARN                 qtdemux
qtdemux_types.c:154:qtdemux_type_get: unknown QuickTime node type avcC
0:00:00.129232998  2421  0x91fcb78 WARN                 qtdemux
qtdemux.c:3186:qtdemux_parse_container:<qtdemux0> length too long (1572864 >
28)
0:00:00.129468726  2421  0x91fcb78 WARN                 qtdemux
qtdemux.c:3186:qtdemux_parse_container:<qtdemux0> length too long (1507328 >
27)
0:00:00.130451079  2421  0x91fcb78 WARN                 qtdemux
qtdemux.c:4907:qtdemux_parse_trak:<qtdemux0> unknown version 00000000
/GstPipeline:pipeline0/ffdec_h264:ffdec_h2640.GstPad:sink: caps =
video/x-h264,
codec_data=(buffer)01404033ffe1001d674d40339a7406c1ef3fffdd0fdd9a880000030008000003014478c19501000468ee3c80,
width=(int)852, height=(int)480, framerate=(fraction)143/7,
pixel-aspect-ratio=(fraction)847/852
Pipeline is PREROLLING ...
/GstPipeline:pipeline0/ffdec_h264:ffdec_h2640.GstPad:src: caps =
video/x-raw-yuv, width=(int)852, height=(int)480, framerate=(fraction)143/7,
format=(fourcc)I420, interlaced=(boolean)false,
pixel-aspect-ratio=(fraction)847/852
0:00:00.229889863  2421  0x91fcb78 WARN                 qtdemux
qtdemux.c:2645:gst_qtdemux_loop:<qtdemux0> error: streaming stopped, reason
not-negotiated
ERROR: from element /GstPipeline:pipeline0/GstQTDemux:qtdemux0: GStreamer
encountered a general stream error.
Additional debug info:
qtdemux.c(2645): gst_qtdemux_loop ():
/GstPipeline:pipeline0/GstQTDemux:qtdemux0:
streaming stopped, reason not-negotiated
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
/GstPipeline:pipeline0/ffdec_h264:ffdec_h2640.GstPad:src: caps = NULL
/GstPipeline:pipeline0/ffdec_h264:ffdec_h2640.GstPad:sink: caps = NULL
/GstPipeline:pipeline0/GstQTDemux:qtdemux0.GstPad:audio_00: caps = NULL
/GstPipeline:pipeline0/GstQTDemux:qtdemux0.GstPad:video_00: caps = NULL
Freeing pipeline ...

--
View this message in context: http://n4.nabble.com/h264-playback-qtdemux-issue-tp1469069p1469069.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.



------------------------------

Message: 4
Date: Thu, 4 Feb 2010 09:13:05 -0800
From: Michael Smith <[hidden email]>
Subject: Re: [gst-devel] h264 playback, qtdemux issue
To: Discussion of the development of GStreamer
       <[hidden email]>
Message-ID:
       <[hidden email]>
Content-Type: text/plain; charset=ISO-8859-1

On Thu, Feb 4, 2010 at 8:51 AM, na <[hidden email]> wrote:
>
> Hello,
>
> I am new to gstreamer and I wanted to setup a pipeline that can playback an
> h.264 video that is encapsulated within an MP4 container.
>
> I am using the following command:
>
> gst-launch -v --gst-debug-level=2 filesrc
> location=hdv_0015_480p_384kbps_20fps.mp4 ! qtdemux ! ffdec_h264 ! ximagesink

Use xvimagesink. In general it's also a good idea to have
ffmpegcolorspace in between the decoder and the video sink in case the
decoder is outputting a format that the sink can't accept.

Mike



------------------------------

Message: 5
Date: Thu, 04 Feb 2010 18:14:44 +0100
From: Wim Taymans <[hidden email]>
Subject: Re: [gst-devel] h264 playback, qtdemux issue
To: Discussion of the development of GStreamer
       <[hidden email]>
Message-ID: <1265303684.3283.100.camel@metal>
Content-Type: text/plain; charset="UTF-8"

On Thu, 2010-02-04 at 08:51 -0800, na wrote:
> Hello,
>
> I am new to gstreamer and I wanted to setup a pipeline that can playback an
> h.264 video that is encapsulated within an MP4 container.
>
> I am using the following command:
>
> gst-launch -v --gst-debug-level=2 filesrc
> location=hdv_0015_480p_384kbps_20fps.mp4 ! qtdemux ! ffdec_h264 ! ximagesink
>

Add ffmpegcolorspace before ximagesink or use:

gst-launch playbin2 uri=file:///path/to/file.mp4

Wim

> I have attached the console output below.  Any help is greatly appreciated.
> Thanks.
>
> Best regards,
>
> Nadeem
>
> ----------------------
>
> gst-launch -v --gst-debug-level=2 filesrc
> location=hdv_0015_480p_384kbps_20fps.mp4 ! qtdemux ! ffdec_h264 ! ximagesink
> Setting pipeline to PAUSED ...
> 0:00:00.128491689  2421  0x91fcb78 WARN                 qtdemux
> qtdemux_types.c:154:qtdemux_type_get: unknown QuickTime node type avc1
> 0:00:00.128991982  2421  0x91fcb78 WARN                 qtdemux
> qtdemux_types.c:154:qtdemux_type_get: unknown QuickTime node type avcC
> 0:00:00.129232998  2421  0x91fcb78 WARN                 qtdemux
> qtdemux.c:3186:qtdemux_parse_container:<qtdemux0> length too long (1572864 >
> 28)
> 0:00:00.129468726  2421  0x91fcb78 WARN                 qtdemux
> qtdemux.c:3186:qtdemux_parse_container:<qtdemux0> length too long (1507328 >
> 27)
> 0:00:00.130451079  2421  0x91fcb78 WARN                 qtdemux
> qtdemux.c:4907:qtdemux_parse_trak:<qtdemux0> unknown version 00000000
> /GstPipeline:pipeline0/ffdec_h264:ffdec_h2640.GstPad:sink: caps =
> video/x-h264,
> codec_data=(buffer)01404033ffe1001d674d40339a7406c1ef3fffdd0fdd9a880000030008000003014478c19501000468ee3c80,
> width=(int)852, height=(int)480, framerate=(fraction)143/7,
> pixel-aspect-ratio=(fraction)847/852
> Pipeline is PREROLLING ...
> /GstPipeline:pipeline0/ffdec_h264:ffdec_h2640.GstPad:src: caps =
> video/x-raw-yuv, width=(int)852, height=(int)480, framerate=(fraction)143/7,
> format=(fourcc)I420, interlaced=(boolean)false,
> pixel-aspect-ratio=(fraction)847/852
> 0:00:00.229889863  2421  0x91fcb78 WARN                 qtdemux
> qtdemux.c:2645:gst_qtdemux_loop:<qtdemux0> error: streaming stopped, reason
> not-negotiated
> ERROR: from element /GstPipeline:pipeline0/GstQTDemux:qtdemux0: GStreamer
> encountered a general stream error.
> Additional debug info:
> qtdemux.c(2645): gst_qtdemux_loop ():
> /GstPipeline:pipeline0/GstQTDemux:qtdemux0:
> streaming stopped, reason not-negotiated
> ERROR: pipeline doesn't want to preroll.
> Setting pipeline to NULL ...
> /GstPipeline:pipeline0/ffdec_h264:ffdec_h2640.GstPad:src: caps = NULL
> /GstPipeline:pipeline0/ffdec_h264:ffdec_h2640.GstPad:sink: caps = NULL
> /GstPipeline:pipeline0/GstQTDemux:qtdemux0.GstPad:audio_00: caps = NULL
> /GstPipeline:pipeline0/GstQTDemux:qtdemux0.GstPad:video_00: caps = NULL
> Freeing pipeline ...
>





------------------------------

Message: 6
Date: Thu, 04 Feb 2010 17:27:36 +0000
From: Tim-Philipp M?ller <[hidden email]>
Subject: Re: [gst-devel] h264 playback, qtdemux issue
To: [hidden email]
Message-ID: <1265304456.3607.32.camel@zingle>
Content-Type: text/plain; charset="UTF-8"

On Thu, 2010-02-04 at 18:14 +0100, Wim Taymans wrote:

> Add ffmpegcolorspace before ximagesink or use:

If you use ximagesink (and not e.g. xvimagesink), a videoscale may also
be needed, in case the image needs to be scaled to accommodate the
aspect ratio.

Cheers
 -Tim




------------------------------

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com

------------------------------

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel


End of gstreamer-devel Digest, Vol 45, Issue 8
**********************************************


------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to implement a pull-based sink?

Hsu France
In reply to this post by Hsu France
Dears,

I found the reason why my buffer_alloc() is not called.
So I answer this question by myself and for your reference if some body needs it.

At first, I used the udpsrc as my source, but udpsrc malloc the buffer itself, and doesn't use gst_pad_alloc_buffer(). gst_pad_alloc_buffer() will invoke the sink's buffer_alloc() function.

It is independent of pull-mode or push-mode.

The source, videotestsrc, is an example to use gst_pad_alloc_buffer().

France Hsu



Hi! Tim,

Thanks for your reply.
I would misunderstand the meaning of "pull-mode sink".
You mean, pull-mode and buffer allocated by sink are two different things,
right?

In the fact, my sink is for a HW device, so I want the source to use the HW
buffer (allocated in sink) for data flow, not to allocate by source itself.

I wish to use udpsrc for the pipeline, and found it is based on GstPushSrc.
(Therefore, I thought I should implement a pull-based sink, and find a
pull-based source)
$ gst-launch udpsrc udp://IP:PORT ! mysink

However, my buffer_alloc function is not called.

France Hsu


> Hi,
>
> > I'm a newbie for gstreamer and  working on a sink that I wish it would
> > provide buffer for source. I think it would be a pull-based sink.
> >  (...)
> > I implemented this sink based on base-sink, and added the virtual
> > function: buffer_alloc() (gst_my_sink_buffer_alloc) and render()
> > (gst_my_sink_render).
>
> What kind of sink is this?
>
> There's no need for the sink to operate in pull mode to be able to
> provide buffers to upstream. It should be sufficient to implement a
> buffer alloc function.
>
> Take for example:
>
>  $ GST_DEBUG=*src:5,*sink:5 videotestsrc num-buffers=2 ! ximagesink
>
> This will operate in push mode, but videotestsrc will call
> gst_pad_alloc_buffer() to get a buffer from ximagesink and then fill
> that with data and push it back to ximagesink.
>
> Pull mode for sinks is something that's not really used much in practice
> and is rarely useful. Maybe you could provide some more details of what
> you're trying to do?
>
>  Cheers
>  -Tim
>
>

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel