static gboolean play_do_seek (GstElement * pipeline, gint64 pos, gdouble rate, GstPlayTrickMode mode) { GstSeekFlags seek_flags; GstQuery *query; GstEvent *seek; gboolean seekable = FALSE; query = gst_query_new_seeking (GST_FORMAT_TIME); if (!gst_element_query (pipeline, query)) { gst_query_unref (query); return FALSE; } gst_query_parse_seeking (query, NULL, &seekable, NULL, NULL); gst_query_unref (query); if (!seekable) return FALSE; seek_flags = GST_SEEK_FLAG_FLUSH; switch (mode) { case GST_PLAY_TRICK_MODE_DEFAULT: seek_flags |= GST_SEEK_FLAG_TRICKMODE; break; case GST_PLAY_TRICK_MODE_DEFAULT_NO_AUDIO: seek_flags |= GST_SEEK_FLAG_TRICKMODE | GST_SEEK_FLAG_TRICKMODE_NO_AUDIO; break; case GST_PLAY_TRICK_MODE_KEY_UNITS: seek_flags |= GST_SEEK_FLAG_TRICKMODE_KEY_UNITS; break; case GST_PLAY_TRICK_MODE_KEY_UNITS_NO_AUDIO: seek_flags |= GST_SEEK_FLAG_TRICKMODE_KEY_UNITS | GST_SEEK_FLAG_TRICKMODE_NO_AUDIO; break; case GST_PLAY_TRICK_MODE_NONE: default: break; } if (rate >= 0) seek = gst_event_new_seek (rate, GST_FORMAT_TIME, seek_flags | GST_SEEK_FLAG_ACCURATE, /* start */ GST_SEEK_TYPE_SET, pos, /* stop */ GST_SEEK_TYPE_SET, GST_CLOCK_TIME_NONE); else seek = gst_event_new_seek (rate, GST_FORMAT_TIME, seek_flags | GST_SEEK_FLAG_ACCURATE, /* start */ GST_SEEK_TYPE_SET, 0, /* stop */ GST_SEEK_TYPE_SET, pos); if (!gst_element_send_event (pipeline, seek)) return FALSE; cur_rate = rate; trick_mode = mode; return TRUE; }
float MediaPlayerPrivate::currentTime() const { if (!m_playBin) return 0; if (m_errorOccured) return 0; float ret = 0.0; GstQuery* query = gst_query_new_position(GST_FORMAT_TIME); if (!gst_element_query(m_playBin, query)) { LOG_VERBOSE(Media, "Position query failed..."); gst_query_unref(query); return ret; } gint64 position; gst_query_parse_position(query, 0, &position); ret = (float) (position / 1000000000.0); LOG_VERBOSE(Media, "Position %" GST_TIME_FORMAT, GST_TIME_ARGS(position)); gst_query_unref(query); return ret; }
static gboolean gst_rnd_buffer_size_activate (GstPad * pad, GstObject * parent) { GstQuery *query; gboolean pull_mode; query = gst_query_new_scheduling (); if (!gst_pad_peer_query (pad, query)) { gst_query_unref (query); goto no_pull; } pull_mode = gst_query_has_scheduling_mode (query, GST_PAD_MODE_PULL); gst_query_unref (query); if (!pull_mode) goto no_pull; GST_DEBUG_OBJECT (pad, "activating pull"); return gst_pad_activate_mode (pad, GST_PAD_MODE_PULL, TRUE); /* ERRORS */ no_pull: { GST_DEBUG_OBJECT (pad, "pull mode not supported"); return FALSE; } }
static gboolean gst_wildmidi_activate (GstPad * sinkpad, GstObject * parent) { GstQuery *query; gboolean pull_mode; query = gst_query_new_scheduling (); if (!gst_pad_peer_query (sinkpad, query)) { gst_query_unref (query); goto activate_push; } pull_mode = gst_query_has_scheduling_mode_with_flags (query, GST_PAD_MODE_PULL, GST_SCHEDULING_FLAG_SEEKABLE); gst_query_unref (query); if (!pull_mode) goto activate_push; GST_DEBUG_OBJECT (sinkpad, "activating pull"); return gst_pad_activate_mode (sinkpad, GST_PAD_MODE_PULL, TRUE); activate_push: { GST_DEBUG_OBJECT (sinkpad, "activating push"); return gst_pad_activate_mode (sinkpad, GST_PAD_MODE_PUSH, TRUE); } }
static gboolean gst_asf_parse_sink_activate (GstPad * sinkpad, GstObject * parent) { GstQuery *query; gboolean pull_mode; query = gst_query_new_scheduling (); if (!gst_pad_peer_query (sinkpad, query)) { gst_query_unref (query); goto activate_push; } pull_mode = gst_query_has_scheduling_mode (query, GST_PAD_MODE_PULL); gst_query_unref (query); if (!pull_mode) goto activate_push; GST_DEBUG_OBJECT (sinkpad, "activating pull"); return gst_pad_activate_mode (sinkpad, GST_PAD_MODE_PULL, TRUE); activate_push: { GST_DEBUG_OBJECT (sinkpad, "activating push"); return gst_pad_activate_mode (sinkpad, GST_PAD_MODE_PUSH, TRUE); } }
static gboolean gst_type_find_element_activate_sink (GstPad * pad, GstObject * parent) { GstQuery *query; gboolean pull_mode; query = gst_query_new_scheduling (); if (!gst_pad_peer_query (pad, query)) { gst_query_unref (query); goto typefind_push; } pull_mode = gst_query_has_scheduling_mode_with_flags (query, GST_PAD_MODE_PULL, GST_SCHEDULING_FLAG_SEEKABLE); gst_query_unref (query); if (!pull_mode) goto typefind_push; if (!gst_pad_activate_mode (pad, GST_PAD_MODE_PULL, TRUE)) goto typefind_push; /* only start our task if we ourselves decide to start in pull mode */ return gst_pad_start_task (pad, (GstTaskFunction) gst_type_find_element_loop, pad, NULL); typefind_push: { return gst_pad_activate_mode (pad, GST_PAD_MODE_PUSH, TRUE); } }
/* generate queries to adaptive demux */ static gboolean testQueryCheckDataReceived (GstAdaptiveDemuxTestEngine * engine, GstAdaptiveDemuxTestOutputStream * stream, GstBuffer * buffer, gpointer user_data) { GList *pads; GstPad *pad; GstQuery *query; gboolean ret; gint64 duration; gboolean seekable; gint64 segment_start; gint64 segment_end; gchar *uri; gchar *redirect_uri; gboolean redirect_permanent; pads = GST_ELEMENT_PADS (stream->appsink); /* AppSink should have only 1 pad */ fail_unless (pads != NULL); fail_unless (g_list_length (pads) == 1); pad = GST_PAD (pads->data); query = gst_query_new_duration (GST_FORMAT_TIME); ret = gst_pad_peer_query (pad, query); fail_unless (ret == TRUE); gst_query_parse_duration (query, NULL, &duration); fail_unless (duration == 135743 * GST_MSECOND); gst_query_unref (query); query = gst_query_new_seeking (GST_FORMAT_TIME); ret = gst_pad_peer_query (pad, query); fail_unless (ret == TRUE); gst_query_parse_seeking (query, NULL, &seekable, &segment_start, &segment_end); fail_unless (seekable == TRUE); fail_unless (segment_start == 0); fail_unless (segment_end == duration); gst_query_unref (query); query = gst_query_new_uri (); ret = gst_pad_peer_query (pad, query); fail_unless (ret == TRUE); gst_query_parse_uri (query, &uri); gst_query_parse_uri_redirection (query, &redirect_uri); gst_query_parse_uri_redirection_permanent (query, &redirect_permanent); fail_unless (strcmp (uri, "http://unit.test/test.mpd") == 0); /* adaptive demux does not reply with redirect information */ fail_unless (redirect_uri == NULL); fail_unless (redirect_permanent == FALSE); g_free (uri); g_free (redirect_uri); gst_query_unref (query); return gst_adaptive_demux_test_check_received_data (engine, stream, buffer, user_data); }
static void relative_seek (GstPlay * play, gdouble percent) { GstQuery *query; gboolean seekable = FALSE; gint64 dur = -1, pos = -1, step; g_return_if_fail (percent >= -1.0 && percent <= 1.0); if (!gst_element_query_position (play->playbin, GST_FORMAT_TIME, &pos)) goto seek_failed; query = gst_query_new_seeking (GST_FORMAT_TIME); if (!gst_element_query (play->playbin, query)) { gst_query_unref (query); goto seek_failed; } gst_query_parse_seeking (query, NULL, &seekable, NULL, &dur); gst_query_unref (query); if (!seekable || dur <= 0) goto seek_failed; step = dur * percent; if (ABS (step) < GST_SECOND) step = (percent < 0) ? -GST_SECOND : GST_SECOND; pos = pos + step; if (pos > dur) { if (!play_next (play)) { g_print ("\n%s\n", _("Reached end of play list.")); g_main_loop_quit (play->loop); } } else { if (pos < 0) pos = 0; play_do_seek (play, pos, play->rate, play->trick_mode); } return; seek_failed: { g_print ("\nCould not seek.\n"); } }
P_INVOKE gboolean bp_can_seek (BansheePlayer *player) { GstQuery *query; gboolean can_seek = TRUE; g_return_val_if_fail (IS_BANSHEE_PLAYER (player), FALSE); if (player->playbin == NULL) { return FALSE; } query = gst_query_new_seeking (GST_FORMAT_TIME); if (!gst_element_query (player->playbin, query)) { // This will probably fail, 100% of the time, because it's apparently // very unimplemented in GStreamer... when it's fixed // we will return FALSE here, and show the warning // g_warning ("Could not query pipeline for seek ability"); return bp_get_duration (player) > 0; } gst_query_parse_seeking (query, NULL, &can_seek, NULL, NULL); gst_query_unref (query); return can_seek && bp_get_duration (player) > 0; }
bool GstPipe::speed(gdouble speed) { g_debug("GstPipeliner::speed %f", speed); speed_ = speed; GstQuery *query; gboolean res; // query position query = gst_query_new_position(GST_FORMAT_TIME); res = gst_element_query(pipeline_, query); gint64 cur_pos = 0; if (res) { gst_query_parse_position(query, nullptr, &cur_pos); g_debug("cur pos = %" GST_TIME_FORMAT "\n", GST_TIME_ARGS(cur_pos)); } else { g_warning("position query failed..."); } gst_query_unref(query); gboolean ret; ret = gst_element_seek(pipeline_, speed, GST_FORMAT_TIME, (GstSeekFlags) (GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE), GST_SEEK_TYPE_SET, cur_pos, GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE); if (!ret) g_debug("speed not handled\n"); return true; }
static gboolean _latency_query (GstAggregator * self, GstPad * pad, gpointer user_data) { LatencyData *data = user_data; GstClockTime min, max; GstQuery *query; gboolean live, res; query = gst_query_new_latency (); res = gst_pad_peer_query (pad, query); if (res) { gst_query_parse_latency (query, &live, &min, &max); GST_LOG_OBJECT (self, "got latency live:%s min:%" G_GINT64_FORMAT " max:%" G_GINT64_FORMAT, live ? "true" : "false", min, max); if (min > data->min) data->min = min; if (max != GST_CLOCK_TIME_NONE && ((data->max != GST_CLOCK_TIME_NONE && max < data->max) || (data->max == GST_CLOCK_TIME_NONE))) data->max = max; data->live |= live; } gst_query_unref (query); return TRUE; }
GstQuery * gst_vulkan_local_context_query (GstElement * element, const gchar * context_type, gboolean set_context) { GstQuery *query; GstContext *ctxt; _init_context_debug (); /* 2a) Query downstream with GST_QUERY_CONTEXT for the context and * check if downstream already has a context of the specific type * 2b) Query upstream as above. */ query = gst_query_new_context (context_type); if (gst_vulkan_run_query (element, query, GST_PAD_SRC)) { gst_query_parse_context (query, &ctxt); GST_CAT_INFO_OBJECT (GST_CAT_CONTEXT, element, "found context (%p) in downstream query", ctxt); if (set_context) gst_element_set_context (element, ctxt); } else if (gst_vulkan_run_query (element, query, GST_PAD_SINK)) { gst_query_parse_context (query, &ctxt); GST_CAT_INFO_OBJECT (GST_CAT_CONTEXT, element, "found context (%p) in upstream query", ctxt); if (set_context) gst_element_set_context (element, ctxt); } else { gst_query_unref (query); query = NULL; } return query; }
void gst_vulkan_global_context_query (GstElement * element, const gchar * context_type) { GstQuery *query; GstMessage *msg; if ((query = gst_vulkan_local_context_query (element, context_type, TRUE))) { gst_query_unref (query); return; } /* 3) Post a GST_MESSAGE_NEED_CONTEXT message on the bus with * the required context type and afterwards check if a * usable context was set now as in 1). The message could * be handled by the parent bins of the element and the * application. */ GST_CAT_INFO_OBJECT (GST_CAT_CONTEXT, element, "posting need context message"); msg = gst_message_new_need_context (GST_OBJECT_CAST (element), context_type); gst_element_post_message (element, msg); /* * Whomever responds to the need-context message performs a * GstElement::set_context() with the required context in which the element * is required to update the display_ptr or call gst_vulkan_handle_set_context(). */ }
/** * gst_gl_query_local_gl_context: * @element: a #GstElement to query from * @direction: the #GstPadDirection to query * @context_ptr: (inout): location containing the current and/or resulting * #GstGLContext * * Performs a GST_QUERY_CONTEXT query of type "gst.gl.local_context" on all * #GstPads in @element of @direction for the local OpenGL context used by * GStreamer elements. * * Returns: whether @context_ptr contains a #GstGLContext */ gboolean gst_gl_query_local_gl_context (GstElement * element, GstPadDirection direction, GstGLContext ** context_ptr) { GstQuery *query; GstContext *context; const GstStructure *s; g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE); g_return_val_if_fail (context_ptr != NULL, FALSE); if (*context_ptr) return TRUE; query = gst_query_new_context ("gst.gl.local_context"); if (gst_gl_run_query (GST_ELEMENT (element), query, direction)) { gst_query_parse_context (query, &context); if (context) { s = gst_context_get_structure (context); gst_structure_get (s, "context", GST_TYPE_GL_CONTEXT, context_ptr, NULL); } } gst_query_unref (query); return *context_ptr != NULL; }
static gboolean gst_hls_demux_sink_event (GstPad * pad, GstEvent * event) { GstHLSDemux *demux = GST_HLS_DEMUX (gst_pad_get_parent (pad)); GstQuery *query; gboolean ret; gchar *uri; switch (event->type) { case GST_EVENT_EOS:{ gchar *playlist; if (demux->playlist == NULL) { GST_WARNING_OBJECT (demux, "Received EOS without a playlist."); break; } GST_DEBUG_OBJECT (demux, "Got EOS on the sink pad: main playlist fetched"); query = gst_query_new_uri (); ret = gst_pad_peer_query (demux->sinkpad, query); if (ret) { gst_query_parse_uri (query, &uri); gst_hls_demux_set_location (demux, uri); g_free (uri); } gst_query_unref (query); playlist = gst_hls_src_buf_to_utf8_playlist ((gchar *) GST_BUFFER_DATA (demux->playlist), GST_BUFFER_SIZE (demux->playlist)); gst_buffer_unref (demux->playlist); if (playlist == NULL) { GST_WARNING_OBJECT (demux, "Error validating first playlist."); } else if (!gst_m3u8_client_update (demux->client, playlist)) { /* In most cases, this will happen if we set a wrong url in the * source element and we have received the 404 HTML response instead of * the playlist */ GST_ELEMENT_ERROR (demux, STREAM, DECODE, ("Invalid playlist."), NULL); return FALSE; } if (!ret && gst_m3u8_client_is_live (demux->client)) { GST_ELEMENT_ERROR (demux, RESOURCE, NOT_FOUND, ("Failed querying the playlist uri, " "required for live sources."), NULL); return FALSE; } gst_task_start (demux->task); gst_event_unref (event); return TRUE; } default: break; } return gst_pad_event_default (pad, event); }
static void check_uri_for_uri (GstElement * e, const gchar * in_uri, const gchar * uri) { GstQuery *query; gchar *query_uri = NULL; gst_uri_handler_set_uri (GST_URI_HANDLER (e), in_uri, NULL); query = gst_query_new_uri (); fail_unless (gst_element_query (e, query)); gst_query_parse_uri (query, &query_uri); gst_query_unref (query); if (uri != NULL) { fail_unless_equals_string (query_uri, uri); } else { gchar *fn; fail_unless (gst_uri_is_valid (query_uri)); fn = g_filename_from_uri (query_uri, NULL, NULL); fail_unless (g_path_is_absolute (fn)); fail_unless (fn != NULL); g_free (fn); } g_free (query_uri); }
static void check_uri_for_location (GstElement * e, const gchar * location, const gchar * uri) { GstQuery *query; gchar *query_uri = NULL; g_object_set (e, "location", location, NULL); query = gst_query_new_uri (); fail_unless (gst_element_query (e, query)); gst_query_parse_uri (query, &query_uri); gst_query_unref (query); if (uri != NULL) { fail_unless_equals_string (query_uri, uri); } else { gchar *fn; fail_unless (gst_uri_is_valid (query_uri)); fn = g_filename_from_uri (query_uri, NULL, NULL); fail_unless (g_path_is_absolute (fn)); fail_unless (fn != NULL); g_free (fn); } g_free (query_uri); }
gboolean gst_vulkan_device_run_context_query (GstElement * element, GstVulkanDevice ** device) { GstQuery *query; g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE); g_return_val_if_fail (device != NULL, FALSE); if (*device && GST_IS_VULKAN_DEVICE (*device)) return TRUE; if ((query = gst_vulkan_local_context_query (element, GST_VULKAN_DEVICE_CONTEXT_TYPE_STR, FALSE))) { GstContext *context; gst_query_parse_context (query, &context); if (context) gst_context_get_vulkan_device (context, device); } GST_DEBUG_OBJECT (element, "found device %p", *device); gst_query_unref (query); if (*device) return TRUE; return FALSE; }
static void handle_message (CustomData *data, GstMessage *msg) { GError *err; gchar *debug_info; switch (GST_MESSAGE_TYPE (msg)) { case GST_MESSAGE_ERROR: gst_message_parse_error (msg, &err, &debug_info); g_printerr ("Error received from element %s: %s\n", GST_OBJECT_NAME (msg->src), err->message); g_printerr ("Debugging information: %s\n", debug_info ? debug_info : "none"); g_clear_error (&err); g_free (debug_info); data->terminate = TRUE; break; case GST_MESSAGE_EOS: g_print ("End-Of-Stream reached.\n"); data->terminate = TRUE; break; case GST_MESSAGE_DURATION: /* The duration has changed, mark the current one as invalid */ data->duration = GST_CLOCK_TIME_NONE; break; case GST_MESSAGE_STATE_CHANGED: { GstState old_state, new_state, pending_state; gst_message_parse_state_changed (msg, &old_state, &new_state, &pending_state); if (GST_MESSAGE_SRC (msg) == GST_OBJECT (data->playbin2)) { g_print ("Pipeline state changed from %s to %s:\n", gst_element_state_get_name (old_state), gst_element_state_get_name (new_state)); /* Remember whether we are in the PLAYING state or not */ data->playing = (new_state == GST_STATE_PLAYING); if (data->playing) { /* We just moved to PLAYING. Check if seeking is possible */ GstQuery *query; gint64 start, end; query = gst_query_new_seeking (GST_FORMAT_TIME); if (gst_element_query (data->playbin2, query)) { gst_query_parse_seeking (query, NULL, &data->seek_enabled, &start, &end); if (data->seek_enabled) { g_print ("Seeking is ENABLED from %" GST_TIME_FORMAT " to %" GST_TIME_FORMAT "\n", GST_TIME_ARGS (start), GST_TIME_ARGS (end)); } else { g_print ("Seeking is DISABLED for this stream.\n"); } } else { g_printerr ("Seeking query failed."); } gst_query_unref (query); } } } break; default: /* We should not reach here */ g_printerr ("Unexpected message received.\n"); break; } gst_message_unref (msg); }
static gboolean gst_wayland_sink_find_display (GstWaylandSink * sink) { GstQuery *query; GstMessage *msg; GstContext *context = NULL; GError *error = NULL; gboolean ret = TRUE; g_mutex_lock (&sink->display_lock); if (!sink->display) { /* first query upstream for the needed display handle */ query = gst_query_new_context (GST_WAYLAND_DISPLAY_HANDLE_CONTEXT_TYPE); if (gst_pad_peer_query (GST_VIDEO_SINK_PAD (sink), query)) { gst_query_parse_context (query, &context); gst_wayland_sink_set_display_from_context (sink, context); } gst_query_unref (query); if (G_LIKELY (!sink->display)) { /* now ask the application to set the display handle */ msg = gst_message_new_need_context (GST_OBJECT_CAST (sink), GST_WAYLAND_DISPLAY_HANDLE_CONTEXT_TYPE); g_mutex_unlock (&sink->display_lock); gst_element_post_message (GST_ELEMENT_CAST (sink), msg); /* at this point we expect gst_wayland_sink_set_context * to get called and fill sink->display */ g_mutex_lock (&sink->display_lock); if (!sink->display) { /* if the application didn't set a display, let's create it ourselves */ GST_OBJECT_LOCK (sink); sink->display = gst_wl_display_new (sink->display_name, &error); GST_OBJECT_UNLOCK (sink); if (error) { GST_ELEMENT_WARNING (sink, RESOURCE, OPEN_READ_WRITE, ("Could not initialise Wayland output"), ("Failed to create GstWlDisplay: '%s'", error->message)); g_error_free (error); ret = FALSE; } else { /* inform the world about the new display */ context = gst_wayland_display_handle_context_new (sink->display->display); msg = gst_message_new_have_context (GST_OBJECT_CAST (sink), context); gst_element_post_message (GST_ELEMENT_CAST (sink), msg); } } } } g_mutex_unlock (&sink->display_lock); return ret; }
static gboolean gst_y4m_dec_src_query (GstPad * pad, GstQuery * query) { GstY4mDec *y4mdec = GST_Y4M_DEC (gst_pad_get_parent (pad)); gboolean res = FALSE; switch (GST_QUERY_TYPE (query)) { case GST_QUERY_DURATION: { GstFormat format; GstPad *peer; GST_DEBUG ("duration query"); gst_query_parse_duration (query, &format, NULL); if (format != GST_FORMAT_TIME) { res = FALSE; GST_DEBUG_OBJECT (y4mdec, "not handling duration query in format %d", format); break; } peer = gst_pad_get_peer (y4mdec->sinkpad); if (peer) { GstQuery *peer_query = gst_query_new_duration (GST_FORMAT_BYTES); res = gst_pad_query (peer, peer_query); if (res) { gint64 duration; int n_frames; gst_query_parse_duration (peer_query, &format, &duration); n_frames = gst_y4m_dec_bytes_to_frames (y4mdec, duration); GST_DEBUG ("duration in frames %d", n_frames); duration = gst_y4m_dec_frames_to_timestamp (y4mdec, n_frames); GST_DEBUG ("duration in time %" GST_TIME_FORMAT, GST_TIME_ARGS (duration)); gst_query_set_duration (query, GST_FORMAT_TIME, duration); res = TRUE; } gst_query_unref (peer_query); gst_object_unref (peer); } break; } default: res = gst_pad_query_default (pad, query); break; } gst_object_unref (y4mdec); return res; }
static void relative_seek (GstPlay * play, gdouble percent) { GstQuery *query; gboolean seekable = FALSE; gint64 dur = -1, pos = -1; g_return_if_fail (percent >= -1.0 && percent <= 1.0); if (!gst_element_query_position (play->playbin, GST_FORMAT_TIME, &pos)) goto seek_failed; query = gst_query_new_seeking (GST_FORMAT_TIME); if (!gst_element_query (play->playbin, query)) { gst_query_unref (query); goto seek_failed; } gst_query_parse_seeking (query, NULL, &seekable, NULL, &dur); gst_query_unref (query); if (!seekable || dur <= 0) goto seek_failed; pos = pos + dur * percent; if (pos > dur) { if (!play_next (play)) { g_print ("\nReached end of play list.\n"); g_main_loop_quit (play->loop); } } else { if (pos < 0) pos = 0; if (!gst_element_seek_simple (play->playbin, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT, pos)) goto seek_failed; } return; seek_failed: { g_print ("\nCould not seek.\n"); } }
static void gst_gl_display_context_query (GstElement * element, GstGLDisplay ** display_ptr) { GstContext *ctxt; GstQuery *query; #ifndef GST_DISABLE_GST_DEBUG if (!GST_CAT_CONTEXT) GST_DEBUG_CATEGORY_GET (GST_CAT_CONTEXT, "GST_CONTEXT"); #endif query = _gst_context_query (element, display_ptr, GST_GL_DISPLAY_CONTEXT_TYPE); gst_query_parse_context (query, &ctxt); if (ctxt && gst_context_has_context_type (ctxt, GST_GL_DISPLAY_CONTEXT_TYPE)) gst_context_get_gl_display (ctxt, display_ptr); if (*display_ptr) goto out; #if GST_GL_HAVE_WINDOW_X11 gst_query_unref (query); query = _gst_context_query (element, display_ptr, "gst.x11.display.handle"); gst_query_parse_context (query, &ctxt); if (ctxt && gst_context_has_context_type (ctxt, "gst.x11.display.handle")) { const GstStructure *s; Display *display; s = gst_context_get_structure (ctxt); if (gst_structure_get (s, "display", G_TYPE_POINTER, &display, NULL) && display) { *display_ptr = (GstGLDisplay *) gst_gl_display_x11_new_with_display (display); } } if (*display_ptr) goto out; #endif out: gst_query_unref (query); }
uint64_t ofGstUtils::getMaxLatencyNanos(){ GstClockTime minlat=0, maxlat=0; GstQuery * q = gst_query_new_latency(); if (gst_element_query (gstPipeline, q)) { gboolean live; gst_query_parse_latency (q, &live, &minlat, &maxlat); } gst_query_unref (q); return maxlat; }
static void push_query (gpointer data, gpointer user_data) { GstHarness *h = user_data; GstCaps *caps = gst_caps_new_empty_simple ("mycaps"); GstQuery *query = gst_query_new_allocation (caps, FALSE); gst_caps_unref (caps); gst_pad_peer_query (h->srcpad, query); gst_query_unref (query); }
unsigned MediaPlayerPrivateGStreamerBase::videoDecodedByteCount() const { GstQuery* query = gst_query_new_position(GST_FORMAT_BYTES); gint64 position = 0; if (gst_element_query(m_webkitVideoSink.get(), query)) gst_query_parse_position(query, 0, &position); gst_query_unref(query); return static_cast<unsigned>(position); }
void test_nonseeking() { GstElement *src; GstQuery *seeking_query; gint pipe_fd[2]; gchar data[4096]; gboolean seekable; xmlfile = "fdsrc_test_nonseeking"; std_log(LOG_FILENAME_LINE, "Test Started test_nonseeking"); fail_if (pipe (pipe_fd) < 0); src = setup_fdsrc (); g_object_set (G_OBJECT (src), "num-buffers", 3, NULL); g_object_set (G_OBJECT (src), "fd", pipe_fd[0], NULL); fail_unless (gst_element_set_state (src, GST_STATE_PAUSED) == GST_STATE_CHANGE_SUCCESS, "could not set to paused"); memset (data, 0, 4096); fail_if (write (pipe_fd[1], data, 256) < 0); /* Test that fdsrc is non-seekable with a pipe */ fail_unless ((seeking_query = gst_query_new_seeking (GST_FORMAT_BYTES)) != NULL); fail_unless (gst_element_query (src, seeking_query) == TRUE); gst_query_parse_seeking (seeking_query, NULL, &seekable, NULL, NULL); fail_unless (seekable == FALSE); gst_query_unref (seeking_query); fail_unless (gst_element_set_state (src, GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null"); /* cleanup */ cleanup_fdsrc (src); close (pipe_fd[0]); close (pipe_fd[1]); std_log(LOG_FILENAME_LINE, "Test Successful"); create_xml(0); }
static gboolean stereosplit_do_bufferpool (GstGLStereoSplit * self, GstCaps * caps) { GstQuery *query; query = gst_query_new_allocation (caps, TRUE); if (!gst_pad_peer_query (self->left_pad, query)) { if (!gst_pad_peer_query (self->right_pad, query)) { GST_DEBUG_OBJECT (self, "peer ALLOCATION query failed on both src pads"); } } if (!stereosplit_decide_allocation (self, query)) { gst_query_unref (query); return FALSE; } gst_query_unref (query); return TRUE; }
static gboolean gst_gl_base_mixer_do_bufferpool (GstGLBaseMixer * mix, GstCaps * outcaps) { GstQuery *query; gboolean result = TRUE; GstBufferPool *pool = NULL; GstAllocator *allocator; GstAllocationParams params; GstAggregator *agg = GST_AGGREGATOR (mix); /* find a pool for the negotiated caps now */ GST_DEBUG_OBJECT (mix, "doing allocation query"); query = gst_query_new_allocation (outcaps, TRUE); if (!gst_pad_peer_query (agg->srcpad, query)) { /* not a problem, just debug a little */ GST_DEBUG_OBJECT (mix, "peer ALLOCATION query failed"); } GST_DEBUG_OBJECT (mix, "calling decide_allocation"); result = gst_gl_base_mixer_decide_allocation (mix, query); GST_DEBUG_OBJECT (mix, "ALLOCATION (%d) params: %" GST_PTR_FORMAT, result, query); if (!result) goto no_decide_allocation; /* we got configuration from our peer or the decide_allocation method, * parse them */ if (gst_query_get_n_allocation_params (query) > 0) { gst_query_parse_nth_allocation_param (query, 0, &allocator, ¶ms); } else { allocator = NULL; gst_allocation_params_init (¶ms); } if (gst_query_get_n_allocation_pools (query) > 0) gst_query_parse_nth_allocation_pool (query, 0, &pool, NULL, NULL, NULL); /* now store */ result = gst_gl_base_mixer_set_allocation (mix, pool, allocator, ¶ms, query); return result; /* Errors */ no_decide_allocation: { GST_WARNING_OBJECT (mix, "Failed to decide allocation"); gst_query_unref (query); return result; } }
static gboolean gst_gdk_pixbuf_dec_setup_pool (GstGdkPixbufDec * filter, GstVideoInfo * info) { GstCaps *target; GstQuery *query; GstBufferPool *pool; GstStructure *config; guint size, min, max; target = gst_pad_get_current_caps (filter->srcpad); /* try to get a bufferpool now */ /* find a pool for the negotiated caps now */ query = gst_query_new_allocation (target, TRUE); if (!gst_pad_peer_query (filter->srcpad, query)) { /* not a problem, we use the query defaults */ GST_DEBUG_OBJECT (filter, "ALLOCATION query failed"); } if (gst_query_get_n_allocation_pools (query) > 0) { /* we got configuration from our peer, parse them */ gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max); } else { pool = NULL; size = info->size; min = max = 0; } gst_query_unref (query); if (pool == NULL) { /* we did not get a pool, make one ourselves then */ pool = gst_buffer_pool_new (); } /* and configure */ config = gst_buffer_pool_get_config (pool); gst_buffer_pool_config_set_params (config, target, size, min, max); gst_buffer_pool_set_config (pool, config); if (filter->pool) { gst_buffer_pool_set_active (filter->pool, FALSE); gst_object_unref (filter->pool); } filter->pool = pool; /* and activate */ gst_buffer_pool_set_active (filter->pool, TRUE); gst_caps_unref (target); return TRUE; }