Insert data to pipe with UDPSRC

yxxone xuchangxue365812 at 126.com
Fri Nov 29 01:22:54 PST 2013


I find the tutorial given by Gdstreamer . It insert audio data like this:

static gboolean push_data (CustomData *data) {
  GstBuffer *buffer;
  GstFlowReturn ret;
  int i;
  gint16 *raw;
  gint num_samples = CHUNK_SIZE / 2; /* Because each sample is 16 bits */
  gfloat freq;
   
  /* Create a new empty buffer */
  buffer = gst_buffer_new_and_alloc (CHUNK_SIZE);
   
  /* Set its timestamp and duration */
  GST_BUFFER_TIMESTAMP (buffer) = gst_util_uint64_scale (data->num_samples,
GST_SECOND, SAMPLE_RATE);
  GST_BUFFER_DURATION (buffer) = gst_util_uint64_scale (CHUNK_SIZE,
GST_SECOND, SAMPLE_RATE);
   
  /* Generate some psychodelic waveforms */
  raw = (gint16 *)GST_BUFFER_DATA (buffer);
  data->c += data->d;
  data->d -= data->c / 1000;
  freq = 1100 + 1000 * data->d;
  for (i = 0; i < num_samples; i++) {
    data->a += data->b;
    data->b -= data->a / freq;
    raw[i] = (gint16)(500 * data->a);
  }
  data->num_samples += num_samples;
   
  /* Push the buffer into the appsrc */
  g_signal_emit_by_name (data->app_source, "push-buffer", buffer, &ret);
   
  /* Free the buffer now that we are done with it */
  gst_buffer_unref (buffer);
   
  if (ret != GST_FLOW_OK) {
    /* We got some error, stop sending data */
    return FALSE;
  }
  return TRUE;
}

I just get confused , shall I set timestamp and duration like this when I
insert my mp4 file into the pipeline?  dose the size of buffer size matter ?
if it dose, how can I set it correctly?

It use caps like this:
#define AUDIO_CAPS
"audio/x-raw-int,channels=1,rate=%d,signed=(boolean)true,width=16,depth=16,endianness=BYTE_ORDER"
what I want to know is , in my case, is "video/x-h264" enogh?  I just do not
know what property does an mp4 file have.



--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Insert-data-to-pipe-with-UDPSRC-tp4663693.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.


More information about the gstreamer-devel mailing list