您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ GST_BUFFER_OFFSET函数代码示例

51自学网 2021-06-01 20:56:04
  C++
这篇教程C++ GST_BUFFER_OFFSET函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中GST_BUFFER_OFFSET函数的典型用法代码示例。如果您正苦于以下问题:C++ GST_BUFFER_OFFSET函数的具体用法?C++ GST_BUFFER_OFFSET怎么用?C++ GST_BUFFER_OFFSET使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了GST_BUFFER_OFFSET函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: gstbt_audio_synth_create

static GstFlowReturngstbt_audio_synth_create (GstBaseSrc * basesrc, guint64 offset,    guint length, GstBuffer ** buffer){  GstBtAudioSynth *src = GSTBT_AUDIO_SYNTH (basesrc);  GstBtAudioSynthClass *klass = GSTBT_AUDIO_SYNTH_GET_CLASS (src);  GstFlowReturn res;  GstBuffer *buf;  GstMapInfo info;  GstClockTime next_running_time, ticktime;  gint64 n_samples;  gdouble samples_done;  guint samples_per_buffer;  gboolean partial_buffer = FALSE;  if (G_UNLIKELY (src->eos_reached)) {    GST_WARNING_OBJECT (src, "EOS reached");    return GST_FLOW_EOS;  }  // the amount of samples to produce (handle rounding errors by collecting left over fractions)  samples_done =      (gdouble) src->running_time * (gdouble) src->info.rate /      (gdouble) GST_SECOND;  if (!src->reverse) {    samples_per_buffer =        (guint) (src->samples_per_buffer + (samples_done -            (gdouble) src->n_samples));  } else {    samples_per_buffer =        (guint) (src->samples_per_buffer + ((gdouble) src->n_samples -            samples_done));  }  GST_DEBUG_OBJECT (src,      "samples_done=%lf, src->n_samples=%" G_GUINT64_FORMAT      ", src->n_samples_stop=%" G_GUINT64_FORMAT,      samples_done, src->n_samples, src->n_samples_stop);  GST_DEBUG_OBJECT (src, "samples-per-buffer=%7u (%8.3lf), length=%u",      samples_per_buffer, src->samples_per_buffer, length);  /* check for eos */  if (src->check_eos) {    if (!src->reverse) {      partial_buffer = ((src->n_samples_stop >= src->n_samples) &&          (src->n_samples_stop < src->n_samples + samples_per_buffer));    } else {      partial_buffer = ((src->n_samples_stop < src->n_samples) &&          (src->n_samples_stop >= src->n_samples - samples_per_buffer));    }  }  if (G_UNLIKELY (partial_buffer)) {    /* calculate only partial buffer */    if (!src->reverse) {      src->generate_samples_per_buffer =          (guint) (src->n_samples_stop - src->n_samples);      ticktime = src->stop_time - src->running_time;    } else {      src->generate_samples_per_buffer =          (guint) (src->n_samples - src->n_samples_stop);      ticktime = src->running_time - src->stop_time;    }    if (G_UNLIKELY (!src->generate_samples_per_buffer)) {      GST_WARNING_OBJECT (src, "0 samples left -> EOS reached");      src->eos_reached = TRUE;      return GST_FLOW_EOS;    }    n_samples = src->n_samples_stop;    src->eos_reached = TRUE;    GST_INFO_OBJECT (src, "partial buffer: %u, ticktime: %" GST_TIME_FORMAT,        src->generate_samples_per_buffer, GST_TIME_ARGS (ticktime));  } else {    /* calculate full buffer */    src->generate_samples_per_buffer = samples_per_buffer;    n_samples =        src->n_samples +        (src->reverse ? (-samples_per_buffer) : samples_per_buffer);    ticktime = src->ticktime;  }  next_running_time =      src->running_time + (src->reverse ? (-ticktime) : ticktime);  src->ticktime_err_accum =      src->ticktime_err_accum +      (src->reverse ? (-src->ticktime_err) : src->ticktime_err);  res = GST_BASE_SRC_GET_CLASS (basesrc)->alloc (basesrc, src->n_samples,      gstbt_audio_synth_calculate_buffer_size (src), &buf);  if (G_UNLIKELY (res != GST_FLOW_OK)) {    return res;  }  if (!src->reverse) {    GST_BUFFER_TIMESTAMP (buf) =        src->running_time + (GstClockTime) src->ticktime_err_accum;    GST_BUFFER_DURATION (buf) = next_running_time - src->running_time;    GST_BUFFER_OFFSET (buf) = src->n_samples;    GST_BUFFER_OFFSET_END (buf) = n_samples;  } else {    GST_BUFFER_TIMESTAMP (buf) =        next_running_time + (GstClockTime) src->ticktime_err_accum;//.........这里部分代码省略.........
开发者ID:Buzztrax,项目名称:buzztrax,代码行数:101,


示例2: data_proc

static OSErrdata_proc (SGChannel c, Ptr p, long len, long *offset, long chRefCon,    TimeValue time, short writeType, long refCon){  GstOSXVideoSrc *self;  gint fps_n, fps_d;  GstClockTime duration, timestamp, latency;  CodecFlags flags;  ComponentResult err;  PixMapHandle hPixMap;  Rect portRect;  int pix_rowBytes;  void *pix_ptr;  int pix_height;  int pix_size;  self = GST_OSX_VIDEO_SRC (refCon);  if (self->buffer != NULL) {    gst_buffer_unref (self->buffer);    self->buffer = NULL;  }  err = DecompressSequenceFrameS (self->dec_seq, p, len, 0, &flags, NULL);  if (err != noErr) {    GST_ERROR_OBJECT (self, "DecompressSequenceFrameS returned %d", (int) err);    return err;  }  hPixMap = GetGWorldPixMap (self->world);  LockPixels (hPixMap);  GetPortBounds (self->world, &portRect);  pix_rowBytes = (int) GetPixRowBytes (hPixMap);  pix_ptr = GetPixBaseAddr (hPixMap);  pix_height = (portRect.bottom - portRect.top);  pix_size = pix_rowBytes * pix_height;  GST_DEBUG_OBJECT (self, "num=%5d, height=%d, rowBytes=%d, size=%d",      self->seq_num, pix_height, pix_rowBytes, pix_size);  fps_n = FRAMERATE;  fps_d = 1;  duration = gst_util_uint64_scale_int (GST_SECOND, fps_d, fps_n);  latency = duration;  timestamp = gst_clock_get_time (GST_ELEMENT_CAST (self)->clock);  timestamp -= gst_element_get_base_time (GST_ELEMENT_CAST (self));  if (timestamp > latency)    timestamp -= latency;  else    timestamp = 0;  self->buffer = gst_buffer_new_and_alloc (pix_size);  GST_BUFFER_OFFSET (self->buffer) = self->seq_num;  GST_BUFFER_TIMESTAMP (self->buffer) = timestamp;  memcpy (GST_BUFFER_DATA (self->buffer), pix_ptr, pix_size);  self->seq_num++;  UnlockPixels (hPixMap);  return noErr;}
开发者ID:ChinnaSuhas,项目名称:ossbuild,代码行数:64,


示例3: gst_pad_probe_info_get_buffer

GstPadProbeReturn GstEnginePipeline::HandoffCallback(GstPad*,                                                     GstPadProbeInfo* info,                                                     gpointer self) {  GstEnginePipeline* instance = reinterpret_cast<GstEnginePipeline*>(self);  GstBuffer* buf = gst_pad_probe_info_get_buffer(info);  QList<BufferConsumer*> consumers;  {    QMutexLocker l(&instance->buffer_consumers_mutex_);    consumers = instance->buffer_consumers_;  }  for (BufferConsumer* consumer : consumers) {    gst_buffer_ref(buf);    consumer->ConsumeBuffer(buf, instance->id());  }  // Calculate the end time of this buffer so we can stop playback if it's  // after the end time of this song.  if (instance->end_offset_nanosec_ > 0) {    quint64 start_time = GST_BUFFER_TIMESTAMP(buf) - instance->segment_start_;    quint64 duration = GST_BUFFER_DURATION(buf);    quint64 end_time = start_time + duration;    if (end_time > instance->end_offset_nanosec_) {      if (instance->has_next_valid_url()) {        if (instance->next_url_ == instance->url_ &&            instance->next_beginning_offset_nanosec_ ==                instance->end_offset_nanosec_) {          // The "next" song is actually the next segment of this file - so          // cheat and keep on playing, but just tell the Engine we've moved on.          instance->end_offset_nanosec_ = instance->next_end_offset_nanosec_;          instance->next_url_ = QUrl();          instance->next_beginning_offset_nanosec_ = 0;          instance->next_end_offset_nanosec_ = 0;          // GstEngine will try to seek to the start of the new section, but          // we're already there so ignore it.          instance->ignore_next_seek_ = true;          emit instance->EndOfStreamReached(instance->id(), true);        } else {          // We have a next song but we can't cheat, so move to it normally.          instance->TransitionToNext();        }      } else {        // There's no next song        emit instance->EndOfStreamReached(instance->id(), false);      }    }  }  if (instance->emit_track_ended_on_time_discontinuity_) {    if (GST_BUFFER_FLAG_IS_SET(buf, GST_BUFFER_FLAG_DISCONT) ||        GST_BUFFER_OFFSET(buf) < instance->last_buffer_offset_) {      qLog(Debug) << "Buffer discontinuity - emitting EOS";      instance->emit_track_ended_on_time_discontinuity_ = false;      emit instance->EndOfStreamReached(instance->id(), true);    }  }  instance->last_buffer_offset_ = GST_BUFFER_OFFSET(buf);  return GST_PAD_PROBE_OK;}
开发者ID:ivovegter,项目名称:Clementine,代码行数:64,


示例4: gst_wavpack_dec_handle_frame

//.........这里部分代码省略.........    dec->sample_rate = WavpackGetSampleRate (dec->context);    dec->channels = WavpackGetNumChannels (dec->context);    dec->depth = WavpackGetBytesPerSample (dec->context) * 8;#ifdef WAVPACK_OLD_API    channel_mask = dec->context->config.channel_mask;#else    channel_mask = WavpackGetChannelMask (dec->context);#endif    if (channel_mask == 0)      channel_mask = gst_wavpack_get_default_channel_mask (dec->channels);    dec->channel_mask = channel_mask;    gst_wavpack_dec_negotiate (dec);    /* send GST_TAG_AUDIO_CODEC and GST_TAG_BITRATE tags before something     * is decoded or after the format has changed */    gst_wavpack_dec_post_tags (dec);  }  /* alloc output buffer */  dec_data = g_malloc (4 * wph.block_samples * dec->channels);  /* decode */  decoded = WavpackUnpackSamples (dec->context, dec_data, wph.block_samples);  if (decoded != wph.block_samples)    goto decode_error;  unpacked_size = (dec->width / 8) * wph.block_samples * dec->channels;  outbuf = gst_buffer_new_and_alloc (unpacked_size);  /* legacy; pass along offset, whatever that might entail */  GST_BUFFER_OFFSET (outbuf) = GST_BUFFER_OFFSET (buf);  gst_buffer_map (outbuf, &omap, GST_MAP_WRITE);  out_data = omap.data;  width = dec->width;  depth = dec->depth;  max = dec->channels * wph.block_samples;  if (width == 8) {    gint8 *outbuffer = (gint8 *) out_data;    gint *reorder_map = dec->channel_reorder_map;    for (i = 0; i < max; i += dec->channels) {      for (j = 0; j < dec->channels; j++)        *outbuffer++ = (gint8) (dec_data[i + reorder_map[j]]);    }  } else if (width == 16) {    gint16 *outbuffer = (gint16 *) out_data;    gint *reorder_map = dec->channel_reorder_map;    for (i = 0; i < max; i += dec->channels) {      for (j = 0; j < dec->channels; j++)        *outbuffer++ = (gint16) (dec_data[i + reorder_map[j]]);    }  } else if (dec->width == 32) {    gint32 *outbuffer = (gint32 *) out_data;    gint *reorder_map = dec->channel_reorder_map;    if (width != depth) {      for (i = 0; i < max; i += dec->channels) {        for (j = 0; j < dec->channels; j++)          *outbuffer++ =              (gint32) (dec_data[i + reorder_map[j]] << (width - depth));
开发者ID:Lachann,项目名称:gst-plugins-good,代码行数:67,


示例5: gst_jif_mux_recombine_image

static GstFlowReturngst_jif_mux_recombine_image (GstJifMux * self, GstBuffer ** new_buf,                             GstBuffer * old_buf){    GstBuffer *buf;    GstByteWriter *writer;    GstFlowReturn fret;    GstJifMuxMarker *m;    GList *node;    guint size = self->priv->scan_size;    gboolean writer_status = TRUE;    /* iterate list and collect size */    for (node = self->priv->markers; node; node = g_list_next (node)) {        m = (GstJifMuxMarker *) node->data;        /* some markers like e.g. SOI are empty */        if (m->size) {            size += 2 + m->size;        }        /* 0xff <marker> */        size += 2;    }    GST_INFO_OBJECT (self, "old size: %u, new size: %u",                     GST_BUFFER_SIZE (old_buf), size);    /* allocate new buffer */    fret = gst_pad_alloc_buffer_and_set_caps (self->priv->srcpad,            GST_BUFFER_OFFSET (old_buf), size, GST_PAD_CAPS (self->priv->srcpad),            &buf);    if (fret != GST_FLOW_OK)        goto no_buffer;    /* copy buffer metadata */    gst_buffer_copy_metadata (buf, old_buf,                              GST_BUFFER_COPY_FLAGS | GST_BUFFER_COPY_TIMESTAMPS);    /* memcopy markers */    writer = gst_byte_writer_new_with_buffer (buf, TRUE);    for (node = self->priv->markers; node && writer_status;            node = g_list_next (node)) {        m = (GstJifMuxMarker *) node->data;        writer_status &= gst_byte_writer_put_uint8 (writer, 0xff);        writer_status &= gst_byte_writer_put_uint8 (writer, m->marker);        GST_DEBUG_OBJECT (self, "marker = %2x, size = %u", m->marker, m->size + 2);        if (m->size) {            writer_status &= gst_byte_writer_put_uint16_be (writer, m->size + 2);            writer_status &= gst_byte_writer_put_data (writer, m->data, m->size);        }        if (m->marker == SOS) {            GST_DEBUG_OBJECT (self, "scan data, size = %u", self->priv->scan_size);            writer_status &=                gst_byte_writer_put_data (writer, self->priv->scan_data,                                          self->priv->scan_size);        }    }    gst_byte_writer_free (writer);    if (!writer_status) {        GST_WARNING_OBJECT (self, "Failed to write to buffer, calculated size "                            "was probably too short");        g_assert_not_reached ();    }    *new_buf = buf;    return GST_FLOW_OK;no_buffer:    GST_WARNING_OBJECT (self, "failed to allocate output buffer, flow_ret = %s",                        gst_flow_get_name (fret));    return fret;}
开发者ID:neduartes,项目名称:gst-plugins-bad,代码行数:76,


示例6: do_perfect_stream_test

static voiddo_perfect_stream_test (guint rate, guint width, gdouble drop_probability,    gdouble inject_probability){  GstElement *pipe, *src, *conv, *filter, *injector, *audiorate, *sink;  GstMessage *msg;  GstCaps *caps;  GstPad *srcpad;  GList *l, *bufs = NULL;  GstClockTime next_time = GST_CLOCK_TIME_NONE;  guint64 next_offset = GST_BUFFER_OFFSET_NONE;  caps = gst_caps_new_simple ("audio/x-raw-int", "rate", G_TYPE_INT,      rate, "width", G_TYPE_INT, width, NULL);  GST_INFO ("-------- drop=%.0f%% caps = %" GST_PTR_FORMAT " ---------- ",      drop_probability * 100.0, caps);  g_assert (drop_probability >= 0.0 && drop_probability <= 1.0);  g_assert (inject_probability >= 0.0 && inject_probability <= 1.0);  g_assert (width > 0 && (width % 8) == 0);  pipe = gst_pipeline_new ("pipeline");  fail_unless (pipe != NULL);  src = gst_element_factory_make ("audiotestsrc", "audiotestsrc");  fail_unless (src != NULL);  g_object_set (src, "num-buffers", 100, NULL);  conv = gst_element_factory_make ("audioconvert", "audioconvert");  fail_unless (conv != NULL);  filter = gst_element_factory_make ("capsfilter", "capsfilter");  fail_unless (filter != NULL);  g_object_set (filter, "caps", caps, NULL);  injector_inject_probability = inject_probability;  injector = GST_ELEMENT (g_object_new (test_injector_get_type (), NULL));  srcpad = gst_element_get_static_pad (injector, "src");  fail_unless (srcpad != NULL);  gst_pad_add_buffer_probe (srcpad, G_CALLBACK (probe_cb), &drop_probability);  gst_object_unref (srcpad);  audiorate = gst_element_factory_make ("audiorate", "audiorate");  fail_unless (audiorate != NULL);  sink = gst_element_factory_make ("fakesink", "fakesink");  fail_unless (sink != NULL);  g_object_set (sink, "signal-handoffs", TRUE, NULL);  g_signal_connect (sink, "handoff", G_CALLBACK (got_buf), &bufs);  gst_bin_add_many (GST_BIN (pipe), src, conv, filter, injector, audiorate,      sink, NULL);  gst_element_link_many (src, conv, filter, injector, audiorate, sink, NULL);  fail_unless_equals_int (gst_element_set_state (pipe, GST_STATE_PLAYING),      GST_STATE_CHANGE_ASYNC);  fail_unless_equals_int (gst_element_get_state (pipe, NULL, NULL, -1),      GST_STATE_CHANGE_SUCCESS);  msg = gst_bus_poll (GST_ELEMENT_BUS (pipe),      GST_MESSAGE_EOS | GST_MESSAGE_ERROR, -1);  fail_unless_equals_string (GST_MESSAGE_TYPE_NAME (msg), "eos");  for (l = bufs; l != NULL; l = l->next) {    GstBuffer *buf = GST_BUFFER (l->data);    guint num_samples;    fail_unless (GST_BUFFER_TIMESTAMP_IS_VALID (buf));    fail_unless (GST_BUFFER_DURATION_IS_VALID (buf));    fail_unless (GST_BUFFER_OFFSET_IS_VALID (buf));    fail_unless (GST_BUFFER_OFFSET_END_IS_VALID (buf));    GST_LOG ("buffer: ts=%" GST_TIME_FORMAT ", end_ts=%" GST_TIME_FORMAT        " off=%" G_GINT64_FORMAT ", end_off=%" G_GINT64_FORMAT,        GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),        GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf) + GST_BUFFER_DURATION (buf)),        GST_BUFFER_OFFSET (buf), GST_BUFFER_OFFSET_END (buf));    if (GST_CLOCK_TIME_IS_VALID (next_time)) {      fail_unless_equals_uint64 (next_time, GST_BUFFER_TIMESTAMP (buf));    }    if (next_offset != GST_BUFFER_OFFSET_NONE) {      fail_unless_equals_uint64 (next_offset, GST_BUFFER_OFFSET (buf));    }    /* check buffer size for sanity */    fail_unless_equals_int (GST_BUFFER_SIZE (buf) % (width / 8), 0);    /* check there is actually as much data as there should be */    num_samples = GST_BUFFER_OFFSET_END (buf) - GST_BUFFER_OFFSET (buf);    fail_unless_equals_int (GST_BUFFER_SIZE (buf), num_samples * (width / 8));//.........这里部分代码省略.........
开发者ID:ChinnaSuhas,项目名称:ossbuild,代码行数:101,


示例7: gst_buffer_create_sub

/** * gst_buffer_create_sub: * @parent: a #GstBuffer. * @offset: the offset into parent #GstBuffer at which the new sub-buffer  *          begins. * @size: the size of the new #GstBuffer sub-buffer, in bytes. * * Creates a sub-buffer from @parent at @offset and @size. * This sub-buffer uses the actual memory space of the parent buffer. * This function will copy the offset and timestamp fields when the * offset is 0. If not, they will be set to #GST_CLOCK_TIME_NONE and  * #GST_BUFFER_OFFSET_NONE. * If @offset equals 0 and @size equals the total size of @buffer, the * duration and offset end fields are also copied. If not they will be set * to #GST_CLOCK_TIME_NONE and #GST_BUFFER_OFFSET_NONE. * * MT safe. * Returns: the new #GstBuffer. * Returns NULL if the arguments were invalid. */GstBuffer *gst_buffer_create_sub (GstBuffer * buffer, guint offset, guint size){  GstBuffer *subbuffer;  GstBuffer *parent;  gboolean complete;  g_return_val_if_fail (buffer != NULL, NULL);  g_return_val_if_fail (buffer->mini_object.refcount > 0, NULL);  g_return_val_if_fail (buffer->size >= offset + size, NULL);  /* find real parent */  if (GST_IS_SUBBUFFER (buffer)) {    parent = buffer->parent;  } else {    parent = buffer;  }  gst_buffer_ref (parent);  /* create the new buffer */  subbuffer = gst_buffer_new ();  subbuffer->parent = parent;  GST_BUFFER_FLAG_SET (subbuffer, GST_BUFFER_FLAG_READONLY);  GST_CAT_LOG (GST_CAT_BUFFER, "new subbuffer %p (parent %p)", subbuffer,      parent);  /* set the right values in the child */  GST_BUFFER_DATA (subbuffer) = buffer->data + offset;  GST_BUFFER_SIZE (subbuffer) = size;  if ((offset == 0) && (size == GST_BUFFER_SIZE (buffer))) {    /* copy all the flags except IN_CAPS */    GST_BUFFER_FLAG_SET (subbuffer, GST_BUFFER_FLAGS (buffer));    GST_BUFFER_FLAG_UNSET (subbuffer, GST_BUFFER_FLAG_IN_CAPS);  } else {    /* copy only PREROLL & GAP flags */    GST_BUFFER_FLAG_SET (subbuffer, (GST_BUFFER_FLAGS (buffer) &            (GST_BUFFER_FLAG_PREROLL | GST_BUFFER_FLAG_GAP)));  }  /* we can copy the timestamp and offset if the new buffer starts at   * offset 0 */  if (offset == 0) {    GST_BUFFER_TIMESTAMP (subbuffer) = GST_BUFFER_TIMESTAMP (buffer);    GST_BUFFER_OFFSET (subbuffer) = GST_BUFFER_OFFSET (buffer);    complete = (buffer->size == size);  } else {    GST_BUFFER_TIMESTAMP (subbuffer) = GST_CLOCK_TIME_NONE;    GST_BUFFER_OFFSET (subbuffer) = GST_BUFFER_OFFSET_NONE;    complete = FALSE;  }  if (complete) {    GstCaps *caps;    /* if we copied the complete buffer we can copy the duration,     * offset_end and caps as well */    GST_BUFFER_DURATION (subbuffer) = GST_BUFFER_DURATION (buffer);    GST_BUFFER_OFFSET_END (subbuffer) = GST_BUFFER_OFFSET_END (buffer);    if ((caps = GST_BUFFER_CAPS (buffer)))      gst_caps_ref (caps);    GST_BUFFER_CAPS (subbuffer) = caps;  } else {    GST_BUFFER_DURATION (subbuffer) = GST_CLOCK_TIME_NONE;    GST_BUFFER_OFFSET_END (subbuffer) = GST_BUFFER_OFFSET_NONE;    GST_BUFFER_CAPS (subbuffer) = NULL;  }  return subbuffer;}
开发者ID:zsx,项目名称:ossbuild,代码行数:90,


示例8: gst_interleave_collected

static GstFlowReturngst_interleave_collected (GstCollectPads * pads, GstInterleave * self){  guint size;  GstBuffer *outbuf;  GstFlowReturn ret = GST_FLOW_OK;  GSList *collected;  guint nsamples;  guint ncollected = 0;  gboolean empty = TRUE;  gint width = self->width / 8;  g_return_val_if_fail (self->func != NULL, GST_FLOW_NOT_NEGOTIATED);  g_return_val_if_fail (self->width > 0, GST_FLOW_NOT_NEGOTIATED);  g_return_val_if_fail (self->channels > 0, GST_FLOW_NOT_NEGOTIATED);  g_return_val_if_fail (self->rate > 0, GST_FLOW_NOT_NEGOTIATED);  size = gst_collect_pads_available (pads);  g_return_val_if_fail (size % width == 0, GST_FLOW_ERROR);  GST_DEBUG_OBJECT (self, "Starting to collect %u bytes from %d channels", size,      self->channels);  nsamples = size / width;  ret =      gst_pad_alloc_buffer (self->src, GST_BUFFER_OFFSET_NONE,      size * self->channels, GST_PAD_CAPS (self->src), &outbuf);  if (ret != GST_FLOW_OK) {    return ret;  } else if (outbuf == NULL || GST_BUFFER_SIZE (outbuf) < size * self->channels) {    gst_buffer_unref (outbuf);    return GST_FLOW_NOT_NEGOTIATED;  } else if (!gst_caps_is_equal (GST_BUFFER_CAPS (outbuf),          GST_PAD_CAPS (self->src))) {    gst_buffer_unref (outbuf);    return GST_FLOW_NOT_NEGOTIATED;  }  memset (GST_BUFFER_DATA (outbuf), 0, size * self->channels);  for (collected = pads->data; collected != NULL; collected = collected->next) {    GstCollectData *cdata;    GstBuffer *inbuf;    guint8 *outdata;    cdata = (GstCollectData *) collected->data;    inbuf = gst_collect_pads_take_buffer (pads, cdata, size);    if (inbuf == NULL) {      GST_DEBUG_OBJECT (cdata->pad, "No buffer available");      goto next;    }    ncollected++;    if (GST_BUFFER_FLAG_IS_SET (inbuf, GST_BUFFER_FLAG_GAP))      goto next;    empty = FALSE;    outdata =        GST_BUFFER_DATA (outbuf) +        width * GST_INTERLEAVE_PAD_CAST (cdata->pad)->channel;    self->func (outdata, GST_BUFFER_DATA (inbuf), self->channels, nsamples);  next:    if (inbuf)      gst_buffer_unref (inbuf);  }  if (ncollected == 0)    goto eos;  if (self->segment_pending) {    GstEvent *event;    event = gst_event_new_new_segment_full (FALSE, self->segment_rate,        1.0, GST_FORMAT_TIME, self->timestamp, -1, self->segment_position);    gst_pad_push_event (self->src, event);    self->segment_pending = FALSE;    self->segment_position = 0;  }  GST_BUFFER_TIMESTAMP (outbuf) = self->timestamp;  GST_BUFFER_OFFSET (outbuf) = self->offset;  self->offset += nsamples;  self->timestamp = gst_util_uint64_scale_int (self->offset,//.........这里部分代码省略.........
开发者ID:prajnashi,项目名称:gst-plugins-good,代码行数:101,


示例9: gst_wavpack_parse_push_buffer

static GstFlowReturngst_wavpack_parse_push_buffer (GstWavpackParse * wvparse, GstBuffer * buf,    WavpackHeader * header){  wvparse->current_offset += header->ckSize + 8;  wvparse->segment.last_stop = header->block_index;  if (wvparse->need_newsegment) {    if (gst_wavpack_parse_send_newsegment (wvparse, FALSE))      wvparse->need_newsegment = FALSE;  }  /* send any queued events */  if (wvparse->queued_events) {    GList *l;    for (l = wvparse->queued_events; l != NULL; l = l->next) {      gst_pad_push_event (wvparse->srcpad, GST_EVENT (l->data));    }    g_list_free (wvparse->queued_events);    wvparse->queued_events = NULL;  }  if (wvparse->pending_buffer == NULL) {    wvparse->pending_buffer = buf;    wvparse->pending_offset = header->block_index;  } else if (wvparse->pending_offset == header->block_index) {    wvparse->pending_buffer = gst_buffer_join (wvparse->pending_buffer, buf);  } else {    GST_ERROR ("Got incomplete block, dropping");    gst_buffer_unref (wvparse->pending_buffer);    wvparse->pending_buffer = buf;    wvparse->pending_offset = header->block_index;  }  if (!(header->flags & FINAL_BLOCK))    return GST_FLOW_OK;  buf = wvparse->pending_buffer;  wvparse->pending_buffer = NULL;  GST_BUFFER_TIMESTAMP (buf) = gst_util_uint64_scale_int (header->block_index,      GST_SECOND, wvparse->samplerate);  GST_BUFFER_DURATION (buf) = gst_util_uint64_scale_int (header->block_samples,      GST_SECOND, wvparse->samplerate);  GST_BUFFER_OFFSET (buf) = header->block_index;  GST_BUFFER_OFFSET_END (buf) = header->block_index + header->block_samples;  if (wvparse->discont || wvparse->next_block_index != header->block_index) {    GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DISCONT);    wvparse->discont = FALSE;  }  wvparse->next_block_index = header->block_index + header->block_samples;  gst_buffer_set_caps (buf, GST_PAD_CAPS (wvparse->srcpad));  GST_LOG_OBJECT (wvparse, "Pushing buffer with time %" GST_TIME_FORMAT,      GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)));  return gst_pad_push (wvparse->srcpad, buf);}
开发者ID:JJCG,项目名称:gst-plugins-good,代码行数:63,


