/* doesn't return a ref to the pixbuf */
static GdkPixbuf *
check_message_pixbuf (GstMessage * msg, const gchar * name, gint channels,
    gboolean has_alpha)
{
  GdkPixbuf *pixbuf;
  const GstStructure *s;

  fail_unless (gst_message_get_structure (msg) != NULL);

  s = gst_message_get_structure (msg);
  fail_unless_equals_string (gst_structure_get_name (s), name);

  fail_unless (gst_structure_has_field (s, "pixbuf"));
  fail_unless (gst_structure_has_field_typed (s, "pixel-aspect-ratio",
          GST_TYPE_FRACTION));
  pixbuf =
      GDK_PIXBUF (g_value_get_object (gst_structure_get_value (s, "pixbuf")));
  fail_unless (GDK_IS_PIXBUF (pixbuf));
  fail_unless_equals_int (gdk_pixbuf_get_n_channels (pixbuf), channels);
  fail_unless_equals_int (gdk_pixbuf_get_has_alpha (pixbuf), has_alpha);
  fail_unless_equals_int (gdk_pixbuf_get_width (pixbuf), 319);
  fail_unless_equals_int (gdk_pixbuf_get_height (pixbuf), 241);

  return pixbuf;
}
示例#2
0
static gboolean bus_call(GstBus *bus, GstMessage *msg, void *user_data)
{

	switch (GST_MESSAGE_TYPE(msg)) {
	case GST_MESSAGE_EOS: {
		//g_message("End-of-stream");
		g_main_loop_quit(loop);
		break;
	}
	case GST_MESSAGE_ERROR: {
		GError *err;
		gst_message_parse_error(msg, &err, NULL);
		//report error
		printf ("ERROR: %s", err->message);
		g_error_free(err);
		
		g_main_loop_quit(loop);
		
		break;
	} 
	case GST_MESSAGE_ELEMENT: {
		const GstStructure *str;
		str = gst_message_get_structure (msg);
		
		if (gst_structure_has_name(str,"espeak-mark") || 
			gst_structure_has_name(str,"espeak-word")) {
			//espeak messages
		}
		break;
	}
	//onther element specific message

	case GST_MESSAGE_APPLICATION: {

		const GstStructure *str;
		str = gst_message_get_structure (msg);
		 if (gst_structure_has_name(str,"turn_off"))
			{
				g_main_loop_quit(loop);
			}

		break;
	}
	default:
	
		break;
	}

		//printf("info: %i %s\n", (int)(msg->timestamp), GST_MESSAGE_TYPE_NAME (msg));

	return true;
}
示例#3
0
static void
gst_level_message_append_channel (GstMessage * m, gdouble rms, gdouble peak,
    gdouble decay)
{
  const GValue *array_val;
  GstStructure *s;
  GValueArray *arr;
  GValue v = { 0, };

  g_value_init (&v, G_TYPE_DOUBLE);

  s = (GstStructure *) gst_message_get_structure (m);

  array_val = gst_structure_get_value (s, "rms");
  arr = (GValueArray *) g_value_get_boxed (array_val);
  g_value_set_double (&v, rms);
  g_value_array_append (arr, &v);       /* copies by value */

  array_val = gst_structure_get_value (s, "peak");
  arr = (GValueArray *) g_value_get_boxed (array_val);
  g_value_set_double (&v, peak);
  g_value_array_append (arr, &v);       /* copies by value */

  array_val = gst_structure_get_value (s, "decay");
  arr = (GValueArray *) g_value_get_boxed (array_val);
  g_value_set_double (&v, decay);
  g_value_array_append (arr, &v);       /* copies by value */

  g_value_unset (&v);
}
/* This function is called when an "application" message is posted on the bus.
 * Here we retrieve the message posted by the tags_cb callback */
