Decoder behaviour model

Tim-Philipp Müller t.i.m at zen.co.uk
Tue Nov 29 01:47:32 PST 2011


On Tue, 2011-11-29 at 01:28 -0800, Siber wrote:

> Ok, so now my decoder looks: if there is enough input data to decode so it
> will decode it

That's ok.

> if there isn't so it will save input data and wait for the
> next part of data.

That's good too (you may find GstAdapter useful).

> But I can't understand what exactly should my chain
> function return in following cases:
> 1. There is input data enough to decode not only one frame, but several
> frames.

You basically do something like:

  while (can_decode_frame()) {
    buf = decode_one_frame();
    flow = gst_pad_push (srcpad, buf);
    if (flow != GST_FLOW_OK)
      break;
  }
  return flow;

that is: push out as many frames as you can (but be sure to bail out if
you get a non-OK flow return).


> 2. The input data is not enough to decode even one frame.

You just hang onto the data you got (e.g. push it into a GstAdapter) and
return GST_FLOW_OK from your chain function so filesrc can push more
data to you.


> I think that in first case I should call gst_pad_push(src_pad,
> decoded_buffer) function as many times as much frames I can decode using the
> input buffer and then exit chain function returning
> <some_value_i_don't_know_exactly> .

You return the flow value you got from downstream when you did
gst_pad_push() to push out the buffers.

Cheers
 -Tim






More information about the gstreamer-devel mailing list