示例10: gst_decklink_src_task

static voidgst_decklink_src_task (void *priv){  GstDecklinkSrc *decklinksrc = GST_DECKLINK_SRC (priv);  GstBuffer *buffer;  GstBuffer *audio_buffer;  IDeckLinkVideoInputFrame *video_frame;  IDeckLinkAudioInputPacket *audio_frame;  void *data;  int n_samples;  GstFlowReturn ret;  const GstDecklinkMode *mode;  GST_DEBUG_OBJECT (decklinksrc, "task");  g_mutex_lock (decklinksrc->mutex);  while (decklinksrc->video_frame == NULL && !decklinksrc->stop) {    g_cond_wait (decklinksrc->cond, decklinksrc->mutex);  }  video_frame = decklinksrc->video_frame;  audio_frame = decklinksrc->audio_frame;  decklinksrc->video_frame = NULL;  decklinksrc->audio_frame = NULL;  g_mutex_unlock (decklinksrc->mutex);  if (decklinksrc->stop) {    GST_DEBUG ("stopping task");    return;  }  /* warning on dropped frames */  if (decklinksrc->dropped_frames - decklinksrc->dropped_frames_old > 0) {    GST_ELEMENT_WARNING (decklinksrc, RESOURCE, READ,        ("Dropped %d frame(s), for a total of %d frame(s)",            decklinksrc->dropped_frames - decklinksrc->dropped_frames_old,            decklinksrc->dropped_frames), (NULL));    decklinksrc->dropped_frames_old = decklinksrc->dropped_frames;  }  mode = gst_decklink_get_mode (decklinksrc->mode);  video_frame->GetBytes (&data);  if (decklinksrc->copy_data) {    buffer = gst_buffer_new_and_alloc (mode->width * mode->height * 2);    memcpy (GST_BUFFER_DATA (buffer), data, mode->width * mode->height * 2);    video_frame->Release ();  } else {    buffer = gst_buffer_new ();    GST_BUFFER_SIZE (buffer) = mode->width * mode->height * 2;    GST_BUFFER_DATA (buffer) = (guint8 *) data;    GST_BUFFER_FREE_FUNC (buffer) = video_frame_free;    GST_BUFFER_MALLOCDATA (buffer) = (guint8 *) video_frame;  }  GST_BUFFER_TIMESTAMP (buffer) =      gst_util_uint64_scale_int (decklinksrc->frame_num * GST_SECOND,      mode->fps_d, mode->fps_n);  GST_BUFFER_DURATION (buffer) =      gst_util_uint64_scale_int ((decklinksrc->frame_num + 1) * GST_SECOND,      mode->fps_d, mode->fps_n) - GST_BUFFER_TIMESTAMP (buffer);  GST_BUFFER_OFFSET (buffer) = decklinksrc->frame_num;  GST_BUFFER_OFFSET_END (buffer) = decklinksrc->frame_num;  if (decklinksrc->frame_num == 0) {    GstEvent *event;    gboolean ret;    GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DISCONT);    event = gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME, 0,        GST_CLOCK_TIME_NONE, 0);    if (gst_pad_is_linked (decklinksrc->videosrcpad)) {      gst_event_ref (event);      ret = gst_pad_push_event (decklinksrc->videosrcpad, event);      if (!ret) {        GST_ERROR_OBJECT (decklinksrc, "new segment event ret=%d", ret);        gst_event_unref (event);        return;      }    } else {      gst_event_unref (event);    }    if (gst_pad_is_linked (decklinksrc->audiosrcpad)) {      ret = gst_pad_push_event (decklinksrc->audiosrcpad, event);      if (!ret) {        GST_ERROR_OBJECT (decklinksrc, "new segment event ret=%d", ret);        gst_event_unref (event);      }    } else {      gst_event_unref (event);    }  }  if (decklinksrc->video_caps == NULL) {//.........这里部分代码省略.........
开发者ID:drothlis,项目名称:gst-plugins-bad,代码行数:101,


示例11: gst_identity_transform_ip

static GstFlowReturngst_identity_transform_ip (GstBaseTransform * trans, GstBuffer * buf){  GstFlowReturn ret = GST_FLOW_OK;  GstIdentity *identity = GST_IDENTITY (trans);  GstClockTime rundts = GST_CLOCK_TIME_NONE;  GstClockTime runpts = GST_CLOCK_TIME_NONE;  GstClockTime ts, duration, runtimestamp;  gsize size;  size = gst_buffer_get_size (buf);  if (identity->check_imperfect_timestamp)    gst_identity_check_imperfect_timestamp (identity, buf);  if (identity->check_imperfect_offset)    gst_identity_check_imperfect_offset (identity, buf);  /* update prev values */  identity->prev_timestamp = GST_BUFFER_TIMESTAMP (buf);  identity->prev_duration = GST_BUFFER_DURATION (buf);  identity->prev_offset_end = GST_BUFFER_OFFSET_END (buf);  identity->prev_offset = GST_BUFFER_OFFSET (buf);  if (identity->error_after >= 0) {    identity->error_after--;    if (identity->error_after == 0)      goto error_after;  }  if (identity->drop_probability > 0.0) {    if ((gfloat) (1.0 * rand () / (RAND_MAX)) < identity->drop_probability)      goto dropped;  }  if (identity->dump) {    GstMapInfo info;    gst_buffer_map (buf, &info, GST_MAP_READ);    gst_util_dump_mem (info.data, info.size);    gst_buffer_unmap (buf, &info);  }  if (!identity->silent) {    gst_identity_update_last_message_for_buffer (identity, "chain", buf, size);  }  if (identity->datarate > 0) {    GstClockTime time = gst_util_uint64_scale_int (identity->offset,        GST_SECOND, identity->datarate);    GST_BUFFER_PTS (buf) = GST_BUFFER_DTS (buf) = time;    GST_BUFFER_DURATION (buf) = size * GST_SECOND / identity->datarate;  }  if (identity->signal_handoffs)    g_signal_emit (identity, gst_identity_signals[SIGNAL_HANDOFF], 0, buf);  if (trans->segment.format == GST_FORMAT_TIME) {    rundts = gst_segment_to_running_time (&trans->segment,        GST_FORMAT_TIME, GST_BUFFER_DTS (buf));    runpts = gst_segment_to_running_time (&trans->segment,        GST_FORMAT_TIME, GST_BUFFER_PTS (buf));  }  if (GST_CLOCK_TIME_IS_VALID (rundts))    runtimestamp = rundts;  else if (GST_CLOCK_TIME_IS_VALID (runpts))    runtimestamp = runpts;  else    runtimestamp = 0;  ret = gst_identity_do_sync (identity, runtimestamp);  identity->offset += size;  if (identity->sleep_time && ret == GST_FLOW_OK)    g_usleep (identity->sleep_time);  if (identity->single_segment && (trans->segment.format == GST_FORMAT_TIME)      && (ret == GST_FLOW_OK)) {    GST_BUFFER_DTS (buf) = rundts;    GST_BUFFER_PTS (buf) = runpts;    GST_BUFFER_OFFSET (buf) = GST_CLOCK_TIME_NONE;    GST_BUFFER_OFFSET_END (buf) = GST_CLOCK_TIME_NONE;  }  return ret;  /* ERRORS */error_after:  {    GST_ELEMENT_ERROR (identity, CORE, FAILED,        (_("Failed after iterations as requested.")), (NULL));    return GST_FLOW_ERROR;  }dropped:  {    if (!identity->silent) {      gst_identity_update_last_message_for_buffer (identity, "dropping", buf,          size);    }//.........这里部分代码省略.........
开发者ID:mparis,项目名称:gstreamer,代码行数:101,


示例12: gst_vdp_mpeg_dec_decode

static GstFlowReturngst_vdp_mpeg_dec_decode (GstVdpMpegDec * mpeg_dec,                         GstClockTime timestamp, gint64 size){    VdpPictureInfoMPEG1Or2 *info;    GstBuffer *buffer;    GstBuffer *outbuf;    VdpVideoSurface surface;    GstVdpDevice *device;    VdpBitstreamBuffer vbit[1];    VdpStatus status;    info = &mpeg_dec->vdp_info;    if (info->picture_coding_type != B_FRAME) {        if (info->backward_reference != VDP_INVALID_HANDLE) {            gst_buffer_ref (mpeg_dec->b_buffer);            gst_vdp_mpeg_dec_push_video_buffer (mpeg_dec,                                                GST_VDP_VIDEO_BUFFER (mpeg_dec->b_buffer));        }        if (info->forward_reference != VDP_INVALID_HANDLE) {            gst_buffer_unref (mpeg_dec->f_buffer);            info->forward_reference = VDP_INVALID_HANDLE;        }        info->forward_reference = info->backward_reference;        mpeg_dec->f_buffer = mpeg_dec->b_buffer;        info->backward_reference = VDP_INVALID_HANDLE;    }    if (gst_vdp_mpeg_dec_alloc_buffer (mpeg_dec, &outbuf) != GST_FLOW_OK) {        gst_adapter_clear (mpeg_dec->adapter);        return GST_FLOW_ERROR;    }    device = GST_VDP_VIDEO_BUFFER (outbuf)->device;    if (info->forward_reference != VDP_INVALID_HANDLE &&            info->picture_coding_type != I_FRAME)        gst_vdp_video_buffer_add_reference (GST_VDP_VIDEO_BUFFER (outbuf),                                            GST_VDP_VIDEO_BUFFER (mpeg_dec->f_buffer));    if (info->backward_reference != VDP_INVALID_HANDLE            && info->picture_coding_type == B_FRAME)        gst_vdp_video_buffer_add_reference (GST_VDP_VIDEO_BUFFER (outbuf),                                            GST_VDP_VIDEO_BUFFER (mpeg_dec->b_buffer));    GST_BUFFER_TIMESTAMP (outbuf) = timestamp;    GST_BUFFER_DURATION (outbuf) = mpeg_dec->duration;    GST_BUFFER_OFFSET (outbuf) = mpeg_dec->frame_nr;    GST_BUFFER_SIZE (outbuf) = size;    if (info->picture_coding_type == I_FRAME)        GST_BUFFER_FLAG_UNSET (outbuf, GST_BUFFER_FLAG_DELTA_UNIT);    else        GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DELTA_UNIT);    if (info->top_field_first)        GST_BUFFER_FLAG_SET (outbuf, GST_VIDEO_BUFFER_TFF);    else        GST_BUFFER_FLAG_UNSET (outbuf, GST_VIDEO_BUFFER_TFF);    buffer = gst_adapter_take_buffer (mpeg_dec->adapter,                                      gst_adapter_available (mpeg_dec->adapter));    surface = GST_VDP_VIDEO_BUFFER (outbuf)->surface;    vbit[0].struct_version = VDP_BITSTREAM_BUFFER_VERSION;    vbit[0].bitstream = GST_BUFFER_DATA (buffer);    vbit[0].bitstream_bytes = GST_BUFFER_SIZE (buffer);    status = device->vdp_decoder_render (mpeg_dec->decoder, surface,                                         (VdpPictureInfo *) info, 1, vbit);    gst_buffer_unref (buffer);    info->slice_count = 0;    if (status != VDP_STATUS_OK) {        GST_ELEMENT_ERROR (mpeg_dec, RESOURCE, READ,                           ("Could not decode"),                           ("Error returned from vdpau was: %s",                            device->vdp_get_error_string (status)));        gst_buffer_unref (GST_BUFFER (outbuf));        return GST_FLOW_ERROR;    }    if (info->picture_coding_type == B_FRAME) {        gst_vdp_mpeg_dec_push_video_buffer (mpeg_dec,                                            GST_VDP_VIDEO_BUFFER (outbuf));    } else {        info->backward_reference = surface;        mpeg_dec->b_buffer = GST_BUFFER (outbuf);    }    return GST_FLOW_OK;}
开发者ID:zsx,项目名称:ossbuild,代码行数:99,


示例13: gst_identity_transform_ip

static GstFlowReturngst_identity_transform_ip (GstBaseTransform * trans, GstBuffer * buf){  GstFlowReturn ret = GST_FLOW_OK;  GstIdentity *identity = GST_IDENTITY (trans);  GstClockTime runtimestamp = G_GINT64_CONSTANT (0);  gsize size;  size = gst_buffer_get_size (buf);  if (identity->check_imperfect_timestamp)    gst_identity_check_imperfect_timestamp (identity, buf);  if (identity->check_imperfect_offset)    gst_identity_check_imperfect_offset (identity, buf);  /* update prev values */  identity->prev_timestamp = GST_BUFFER_TIMESTAMP (buf);  identity->prev_duration = GST_BUFFER_DURATION (buf);  identity->prev_offset_end = GST_BUFFER_OFFSET_END (buf);  identity->prev_offset = GST_BUFFER_OFFSET (buf);  if (identity->error_after >= 0) {    identity->error_after--;    if (identity->error_after == 0)      goto error_after;  }  if (identity->drop_probability > 0.0) {    if ((gfloat) (1.0 * rand () / (RAND_MAX)) < identity->drop_probability)      goto dropped;  }  if (identity->dump) {    GstMapInfo info;    gst_buffer_map (buf, &info, GST_MAP_READ);    gst_util_dump_mem (info.data, info.size);    gst_buffer_unmap (buf, &info);  }  if (!identity->silent) {    gst_identity_update_last_message_for_buffer (identity, "chain", buf, size);  }  if (identity->datarate > 0) {    GstClockTime time = gst_util_uint64_scale_int (identity->offset,        GST_SECOND, identity->datarate);    GST_BUFFER_PTS (buf) = GST_BUFFER_DTS (buf) = time;    GST_BUFFER_DURATION (buf) = size * GST_SECOND / identity->datarate;  }  if (identity->signal_handoffs)    g_signal_emit (identity, gst_identity_signals[SIGNAL_HANDOFF], 0, buf);  if (trans->segment.format == GST_FORMAT_TIME)    runtimestamp = gst_segment_to_running_time (&trans->segment,        GST_FORMAT_TIME, GST_BUFFER_TIMESTAMP (buf));  if ((identity->sync) && (trans->segment.format == GST_FORMAT_TIME)) {    GstClock *clock;    GST_OBJECT_LOCK (identity);    if ((clock = GST_ELEMENT (identity)->clock)) {      GstClockReturn cret;      GstClockTime timestamp;      timestamp = runtimestamp + GST_ELEMENT (identity)->base_time;      /* save id if we need to unlock */      identity->clock_id = gst_clock_new_single_shot_id (clock, timestamp);      GST_OBJECT_UNLOCK (identity);      cret = gst_clock_id_wait (identity->clock_id, NULL);      GST_OBJECT_LOCK (identity);      if (identity->clock_id) {        gst_clock_id_unref (identity->clock_id);        identity->clock_id = NULL;      }      if (cret == GST_CLOCK_UNSCHEDULED)        ret = GST_FLOW_EOS;    }    GST_OBJECT_UNLOCK (identity);  }  identity->offset += size;  if (identity->sleep_time && ret == GST_FLOW_OK)    g_usleep (identity->sleep_time);  if (identity->single_segment && (trans->segment.format == GST_FORMAT_TIME)      && (ret == GST_FLOW_OK)) {    GST_BUFFER_PTS (buf) = GST_BUFFER_DTS (buf) = runtimestamp;    GST_BUFFER_OFFSET (buf) = GST_CLOCK_TIME_NONE;    GST_BUFFER_OFFSET_END (buf) = GST_CLOCK_TIME_NONE;  }  return ret;//.........这里部分代码省略.........
开发者ID:sebras,项目名称:gstreamer,代码行数:101,


示例14: gst_inter_video_src_create

static GstFlowReturngst_inter_video_src_create (GstBaseSrc * src, guint64 offset, guint size,    GstBuffer ** buf){  GstInterVideoSrc *intervideosrc = GST_INTER_VIDEO_SRC (src);  GstBuffer *buffer;  GST_DEBUG_OBJECT (intervideosrc, "create");  buffer = NULL;  g_mutex_lock (&intervideosrc->surface->mutex);  if (intervideosrc->surface->video_buffer) {    buffer = gst_buffer_ref (intervideosrc->surface->video_buffer);    intervideosrc->surface->video_buffer_count++;    if (intervideosrc->surface->video_buffer_count >= 30) {      gst_buffer_unref (intervideosrc->surface->video_buffer);      intervideosrc->surface->video_buffer = NULL;    }  }  g_mutex_unlock (&intervideosrc->surface->mutex);  if (buffer == NULL) {    GstMapInfo map;    buffer =        gst_buffer_new_and_alloc (GST_VIDEO_INFO_SIZE (&intervideosrc->info));    gst_buffer_map (buffer, &map, GST_MAP_WRITE);    memset (map.data, 16, GST_VIDEO_INFO_COMP_STRIDE (&intervideosrc->info, 0) *        GST_VIDEO_INFO_COMP_HEIGHT (&intervideosrc->info, 0));    memset (map.data + GST_VIDEO_INFO_COMP_OFFSET (&intervideosrc->info, 1),        128,        2 * GST_VIDEO_INFO_COMP_STRIDE (&intervideosrc->info, 1) *        GST_VIDEO_INFO_COMP_HEIGHT (&intervideosrc->info, 1));    gst_buffer_unmap (buffer, &map);  }  buffer = gst_buffer_make_writable (buffer);  GST_BUFFER_TIMESTAMP (buffer) =      gst_util_uint64_scale_int (GST_SECOND * intervideosrc->n_frames,      GST_VIDEO_INFO_FPS_D (&intervideosrc->info),      GST_VIDEO_INFO_FPS_N (&intervideosrc->info));  GST_DEBUG_OBJECT (intervideosrc, "create ts %" GST_TIME_FORMAT,      GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)));  GST_BUFFER_DURATION (buffer) =      gst_util_uint64_scale_int (GST_SECOND * (intervideosrc->n_frames + 1),      GST_VIDEO_INFO_FPS_D (&intervideosrc->info),      GST_VIDEO_INFO_FPS_N (&intervideosrc->info)) -      GST_BUFFER_TIMESTAMP (buffer);  GST_BUFFER_OFFSET (buffer) = intervideosrc->n_frames;  GST_BUFFER_OFFSET_END (buffer) = -1;  GST_BUFFER_FLAG_UNSET (buffer, GST_BUFFER_FLAG_DISCONT);  if (intervideosrc->n_frames == 0) {    GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DISCONT);  }  intervideosrc->n_frames++;  *buf = buffer;  return GST_FLOW_OK;}
开发者ID:jcaden,项目名称:gst-plugins-bad,代码行数:64,