static void application_cb (GstBus *bus, GstMessage *msg, CustomData *data) {
  if (g_strcmp0 (gst_structure_get_name (gst_message_get_structure (msg)), "tags-changed") == 0) {
    /* If the message is the "tags-changed" (only one we are currently issuing), update
     * the stream info GUI */
    analyze_streams (data);
  }
}
示例#5
0
static void
check_get_dtmf_event_message (GstBus * bus, gint number, gint volume)
{
  GstMessage *message;
  gboolean have_message = FALSE;

  while (!have_message &&
      (message = gst_bus_pop_filtered (bus, GST_MESSAGE_ELEMENT)) != NULL) {
    if (gst_message_has_name (message, "dtmf-event")) {
      const GstStructure *s = gst_message_get_structure (message);
      gint stype, snumber, smethod, svolume;

      fail_unless (gst_structure_get (s,
              "type", G_TYPE_INT, &stype,
              "number", G_TYPE_INT, &snumber,
              "method", G_TYPE_INT, &smethod,
              "volume", G_TYPE_INT, &svolume, NULL));

      fail_unless (stype == 1);
      fail_unless (smethod == 1);
      fail_unless (snumber == number);
      fail_unless (svolume == volume);
      have_message = TRUE;
    }
    gst_message_unref (message);
  }

  fail_unless (have_message);
}
示例#6
0
void ZBarFilterImpl::busMessage (GstMessage *message)
{

  if (GST_MESSAGE_SRC (message) == GST_OBJECT (zbar) &&
      GST_MESSAGE_TYPE (message) == GST_MESSAGE_ELEMENT) {
    const GstStructure *st;
    guint64 ts;
    gchar *type, *symbol;

    st = gst_message_get_structure (message);

    if (g_strcmp0 (gst_structure_get_name (st), "barcode") != 0) {
      return;
    }

    if (!gst_structure_get (st, "timestamp", G_TYPE_UINT64, &ts,
                            "type", G_TYPE_STRING, &type, "symbol",
                            G_TYPE_STRING, &symbol, NULL) ) {
      return;
    }

    std::string symbolStr (symbol);
    std::string typeStr (type);

    g_free (type);
    g_free (symbol);

    barcodeDetected (ts, typeStr, symbolStr);
  }
}
示例#7
0
EXPORT_C
#endif

GstNavigationMessageType
gst_navigation_message_get_type (GstMessage * message)
{
  const GstStructure *s;
  const gchar *m_type;

  if (message == NULL || GST_MESSAGE_TYPE (message) != GST_MESSAGE_ELEMENT)
    return GST_NAVIGATION_MESSAGE_INVALID;

  s = gst_message_get_structure (message);
  if (s == NULL || !gst_structure_has_name (s, GST_NAVIGATION_MESSAGE_NAME))
    return GST_NAVIGATION_MESSAGE_INVALID;

  m_type = gst_structure_get_string (s, "type");
  if (m_type == NULL)
    return GST_NAVIGATION_MESSAGE_INVALID;

  if (g_str_equal (m_type, "mouse-over"))
    return GST_NAVIGATION_MESSAGE_MOUSE_OVER;
  else if (g_str_equal (m_type, "commands-changed"))
    return GST_NAVIGATION_MESSAGE_COMMANDS_CHANGED;
  else if (g_str_equal (m_type, "angles-changed"))
    return GST_NAVIGATION_MESSAGE_ANGLES_CHANGED;

  return GST_NAVIGATION_MESSAGE_INVALID;
}
示例#8
0
EXPORT_C
#endif

void
gst_mixer_message_parse_option_changed (GstMessage * message,
    GstMixerOptions ** options, const gchar ** value)
{
  const GstStructure *s;

  g_return_if_fail (gst_mixer_message_is_mixer_message (message));
  g_return_if_fail (GST_MIXER_MESSAGE_HAS_TYPE (message, OPTION_CHANGED));

  s = gst_message_get_structure (message);

  if (options) {
    const GValue *v = gst_structure_get_value (s, "options");

    g_return_if_fail (v != NULL);
    *options = (GstMixerOptions *) g_value_get_object (v);
    g_return_if_fail (GST_IS_MIXER_OPTIONS (*options));
  }

  if (value)
    *value = gst_structure_get_string (s, "value");
}
示例#9
0
static void
dvb_base_bin_handle_message (GstBin * bin, GstMessage * message)
{
  DvbBaseBin *dvbbasebin;

  dvbbasebin = GST_DVB_BASE_BIN (bin);

  if (message->type == GST_MESSAGE_ELEMENT &&
      GST_ELEMENT (message->src) == GST_ELEMENT (dvbbasebin->mpegtsparse)) {
    const GstStructure *s = gst_message_get_structure (message);
    const gchar *structure_name = gst_structure_get_name (s);

    if (strcmp (structure_name, "pat") == 0)
      dvb_base_bin_pat_info_cb (dvbbasebin, s);
    else if (strcmp (structure_name, "pmt") == 0)
      dvb_base_bin_pmt_info_cb (dvbbasebin, s);

    /*else if (strcmp (structure_name, "nit") == 0)
       dvb_base_bin_nit_info_cb (dvbbasebin, message->structure);
       else if (strcmp (structure_name, "sdt") == 0)
       dvb_base_bin_sdt_info_cb (dvbbasebin, message->structure);
       else if (strcmp (structure_name, "eit") == 0)
       dvb_base_bin_eit_info_cb (dvbbasebin, message->structure); */
    /* forward the message on */
    gst_element_post_message (GST_ELEMENT_CAST (bin), message);
  } else {
    /* chain up */
    GST_BIN_CLASS (parent_class)->handle_message (bin, message);
  }

}
示例#10
0
EXPORT_C
#endif

