示例#1
0
文件: testegl.c 项目: 01org/gst-omx
static void
qos_cb (GstBus * bus, GstMessage * msg, APP_STATE_T * state)
{
  GstFormat fmt = GST_FORMAT_BUFFERS;
  gchar *name = gst_element_get_name (GST_MESSAGE_SRC (msg));
  gst_message_parse_qos_stats (msg, &fmt, &state->rendered, &state->dropped);
  g_print ("%s rendered: %" G_GUINT64_FORMAT " dropped: %" G_GUINT64_FORMAT
      " %s\n",
      name, state->rendered, state->dropped,
      (fmt == GST_FORMAT_BUFFERS ? "frames" : "samples"));
  g_free (name);
}
示例#2
0
bool ofxGstRTPServer::on_message(GstMessage * msg){
	// read messages from the pipeline like dropped packages
	switch (GST_MESSAGE_TYPE (msg)) {
	case GST_MESSAGE_ELEMENT:{
		GstObject * messageSrc = GST_MESSAGE_SRC(msg);
		ofLogVerbose(LOG_NAME) << "Got " << GST_MESSAGE_TYPE_NAME(msg) << " message from " << GST_MESSAGE_SRC_NAME(msg);
		ofLogVerbose(LOG_NAME) << "Message source type: " << G_OBJECT_CLASS_NAME(G_OBJECT_GET_CLASS(messageSrc));
		ofLogVerbose(LOG_NAME) << "With structure name: " << gst_structure_get_name(gst_message_get_structure(msg));
		ofLogVerbose(LOG_NAME) << gst_structure_to_string(gst_message_get_structure(msg));
		return true;
	}
	case GST_MESSAGE_QOS:{
		GstObject * messageSrc = GST_MESSAGE_SRC(msg);
		ofLogVerbose(LOG_NAME) << "Got " << GST_MESSAGE_TYPE_NAME(msg) << " message from " << GST_MESSAGE_SRC_NAME(msg);
		ofLogVerbose(LOG_NAME) << "Message source type: " << G_OBJECT_CLASS_NAME(G_OBJECT_GET_CLASS(messageSrc));

		GstFormat format;
		guint64 processed;
		guint64 dropped;
		gst_message_parse_qos_stats(msg,&format,&processed,&dropped);
		ofLogVerbose(LOG_NAME) << "format " << gst_format_get_name(format) << " processed " << processed << " dropped " << dropped;

		gint64 jitter;
		gdouble proportion;
		gint quality;
		gst_message_parse_qos_values(msg,&jitter,&proportion,&quality);
		ofLogVerbose(LOG_NAME) << "jitter " << jitter << " proportion " << proportion << " quality " << quality;

		gboolean live;
		guint64 running_time;
		guint64 stream_time;
		guint64 timestamp;
		guint64 duration;
		gst_message_parse_qos(msg,&live,&running_time,&stream_time,&timestamp,&duration);
		ofLogVerbose(LOG_NAME) << "live stream " << live << " runninng_time " << running_time << " stream_time " << stream_time << " timestamp " << timestamp << " duration " << duration;

		return true;
	}
	default:
		//ofLogVerbose(LOG_NAME) << "Got " << GST_MESSAGE_TYPE_NAME(msg) << " message from " << GST_MESSAGE_SRC_NAME(msg);
		return false;
	}
}
static void
fps_display_sink_handle_message (GstBin * bin, GstMessage * message)
{
  GstFPSDisplaySink *self = (GstFPSDisplaySink *) bin;

  if (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS) {
    GstFormat format;
    guint64 rendered, dropped;

    gst_message_parse_qos_stats (message, &format, &rendered, &dropped);
    if (format != GST_FORMAT_UNDEFINED) {
      if (rendered != -1)
        g_atomic_int_set (&self->frames_rendered, rendered);

      if (dropped != -1)
        g_atomic_int_set (&self->frames_dropped, dropped);
    }
  }

  GST_BIN_CLASS (parent_class)->handle_message (bin, message);
}
示例#4
0
quint64 QosMessage::dropped() const
{
    guint64 p;
    gst_message_parse_qos_stats(object<GstMessage>(), NULL, NULL, &p);
    return p;
}
示例#5
0
quint64 QosMessage::processed() const
{
    guint64 p;
    gst_message_parse_qos_stats(object<GstMessage>(), NULL, &p, NULL);
    return p;
}
示例#6
0
Format QosMessage::format() const
{
    GstFormat f;
    gst_message_parse_qos_stats(object<GstMessage>(), &f, NULL, NULL);
    return static_cast<Format>(f);
}
示例#7
0
static gboolean bus_callback(GstBus *bus, GstMessage *msg, gpointer data) {
	GMainLoop *loop = (GMainLoop *)data;

	switch (GST_MESSAGE_TYPE (msg)) {
	case GST_MESSAGE_EOS:
		if (config_quit_on_stream_end() || !main_have_gui()) {
			gstreamer_destroy_pipeline();
			g_main_loop_quit(loop);
		}
		gstreamer_pause();
		end_of_stream = TRUE;
		break;
	case GST_MESSAGE_ERROR: {
		gchar  *debug;
		GError *error;

		gst_message_parse_error(msg, &error, &debug);
		g_free(debug);

		gstreamer_destroy_pipeline();

		main_show_error_message(
			"Processing error (unrecognized format or other error).",
			error->message);
		g_error_free (error);
		break;
		}
	case GST_MESSAGE_QOS: {
		GstFormat format;
		guint64 processed;
		guint64 dropped;
		gst_message_parse_qos_stats(msg, &format, &processed, &dropped);
		if (format == GST_FORMAT_BUFFERS)  {
			GstElement *src = GST_MESSAGE_SRC(msg);
			char *name = gst_element_get_name(src);
			stats_report_dropped_frames_cb(src, name, processed, dropped);
//			printf("gstplay: %s reports %lu out of %lu frames (%d%%) dropped.\n",
//				name,
//				dropped, processed + dropped,
//				(int)(dropped * 100 / (processed + dropped)));
			g_free(name);
		}
		break;
	}
	case GST_MESSAGE_STATE_CHANGED:
		if (bus_quit_on_playing) {
			// When doing the initial run to determine video parameters,
			// stop immediately when play starts.
			if (GST_STATE(playbin_pipeline) == GST_STATE_PLAYING)
				g_main_loop_quit(loop);
		}
		if (!state_change_to_playing_already_occurred &&
		GST_STATE(pipeline) == GST_STATE_PLAYING) {
			gstreamer_set_default_settings();
#if !GST_CHECK_VERSION(1, 0, 0)
			// GStreamer 0.10's xvimagesink does not force aspect ratio by default.
			GstElement *xvimagesink = find_xvimagesink();
			if (xvimagesink)
				g_object_set(G_OBJECT(xvimagesink),
					"force-aspect-ratio", TRUE, NULL);
#endif
			// Trigger a callback for the GUI to update the status bar etc.
			gui_play_start_cb();
			state_change_to_playing_already_occurred = TRUE;
		}
		if (GST_STATE(pipeline) == GST_STATE_PLAYING)
			gui_state_change_to_playing_cb();
		if (GST_STATE(pipeline) == GST_STATE_PLAYING && pause_on_state_change_to_playing) {
			pause_on_state_change_to_playing = FALSE;
			gstreamer_pause();
		}
		break;
	case GST_MESSAGE_BUFFERING:
		if (bus_quit_on_playing)
			break;
		gint percent = 0;
		gst_message_parse_buffering(msg, &percent);
		if (percent < 100) {
			if (GST_STATE(pipeline) != GST_STATE_PAUSED)
				gst_element_set_state(pipeline, GST_STATE_PAUSED);
//			printf("Buffering (%u percent done)\n", percent);
		}
		else {
			if (GST_STATE(pipeline) != GST_STATE_PLAYING)
				gst_element_set_state(pipeline, GST_STATE_PLAYING);
		}
		break;
	case GST_MESSAGE_APPLICATION: {
	        const GstStructure *s;
	        s = gst_message_get_structure (msg);
	        if (gst_structure_has_name (s, "GstLaunchInterrupt")) {
			/* This application message is posted when we caught an interrupt and
			 * we need to stop the pipeline. */
			printf("gstplay: Interrupt: Stopping pipeline ...\n");
			fflush(stdout);
			fflush(stderr);
			gstreamer_destroy_pipeline();
	          	g_main_loop_quit(loop);
		}
		break;
        }
	default:
		break;
	}

	return TRUE;
}