示例15: gst_fake_sink_render

static GstFlowReturngst_fake_sink_render (GstBaseSink * bsink, GstBuffer * buf){  GstFakeSink *sink = GST_FAKE_SINK_CAST (bsink);  if (sink->num_buffers_left == 0)    goto eos;  if (sink->num_buffers_left != -1)    sink->num_buffers_left--;  if (!sink->silent) {    gchar dts_str[64], pts_str[64], dur_str[64];    gchar flag_str[100];    GST_OBJECT_LOCK (sink);    g_free (sink->last_message);    if (GST_BUFFER_DTS (buf) != GST_CLOCK_TIME_NONE) {      g_snprintf (dts_str, sizeof (dts_str), "%" GST_TIME_FORMAT,          GST_TIME_ARGS (GST_BUFFER_DTS (buf)));    } else {      g_strlcpy (dts_str, "none", sizeof (dts_str));    }    if (GST_BUFFER_PTS (buf) != GST_CLOCK_TIME_NONE) {      g_snprintf (pts_str, sizeof (pts_str), "%" GST_TIME_FORMAT,          GST_TIME_ARGS (GST_BUFFER_PTS (buf)));    } else {      g_strlcpy (pts_str, "none", sizeof (pts_str));    }    if (GST_BUFFER_DURATION (buf) != GST_CLOCK_TIME_NONE) {      g_snprintf (dur_str, sizeof (dur_str), "%" GST_TIME_FORMAT,          GST_TIME_ARGS (GST_BUFFER_DURATION (buf)));    } else {      g_strlcpy (dur_str, "none", sizeof (dur_str));    }    {      const char *flag_list[15] = {        "", "", "", "", "live", "decode-only", "discont", "resync", "corrupted",        "marker", "header", "gap", "droppable", "delta-unit", "in-caps"      };      int i;      char *end = flag_str;      end[0] = '/0';      for (i = 0; i < G_N_ELEMENTS (flag_list); i++) {        if (GST_MINI_OBJECT_CAST (buf)->flags & (1 << i)) {          strcpy (end, flag_list[i]);          end += strlen (end);          end[0] = ' ';          end[1] = '/0';          end++;        }      }    }    sink->last_message =        g_strdup_printf ("chain   ******* (%s:%s) (%u bytes, dts: %s, pts: %s"        ", duration: %s, offset: %" G_GINT64_FORMAT ", offset_end: %"        G_GINT64_FORMAT ", flags: %08x %s) %p",        GST_DEBUG_PAD_NAME (GST_BASE_SINK_CAST (sink)->sinkpad),        (guint) gst_buffer_get_size (buf), dts_str, pts_str,        dur_str, GST_BUFFER_OFFSET (buf), GST_BUFFER_OFFSET_END (buf),        GST_MINI_OBJECT_CAST (buf)->flags, flag_str, buf);    GST_OBJECT_UNLOCK (sink);    gst_fake_sink_notify_last_message (sink);  }  if (sink->signal_handoffs)    g_signal_emit (sink, gst_fake_sink_signals[SIGNAL_HANDOFF], 0, buf,        bsink->sinkpad);  if (sink->dump) {    GstMapInfo info;    gst_buffer_map (buf, &info, GST_MAP_READ);    gst_util_dump_mem (info.data, info.size);    gst_buffer_unmap (buf, &info);  }  if (sink->num_buffers_left == 0)    goto eos;  return GST_FLOW_OK;  /* ERRORS */eos:  {    GST_DEBUG_OBJECT (sink, "we are EOS");    return GST_FLOW_EOS;  }}
开发者ID:Grobik1,项目名称:gstreamer,代码行数:93,