GstMixerMessageType
gst_mixer_message_get_type (GstMessage * message)
{
  const GstStructure *s;
  const gchar *m_type;

  if (!gst_mixer_message_is_mixer_message (message))
    return GST_MIXER_MESSAGE_INVALID;

  s = gst_message_get_structure (message);
  m_type = gst_structure_get_string (s, "type");
  g_return_val_if_fail (m_type != NULL, GST_MIXER_MESSAGE_INVALID);

  if (g_str_equal (m_type, "mute-toggled"))
    return GST_MIXER_MESSAGE_MUTE_TOGGLED;
  else if (g_str_equal (m_type, "record-toggled"))
    return GST_MIXER_MESSAGE_RECORD_TOGGLED;
  else if (g_str_equal (m_type, "volume-changed"))
    return GST_MIXER_MESSAGE_VOLUME_CHANGED;
  else if (g_str_equal (m_type, "option-changed"))
    return GST_MIXER_MESSAGE_OPTION_CHANGED;
  else if (g_str_equal (m_type, "options-list-changed"))
    return GST_MIXER_MESSAGE_OPTIONS_LIST_CHANGED;
  else if (g_str_equal (m_type, "mixer-changed"))
    return GST_MIXER_MESSAGE_MIXER_CHANGED;

  return GST_MIXER_MESSAGE_INVALID;
}
示例#11
0
EXPORT_C
#endif

void
gst_mixer_message_parse_record_toggled (GstMessage * message,
    GstMixerTrack ** track, gboolean * record)
{
  const GstStructure *s;

  g_return_if_fail (gst_mixer_message_is_mixer_message (message));
  g_return_if_fail (GST_MIXER_MESSAGE_HAS_TYPE (message, RECORD_TOGGLED));

  s = gst_message_get_structure (message);

  if (track) {
    const GValue *v = gst_structure_get_value (s, "track");

    g_return_if_fail (v != NULL);
    *track = (GstMixerTrack *) g_value_get_object (v);
    g_return_if_fail (GST_IS_MIXER_TRACK (*track));
  }

  if (record)
    g_return_if_fail (gst_structure_get_boolean (s, "record", record));
}
示例#12
0
/**
 * fs_stream_parse_component_state_changed:
 * @stream: a #FsStream to match against the message
 * @message: a #GstMessage to parse
 * @component: (out): Returns the component from the #GstMessage if not %NULL
 * @state: (out): Returns the #FsStreamState from the #GstMessage if not %NULL
 *
 * Parses a "farstream-component-state-changed" message and checks if it matches
 * the @stream parameters.
 *
 * Returns: %TRUE if the message matches the stream and is valid.
 */
gboolean
fs_stream_parse_component_state_changed (FsStream *stream,
        GstMessage *message,
        guint *component,
        FsStreamState *state)
{
    const GstStructure *s;
    const GValue *value;

    g_return_val_if_fail (stream != NULL, FALSE);

    if (!check_message (message, stream, "farstream-component-state-changed"))
        return FALSE;

    s = gst_message_get_structure (message);

    value = gst_structure_get_value (s, "component");
    if (!value || !G_VALUE_HOLDS (value, G_TYPE_UINT))
        return FALSE;
    if (component)
        *component = g_value_get_uint (value);


    value = gst_structure_get_value (s, "state");
    if (!value || !G_VALUE_HOLDS (value, G_TYPE_ENUM))
        return FALSE;
    if (state)
        *state = g_value_get_enum (value);

    return TRUE;
}
示例#13
0
/**
 * fs_stream_parse_new_active_candidate_pair:
 * @stream: a #FsStream to match against the message
 * @message: a #GstMessage to parse
 * @local_candidate: (out) (transfer none): Returns the local #FsCandidate in
 *  the message if not %NULL.
 * @remote_candidate: (out) (transfer none): Returns the remote #FsCandidate in
 *  the message if not %NULL.
 *
 * Parses a "farstream-new-active-candidate-pair" message and checks
 * if it matches the @stream parameters.
 *
 * Returns: %TRUE if the message matches the stream and is valid.
 */
