Beispiel #1
0
static gboolean
gst_gio_base_sink_query (GstPad * pad, GstQuery * query)
{
    GstGioBaseSink *sink = GST_GIO_BASE_SINK (GST_PAD_PARENT (pad));
    GstFormat format;

    switch (GST_QUERY_TYPE (query)) {
    case GST_QUERY_POSITION:
        gst_query_parse_position (query, &format, NULL);
        switch (format) {
        case GST_FORMAT_BYTES:
        case GST_FORMAT_DEFAULT:
            gst_query_set_position (query, GST_FORMAT_BYTES, sink->position);
            return TRUE;
        default:
            return FALSE;
        }
    case GST_QUERY_FORMATS:
        gst_query_set_formats (query, 2, GST_FORMAT_DEFAULT, GST_FORMAT_BYTES);
        return TRUE;
    case GST_QUERY_URI:
        if (GST_IS_URI_HANDLER (sink)) {
            const gchar *uri;

            uri = gst_uri_handler_get_uri (GST_URI_HANDLER (sink));
            gst_query_set_uri (query, uri);
            return TRUE;
        }
        return FALSE;
    default:
        return gst_pad_query_default (pad, query);
    }
}
static gboolean
gst_gnome_vfs_sink_query (GstPad * pad, GstQuery * query)
{
    GstGnomeVFSSink *sink;
    GstFormat format;

    sink = GST_GNOME_VFS_SINK (GST_PAD_PARENT (pad));

    switch (GST_QUERY_TYPE (query)) {
    case GST_QUERY_POSITION:
        gst_query_parse_position (query, &format, NULL);
        switch (format) {
        case GST_FORMAT_DEFAULT:
        case GST_FORMAT_BYTES:
            gst_query_set_position (query, GST_FORMAT_BYTES, sink->current_pos);
            return TRUE;
        default:
            return FALSE;
        }

    case GST_QUERY_FORMATS:
        gst_query_set_formats (query, 2, GST_FORMAT_DEFAULT, GST_FORMAT_BYTES);
        return TRUE;

    case GST_QUERY_URI:
        gst_query_set_uri (query, sink->uri_name);
        return TRUE;

    default:
        return gst_pad_query_default (pad, query);
    }
}
Beispiel #3
0
static gboolean
gst_midi_parse_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
{
  gboolean res = TRUE;
  GstMidiParse *midiparse = GST_MIDI_PARSE (parent);

  switch (GST_QUERY_TYPE (query)) {
    case GST_QUERY_DURATION:
      gst_query_set_duration (query, GST_FORMAT_TIME,
          midiparse->segment.duration);
      break;
    case GST_QUERY_POSITION:
      gst_query_set_position (query, GST_FORMAT_TIME,
          midiparse->segment.position);
      break;
    case GST_QUERY_FORMATS:
      gst_query_set_formats (query, 1, GST_FORMAT_TIME);
      break;
    case GST_QUERY_SEGMENT:
      gst_query_set_segment (query, midiparse->segment.rate,
          midiparse->segment.format, midiparse->segment.start,
          midiparse->segment.stop);
      break;
    case GST_QUERY_SEEKING:
      gst_query_set_seeking (query, midiparse->segment.format,
          FALSE, 0, midiparse->segment.duration);
      break;
    default:
      res = gst_pad_query_default (pad, parent, query);
      break;
  }

  return res;
}
Beispiel #4
0
static gboolean
gst_file_sink_query (GstPad * pad, GstQuery * query)
{
  GstFileSink *self;
  GstFormat format;

  self = GST_FILE_SINK (GST_PAD_PARENT (pad));

  switch (GST_QUERY_TYPE (query)) {
    case GST_QUERY_POSITION:
      gst_query_parse_position (query, &format, NULL);
      switch (format) {
        case GST_FORMAT_DEFAULT:
        case GST_FORMAT_BYTES:
          gst_query_set_position (query, GST_FORMAT_BYTES, self->current_pos);
          return TRUE;
        default:
          return FALSE;
      }

    case GST_QUERY_FORMATS:
      gst_query_set_formats (query, 2, GST_FORMAT_DEFAULT, GST_FORMAT_BYTES);
      return TRUE;

    case GST_QUERY_URI:
      gst_query_set_uri (query, self->uri);
      return TRUE;

    default:
      return gst_pad_query_default (pad, query);
  }
}
Beispiel #5
0
static gboolean
gst_wildmidi_src_query (GstPad * pad, GstQuery * query)
{
  gboolean res = TRUE;
  GstWildmidi *wildmidi = GST_WILDMIDI (gst_pad_get_parent (pad));
  GstFormat src_format, dst_format;
  gint64 src_value, dst_value;

  if (!wildmidi->song) {
    gst_object_unref (wildmidi);
    return FALSE;
  }

  switch (GST_QUERY_TYPE (query)) {
    case GST_QUERY_DURATION:
      gst_query_set_duration (query, GST_FORMAT_TIME,
          gst_util_uint64_scale_int (wildmidi->o_len, GST_SECOND,
              WILDMIDI_RATE));
      break;
    case GST_QUERY_POSITION:
      gst_query_set_position (query, GST_FORMAT_TIME,
          gst_util_uint64_scale_int (wildmidi->o_segment->last_stop, GST_SECOND,
              WILDMIDI_RATE));
      break;
    case GST_QUERY_CONVERT:
      gst_query_parse_convert (query, &src_format, &src_value,
          &dst_format, NULL);

      res =
          gst_wildmidi_src_convert (wildmidi, src_format, src_value,
          &dst_format, &dst_value);
      if (res)
        gst_query_set_convert (query, src_format, src_value, dst_format,
            dst_value);

      break;
    case GST_QUERY_FORMATS:
      gst_query_set_formats (query, 3,
          GST_FORMAT_TIME, GST_FORMAT_BYTES, GST_FORMAT_DEFAULT);
      break;
    case GST_QUERY_SEGMENT:
      gst_query_set_segment (query, wildmidi->o_segment->rate,
          wildmidi->o_segment->format, wildmidi->o_segment->start,
          wildmidi->o_segment->stop);
      break;
    case GST_QUERY_SEEKING:
      gst_query_set_seeking (query, wildmidi->o_segment->format,
          TRUE, 0, wildmidi->o_len);
      break;
    default:
      res = FALSE;
      break;
  }

  gst_object_unref (wildmidi);
  return res;
}
Beispiel #6
0
static gboolean
gst_timidity_src_query (GstPad * pad, GstQuery * query)
{
  gboolean res = TRUE;
  GstTimidity *timidity = GST_TIMIDITY (gst_pad_get_parent (pad));
  GstFormat src_format, dst_format;
  gint64 src_value, dst_value;

  if (!timidity->song) {
    gst_object_unref (timidity);
    return FALSE;
  }

  switch (GST_QUERY_TYPE (query)) {
    case GST_QUERY_DURATION:
      gst_query_set_duration (query, GST_FORMAT_TIME,
          GST_MSECOND * (gint64) mid_song_get_total_time (timidity->song));
      break;
    case GST_QUERY_POSITION:
      gst_query_set_position (query, GST_FORMAT_TIME,
          timidity->o_segment->last_stop * timidity->time_per_frame);
      break;
    case GST_QUERY_CONVERT:
      gst_query_parse_convert (query, &src_format, &src_value,
          &dst_format, NULL);

      res =
          gst_timidity_src_convert (timidity, src_format, src_value,
          &dst_format, &dst_value);
      if (res)
        gst_query_set_convert (query, src_format, src_value, dst_format,
            dst_value);

      break;
    case GST_QUERY_FORMATS:
      gst_query_set_formats (query, 3,
          GST_FORMAT_TIME, GST_FORMAT_BYTES, GST_FORMAT_DEFAULT);
      break;
    case GST_QUERY_SEGMENT:
      gst_query_set_segment (query, timidity->o_segment->rate,
          timidity->o_segment->format, timidity->o_segment->start,
          timidity->o_segment->stop);
      break;
    case GST_QUERY_SEEKING:
      gst_query_set_seeking (query, timidity->o_segment->format,
          TRUE, 0, timidity->o_len);
      break;
    default:
      res = FALSE;
      break;
  }

  gst_object_unref (timidity);
  return res;
}
Beispiel #7
0
static gboolean
gst_fd_sink_query (GstBaseSink * bsink, GstQuery * query)
{
  gboolean res = FALSE;
  GstFdSink *fdsink;

  fdsink = GST_FD_SINK (bsink);

  switch (GST_QUERY_TYPE (query)) {
    case GST_QUERY_POSITION:
    {
      GstFormat format;

      gst_query_parse_position (query, &format, NULL);

      switch (format) {
        case GST_FORMAT_DEFAULT:
        case GST_FORMAT_BYTES:
          gst_query_set_position (query, GST_FORMAT_BYTES, fdsink->current_pos);
          res = TRUE;
          break;
        default:
          break;
      }
      break;
    }
    case GST_QUERY_FORMATS:
      gst_query_set_formats (query, 2, GST_FORMAT_DEFAULT, GST_FORMAT_BYTES);
      res = TRUE;
      break;
    case GST_QUERY_URI:
      gst_query_set_uri (query, fdsink->uri);
      res = TRUE;
      break;
    case GST_QUERY_SEEKING:{
      GstFormat format;

      gst_query_parse_seeking (query, &format, NULL, NULL, NULL);
      if (format == GST_FORMAT_BYTES || format == GST_FORMAT_DEFAULT) {
        gst_query_set_seeking (query, GST_FORMAT_BYTES, fdsink->seekable, 0,
            -1);
      } else {
        gst_query_set_seeking (query, format, FALSE, 0, -1);
      }
      res = TRUE;
      break;
    }
    default:
      res = GST_BASE_SINK_CLASS (parent_class)->query (bsink, query);
      break;

  }
  return res;
}
static gboolean
gst_gio_base_sink_query (GstBaseSink * bsink, GstQuery * query)
{
  GstGioBaseSink *sink = GST_GIO_BASE_SINK (bsink);
  GstFormat format;

  switch (GST_QUERY_TYPE (query)) {
    case GST_QUERY_POSITION:
      gst_query_parse_position (query, &format, NULL);
      switch (format) {
        case GST_FORMAT_BYTES:
        case GST_FORMAT_DEFAULT:
          gst_query_set_position (query, format, sink->position);
          return TRUE;
        default:
          return FALSE;
      }
    case GST_QUERY_FORMATS:
      gst_query_set_formats (query, 2, GST_FORMAT_DEFAULT, GST_FORMAT_BYTES);
      return TRUE;
    case GST_QUERY_URI:
      if (GST_IS_URI_HANDLER (sink)) {
        gchar *uri;

        uri = gst_uri_handler_get_uri (GST_URI_HANDLER (sink));
        gst_query_set_uri (query, uri);
        g_free (uri);
        return TRUE;
      }
      return FALSE;
    case GST_QUERY_SEEKING:
      gst_query_parse_seeking (query, &format, NULL, NULL, NULL);
      if (format == GST_FORMAT_BYTES || format == GST_FORMAT_DEFAULT) {
        gst_query_set_seeking (query, format,
            GST_GIO_STREAM_IS_SEEKABLE (sink->stream), 0, -1);
      } else {
        gst_query_set_seeking (query, format, FALSE, 0, -1);
      }
      return TRUE;
    default:
      return GST_BASE_SINK_CLASS (parent_class)->query (bsink, query);
  }
}
Beispiel #9
0
static gboolean
gst_wildmidi_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
{
  gboolean res = TRUE;
  GstWildmidi *wildmidi = GST_WILDMIDI (parent);
  GstFormat src_format, dst_format;
  gint64 src_value, dst_value;

  if (!wildmidi->song)
    return FALSE;

  switch (GST_QUERY_TYPE (query)) {
    case GST_QUERY_DURATION:
      gst_query_set_duration (query, GST_FORMAT_TIME,
          gst_util_uint64_scale_int (wildmidi->o_len, GST_SECOND,
              WILDMIDI_RATE));
      break;
    case GST_QUERY_POSITION:
      gst_query_set_position (query, GST_FORMAT_TIME,
          gst_util_uint64_scale_int (wildmidi->o_segment->position, GST_SECOND,
              WILDMIDI_RATE));
      break;
    case GST_QUERY_CONVERT:
      gst_query_parse_convert (query, &src_format, &src_value,
          &dst_format, NULL);

      res =
          gst_wildmidi_src_convert (wildmidi, src_format, src_value,
          &dst_format, &dst_value);
      if (res)
        gst_query_set_convert (query, src_format, src_value, dst_format,
            dst_value);

      break;
    case GST_QUERY_FORMATS:
      gst_query_set_formats (query, 3,
          GST_FORMAT_TIME, GST_FORMAT_BYTES, GST_FORMAT_DEFAULT);
      break;
    case GST_QUERY_SEGMENT:{
      GstFormat format;
      gint64 start, stop;

      format = wildmidi->o_segment->format;

      start =
          gst_segment_to_stream_time (wildmidi->o_segment, format,
          wildmidi->o_segment->start);
      if ((stop = wildmidi->o_segment->stop) == -1)
        stop = wildmidi->o_segment->duration;
      else
        stop = gst_segment_to_stream_time (wildmidi->o_segment, format, stop);

      gst_query_set_segment (query, wildmidi->o_segment->rate, format, start,
          stop);
      res = TRUE;
      break;
    }
    case GST_QUERY_SEEKING:
      gst_query_set_seeking (query, wildmidi->o_segment->format,
          TRUE, 0, wildmidi->o_len);
      break;
    default:
      res = gst_pad_query_default (pad, parent, query);
      break;
  }

  return res;
}
Beispiel #10
0
void create_queries()
{
  GstQuery *query;

  /* POSITION */
  {
    GstFormat format;
    gint64 position;
		xmlfile = "gstquery_create_queries";
		std_log(LOG_FILENAME_LINE, "Test Started create_queries");
    query = gst_query_new_position (GST_FORMAT_TIME);
    fail_if (query == NULL);
    fail_unless (GST_QUERY_TYPE (query) == GST_QUERY_POSITION);

    gst_query_parse_position (query, &format, NULL);
    fail_if (format != GST_FORMAT_TIME);

    gst_query_set_position (query, GST_FORMAT_TIME, 0xdeadbeaf);

    gst_query_parse_position (query, &format, &position);
    fail_if (format != GST_FORMAT_TIME);
    fail_if (position != 0xdeadbeaf);

    gst_query_unref (query);
  }
  /* DURATION */
  {
    GstFormat format;
    gint64 duration;

    query = gst_query_new_duration (GST_FORMAT_TIME);
    fail_if (query == NULL);
    fail_unless (GST_QUERY_TYPE (query) == GST_QUERY_DURATION);

    gst_query_parse_duration (query, &format, NULL);
    fail_if (format != GST_FORMAT_TIME);

    gst_query_set_duration (query, GST_FORMAT_TIME, 0xdeadbeaf);

    gst_query_parse_duration (query, &format, &duration);
    fail_if (format != GST_FORMAT_TIME);
    fail_if (duration != 0xdeadbeaf);

    gst_query_unref (query);
  }
  {
    /* FIXME make tests for:
     *
     * LATENCY
     * JITTER
     * RATE
     * SEEKING
     * SEGMENT
     * CONVERT
     */
  }
  /* SEGMENT */
  {
    gdouble rate;
    GstFormat format;
    gint64 start, stop;

    format = GST_FORMAT_BYTES;
    query = gst_query_new_segment (format);

    fail_if (query == NULL);
    fail_unless (GST_QUERY_TYPE (query) == GST_QUERY_SEGMENT);

    gst_query_parse_segment (query, &rate, &format, &start, &stop);

    /* see if empty gives undefined formats */
    fail_if (rate != 0.0);
    fail_if (format != GST_FORMAT_BYTES);
    fail_if (start != -1);
    fail_if (stop != -1);

    /* change all values */
    gst_query_set_segment (query, 2.0, GST_FORMAT_TIME, 1 * GST_SECOND,
        3 * GST_SECOND);

    gst_query_parse_segment (query, &rate, &format, &start, &stop);

    /* see if the values were changed */
    fail_if (rate != 2.0);
    fail_if (format != GST_FORMAT_TIME);
    fail_if (start != 1 * GST_SECOND);
    fail_if (stop != 3 * GST_SECOND);

    gst_query_unref (query);
  }

  /* FORMATS */
  {
    guint size;
    GstFormat format;

    query = gst_query_new_formats ();
    fail_if (query == NULL);
    fail_unless (GST_QUERY_TYPE (query) == GST_QUERY_FORMATS);

    /* empty */
    gst_query_parse_formats_length (query, &size);
    fail_if (size != 0);

    /* see if empty gives undefined formats */
    gst_query_parse_formats_nth (query, 0, &format);
    fail_if (format != GST_FORMAT_UNDEFINED);
    gst_query_parse_formats_nth (query, 1, &format);
    fail_if (format != GST_FORMAT_UNDEFINED);

    /* set 2 formats */
    gst_query_set_formats (query, 2, GST_FORMAT_TIME, GST_FORMAT_BYTES);

    gst_query_parse_formats_length (query, &size);
    fail_if (size != 2);

    format = GST_FORMAT_UNDEFINED;

    gst_query_parse_formats_nth (query, 0, &format);
    fail_if (format != GST_FORMAT_TIME);
    gst_query_parse_formats_nth (query, 1, &format);
    fail_if (format != GST_FORMAT_BYTES);

    /* out of bounds, should return UNDEFINED */
    gst_query_parse_formats_nth (query, 2, &format);
    fail_if (format != GST_FORMAT_UNDEFINED);

    /* overwrite with 3 formats */
    gst_query_set_formats (query, 3, GST_FORMAT_TIME, GST_FORMAT_BYTES,
        GST_FORMAT_PERCENT);

    gst_query_parse_formats_length (query, &size);
    fail_if (size != 3);

    gst_query_parse_formats_nth (query, 2, &format);
    fail_if (format != GST_FORMAT_PERCENT);

    /* create one from an array */
    {
      static GstFormat formats[] = {
        GST_FORMAT_TIME,
        GST_FORMAT_BYTES,
        GST_FORMAT_PERCENT
      };
      gst_query_set_formatsv (query, 3, formats);

      gst_query_parse_formats_length (query, &size);
      fail_if (size != 3);

      gst_query_parse_formats_nth (query, 0, &format);
      fail_if (format != GST_FORMAT_TIME);
      gst_query_parse_formats_nth (query, 2, &format);
      fail_if (format != GST_FORMAT_PERCENT);
    }
    gst_query_unref (query);
  }
	std_log(LOG_FILENAME_LINE, "Test Successful");
	create_xml(0);


}