示例16: gst_rtp_amr_pay_handle_buffer

//.........这里部分代码省略.........  if (packet_len > mtu)    goto too_big;  /* now alloc output buffer */  outbuf = gst_rtp_buffer_new_allocate (payload_len, 0, 0);  gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);  /* copy timestamp */  GST_BUFFER_TIMESTAMP (outbuf) = timestamp;  if (duration != GST_CLOCK_TIME_NONE)    GST_BUFFER_DURATION (outbuf) = duration;  else {    GST_BUFFER_DURATION (outbuf) = num_packets * 20 * GST_MSECOND;  }  if (GST_BUFFER_IS_DISCONT (buffer)) {    GST_DEBUG_OBJECT (basepayload, "discont, setting marker bit");    GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);    gst_rtp_buffer_set_marker (&rtp, TRUE);    gst_rtp_amr_pay_recalc_rtp_time (rtpamrpay, timestamp);  }  if (G_UNLIKELY (sid)) {    gst_rtp_amr_pay_recalc_rtp_time (rtpamrpay, timestamp);  }  /* perfect rtptime */  if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (rtpamrpay->first_ts))) {    rtpamrpay->first_ts = timestamp;    rtpamrpay->first_rtp_time = rtpamrpay->next_rtp_time;  }  GST_BUFFER_OFFSET (outbuf) = rtpamrpay->next_rtp_time;  rtpamrpay->next_rtp_time +=      (num_packets * 160) << (rtpamrpay->mode == GST_RTP_AMR_P_MODE_WB);  /* get payload, this is now writable */  payload = gst_rtp_buffer_get_payload (&rtp);  /*   0 1 2 3 4 5 6 7   *  +-+-+-+-+-+-+-+-+   *  |  CMR  |R|R|R|R|   *  +-+-+-+-+-+-+-+-+   */  payload[0] = 0xF0;            /* CMR, no specific mode requested */  /* this is where we copy the AMR data, after num_packets FTs and the   * CMR. */  payload_amr = payload + num_packets + 1;  /* copy data in payload, first we copy all the FTs then all   * the AMR data. The last FT has to have the F flag cleared. */  ptr = map.data;  for (i = 1; i <= num_packets; i++) {    guint8 FT;    gint fr_size;    /*   0 1 2 3 4 5 6 7     *  +-+-+-+-+-+-+-+-+     *  |F|  FT   |Q|P|P| more FT...     *  +-+-+-+-+-+-+-+-+     */    FT = (*ptr & 0x78) >> 3;    fr_size = frame_size[FT];
开发者ID:PeterXu,项目名称:gst-mobile,代码行数:67,