gboolean
fs_stream_parse_new_active_candidate_pair (FsStream *stream,
        GstMessage *message,
        FsCandidate **local_candidate,
        FsCandidate **remote_candidate)
{
    const GstStructure *s;
    const GValue *value;

    g_return_val_if_fail (stream != NULL, FALSE);

    if (!check_message (message, stream, "farstream-new-active-candidate-pair"))
        return FALSE;

    s = gst_message_get_structure (message);

    value = gst_structure_get_value (s, "local-candidate");
    if (!value || !G_VALUE_HOLDS (value, FS_TYPE_CANDIDATE))
        return FALSE;
    if (local_candidate)
        *local_candidate = g_value_get_boxed (value);


    value = gst_structure_get_value (s, "remote-candidate");
    if (!value || !G_VALUE_HOLDS (value, FS_TYPE_CANDIDATE))
        return FALSE;
    if (remote_candidate)
        *remote_candidate = g_value_get_boxed (value);

    return TRUE;
}
示例#14
0
static gboolean
check_message (GstMessage *message,
               FsStream *stream,
               const gchar *message_name)
{
    const GstStructure *s;
    const GValue *value;
    FsStream *message_stream;

    if (GST_MESSAGE_TYPE (message) != GST_MESSAGE_ELEMENT)
        return FALSE;

    s = gst_message_get_structure (message);

    if (!gst_structure_has_name (s, message_name))
        return FALSE;

    value = gst_structure_get_value (s, "stream");
    if (!value || !G_VALUE_HOLDS (value, FS_TYPE_STREAM))
        return FALSE;
    message_stream = g_value_get_object (value);

    if (stream != message_stream)
        return FALSE;

    return TRUE;
}
示例#15
0
/**
 * fs_session_parse_send_codec_changed:
 * @session: a #FsSession to match against the message
 * @message: a #GstMessage to parse
 * @codec: (out) (transfer none): Returns the #FsCodec in the message if not
 *   %NULL.
 * @secondary_codecs: (out) (transfer none) (element-type FsCodec):
 *  Returns a #GList of #FsCodec of the message if not %NULL
 *
 * Parses a "farstream-send-codec-changed" message and checks if it matches
 * the @session parameters.
 *
 * Returns: %TRUE if the message matches the session and is valid.
 */
gboolean
fs_session_parse_send_codec_changed ( FsSession *session,
    GstMessage *message,
    FsCodec **codec,
    GList **secondary_codecs)
{
  const GstStructure *s;
  const GValue *value;

  g_return_val_if_fail (session != NULL, FALSE);

  if (!check_message (message, session, "farstream-send-codec-changed"))
    return FALSE;

  s = gst_message_get_structure (message);

  value = gst_structure_get_value (s, "codec");
  if (!value || !G_VALUE_HOLDS (value, FS_TYPE_CODEC))
    return FALSE;
  if (codec)
    *codec = g_value_get_boxed (value);

  value = gst_structure_get_value (s, "secondary-codecs");
  if (!value || !G_VALUE_HOLDS (value, FS_TYPE_CODEC_LIST))
    return FALSE;
  if (secondary_codecs)
    *secondary_codecs = g_value_get_boxed (value);

  return TRUE;
}
示例#16
0
void
zbar_receive_message (GstBus *bus, GstMessage *message, gpointer zbar)
{
  ZBarFilter *filter = (ZBarFilter *) zbar;

  if (GST_MESSAGE_SRC (message) == GST_OBJECT (filter->zbar) &&
      GST_MESSAGE_TYPE (message) == GST_MESSAGE_ELEMENT) {
    const GstStructure *st;
    guint64 ts;
    gchar *type, *symbol;

    st = gst_message_get_structure (message);

    if (g_strcmp0 (gst_structure_get_name (st), "barcode") != 0)
      return;

    if (!gst_structure_get (st, "timestamp", G_TYPE_UINT64, &ts,
                            "type", G_TYPE_STRING, &type, "symbol", G_TYPE_STRING, &symbol, NULL) )
      return;

    std::string symbolStr (symbol);
    std::string typeStr (type);

    g_free (type);
    g_free (symbol);

    filter->barcodeDetected (ts, typeStr, symbolStr);
  }
}
示例#17
0
/**
 * fs_session_parse_telephony_event_started:
 * @session: a #FsSession to match against the message
 * @message: a #GstMessage to parse
 * @method: (out): Returns the #FsDTMFMethod in the message if not %NULL.
 * @event: (out): Returns the #FsDTMFEvent in the message if not %NULL.
 * @volume: (out): Returns the volume in the message if not %NULL.
 *
 * Parses a "farstream-telephony-event-started" message and checks if it matches
 * the @session parameters.
 *
 * Returns: %TRUE if the message matches the session and is valid.
 */
