3

Is there a way to limit gstreamer's udpsink, if I'm sending out data without demultiplexing it?

I have a pipe that needs to send out the stream unmultiplexed.

filesrc ! tee name=t ! tsdemux ! ffdec_h264 ! videosink t. udpsink

Where the main concern is this: filesrc ! udpsink

I don't see any way to limit it via the filesrc, queue, or udpsink options. Using sync doesn't work since, I'm assuming, there's no media stream to sync to. So, the result of using that pipeline is that the data is fed through the udpsink as fast as possible, which the receiving udpsrc can't handle.

We've tried writing our own udpsink using the appsrc as a base element, with this packet limit scheme (there's a thread.sleep(throttleDelay); in the packet sending method):

/**
 * Update the delay to pause the packet sending thread.
 * Calculated by dividing how many bytes (roughly) need to be sent <code>packMaxSize</code>
 * by the target bytes/sec rate to get how many seconds are needed. Then multiplying to get
 * time in milliseconds.
 */
private void updateThrottle() {
  if (targetRate > 0)
  {
    throttleDelay = (long)((1000.0 * packetMaxSize) / (double)targetRate);
    if (throttleDelay < 0) {
      throttleDelay = 0;
    }
  } else {
    throttleDelay = 0;
  }
}

But this doesn't seem to work no matter what the speed is set to. Too slow and one frame gets through. Too fast and one or two get through. At the 'right' speed (500 kB/s), frames come in at 0.5-2 FPS, but it's horribly corrupted.

Is this the correct way to go about this in code? Does gstreamer have any way to limit throughput?

Nick
  • 4,901
  • 40
  • 61

1 Answers1

0

What you probably want to do is to use RTP as your transport-protocol. By using the supplied rtph264pay you get to set the MTU size, so something like:

filesrc !  tsdemux ! tee name=t ! ffdec_h264 ! videosink t. rtph264pay mtu=1300 ! udpsink

Should to the trick.

Havard Graff
  • 2,805
  • 1
  • 15
  • 16
  • 1
    Isn't the issue with this that you can't send the file across unmultiplexed (as specified in the question)? I've also been trying to get a file (MKV) across via UDP, but haven't been able to successfully. I have been able to get a single video stream across using RTP though - similarly to how you've described. – Adam Goodwin Jul 09 '13 at 11:23