示例17: gst_base_audio_src_create

//.........这里部分代码省略.........             last written segment in the ringbuffer (one segment written = segment 0) */          last_segment = segments_written - ringbuffer->segbase - 1;          /* we see how many segments the ringbuffer was timeshifted */          segment_diff = new_last_segment - last_segment;          /* we move the first segment an equal amount */          new_first_segment = first_segment + segment_diff;          /* and we also move the segmentbase the same amount */          ringbuffer->segbase -= segment_diff;          /* we calculate the new sample value */          new_sample = ((guint64) new_first_segment) * sps;          /* and get the relative time to this -> our new timestamp */          timestamp =              gst_util_uint64_scale_int (new_sample, GST_SECOND, spec->rate);          /* we update the next sample accordingly */          src->next_sample = new_sample + samples;          GST_DEBUG_OBJECT (bsrc,              "Timeshifted the ringbuffer with %d segments: "              "Updating the timestamp to %" GST_TIME_FORMAT ", "              "and src->next_sample to %" G_GUINT64_FORMAT, segment_diff,              GST_TIME_ARGS (timestamp), src->next_sample);        }        break;      }      case GST_BASE_AUDIO_SRC_SLAVE_RETIMESTAMP:      {        GstClockTime base_time, latency;        /* We are slaved to another clock, take running time of the pipeline clock and         * timestamp against it. Somebody else in the pipeline should figure out the         * clock drift. We keep the duration we calculated above. */        timestamp = gst_clock_get_time (clock);        base_time = GST_ELEMENT_CAST (src)->base_time;        if (timestamp > base_time)          timestamp -= base_time;        else          timestamp = 0;        /* subtract latency */        latency =            gst_util_uint64_scale_int (total_samples, GST_SECOND, spec->rate);        if (timestamp > latency)          timestamp -= latency;        else          timestamp = 0;      }      case GST_BASE_AUDIO_SRC_SLAVE_NONE:        break;    }  } else {    GstClockTime base_time;    /* we are not slaved, subtract base_time */    base_time = GST_ELEMENT_CAST (src)->base_time;    if (timestamp > base_time)      timestamp -= base_time;    else      timestamp = 0;  }no_sync:  GST_OBJECT_UNLOCK (src);  GST_BUFFER_TIMESTAMP (buf) = timestamp;  GST_BUFFER_DURATION (buf) = duration;  GST_BUFFER_OFFSET (buf) = sample;  GST_BUFFER_OFFSET_END (buf) = sample + samples;  *outbuf = buf;  return GST_FLOW_OK;  /* ERRORS */wrong_state:  {    GST_DEBUG_OBJECT (src, "ringbuffer in wrong state");    return GST_FLOW_WRONG_STATE;  }wrong_offset:  {    GST_ELEMENT_ERROR (src, RESOURCE, SEEK,        (NULL), ("resource can only be operated on sequentially but offset %"            G_GUINT64_FORMAT " was given", offset));    return GST_FLOW_ERROR;  }stopped:  {    gst_buffer_unref (buf);    GST_DEBUG_OBJECT (src, "ringbuffer stopped");    return GST_FLOW_WRONG_STATE;  }}
开发者ID:prajnashi,项目名称:gst-plugins-base,代码行数:101,


示例18: test_injector_chain

static GstFlowReturntest_injector_chain (GstPad * pad, GstBuffer * buf){  GstFlowReturn ret;  GstPad *srcpad;  srcpad =      gst_element_get_static_pad (GST_ELEMENT (GST_PAD_PARENT (pad)), "src");  /* since we're increasing timestamp/offsets, push this one first */  GST_LOG (" passing buffer   [t=%" GST_TIME_FORMAT "-%" GST_TIME_FORMAT      "], offset=%" G_GINT64_FORMAT ", offset_end=%" G_GINT64_FORMAT,      GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),      GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf) + GST_BUFFER_DURATION (buf)),      GST_BUFFER_OFFSET (buf), GST_BUFFER_OFFSET_END (buf));  gst_buffer_ref (buf);  ret = gst_pad_push (srcpad, buf);  if (g_random_double () < injector_inject_probability) {    GstBuffer *ibuf;    ibuf = gst_buffer_copy (buf);    if (GST_BUFFER_OFFSET_IS_VALID (buf) &&        GST_BUFFER_OFFSET_END_IS_VALID (buf)) {      guint64 delta;      delta = GST_BUFFER_OFFSET_END (buf) - GST_BUFFER_OFFSET (buf);      GST_BUFFER_OFFSET (ibuf) += delta / 4;      GST_BUFFER_OFFSET_END (ibuf) += delta / 4;    } else {      GST_BUFFER_OFFSET (ibuf) = GST_BUFFER_OFFSET_NONE;      GST_BUFFER_OFFSET_END (ibuf) = GST_BUFFER_OFFSET_NONE;    }    if (GST_BUFFER_TIMESTAMP_IS_VALID (buf) &&        GST_BUFFER_DURATION_IS_VALID (buf)) {      GstClockTime delta;      delta = GST_BUFFER_DURATION (buf);      GST_BUFFER_TIMESTAMP (ibuf) += delta / 4;    } else {      GST_BUFFER_TIMESTAMP (ibuf) = GST_CLOCK_TIME_NONE;      GST_BUFFER_DURATION (ibuf) = GST_CLOCK_TIME_NONE;    }    if (GST_BUFFER_TIMESTAMP_IS_VALID (ibuf) ||        GST_BUFFER_OFFSET_IS_VALID (ibuf)) {      GST_LOG ("injecting buffer [t=%" GST_TIME_FORMAT "-%" GST_TIME_FORMAT          "], offset=%" G_GINT64_FORMAT ", offset_end=%" G_GINT64_FORMAT,          GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (ibuf)),          GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (ibuf) +              GST_BUFFER_DURATION (ibuf)), GST_BUFFER_OFFSET (ibuf),          GST_BUFFER_OFFSET_END (ibuf));      if (gst_pad_push (srcpad, ibuf) != GST_FLOW_OK) {        /* ignore return value */      }    } else {      GST_WARNING ("couldn't inject buffer, no incoming timestamps or offsets");      gst_buffer_unref (ibuf);    }  }  gst_buffer_unref (buf);  return ret;}
开发者ID:ChinnaSuhas,项目名称:ossbuild,代码行数:70,


