static gboolean
gst_neonhttp_src_query (GstBaseSrc * bsrc, GstQuery * query)
{
    GstNeonhttpSrc *src = GST_NEONHTTP_SRC (bsrc);
    gboolean ret;

    switch (GST_QUERY_TYPE (query)) {
    case GST_QUERY_URI:
        gst_query_set_uri (query, src->location);
        ret = TRUE;
        break;
    default:
        ret = FALSE;
        break;
    }

    if (!ret)
        ret = GST_BASE_SRC_CLASS (parent_class)->query (bsrc, query);

    switch (GST_QUERY_TYPE (query)) {
    case GST_QUERY_SCHEDULING: {
        GstSchedulingFlags flags;
        gint minsize, maxsize, align;

        gst_query_parse_scheduling (query, &flags, &minsize, &maxsize, &align);
        flags |= GST_SCHEDULING_FLAG_BANDWIDTH_LIMITED;
        gst_query_set_scheduling (query, flags, minsize, maxsize, align);
        break;
    }
    default:
        break;
    }

    return ret;
}
예제 #2
0
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);
    }
}
예제 #3
0
static gboolean
gst_gio_base_src_query (GstBaseSrc * base_src, GstQuery * query)
{
  gboolean ret = FALSE;
  GstGioBaseSrc *src = GST_GIO_BASE_SRC (base_src);

  switch (GST_QUERY_TYPE (query)) {
    case GST_QUERY_URI:
      if (GST_IS_URI_HANDLER (src)) {
        gchar *uri = gst_uri_handler_get_uri (GST_URI_HANDLER (src));
        gst_query_set_uri (query, uri);
        g_free (uri);
        ret = TRUE;
      }
      break;
    default:
      ret = FALSE;
      break;
  }

  if (!ret)
    ret = GST_BASE_SRC_CLASS (parent_class)->query (base_src, query);

  return ret;
}
예제 #4
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);
    }
}
예제 #5
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);
  }
}
예제 #6
0
static gboolean
gst_hls_demux_src_query (GstPad * pad, GstQuery * query)
{
  GstHLSDemux *hlsdemux;
  gboolean ret = FALSE;

  if (query == NULL)
    return FALSE;

  hlsdemux = GST_HLS_DEMUX (gst_pad_get_element_private (pad));

  switch (query->type) {
    case GST_QUERY_DURATION:{
      GstClockTime duration;
      GstFormat fmt;

      gst_query_parse_duration (query, &fmt, NULL);
      if (fmt == GST_FORMAT_TIME) {
        duration = gst_m3u8_client_get_duration (hlsdemux->client);
        if (GST_CLOCK_TIME_IS_VALID (duration) && duration > 0) {
          gst_query_set_duration (query, GST_FORMAT_TIME, duration);
          ret = TRUE;
        }
      }
      break;
    }
    case GST_QUERY_URI:
      if (hlsdemux->client) {
        /* FIXME: Do we answer with the variant playlist, with the current
         * playlist or the the uri of the least downlowaded fragment? */
        gst_query_set_uri (query, hlsdemux->client->current->uri);
        ret = TRUE;
      }
      break;
    case GST_QUERY_SEEKING:{
      GstFormat fmt;
      gint stop = -1;

      gst_query_parse_seeking (query, &fmt, NULL, NULL, NULL);
      if (fmt == GST_FORMAT_TIME) {
        GstClockTime duration;

        duration = gst_m3u8_client_get_duration (hlsdemux->client);
        if (GST_CLOCK_TIME_IS_VALID (duration) && duration > 0)
          stop = duration;
      }
      gst_query_set_seeking (query, fmt, FALSE, 0, stop);
      ret = TRUE;
      break;
    }
    default:
      /* Don't fordward queries upstream because of the special nature of this
       * "demuxer", which relies on the upstream element only to be fed with the
       * first playlist */
      break;
  }

  return ret;
}
예제 #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;
}
예제 #8
0
static gboolean
gst_rtmp_src_query (GstBaseSrc * basesrc, GstQuery * query)
{
  gboolean ret = FALSE;
  GstRTMPSrc *src = GST_RTMP_SRC (basesrc);

  switch (GST_QUERY_TYPE (query)) {
    case GST_QUERY_URI:
      gst_query_set_uri (query, src->uri);
      ret = TRUE;
      break;
    case GST_QUERY_POSITION:{
      GstFormat format;

      gst_query_parse_position (query, &format, NULL);
      if (format == GST_FORMAT_TIME) {
        gst_query_set_position (query, format, src->last_timestamp);
        ret = TRUE;
      }
      break;
    }
    case GST_QUERY_DURATION:{
      GstFormat format;
      gdouble duration;

      gst_query_parse_duration (query, &format, NULL);
      if (format == GST_FORMAT_TIME && src->rtmp) {
        duration = RTMP_GetDuration (src->rtmp);
        if (duration != 0.0) {
          gst_query_set_duration (query, format, duration * GST_SECOND);
          ret = TRUE;
        }
      }
      break;
    }
    case GST_QUERY_SCHEDULING:{
      gst_query_set_scheduling (query,
          GST_SCHEDULING_FLAG_SEQUENTIAL |
          GST_SCHEDULING_FLAG_BANDWIDTH_LIMITED, 1, -1, 0);
      gst_query_add_scheduling_mode (query, GST_PAD_MODE_PUSH);

      ret = TRUE;
      break;
    }
    default:
      ret = FALSE;
      break;
  }

  if (!ret)
    ret = GST_BASE_SRC_CLASS (parent_class)->query (basesrc, query);

  return ret;
}
예제 #9
0
static gboolean
gst_rtmp_src_query (GstBaseSrc * basesrc, GstQuery * query)
{
  gboolean ret = FALSE;
  GstRTMPSrc *src = GST_RTMP_SRC (basesrc);

  switch (GST_QUERY_TYPE (query)) {
    case GST_QUERY_URI:
      gst_query_set_uri (query, src->uri);
      ret = TRUE;
      break;
    case GST_QUERY_POSITION:{
      GstFormat format;

      gst_query_parse_position (query, &format, NULL);
      if (format == GST_FORMAT_TIME) {
        gst_query_set_duration (query, format, src->last_timestamp);
        ret = TRUE;
      }
      break;
    }
    case GST_QUERY_DURATION:{
      GstFormat format;
      gdouble duration;

      gst_query_parse_duration (query, &format, NULL);
      if (format == GST_FORMAT_TIME && src->rtmp) {
        duration = RTMP_GetDuration (src->rtmp);
        if (duration != 0.0) {
          gst_query_set_duration (query, format, duration * GST_SECOND);
          ret = TRUE;
        }
      }
      break;
    }
    default:
      ret = FALSE;
      break;
  }

  if (!ret)
    ret = GST_BASE_SRC_CLASS (parent_class)->query (basesrc, query);

  return ret;
}
예제 #10
0
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);
  }
}
예제 #11
0
static gboolean
gst_file_src_query (GstBaseSrc * basesrc, GstQuery * query)
{
  gboolean ret = FALSE;
  GstFileSrc *src = GST_FILE_SRC (basesrc);

  switch (GST_QUERY_TYPE (query)) {
    case GST_QUERY_URI:
      gst_query_set_uri (query, src->uri);
      ret = TRUE;
      break;
    default:
      ret = FALSE;
      break;
  }

  if (!ret)
    ret = GST_BASE_SRC_CLASS (parent_class)->query (basesrc, query);

  return ret;
}
예제 #12
0
static gboolean
gst_soup_http_src_query (GstBaseSrc * bsrc, GstQuery * query)
{
  GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (bsrc);
  gboolean ret;

  switch (GST_QUERY_TYPE (query)) {
    case GST_QUERY_URI:
      gst_query_set_uri (query, src->location);
      ret = TRUE;
      break;
    default:
      ret = FALSE;
      break;
  }

  if (!ret)
    ret = GST_BASE_SRC_CLASS (parent_class)->query (bsrc, query);

  return ret;
}
예제 #13
0
static gboolean
gst_gnome_vfs_src_query (GstBaseSrc * basesrc, GstQuery * query)
{
  gboolean ret = FALSE;
  GstGnomeVFSSrc *src = GST_GNOME_VFS_SRC (basesrc);

  switch (GST_QUERY_TYPE (query)) {
    case GST_QUERY_URI:
      gst_query_set_uri (query, src->uri_name);
      ret = TRUE;
      break;
    default:
      ret = FALSE;
      break;
  }

  if (!ret)
    ret = GST_BASE_SRC_CLASS (parent_class)->query (basesrc, query);

  return ret;
}
예제 #14
0
파일: query.cpp 프로젝트: xohm/qt-gstreamer
void UriQuery::setUri(const QUrl & uri)
{
    gst_query_set_uri(object<GstQuery>(), uri.toEncoded());
}
예제 #15
0
static gboolean
gst_hls_demux_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
{
  GstHLSDemux *hlsdemux;
  gboolean ret = FALSE;

  if (query == NULL)
    return FALSE;

  hlsdemux = GST_HLS_DEMUX (parent);

  switch (query->type) {
    case GST_QUERY_DURATION:{
      GstClockTime duration = -1;
      GstFormat fmt;

      gst_query_parse_duration (query, &fmt, NULL);
      if (fmt == GST_FORMAT_TIME) {
        duration = gst_m3u8_client_get_duration (hlsdemux->client);
        if (GST_CLOCK_TIME_IS_VALID (duration) && duration > 0) {
          gst_query_set_duration (query, GST_FORMAT_TIME, duration);
          ret = TRUE;
        }
      }
      GST_INFO_OBJECT (hlsdemux, "GST_QUERY_DURATION returns %s with duration %"
          GST_TIME_FORMAT, ret ? "TRUE" : "FALSE", GST_TIME_ARGS (duration));
      break;
    }
    case GST_QUERY_URI:
      if (hlsdemux->client) {
        /* FIXME: Do we answer with the variant playlist, with the current
         * playlist or the the uri of the least downlowaded fragment? */
        gst_query_set_uri (query, gst_m3u8_client_get_uri (hlsdemux->client));
        ret = TRUE;
      }
      break;
    case GST_QUERY_SEEKING:{
      GstFormat fmt;
      gint64 stop = -1;

      gst_query_parse_seeking (query, &fmt, NULL, NULL, NULL);
      GST_INFO_OBJECT (hlsdemux, "Received GST_QUERY_SEEKING with format %d",
          fmt);
      if (fmt == GST_FORMAT_TIME) {
        GstClockTime duration;

        duration = gst_m3u8_client_get_duration (hlsdemux->client);
        if (GST_CLOCK_TIME_IS_VALID (duration) && duration > 0)
          stop = duration;

        gst_query_set_seeking (query, fmt,
            !gst_m3u8_client_is_live (hlsdemux->client), 0, stop);
        ret = TRUE;
        GST_INFO_OBJECT (hlsdemux, "GST_QUERY_SEEKING returning with stop : %"
            GST_TIME_FORMAT, GST_TIME_ARGS (stop));
      }
      break;
    }
    default:
      /* Don't fordward queries upstream because of the special nature of this
       * "demuxer", which relies on the upstream element only to be fed with the
       * first playlist */
      break;
  }

  return ret;
}
예제 #16
0
static gboolean
gst_spot_src_query (GstBaseSrc * basesrc, GstQuery * query)
{
  gboolean ret = TRUE;
  GstSpotSrc *spot = GST_SPOT_SRC (basesrc);
  gint samplerate = GST_SPOT_SRC_FORMAT (spot)->sample_rate;
  gint64 src_val, dest_val;

  if (!GST_SPOT_SRC_FORMAT (spot)) {
    ret = FALSE;
    goto no_format_yet;
  }

  samplerate = GST_SPOT_SRC_FORMAT (spot)->sample_rate;

  switch (GST_QUERY_TYPE (query)) {
    case GST_QUERY_POSITION:
      {
      /*FIXME
       * this one we get, answer it or propagate?
       * seems like if we answer it we are not asked
       * to convert, so i guess this is better? 

      gint64 pos;
      GstFormat format;
      gst_query_parse_position (query, &format, &pos);
      pos = GST_SPOT_SRC_READ_POS (GST_SPOT_SRC (basesrc));
      GST_INFO_OBJECT (spot, "Query_position pos=%"G_GINT64_FORMAT);
       
      */
      ret = FALSE;
      }
      break;

    case GST_QUERY_DURATION:{
      GstFormat format;
      guint64 duration;
      gint64 value;
      gst_query_parse_duration (query, &format, &value);
      /* duration in ms */
      duration = run_spot_cmd (spot, SPOT_CMD_DURATION, 0);
      /* duration in ns */
      duration = 1000000 * duration;
      switch (format) {
        case GST_FORMAT_BYTES:
          {
          guint64 duration_bytes = (duration / 1000000000) * samplerate * 4;
          GST_INFO_OBJECT (spot, "Query_duration, duration_bytes=%" G_GUINT64_FORMAT, duration_bytes);
          gst_query_set_duration (query, format, duration_bytes);
          }
          break;
        case GST_FORMAT_TIME:
          {
          guint64 duration_time = duration;
          GST_INFO_OBJECT (spot, "Query_duration, duration_time=%" G_GUINT64_FORMAT, duration_time);
          gst_query_set_duration (query, format, duration_time);
          }
          break;
        default:
          ret = FALSE;
          g_assert_not_reached ();
          break;
      }
      break;
    }

    /* FIXME: JUST FOR DEBUGING */

    case GST_QUERY_LATENCY:
      /* propagate to basesrc */
      ret = FALSE;
      GST_INFO_OBJECT (spot, "Query_latency");
      break;

    case GST_QUERY_RATE:
      /* propagate to basesrc */
      ret = FALSE;
      GST_INFO_OBJECT (spot, "Query_latency");
      break; 

    case GST_QUERY_SEEKING:
      /* propagate to basesrc */
      ret = FALSE;
      GST_INFO_OBJECT (spot, "Query_seeking");
      break; 

    case GST_QUERY_SEGMENT:
      /* propagate to basesrc */
      ret = FALSE;
      GST_INFO_OBJECT (spot, "Query_segment");
      break; 

    case GST_QUERY_FORMATS:
      /* propagate to basesrc */
      ret = FALSE;
      GST_INFO_OBJECT (spot, "Query_formats");
      break; 

    case GST_QUERY_BUFFERING:
      /* propagate to basesrc */
      ret = FALSE;
      GST_INFO_OBJECT (spot, "Query_buffering");
      break; 

    case GST_QUERY_CONVERT:
      {
        GstFormat src_fmt, dest_fmt;

        gst_query_parse_convert (query, &src_fmt, &src_val, &dest_fmt, &dest_val);

        if (src_fmt == dest_fmt) {
          dest_val = src_val;
          GST_INFO_OBJECT (spot, "Convert done, dst_fmt == src_fmt");
          goto done;
        }

        GST_INFO_OBJECT (spot, "Convert src_fmt=%s to dst_fmt=%s", gst_format_get_name (src_fmt), gst_format_get_name (dest_fmt));

        switch (src_fmt) {
        case GST_FORMAT_BYTES:
          switch (dest_fmt) {
          case GST_FORMAT_TIME:
            /* samples to time convertion 
             *   - each sample has two channels with 16 bits, 4byte
             *   - samplerate is usually 44100hz
             *   - time is in nano seconds */
            dest_val = (src_val * 1000000000) / ((float)samplerate * 4);
            GST_INFO_OBJECT (spot,"Convert src_val=%" G_GINT64_FORMAT " b, dst_val=%" G_GINT64_FORMAT " ns", src_val, dest_val);
            break;
          default:
            ret = FALSE;
            g_assert_not_reached ();
            break;
          }
          break;
        case GST_FORMAT_TIME:
          switch (dest_fmt) {
          case GST_FORMAT_BYTES:
            /* time to samples */
            dest_val = (src_val * samplerate * 4) / 1000000000;
            GST_INFO_OBJECT (spot,"Convert src_val=%" G_GINT64_FORMAT " ns, dst_val=%" G_GINT64_FORMAT " b", src_val, dest_val);
            break;
          default:
            ret = FALSE;
            g_assert_not_reached ();
            break;
          }
          break;
        default:
          ret = FALSE;
          g_assert_not_reached ();
          break;
        }
      done:
        gst_query_set_convert (query, src_fmt, src_val, dest_fmt, dest_val);
        break;
      }

    case GST_QUERY_URI:
      gst_query_set_uri (query, spot->uri);
    break;

    default:
      GST_LOG_OBJECT (spot, "Query type unknown, default, type=%s", GST_QUERY_TYPE_NAME (query));
      g_assert_not_reached ();
      break;
  }

  if (!ret) {
    GST_LOG_OBJECT (spot, "Let basesrc handle query type=%s", GST_QUERY_TYPE_NAME (query));
    ret = GST_BASE_SRC_CLASS (parent_class)->query (basesrc, query);
  }

 no_format_yet:
  if (!ret) {
    GST_DEBUG_OBJECT (spot, "Query failed");
  }

  return ret;
}