gboolean
fs_session_parse_telephony_event_started (FsSession *session,
    GstMessage *message,
    FsDTMFMethod *method, FsDTMFEvent *event,
    guint8 *volume)
{
  const GstStructure *s;
  const GValue *value;

  g_return_val_if_fail (session != NULL, FALSE);

  if (!check_message (message, session, "farstream-telephony-event-started"))
    return FALSE;

  s = gst_message_get_structure (message);

  if (!gst_structure_has_field_typed (s, "method", FS_TYPE_DTMF_METHOD))
    return FALSE;
  if (method)
    gst_structure_get_enum (s, "method", FS_TYPE_DTMF_METHOD, (gint*) method);

  if (!gst_structure_has_field_typed (s, "event", FS_TYPE_DTMF_EVENT))
    return FALSE;
  if (event)
    gst_structure_get_enum (s, "event", FS_TYPE_DTMF_EVENT, (gint*) event);

  value = gst_structure_get_value (s, "volume");
  if (!value || !G_VALUE_HOLDS (value, G_TYPE_UCHAR))
    return FALSE;
  if (volume)
    *volume = g_value_get_uchar (value);

  return TRUE;
}
示例#18
0
void CameraBinFocus::handleFocusMessage(GstMessage *gm)
{
    //it's a sync message, so it's called from non main thread
    const GstStructure *structure = gst_message_get_structure(gm);
    if (gst_structure_has_name(structure, GST_PHOTOGRAPHY_AUTOFOCUS_DONE)) {
        gint status = GST_PHOTOGRAPHY_FOCUS_STATUS_NONE;
        gst_structure_get_int (structure, "status", &status);
        QCamera::LockStatus focusStatus = m_focusStatus;
        QCamera::LockChangeReason reason = QCamera::UserRequest;

        switch (status) {
            case GST_PHOTOGRAPHY_FOCUS_STATUS_FAIL:
                focusStatus = QCamera::Unlocked;
                reason = QCamera::LockFailed;
                break;
            case GST_PHOTOGRAPHY_FOCUS_STATUS_SUCCESS:
                focusStatus = QCamera::Locked;
                break;
            case GST_PHOTOGRAPHY_FOCUS_STATUS_NONE:
                break;
            case GST_PHOTOGRAPHY_FOCUS_STATUS_RUNNING:
                focusStatus = QCamera::Searching;
                break;
            default:
                break;
        }

        static int signalIndex = metaObject()->indexOfSlot(
                    "_q_setFocusStatus(QCamera::LockStatus,QCamera::LockChangeReason)");
        metaObject()->method(signalIndex).invoke(this,
                                                 Qt::QueuedConnection,
                                                 Q_ARG(QCamera::LockStatus,focusStatus),
                                                 Q_ARG(QCamera::LockChangeReason,reason));
    }
}
示例#19
0
static void
pull_messages (void)
{
  GstMessage *m;
  const GstStructure *s;
  guint message_ids[NUM_THREADS];
  gint i;

  for (i = 0; i < NUM_THREADS; i++)
    message_ids[i] = 0;

  while (1) {
    gint _t, _i;

    m = gst_bus_pop (test_bus);
    if (!m)
      break;
    g_return_if_fail (GST_MESSAGE_TYPE (m) == GST_MESSAGE_APPLICATION);

    s = gst_message_get_structure (m);
    if (!gst_structure_get_int (s, "thread_id", &_t))
      g_critical ("Invalid message");
    if (!gst_structure_get_int (s, "msg_id", &_i))
      g_critical ("Invalid message");

    g_return_if_fail (_t < NUM_THREADS);
    g_return_if_fail (_i == message_ids[_t]++);

    gst_message_unref (m);
  }

  for (i = 0; i < NUM_THREADS; i++)
    g_return_if_fail (message_ids[i] == NUM_MESSAGES);
}
示例#20
0
static void
on_bus_element_cb (GstBus *bus, GstMessage *message,
    GbpPlayer *player)
{
  const GstStructure *structure;
  const gchar *structure_name;
  GstElement *sink;
  structure = gst_message_get_structure (message);
  if (structure == NULL)
    return;

  structure_name = gst_structure_get_name (structure);

#ifdef XP_MACOSX
  if (!strcmp (structure_name, "have-ns-view") ||
      !strcmp (structure_name, "have-ca-layer")) {
    if (player->priv->xid != 0) {
      gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (GST_ELEMENT (message->src)),
          (gulong) player->priv->xid);
    }
    return;
  }