示例19: stop_typefinding

static voidstop_typefinding (GstTypeFindElement * typefind){  GstState state;  gboolean push_cached_buffers;  gsize avail;  GstBuffer *buffer;  GstClockTime pts, dts;  gst_element_get_state (GST_ELEMENT (typefind), &state, NULL, 0);  push_cached_buffers = (state >= GST_STATE_PAUSED && typefind->caps);  GST_DEBUG_OBJECT (typefind, "stopping typefinding%s",      push_cached_buffers ? " and pushing cached events and buffers" : "");  typefind->mode = MODE_NORMAL;  if (push_cached_buffers)    gst_type_find_element_send_cached_events (typefind);  GST_OBJECT_LOCK (typefind);  avail = gst_adapter_available (typefind->adapter);  if (avail == 0)    goto no_data;  pts = gst_adapter_prev_pts (typefind->adapter, NULL);  dts = gst_adapter_prev_dts (typefind->adapter, NULL);  buffer = gst_adapter_take_buffer (typefind->adapter, avail);  GST_BUFFER_PTS (buffer) = pts;  GST_BUFFER_DTS (buffer) = dts;  GST_BUFFER_OFFSET (buffer) = typefind->initial_offset;  GST_OBJECT_UNLOCK (typefind);  if (!push_cached_buffers) {    gst_buffer_unref (buffer);  } else {    GstPad *peer = gst_pad_get_peer (typefind->src);    /* make sure the user gets a meaningful error message in this case,     * which is not a core bug or bug of any kind (as the default error     * message emitted by gstpad.c otherwise would make you think) */    if (peer && GST_PAD_CHAINFUNC (peer) == NULL) {      GST_DEBUG_OBJECT (typefind, "upstream only supports push mode, while "          "downstream element only works in pull mode, erroring out");      GST_ELEMENT_ERROR (typefind, STREAM, FAILED,          ("%s cannot work in push mode. The operation is not supported "              "with this source element or protocol.",              G_OBJECT_TYPE_NAME (GST_PAD_PARENT (peer))),          ("Downstream pad %s:%s has no chainfunction, and the upstream "              "element does not support pull mode", GST_DEBUG_PAD_NAME (peer)));      typefind->mode = MODE_ERROR;      /* make the chain function error out */      gst_buffer_unref (buffer);    } else {      gst_pad_push (typefind->src, buffer);    }    if (peer)      gst_object_unref (peer);  }  return;  /* ERRORS */no_data:  {    GST_DEBUG_OBJECT (typefind, "we have no data to typefind");    GST_OBJECT_UNLOCK (typefind);    return;  }}
开发者ID:beuthien,项目名称:gstreamer,代码行数:68,


示例20: gst_fake_src_create

