---------- Forwarded message ----------
From: Riccardo Corona <coronariccardo@gmail.com>
Date: 30-mag-2007 13.28
Subject: Re: [gst-devel] Fakesrc signal handoff question
To: Tim Muller <t.i.m@zen.co.uk>

This's my testing pipeline :

pipeline = gst_pipeline_new ("pipeline");
    fakesrc = gst_element_factory_make ("fakesrc", "source");
    decoder = gst_element_factory_make ("ffdec_mpeg4","mpeg4-decoder");
    videoscale = gst_element_factory_make ("videoscale", "scaling-video");
    par = gst_element_factory_make ("capsfilter", "dimens");
    videorate=gst_element_factory_make("videorate", "rateVideo");

    parFakesrc = gst_element_factory_make ("capsfilter", "fakeSrcType");

    parDDSink = gst_element_factory_make ("capsfilter", "ddSinkSetup");

    g_object_set (G_OBJECT(parFakesrc), "caps",
        gst_caps_new_simple ("video/mpeg",
        "width", G_TYPE_INT, 720,
        "height", G_TYPE_INT, 288,

    g_object_set (G_OBJECT(par), "caps",
      gst_caps_new_simple( "video/x-raw-yuv",
        "width", G_TYPE_INT, 720,
        "height", G_TYPE_INT, 576,NULL),
      NULL );

    g_object_set (G_OBJECT (fakesrc),
        "signal-handoffs", TRUE,
        "sizemin", 0,
        "sizemax", 30000,
        "sizetype", 3,
        "datarate", 2000,

    g_object_set (G_OBJECT (videorate),
        "in", 0,
        "out", 25,

    g_object_set (G_OBJECT(parDDSink), "caps",
        gst_caps_new_simple ("video/x-raw-rgb",
        "width", G_TYPE_INT, 720,
        "height", G_TYPE_INT, 576,

    conv = gst_element_factory_make ("ffmpegcolorspace", "converter");

    videosink = gst_element_factory_make ("directdrawsink", "directdraw");

    gst_bin_add_many (GST_BIN (pipeline),
            fakesrc, parFakesrc, decoder,videoscale ,par,videorate, conv,parDDSink, videosink, NULL);

    gst_element_link_many (fakesrc,parFakesrc,decoder,videoscale, par,videorate, conv, parDDSink, videosink, NULL);


Some of the pads are unusefull but I've leaved it...
I can't find any pads or element properties to convert my time_t (the time as seconds elapsed since midnight, January 1, 1970) to the TIME type that you are talking about.
However I've tried the buffer allocation with  GST_BUFFER_MALLOCDATA but nothing is changed.
I don't believe that is possible to run my MFC application with GST_DEBUG output, or I was unable to find a way to do it.
I see that offset parameter of gst_buffer increments with the first packets from 0 to X, it sounds good but the offset_end have a different value (the ending byte of the offset, I assume), so I've tried to force this value to the offset one but nothing to do.
I think that the problem is in timestamp value but I cannot find a way to escape from this hell...

2007/5/30, Tim Muller < t.i.m@zen.co.uk >:
Riccardo Corona < coronariccardo@gmail.com > wrote :


> Hi,during my test with gstreamer app for win32 I've used a fakesrc with
> an handoff function in which I obtain some mpeg4 fragment that is put into
> a gstbuffer. I've also used the right plugin to visualize the mpeg4 packet
> on my directdraw sink.

Some more details about the pipeline used would probably be helpful.

> It works weel only for the first 2-3 packets received and then the refresh
> of the images stops and, if I run in debug mode, I can see that some thread
> stop its execution but there isn't gstreamer thread. This is main part of
> may handoff:

> static void
> cb_handoff (GstElement *fakesrc, GstBuffer  *buffer, GstPad *pad,
>     gpointer user_data)
> {
>   MyClass* dlg=(MyClass*)user_data;
>  //fg_image is the object that contains the correct (I've checked it...)
>  //mpeg4 fragment
>  //dt contains the time of the fragment
>  //dlg->t is a struct tm that allows to obtain time_t
>  ...
>  buffer->timestamp = mktime(&dlg->t);//GST_CLOCK_TIME_NONE;

The timestamps you're creating, are they 0-based? (there may also be problems
due to fakesrc sending a newsegment event in BYTES format, but the videosink
expecting a TIME format, so it depends on your pipeline setup if there's an
element that converts it to TIME Format or not).

> //fg_image->pixel_ptr contains the mpeg4 image buffer
> gst_buffer_set_data(buffer,fg_image->pixel_ptr,fg_image->dimension);

Have you tried memcpy()'ing the data first, to make sure the data you're
passing is not invalidated while it makes its way through the pipeline?
Maybe something like (this assumes you're getting passed empty buffers, which
may not be the case if you've set certain fakesrc properties):

      g_memdup (fg_image->pixel_ptr,fg_image->dimension);
  GST_BUFFER_SIZE(buffer) = fg_image->dimension;

In case it's your handoff callback that stops being called, run your program with

  GST_DEBUG=basesrc:5 yourapp

(or whatever the way to set an environment variable is on win32) to see why it stops/pauses (see 'flow' or 'reason').


Riccardo Corona

Riccardo Corona