#endif

  if (!strcmp (structure_name, "prepare-xwindow-id")) {
    sink = GST_ELEMENT (message->src);
    gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (sink), player->priv->xid);
  }
}
static GstBusSyncReply
sync_bus_callback (GstBus * bus, GstMessage * message, gpointer data)
{
  const GstStructure *st;
  const GValue *image;
  GstBuffer *buf = NULL;
  guint8 *data_buf = NULL;
  gchar *caps_string;
  guint size = 0;
  gchar *preview_filename = NULL;
  FILE *f = NULL;
  size_t written;

  switch (GST_MESSAGE_TYPE (message)) {
    case GST_MESSAGE_ELEMENT:{
      st = gst_message_get_structure (message);
      if (st) {
        if (gst_structure_has_name (message->structure, "prepare-xwindow-id")) {
          if (!no_xwindow && window) {
            gst_x_overlay_set_window_handle (GST_X_OVERLAY (GST_MESSAGE_SRC
                    (message)), window);
            gst_message_unref (message);
            message = NULL;
            return GST_BUS_DROP;
          }
        } else if (gst_structure_has_name (st, "preview-image")) {
          GST_DEBUG ("preview-image");
          /* extract preview-image from msg */
          image = gst_structure_get_value (st, "buffer");
          if (image) {
            buf = gst_value_get_buffer (image);
            data_buf = GST_BUFFER_DATA (buf);
            size = GST_BUFFER_SIZE (buf);
            preview_filename = g_strdup_printf ("test_vga.rgb");
            caps_string = gst_caps_to_string (GST_BUFFER_CAPS (buf));
            g_print ("writing buffer to %s, elapsed: %.2fs, buffer caps: %s\n",
                preview_filename, g_timer_elapsed (timer, NULL), caps_string);
            g_free (caps_string);
            f = g_fopen (preview_filename, "w");
            if (f) {
              written = fwrite (data_buf, size, 1, f);
              if (!written) {
                g_print ("error writing file\n");
              }
              fclose (f);
            } else {
              g_print ("error opening file for raw image writing\n");
            }
            g_free (preview_filename);
          }
        }
      }
      break;
    }
    default:
      /* unhandled message */
      break;
  }
  return GST_BUS_PASS;
}
示例#22
0
static void
code_received_cb (GstBus * bus, GstMessage * message, gpointer data)
{
  KmsSendData *self = KMS_SEND_DATA (data);

  if (GST_MESSAGE_SRC (message) == GST_OBJECT (self->priv->zbar) &&
      GST_MESSAGE_TYPE (message) == GST_MESSAGE_ELEMENT) {
    const GstStructure *st;
    guint64 ts;
    gchar *type, *symbol;

    st = gst_message_get_structure (message);

    if (g_strcmp0 (gst_structure_get_name (st), "barcode") != 0) {
      return;
    }

    if (!gst_structure_get (st, "timestamp", G_TYPE_UINT64, &ts,
            "type", G_TYPE_STRING, &type, "symbol",
            G_TYPE_STRING, &symbol, NULL)) {
      return;
    }

    kms_send_data_new_code (self, ts, type, symbol);

    g_free (type);
    g_free (symbol);
  }

  return;
}
void
pointerDetector_receive_message (GstBus *bus, GstMessage *message, gpointer pointerDetector)
{
  const GstStructure *st;
  gchar *windowID;
  const gchar *type;
  std::string windowIDStr, typeStr;
  PointerDetectorFilter *filter = (PointerDetectorFilter *) pointerDetector;

  if (GST_MESSAGE_SRC (message) != GST_OBJECT (filter->pointerDetector) ||
      GST_MESSAGE_TYPE (message) != GST_MESSAGE_ELEMENT)
    return;

  st = gst_message_get_structure (message);
  type = gst_structure_get_name (st);

  if ( (g_strcmp0 (type, "window-out") != 0) &&
       (g_strcmp0 (type, "window-in") != 0) ) {
    GST_WARNING ("The message does not have the correct name");
    return;
  }

  if (!gst_structure_get (st, "window", G_TYPE_STRING , &windowID, NULL) ) {
    GST_WARNING ("The message does not contain the window ID");
    return;
  }

  windowIDStr = windowID;
  typeStr = type;

  g_free (windowID);

  filter->raiseEvent (typeStr, windowIDStr);

}
示例#24
0
static gboolean
check_message (GstMessage *message,
    FsSession *session,
    const gchar *message_name)
{
  const GstStructure *s;
  const GValue *value;
  FsSession *message_session;

  if (GST_MESSAGE_TYPE (message) != GST_MESSAGE_ELEMENT)
    return FALSE;

  s = gst_message_get_structure (message);

  if (!gst_structure_has_name (s, message_name))
    return FALSE;

  value = gst_structure_get_value (s, "session");
  if (!value || !G_VALUE_HOLDS (value, FS_TYPE_SESSION))
    return FALSE;
  message_session = g_value_get_object (value);

  if (session != message_session)
    return FALSE;

  return TRUE;
}
示例#25
0
static gboolean
message_handler (GstBus * bus, GstMessage * message, gpointer user_data)
{

    switch (GST_MESSAGE_TYPE (message)) {
#ifdef ASYNC_VERSION
    case GST_MESSAGE_ELEMENT: {
        const GstStructure *str;

        str = gst_message_get_structure (message);

        if (gst_structure_has_name (str, "GstBinForwarded")) {
            GstMessage *orig;

            /* unwrap the element message */
            gst_structure_get (str, "message", GST_TYPE_MESSAGE, &orig, NULL);
            g_assert (orig);

            switch (GST_MESSAGE_TYPE (orig)) {
            case GST_MESSAGE_ASYNC_DONE:
                g_print ("ASYNC done %s\n", GST_MESSAGE_SRC_NAME (orig));
                if (GST_MESSAGE_SRC (orig) == GST_OBJECT_CAST (play_bin)) {
                    g_print
                    ("prerolled, starting synchronized playback and recording\n");
                    /* returns ASYNC because the sink linked to the live source is not
                     * prerolled */
                    if (gst_element_set_state (pipeline,
                                               GST_STATE_PLAYING) != GST_STATE_CHANGE_ASYNC) {
                        g_warning ("State change failed");
                    }
                }
                break;
            default:
                break;
            }
        }
        break;
    }
#endif
    case GST_MESSAGE_EOS:
        g_print ("EOS\n");
        g_main_loop_quit (loop);
        break;
    case GST_MESSAGE_ERROR: {
        GError *err = NULL;

        gst_message_parse_error (message, &err, NULL);
        g_print ("error: %s\n", err->message);
        g_clear_error (&err);

        g_main_loop_quit (loop);
        break;
    }
    default:
        break;
    }

    return TRUE;
}
static gboolean
bus_callback (GstBus * bus, GstMessage * message, gpointer data)
{
  switch (GST_MESSAGE_TYPE (message)) {
    case GST_MESSAGE_ERROR:{
      GError *err;
      gchar *debug;

      gst_message_parse_error (message, &err, &debug);
      g_print ("Error: %s\n", err->message);
      g_error_free (err);
      g_free (debug);

      /* Write debug graph to file */
      GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (camerabin),
          GST_DEBUG_GRAPH_SHOW_ALL, "camerabin.error");

      g_main_loop_quit (loop);
      break;
    }
    case GST_MESSAGE_STATE_CHANGED:
      if (GST_IS_BIN (GST_MESSAGE_SRC (message))) {
        GstState oldstate, newstate;

        gst_message_parse_state_changed (message, &oldstate, &newstate, NULL);
        GST_DEBUG_OBJECT (GST_MESSAGE_SRC (message), "state-changed: %s -> %s",
            gst_element_state_get_name (oldstate),
            gst_element_state_get_name (newstate));
      }
      break;
    case GST_MESSAGE_EOS:
      /* end-of-stream */
      GST_INFO ("got eos() - should not happen");
      g_main_loop_quit (loop);
      break;
    case GST_MESSAGE_ELEMENT:
      if (GST_MESSAGE_SRC (message) == (GstObject *) camerabin) {
        const GstStructure *structure = gst_message_get_structure (message);

        if (gst_structure_has_name (structure, "image-done")) {
#ifndef GST_DISABLE_GST_DEBUG
          const gchar *fname = gst_structure_get_string (structure, "filename");

          GST_DEBUG ("image done: %s", fname);
#endif
          if (capture_count < capture_total) {
            g_idle_add ((GSourceFunc) run_pipeline, NULL);
          } else {
            g_main_loop_quit (loop);
          }
        }
      }
      break;
    default:
      /* unhandled message */
      break;
  }
  return TRUE;
}
示例#27
0
static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data)
{
   GMainLoop *loop = (GMainLoop *) data;

   switch (GST_MESSAGE_TYPE (msg))
   {

       case GST_MESSAGE_APPLICATION:
       {
       const GstStructure * msg_struct = gst_message_get_structure(msg);
       guint64 duration = 0;
       guint64 timestamp = 0;
       int stream_thread_id = 0;

       g_debug("APPLICATION CUSTOM MESSAGE !!!");
       g_debug("MESSAGE THREAD ID[%p]", g_thread_self());

       gst_structure_get_clock_time (msg_struct, "duration" , &duration);
       gst_structure_get_clock_time (msg_struct, "timestamp" , &timestamp);
       gst_structure_get_int (msg_struct, "stream_thread_id" , &stream_thread_id);
       
       g_debug("STREAM THREAD ID[0x%x]", stream_thread_id);
       g_debug("DURATION[%llu], TIMESTAMP[%llu]", duration, timestamp);
       g_debug("Testing string message, [%s]\n", gst_structure_get_string(msg_struct, "msg"));
       
       break;
       }

       case GST_MESSAGE_EOS:
       {
       g_print ("End of stream\n");
       g_main_loop_quit (loop);
       break;
       }

       case GST_MESSAGE_ERROR:
       {
       gchar  *debug;
       GError *error;

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

       g_printerr ("Error: %s\n", error->message);
       g_error_free (error);

       g_main_loop_quit (loop);

       break;
       }

       default:
       g_print("Msg type [%d], Msg name [%s]\n", GST_MESSAGE_TYPE (msg), GST_MESSAGE_TYPE_NAME(msg));
       break;
   }       return TRUE;
}
示例#28
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
fs_rtp_conference_handle_message (
    GstBin * bin,
    GstMessage * message)
{
  FsRtpConference *self = FS_RTP_CONFERENCE (bin);

  if (!self->gstrtpbin)
    return;

  switch (GST_MESSAGE_TYPE (message)) {
    case GST_MESSAGE_ELEMENT:
    {
      const GstStructure *s = gst_message_get_structure (message);

      /* we change the structure name and add the session ID to it */
      if (gst_structure_has_name (s, "GstRTPBinSDES") &&
          gst_structure_has_field_typed (s, "session", G_TYPE_UINT) &&
          gst_structure_has_field_typed (s, "ssrc", G_TYPE_UINT) &&
          gst_structure_has_field_typed (s, "cname", G_TYPE_STRING))
      {
        guint session_id;
        guint ssrc;
        const GValue *val;
        FsRtpSession *session;
        const gchar *cname;

        val = gst_structure_get_value (s, "session");
        session_id = g_value_get_uint (val);

        val = gst_structure_get_value (s, "ssrc");
        ssrc = g_value_get_uint (val);

        cname = gst_structure_get_string (s, "cname");

        session = fs_rtp_conference_get_session_by_id (self, session_id);

        if (session) {
          fs_rtp_session_associate_ssrc_cname (session, ssrc, cname);
          g_object_unref (session);
        } else {
          GST_WARNING_OBJECT (self,"Our GstRtpBin announced a new association"
              "for non-existent session %u for ssrc: %u and cname %s",
              session_id, ssrc, cname);
        }
      }
      /* fallthrough to forward the modified message to the parent */
    }
    default:
    {
      GST_BIN_CLASS (parent_class)->handle_message (bin, message);
      break;
    }
  }
}
示例#30
0
static void
element_message_cb (GstBus * bus, GstMessage * message, gpointer user_data)
{
  gchar *s;

  s = gst_structure_to_string (gst_message_get_structure (message));
  GST_DEBUG ("Received message: %s", s);
  g_free (s);

  messages++;
}