static GstFlowReturngst_fake_src_create (GstBaseSrc * basesrc, guint64 offset, guint length,    GstBuffer ** ret){  GstFakeSrc *src;  GstBuffer *buf;  GstClockTime time;  gsize size;  src = GST_FAKE_SRC (basesrc);  buf = gst_fake_src_create_buffer (src, &size);  GST_BUFFER_OFFSET (buf) = offset;  if (src->datarate > 0) {    time = (src->bytes_sent * GST_SECOND) / src->datarate;    GST_BUFFER_DURATION (buf) = size * GST_SECOND / src->datarate;  } else if (gst_base_src_is_live (basesrc)) {    GstClock *clock;    clock = gst_element_get_clock (GST_ELEMENT (src));    if (clock) {      time = gst_clock_get_time (clock);      time -= gst_element_get_base_time (GST_ELEMENT (src));      gst_object_unref (clock);    } else {      /* not an error not to have a clock */      time = GST_CLOCK_TIME_NONE;    }  } else {    time = GST_CLOCK_TIME_NONE;  }  GST_BUFFER_DTS (buf) = time;  GST_BUFFER_PTS (buf) = time;  if (!src->silent) {    gchar dts_str[64], pts_str[64], dur_str[64];    gchar flag_str[100];    GST_OBJECT_LOCK (src);    g_free (src->last_message);    if (GST_BUFFER_DTS (buf) != GST_CLOCK_TIME_NONE) {      g_snprintf (dts_str, sizeof (dts_str), "%" GST_TIME_FORMAT,          GST_TIME_ARGS (GST_BUFFER_DTS (buf)));    } else {      g_strlcpy (dts_str, "none", sizeof (dts_str));    }    if (GST_BUFFER_PTS (buf) != GST_CLOCK_TIME_NONE) {      g_snprintf (pts_str, sizeof (pts_str), "%" GST_TIME_FORMAT,          GST_TIME_ARGS (GST_BUFFER_PTS (buf)));    } else {      g_strlcpy (pts_str, "none", sizeof (pts_str));    }    if (GST_BUFFER_DURATION (buf) != GST_CLOCK_TIME_NONE) {      g_snprintf (dur_str, sizeof (dur_str), "%" GST_TIME_FORMAT,          GST_TIME_ARGS (GST_BUFFER_DURATION (buf)));    } else {      g_strlcpy (dur_str, "none", sizeof (dur_str));    }    {      const char *flag_list[15] = {        "", "", "", "", "live", "decode-only", "discont", "resync", "corrupted",        "marker", "header", "gap", "droppable", "delta-unit", "in-caps"      };      int i;      char *end = flag_str;      end[0] = '/0';      for (i = 0; i < G_N_ELEMENTS (flag_list); i++) {        if (GST_MINI_OBJECT_CAST (buf)->flags & (1 << i)) {          strcpy (end, flag_list[i]);          end += strlen (end);          end[0] = ' ';          end[1] = '/0';          end++;        }      }    }    src->last_message =        g_strdup_printf ("create   ******* (%s:%s) (%u bytes, dts: %s, pts:%s"        ", duration: %s, offset: %" G_GINT64_FORMAT ", offset_end: %"        G_GINT64_FORMAT ", flags: %08x %s) %p",        GST_DEBUG_PAD_NAME (GST_BASE_SRC_CAST (src)->srcpad), (guint) size,        dts_str, pts_str, dur_str, GST_BUFFER_OFFSET (buf),        GST_BUFFER_OFFSET_END (buf), GST_MINI_OBJECT_CAST (buf)->flags,        flag_str, buf);    GST_OBJECT_UNLOCK (src);    g_object_notify_by_pspec ((GObject *) src, pspec_last_message);  }  if (src->signal_handoffs) {    GST_LOG_OBJECT (src, "pre handoff emit");    g_signal_emit (src, gst_fake_src_signals[SIGNAL_HANDOFF], 0, buf,        basesrc->srcpad);//.........这里部分代码省略.........
开发者ID:PeterXu,项目名称:gst-mobile,代码行数:101,


示例21: gst_opus_parse_parse_frame

//.........这里部分代码省略.........    /* Opus streams can decode to 1 or 2 channels, so use the header       value if we have one, or 2 otherwise */    if (is_idheader) {      gst_buffer_replace (&parse->id_header, frame->buffer);      GST_DEBUG_OBJECT (parse, "Found ID header, keeping");      return GST_BASE_PARSE_FLOW_DROPPED;    } else if (is_commentheader) {      gst_buffer_replace (&parse->comment_header, frame->buffer);      GST_DEBUG_OBJECT (parse, "Found comment header, keeping");      return GST_BASE_PARSE_FLOW_DROPPED;    }    parse->got_headers = TRUE;    if (cmeta && cmeta->start) {      parse->pre_skip += cmeta->start;      gst_buffer_map (frame->buffer, &map, GST_MAP_READ);      duration = packet_duration_opus (map.data, map.size);      gst_buffer_unmap (frame->buffer, &map);      /* Queue frame for later once we know all initial padding */      if (duration == cmeta->start) {        frame->flags |= GST_BASE_PARSE_FRAME_FLAG_QUEUE;      }    }    if (!(frame->flags & GST_BASE_PARSE_FRAME_FLAG_QUEUE)) {      if (FALSE && parse->id_header && parse->comment_header) {        guint16 pre_skip;        gst_buffer_map (parse->id_header, &map, GST_MAP_READWRITE);        pre_skip = GST_READ_UINT16_LE (map.data + 10);        if (pre_skip != parse->pre_skip) {          GST_DEBUG_OBJECT (parse,              "Fixing up pre-skip %u -> %" G_GUINT64_FORMAT, pre_skip,              parse->pre_skip);          GST_WRITE_UINT16_LE (map.data + 10, parse->pre_skip);        }        gst_buffer_unmap (parse->id_header, &map);        caps =            gst_codec_utils_opus_create_caps_from_header (parse->id_header,            parse->comment_header);      } else {        GstCaps *sink_caps;        guint32 sample_rate = 48000;        guint8 n_channels, n_streams, n_stereo_streams, channel_mapping_family;        guint8 channel_mapping[256];        GstBuffer *id_header;        sink_caps = gst_pad_get_current_caps (GST_BASE_PARSE_SINK_PAD (parse));        if (!sink_caps            || !gst_codec_utils_opus_parse_caps (sink_caps, &sample_rate,                &n_channels, &channel_mapping_family, &n_streams,                &n_stereo_streams, channel_mapping)) {          GST_INFO_OBJECT (parse,              "No headers and no caps, blindly setting up canonical stereo");          n_channels = 2;          n_streams = 1;          n_stereo_streams = 1;          channel_mapping_family = 0;          channel_mapping[0] = 0;          channel_mapping[1] = 1;        }        if (sink_caps)          gst_caps_unref (sink_caps);        id_header =            gst_codec_utils_opus_create_header (sample_rate, n_channels,            channel_mapping_family, n_streams, n_stereo_streams,            channel_mapping, parse->pre_skip, 0);        caps = gst_codec_utils_opus_create_caps_from_header (id_header, NULL);        gst_buffer_unref (id_header);      }      gst_buffer_replace (&parse->id_header, NULL);      gst_buffer_replace (&parse->comment_header, NULL);      gst_pad_set_caps (GST_BASE_PARSE_SRC_PAD (parse), caps);      gst_caps_unref (caps);      parse->header_sent = TRUE;    }  }  GST_BUFFER_TIMESTAMP (frame->buffer) = parse->next_ts;  gst_buffer_map (frame->buffer, &map, GST_MAP_READ);  duration = packet_duration_opus (map.data, map.size);  gst_buffer_unmap (frame->buffer, &map);  parse->next_ts += duration;  GST_BUFFER_DURATION (frame->buffer) = duration;  GST_BUFFER_OFFSET_END (frame->buffer) =      gst_util_uint64_scale (parse->next_ts, 48000, GST_SECOND);  GST_BUFFER_OFFSET (frame->buffer) = parse->next_ts;  return GST_FLOW_OK;}
开发者ID:pexip,项目名称:gst-plugins-bad,代码行数:101,


示例22: gst_stream_synchronizer_sink_chain

static GstFlowReturngst_stream_synchronizer_sink_chain (GstPad * pad, GstObject * parent,    GstBuffer * buffer){  GstStreamSynchronizer *self = GST_STREAM_SYNCHRONIZER (parent);  GstPad *opad;  GstFlowReturn ret = GST_FLOW_ERROR;  GstSyncStream *stream;  GstClockTime duration = GST_CLOCK_TIME_NONE;  GstClockTime timestamp = GST_CLOCK_TIME_NONE;  GstClockTime timestamp_end = GST_CLOCK_TIME_NONE;  GST_LOG_OBJECT (pad, "Handling buffer %p: size=%" G_GSIZE_FORMAT      ", timestamp=%" GST_TIME_FORMAT " duration=%" GST_TIME_FORMAT      " offset=%" G_GUINT64_FORMAT " offset_end=%" G_GUINT64_FORMAT,      buffer, gst_buffer_get_size (buffer),      GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)),      GST_TIME_ARGS (GST_BUFFER_DURATION (buffer)),      GST_BUFFER_OFFSET (buffer), GST_BUFFER_OFFSET_END (buffer));  timestamp = GST_BUFFER_TIMESTAMP (buffer);  duration = GST_BUFFER_DURATION (buffer);  if (GST_CLOCK_TIME_IS_VALID (timestamp)      && GST_CLOCK_TIME_IS_VALID (duration))    timestamp_end = timestamp + duration;  GST_STREAM_SYNCHRONIZER_LOCK (self);  stream = gst_pad_get_element_private (pad);  if (stream) {    stream->seen_data = TRUE;    if (stream->segment.format == GST_FORMAT_TIME        && GST_CLOCK_TIME_IS_VALID (timestamp)) {      GST_LOG_OBJECT (pad,          "Updating position from %" GST_TIME_FORMAT " to %" GST_TIME_FORMAT,          GST_TIME_ARGS (stream->segment.position), GST_TIME_ARGS (timestamp));      if (stream->segment.rate > 0.0)        stream->segment.position = timestamp;      else        stream->segment.position = timestamp_end;    }  }  GST_STREAM_SYNCHRONIZER_UNLOCK (self);  opad = gst_stream_get_other_pad_from_pad (self, pad);  if (opad) {    ret = gst_pad_push (opad, buffer);    gst_object_unref (opad);  }  GST_LOG_OBJECT (pad, "Push returned: %s", gst_flow_get_name (ret));  if (ret == GST_FLOW_OK) {    GList *l;    GST_STREAM_SYNCHRONIZER_LOCK (self);    stream = gst_pad_get_element_private (pad);    if (stream && stream->segment.format == GST_FORMAT_TIME) {      GstClockTime position;      if (stream->segment.rate > 0.0)        position = timestamp_end;      else        position = timestamp;      if (GST_CLOCK_TIME_IS_VALID (position)) {        GST_LOG_OBJECT (pad,            "Updating position from %" GST_TIME_FORMAT " to %" GST_TIME_FORMAT,            GST_TIME_ARGS (stream->segment.position), GST_TIME_ARGS (position));        stream->segment.position = position;      }    }    /* Advance EOS streams if necessary. For non-EOS     * streams the demuxers should already do this! */    if (!GST_CLOCK_TIME_IS_VALID (timestamp_end) &&        GST_CLOCK_TIME_IS_VALID (timestamp)) {      timestamp_end = timestamp + GST_SECOND;    }    for (l = self->streams; l; l = l->next) {      GstSyncStream *ostream = l->data;      gint64 position;      if (!ostream->is_eos || ostream->eos_sent ||          ostream->segment.format != GST_FORMAT_TIME)        continue;      if (ostream->segment.position != -1)        position = ostream->segment.position;      else        position = ostream->segment.start;      /* Is there a 1 second lag? */      if (position != -1 && GST_CLOCK_TIME_IS_VALID (timestamp_end) &&          position + GST_SECOND < timestamp_end) {        gint64 new_start;        new_start = timestamp_end - GST_SECOND;        GST_DEBUG_OBJECT (ostream->sinkpad,//.........这里部分代码省略.........
开发者ID:GrokImageCompression,项目名称:gst-plugins-base,代码行数:101,


示例23: gst_two_lame_chain

static GstFlowReturngst_two_lame_chain (GstPad * pad, GstBuffer * buf){  GstTwoLame *twolame;  guchar *mp3_data;  gint mp3_buffer_size, mp3_size;  gint64 duration;  GstFlowReturn result;  gint num_samples;  guint8 *data;  guint size;  twolame = GST_TWO_LAME (GST_PAD_PARENT (pad));  GST_LOG_OBJECT (twolame, "entered chain");  if (!twolame->setup)    goto not_setup;  data = GST_BUFFER_DATA (buf);  size = GST_BUFFER_SIZE (buf);  if (twolame->float_input)    num_samples = size / 4;  else    num_samples = size / 2;  /* allocate space for output */  mp3_buffer_size = 1.25 * num_samples + 16384;  mp3_data = g_malloc (mp3_buffer_size);  if (twolame->num_channels == 1) {    if (twolame->float_input)      mp3_size = twolame_encode_buffer_float32 (twolame->glopts,          (float *) data,          (float *) data, num_samples, mp3_data, mp3_buffer_size);    else      mp3_size = twolame_encode_buffer (twolame->glopts,          (short int *) data,          (short int *) data, num_samples, mp3_data, mp3_buffer_size);  } else {    if (twolame->float_input)      mp3_size = twolame_encode_buffer_float32_interleaved (twolame->glopts,          (float *) data,          num_samples / twolame->num_channels, mp3_data, mp3_buffer_size);    else      mp3_size = twolame_encode_buffer_interleaved (twolame->glopts,          (short int *) data,          num_samples / twolame->num_channels, mp3_data, mp3_buffer_size);  }  GST_LOG_OBJECT (twolame, "encoded %d bytes of audio to %d bytes of mp3",      size, mp3_size);  if (twolame->float_input)    duration = gst_util_uint64_scale_int (size, GST_SECOND,        4 * twolame->samplerate * twolame->num_channels);  else    duration = gst_util_uint64_scale_int (size, GST_SECOND,        2 * twolame->samplerate * twolame->num_channels);  if (GST_BUFFER_DURATION (buf) != GST_CLOCK_TIME_NONE &&      GST_BUFFER_DURATION (buf) != duration) {    GST_DEBUG_OBJECT (twolame, "incoming buffer had incorrect duration %"        GST_TIME_FORMAT ", outgoing buffer will have correct duration %"        GST_TIME_FORMAT,        GST_TIME_ARGS (GST_BUFFER_DURATION (buf)), GST_TIME_ARGS (duration));  }  if (twolame->last_ts == GST_CLOCK_TIME_NONE) {    twolame->last_ts = GST_BUFFER_TIMESTAMP (buf);    twolame->last_offs = GST_BUFFER_OFFSET (buf);    twolame->last_duration = duration;  } else {    twolame->last_duration += duration;  }  gst_buffer_unref (buf);  if (mp3_size < 0) {    g_warning ("error %d", mp3_size);  }  if (mp3_size > 0) {    GstBuffer *outbuf;    outbuf = gst_buffer_new ();    GST_BUFFER_DATA (outbuf) = mp3_data;    GST_BUFFER_MALLOCDATA (outbuf) = mp3_data;    GST_BUFFER_SIZE (outbuf) = mp3_size;    GST_BUFFER_TIMESTAMP (outbuf) = twolame->last_ts;    GST_BUFFER_OFFSET (outbuf) = twolame->last_offs;    GST_BUFFER_DURATION (outbuf) = twolame->last_duration;    gst_buffer_set_caps (outbuf, GST_PAD_CAPS (twolame->srcpad));    result = gst_pad_push (twolame->srcpad, outbuf);    twolame->last_flow = result;    if (result != GST_FLOW_OK) {      GST_DEBUG_OBJECT (twolame, "flow return: %s", gst_flow_get_name (result));    }//.........这里部分代码省略.........
开发者ID:prajnashi,项目名称:gst-plugins-bad,代码行数:101,


示例24: gst_gdp_depay_chain

//.........这里部分代码省略.........        break;      }      case GST_GDP_DEPAY_STATE_BUFFER:      {        /* if we receive a buffer without caps first, we error out */        if (!this->caps)          goto no_caps;        GST_LOG_OBJECT (this, "reading GDP buffer from adapter");        buf = gst_dp_buffer_from_header (GST_DP_HEADER_LENGTH, this->header);        if (!buf)          goto buffer_failed;        /* now take the payload if there is any */        if (this->payload_length > 0) {          guint8 *payload;          payload = gst_adapter_take (this->adapter, this->payload_length);          memcpy (GST_BUFFER_DATA (buf), payload, this->payload_length);          g_free (payload);        }        /* set caps and push */        gst_buffer_set_caps (buf, this->caps);        GST_LOG_OBJECT (this, "deserialized buffer %p, pushing, timestamp %"            GST_TIME_FORMAT ", duration %" GST_TIME_FORMAT            ", offset %" G_GINT64_FORMAT ", offset_end %" G_GINT64_FORMAT            ", size %d, flags 0x%x",            buf,            GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),            GST_TIME_ARGS (GST_BUFFER_DURATION (buf)),            GST_BUFFER_OFFSET (buf), GST_BUFFER_OFFSET_END (buf),            GST_BUFFER_SIZE (buf), GST_BUFFER_FLAGS (buf));        ret = gst_pad_push (this->srcpad, buf);        if (ret != GST_FLOW_OK)          goto push_error;        GST_LOG_OBJECT (this, "switching to state HEADER");        this->state = GST_GDP_DEPAY_STATE_HEADER;        break;      }      case GST_GDP_DEPAY_STATE_CAPS:      {        guint8 *payload;        /* take the payload of the caps */        GST_LOG_OBJECT (this, "reading GDP caps from adapter");        payload = gst_adapter_take (this->adapter, this->payload_length);        caps = gst_dp_caps_from_packet (GST_DP_HEADER_LENGTH, this->header,            payload);        g_free (payload);        if (!caps)          goto caps_failed;        GST_DEBUG_OBJECT (this, "deserialized caps %" GST_PTR_FORMAT, caps);        gst_caps_replace (&(this->caps), caps);        gst_pad_set_caps (this->srcpad, caps);        /* drop the creation ref we still have */        gst_caps_unref (caps);        GST_LOG_OBJECT (this, "switching to state HEADER");        this->state = GST_GDP_DEPAY_STATE_HEADER;        break;      }
开发者ID:kuailexs,项目名称:symbiandump-mw1,代码行数:67,


示例25: gst_identity_transform_ip

static GstFlowReturngst_identity_transform_ip (GstBaseTransform * trans, GstBuffer * buf){  GstFlowReturn ret = GST_FLOW_OK;  GstIdentity *identity = GST_IDENTITY (trans);  GstClockTime runtimestamp = G_GINT64_CONSTANT (0);  if (identity->check_perfect)    gst_identity_check_perfect (identity, buf);  if (identity->check_imperfect_timestamp)    gst_identity_check_imperfect_timestamp (identity, buf);  if (identity->check_imperfect_offset)    gst_identity_check_imperfect_offset (identity, buf);  /* update prev values */  identity->prev_timestamp = GST_BUFFER_TIMESTAMP (buf);  identity->prev_duration = GST_BUFFER_DURATION (buf);  identity->prev_offset_end = GST_BUFFER_OFFSET_END (buf);  identity->prev_offset = GST_BUFFER_OFFSET (buf);  if (identity->error_after >= 0) {    identity->error_after--;    if (identity->error_after == 0) {      GST_ELEMENT_ERROR (identity, CORE, FAILED,          (_("Failed after iterations as requested.")), (NULL));      return GST_FLOW_ERROR;    }  }  if (identity->drop_probability > 0.0) {    if ((gfloat) (1.0 * rand () / (RAND_MAX)) < identity->drop_probability) {      if (!identity->silent) {        GST_OBJECT_LOCK (identity);        g_free (identity->last_message);        identity->last_message =            g_strdup_printf            ("dropping   ******* (%s:%s)i (%d bytes, timestamp: %"            GST_TIME_FORMAT ", duration: %" GST_TIME_FORMAT ", offset: %"            G_GINT64_FORMAT ", offset_end: % " G_GINT64_FORMAT            ", flags: %d) %p", GST_DEBUG_PAD_NAME (trans->sinkpad),            GST_BUFFER_SIZE (buf), GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),            GST_TIME_ARGS (GST_BUFFER_DURATION (buf)), GST_BUFFER_OFFSET (buf),            GST_BUFFER_OFFSET_END (buf), GST_BUFFER_FLAGS (buf), buf);        GST_OBJECT_UNLOCK (identity);        gst_identity_notify_last_message (identity);      }      /* return DROPPED to basetransform. */      return GST_BASE_TRANSFORM_FLOW_DROPPED;    }  }  if (identity->dump) {    gst_util_dump_mem (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));  }  if (!identity->silent) {    GST_OBJECT_LOCK (identity);    g_free (identity->last_message);    identity->last_message =        g_strdup_printf ("chain   ******* (%s:%s)i (%d bytes, timestamp: %"        GST_TIME_FORMAT ", duration: %" GST_TIME_FORMAT ", offset: %"        G_GINT64_FORMAT ", offset_end: % " G_GINT64_FORMAT ", flags: %d) %p",        GST_DEBUG_PAD_NAME (trans->sinkpad), GST_BUFFER_SIZE (buf),        GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),        GST_TIME_ARGS (GST_BUFFER_DURATION (buf)),        GST_BUFFER_OFFSET (buf), GST_BUFFER_OFFSET_END (buf),        GST_BUFFER_FLAGS (buf), buf);    GST_OBJECT_UNLOCK (identity);    gst_identity_notify_last_message (identity);  }  if (identity->datarate > 0) {    GstClockTime time = gst_util_uint64_scale_int (identity->offset,        GST_SECOND, identity->datarate);    GST_BUFFER_TIMESTAMP (buf) = time;    GST_BUFFER_DURATION (buf) =        GST_BUFFER_SIZE (buf) * GST_SECOND / identity->datarate;  }  if (identity->signal_handoffs)    g_signal_emit (identity, gst_identity_signals[SIGNAL_HANDOFF], 0, buf);  if (trans->segment.format == GST_FORMAT_TIME)    runtimestamp = gst_segment_to_running_time (&trans->segment,        GST_FORMAT_TIME, GST_BUFFER_TIMESTAMP (buf));  if ((identity->sync) && (trans->segment.format == GST_FORMAT_TIME)) {    GstClock *clock;    GST_OBJECT_LOCK (identity);    if ((clock = GST_ELEMENT (identity)->clock)) {      GstClockReturn cret;      GstClockTime timestamp;      timestamp = runtimestamp + GST_ELEMENT (identity)->base_time;      /* save id if we need to unlock */      /* FIXME: actually unlock this somewhere in the state changes */      identity->clock_id = gst_clock_new_single_shot_id (clock, timestamp);//.........这里部分代码省略.........
开发者ID:genesi,项目名称:gstreamer,代码行数:101,


示例26: gst_ivf_parse_chain

//.........这里部分代码省略.........        const guint8 *data = gst_adapter_peek (ivf->adapter, 32);        guint32 magic = GST_READ_UINT32_LE (data);        guint16 version = GST_READ_UINT16_LE (data + 4);        guint16 header_size = GST_READ_UINT16_LE (data + 6);        guint32 fourcc = GST_READ_UINT32_LE (data + 8);        guint16 width = GST_READ_UINT16_LE (data + 12);        guint16 height = GST_READ_UINT16_LE (data + 14);        guint32 rate_num = GST_READ_UINT32_LE (data + 16);        guint32 rate_den = GST_READ_UINT32_LE (data + 20);#ifndef GST_DISABLE_GST_DEBUG        guint32 num_frames = GST_READ_UINT32_LE (data + 24);#endif        /* last 4 bytes unused */        gst_adapter_flush (ivf->adapter, 32);        if (magic != GST_MAKE_FOURCC ('D', 'K', 'I', 'F') ||            version != 0 || header_size != 32 ||            fourcc != GST_MAKE_FOURCC ('V', 'P', '8', '0')) {          GST_ELEMENT_ERROR (ivf, STREAM, WRONG_TYPE, (NULL), (NULL));          return GST_FLOW_ERROR;        }        /* create src pad caps */        caps = gst_caps_new_simple ("video/x-vp8",            "width", G_TYPE_INT, width, "height", G_TYPE_INT, height,            "framerate", GST_TYPE_FRACTION, rate_num, rate_den, NULL);        GST_INFO_OBJECT (ivf, "Found stream: %" GST_PTR_FORMAT, caps);        GST_LOG_OBJECT (ivf, "Stream has %d frames", num_frames);        gst_pad_set_caps (ivf->srcpad, caps);        gst_caps_unref (caps);        /* keep framerate in instance for convenience */        ivf->rate_num = rate_num;        ivf->rate_den = rate_den;        gst_pad_push_event (ivf->srcpad, gst_event_new_new_segment (FALSE, 1.0,                GST_FORMAT_TIME, 0, -1, 0));        /* move along */        ivf->state = GST_IVF_PARSE_DATA;      } else {        GST_LOG_OBJECT (ivf, "Header data not yet available.");        break;      }      /* fall through */    case GST_IVF_PARSE_DATA:      while (gst_adapter_available (ivf->adapter) > 12) {        const guint8 *data = gst_adapter_peek (ivf->adapter, 12);        guint32 frame_size = GST_READ_UINT32_LE (data);        guint64 frame_pts = GST_READ_UINT64_LE (data + 4);        GST_LOG_OBJECT (ivf,            "Read frame header: size %u, pts %" G_GUINT64_FORMAT, frame_size,            frame_pts);        if (gst_adapter_available (ivf->adapter) >= 12 + frame_size) {          GstBuffer *frame;          gst_adapter_flush (ivf->adapter, 12);          frame = gst_adapter_take_buffer (ivf->adapter, frame_size);          gst_buffer_set_caps (frame, GST_PAD_CAPS (ivf->srcpad));          GST_BUFFER_TIMESTAMP (frame) =              gst_util_uint64_scale_int (GST_SECOND * frame_pts, ivf->rate_den,              ivf->rate_num);          GST_BUFFER_DURATION (frame) =              gst_util_uint64_scale_int (GST_SECOND, ivf->rate_den,              ivf->rate_num);          GST_DEBUG_OBJECT (ivf, "Pushing frame of size %u, ts %"              GST_TIME_FORMAT ", dur %" GST_TIME_FORMAT ", off %"              G_GUINT64_FORMAT ", off_end %" G_GUINT64_FORMAT,              GST_BUFFER_SIZE (frame),              GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (frame)),              GST_TIME_ARGS (GST_BUFFER_DURATION (frame)),              GST_BUFFER_OFFSET (frame), GST_BUFFER_OFFSET_END (frame));          res = gst_pad_push (ivf->srcpad, frame);          if (res != GST_FLOW_OK)            break;        } else {          GST_LOG_OBJECT (ivf, "Frame data not yet available.");          break;        }      }      break;    default:      g_return_val_if_reached (GST_FLOW_ERROR);  }  return res;}
开发者ID:drothlis,项目名称:gst-plugins-bad,代码行数:101,


示例27: gst_dvdec_chain

//.........这里部分代码省略.........    gst_caps_unref (caps);  }  if (dvdec->need_segment) {    gst_pad_push_event (dvdec->srcpad, gst_event_new_segment (&dvdec->segment));    dvdec->need_segment = FALSE;  }  ret = gst_buffer_pool_acquire_buffer (dvdec->pool, &outbuf, NULL);  if (G_UNLIKELY (ret != GST_FLOW_OK))    goto no_buffer;  gst_video_frame_map (&frame, &dvdec->vinfo, outbuf, GST_MAP_WRITE);  outframe_ptrs[0] = GST_VIDEO_FRAME_COMP_DATA (&frame, 0);  outframe_pitches[0] = GST_VIDEO_FRAME_COMP_STRIDE (&frame, 0);  /* the rest only matters for YUY2 */  if (dvdec->bpp < 3) {    outframe_ptrs[1] = GST_VIDEO_FRAME_COMP_DATA (&frame, 1);    outframe_ptrs[2] = GST_VIDEO_FRAME_COMP_DATA (&frame, 2);    outframe_pitches[1] = GST_VIDEO_FRAME_COMP_STRIDE (&frame, 1);    outframe_pitches[2] = GST_VIDEO_FRAME_COMP_STRIDE (&frame, 2);  }  GST_DEBUG_OBJECT (dvdec, "decoding and pushing buffer");  dv_decode_full_frame (dvdec->decoder, inframe,      e_dv_color_yuv, outframe_ptrs, outframe_pitches);  gst_video_frame_unmap (&frame);  GST_BUFFER_FLAG_UNSET (outbuf, GST_VIDEO_BUFFER_FLAG_TFF);  GST_BUFFER_OFFSET (outbuf) = GST_BUFFER_OFFSET (buf);  GST_BUFFER_OFFSET_END (outbuf) = GST_BUFFER_OFFSET_END (buf);  /* FIXME : Compute values when using non-TIME segments,   * but for the moment make sure we at least don't set bogus values   */  if (GST_CLOCK_TIME_IS_VALID (cstart)) {    GST_BUFFER_TIMESTAMP (outbuf) = cstart;    if (GST_CLOCK_TIME_IS_VALID (cstop))      GST_BUFFER_DURATION (outbuf) = cstop - cstart;  }  ret = gst_pad_push (dvdec->srcpad, outbuf);skip:  dvdec->video_offset++;done:  gst_buffer_unmap (buf, &map);  gst_buffer_unref (buf);  return ret;  /* ERRORS */wrong_size:  {    GST_ELEMENT_ERROR (dvdec, STREAM, DECODE,        (NULL), ("Input buffer too small"));    ret = GST_FLOW_ERROR;    goto done;  }parse_header_error:  {    GST_ELEMENT_ERROR (dvdec, STREAM, DECODE,        (NULL), ("Error parsing DV header"));    ret = GST_FLOW_ERROR;    goto done;  }not_negotiated:  {    GST_DEBUG_OBJECT (dvdec, "could not negotiate output");    if (GST_PAD_IS_FLUSHING (dvdec->srcpad))      ret = GST_FLOW_FLUSHING;    else      ret = GST_FLOW_NOT_NEGOTIATED;    goto done;  }flushing:  {    GST_DEBUG_OBJECT (dvdec, "have no current caps");    ret = GST_FLOW_FLUSHING;    goto done;  }no_buffer:  {    GST_DEBUG_OBJECT (dvdec, "could not allocate buffer");    goto done;  }dropping:  {    GST_DEBUG_OBJECT (dvdec,        "dropping buffer since it's out of the configured segment");    goto done;  }}
开发者ID:GrokImageCompression,项目名称:gst-plugins-good,代码行数:101,



注:本文中的GST_BUFFER_OFFSET函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ GST_BUFFER_OFFSET_END函数代码示例
C++ GST_BUFFER_IS_DISCONT函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。