static void
ensure_internal_supported_storages (MMModemMessaging *self,
                                    GArray **dup)
{
    g_mutex_lock (&self->priv->supported_storages_mutex);
    {
        /* If this is the first time ever asking for the array, setup the
         * update listener and the initial array, if any. */
        if (!self->priv->supported_storages_id) {
            GVariant *dictionary;

            dictionary = mm_gdbus_modem_messaging_dup_supported_storages (MM_GDBUS_MODEM_MESSAGING (self));
            if (dictionary) {
                self->priv->supported_storages = mm_common_sms_storages_variant_to_garray (dictionary);
                g_variant_unref (dictionary);
            }

            /* No need to clear this signal connection when freeing self */
            self->priv->supported_storages_id =
                g_signal_connect (self,
                                  "notify::supported-storages",
                                  G_CALLBACK (supported_storages_updated),
                                  NULL);
        }

        if (dup && self->priv->supported_storages)
            *dup = g_array_ref (self->priv->supported_storages);
    }
    g_mutex_unlock (&self->priv->supported_storages_mutex);
}
/**
 * atspi_match_rule_new:
 *
 * @states: An #AtspiStateSet specifying the states to match or NULL if none.
 *
 * @statematchtype: An #AtspiCollectionMatchType specifying how to interpret
 *                  @states.
 *
 * @attributes: (element-type gchar* gchar*): A #GHashTable specifying
 *              attributes to match.
 *
 * @attributematchtype: An #AtspiCollectionMatchType specifying how to
 *                      interpret @attributes.
 *
 * @interfaces: (element-type gchar*): An array of interfaces to match, or
 *              NULL if not applicable.  Interface names should be specified
 *              by their DBus names (org.a11y.Atspi.Accessible,
 *              org.a11y.Atspi.Component, etc).
 *
 * @interfacematchtype: An #AtspiCollectionMatchType specifying how to
 *                      interpret @interfaces.
 *
 * @roles: (element-type AtspiRole): A #GArray of roles to match, or NULL if
 *         not applicable.
 *
 * @rolematchtype: An #AtspiCollectionMatchType specifying how to
 *                      interpret @roles.
 *
 * @invert: if #TRUE, the match rule should be denied (inverted); if #FALSE,
 * it should not. For example, if the match rule defines that a match is
 * an object of ROLE_HEADING which has STATE_FOCUSABLE and a click action,
 * inverting it would match all objects that are not of ROLE_HEADING,
 * focusable and clickable at the same time.
 *
 * Creates a new #AtspiMatchRule with specified @states, @attributes,
 * @interfaces, and @roles.
 *
 * Returns: (transfer full): A new #AtspiMatchRule.
 **/
AtspiMatchRule *
atspi_match_rule_new (AtspiStateSet *states,
                      AtspiCollectionMatchType statematchtype,
                      GHashTable *attributes,
                      AtspiCollectionMatchType attributematchtype,
                      GArray *roles,
                      AtspiCollectionMatchType rolematchtype,
                      GArray *interfaces,
                      AtspiCollectionMatchType interfacematchtype,
                      gboolean invert)
{
    AtspiMatchRule *rule = g_object_new (ATSPI_TYPE_MATCH_RULE, NULL);
    int i;

    if (!rule)
        return NULL;

    if (states)
        rule->states = g_object_ref (states);
    rule->statematchtype = statematchtype;

    if (attributes)
    {
        GHashTableIter hash_table_iter;
        gchar *key, *value;
        rule->attributes = g_hash_table_new_full (g_str_hash, g_str_equal,
                           (GDestroyNotify) g_free,
                           (GDestroyNotify) g_free);
        g_hash_table_iter_init (&hash_table_iter, attributes);
        while (g_hash_table_iter_next (&hash_table_iter, (gpointer *)&key,
                                       (gpointer *)&value))
            g_hash_table_insert (rule->attributes, g_strdup (key), g_strdup (value));
    } else
        rule->attributes = NULL;
    rule->attributematchtype = attributematchtype;

    if (interfaces)
        rule->interfaces = g_array_ref (interfaces);
    rule->interfacematchtype = interfacematchtype;

    if (roles)
    {
        for (i = 0; i < roles->len; i++)
        {
            AtspiRole role = g_array_index (roles, AtspiRole, i);
            if (role < 128)
                rule->roles [role / 32] |= (1 << (role % 32));
            else
                g_warning ("Atspi: unexpected role %d\n", role);
        }
    }
    else
        rule->roles [0] = rule->roles [1] = 0;
    rule->rolematchtype = rolematchtype;

    rule->invert = invert;

    return rule;
}
Esempio n. 3
0
/**
 * cd_spectrum_set_data:
 * @spectrum: the destination spectrum
 * @value: (element-type gdouble): component value
 *
 * Sets the spectrum data.
 *
 * Since: 1.1.6
 **/
void
cd_spectrum_set_data (CdSpectrum *spectrum, GArray *value)
{
	g_return_if_fail (spectrum != NULL);
	g_return_if_fail (value != NULL);
	g_array_unref (spectrum->data);
	spectrum->data = g_array_ref (value);
}
static GArray *
load_current_bands_finish (MMIfaceModem *self,
                           GAsyncResult *res,
                           GError **error)
{
    /* Never fails */
    return (GArray *) g_array_ref (g_simple_async_result_get_op_res_gpointer (
                                       G_SIMPLE_ASYNC_RESULT (res)));
}
static GArray *
load_supported_modes_finish (MMIfaceModem *self,
                             GAsyncResult *res,
                             GError **error)
{
    if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
        return NULL;

    return g_array_ref (g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res)));
}
Esempio n. 6
0
static gboolean
gs_plugin_odrs_load_ratings (GsPlugin *plugin, const gchar *fn, GError **error)
{
	GsPluginData *priv = gs_plugin_get_data (plugin);
	GList *l;
	JsonNode *json_root;
	JsonObject *json_item;
	g_autoptr(GList) apps = NULL;
	g_autoptr(JsonParser) json_parser = NULL;

	/* remove all existing */
	g_hash_table_remove_all (priv->ratings);

	/* parse the data and find the success */
	json_parser = json_parser_new ();
	if (!json_parser_load_from_file (json_parser, fn, error)) {
		gs_utils_error_convert_json_glib (error);
		return FALSE;
	}
	json_root = json_parser_get_root (json_parser);
	if (json_root == NULL) {
		g_set_error_literal (error,
				     GS_PLUGIN_ERROR,
				     GS_PLUGIN_ERROR_INVALID_FORMAT,
				     "no ratings root");
		return FALSE;
	}
	if (json_node_get_node_type (json_root) != JSON_NODE_OBJECT) {
		g_set_error_literal (error,
				     GS_PLUGIN_ERROR,
				     GS_PLUGIN_ERROR_INVALID_FORMAT,
				     "no ratings array");
		return FALSE;
	}

	/* parse each app */
	json_item = json_node_get_object (json_root);
	apps = json_object_get_members (json_item);
	for (l = apps; l != NULL; l = l->next) {
		const gchar *app_id = (const gchar *) l->data;
		JsonObject *json_app = json_object_get_object_member (json_item, app_id);
		g_autoptr(GArray) ratings = NULL;;
		ratings = gs_plugin_odrs_load_ratings_for_app (json_app);
		if (ratings->len == 6) {
			g_hash_table_insert (priv->ratings,
					     g_strdup (app_id),
					     g_array_ref (ratings));
		}
	}
	return TRUE;
}
Esempio n. 7
0
/**
 * gst_buffer_add_mpeg_video_meta:
 * @buffer: a #GstBuffer
 * @seq_hdr: a #GstMpegVideoSequenceHdr
 * @seq_ext: a #GstMpegVideoSequenceExt
 * @disp_ext: a #GstMpegVideoSequenceDisplayExt
 * @pic_hdr: a #GstMpegVideoPictureHdr
 * @pic_ext: a #GstMpegVideoPictureExt
 * @quant_ext: a #GstMpegVideoQuantMatrixExt
 * @slice_info_array: an array of #GstMpegVideoMetaSliceInfo
 *
 * Creates and adds a #GstMpegVideoMeta to a @buffer.
 *
 * Provided structures must either be %NULL or GSlice-allocated.
 *
 * Returns: (transfer full): a newly created #GstMpegVideoMeta
 *
 * Since: 1.2
 */
GstMpegVideoMeta *
gst_buffer_add_mpeg_video_meta (GstBuffer * buffer,
    const GstMpegVideoSequenceHdr * seq_hdr,
    const GstMpegVideoSequenceExt * seq_ext,
    const GstMpegVideoSequenceDisplayExt * disp_ext,
    const GstMpegVideoPictureHdr * pic_hdr,
    const GstMpegVideoPictureExt * pic_ext,
    const GstMpegVideoQuantMatrixExt * quant_ext, GArray * slice_info_array)
{
  GstMpegVideoMeta *mpeg_video_meta;

  mpeg_video_meta =
      (GstMpegVideoMeta *) gst_buffer_add_meta (buffer,
      GST_MPEG_VIDEO_META_INFO, NULL);

  GST_DEBUG
      ("seq_hdr:%p, seq_ext:%p, disp_ext:%p, pic_hdr:%p, pic_ext:%p, quant_ext:%p",
      seq_hdr, seq_ext, disp_ext, pic_hdr, pic_ext, quant_ext);

  if (seq_hdr)
    mpeg_video_meta->sequencehdr =
        g_slice_dup (GstMpegVideoSequenceHdr, seq_hdr);
  if (seq_ext)
    mpeg_video_meta->sequenceext =
        g_slice_dup (GstMpegVideoSequenceExt, seq_ext);
  if (disp_ext)
    mpeg_video_meta->sequencedispext =
        g_slice_dup (GstMpegVideoSequenceDisplayExt, disp_ext);
  mpeg_video_meta->pichdr = g_slice_dup (GstMpegVideoPictureHdr, pic_hdr);
  if (pic_ext)
    mpeg_video_meta->picext = g_slice_dup (GstMpegVideoPictureExt, pic_ext);
  if (quant_ext)
    mpeg_video_meta->quantext =
        g_slice_dup (GstMpegVideoQuantMatrixExt, quant_ext);
  if (slice_info_array)
    mpeg_video_meta->slice_info_array = g_array_ref (slice_info_array);

  return mpeg_video_meta;
}
Esempio n. 8
0
static void
shell_mount_operation_show_processes (GMountOperation *operation,
                                      const gchar     *message,
                                      GArray          *processes,
                                      const gchar     *choices[])
{
  ShellMountOperation *self = SHELL_MOUNT_OPERATION (operation);

  if (self->priv->pids != NULL)
    {
      g_array_unref (self->priv->pids);
      self->priv->pids = NULL;
    }

  g_free (self->priv->message);
  g_strfreev (self->priv->choices);

  /* save the parameters */
  self->priv->pids = g_array_ref (processes);
  self->priv->choices = g_strdupv ((gchar **) choices);
  self->priv->message = g_strdup (message);

  g_signal_emit (self, signals[SHOW_PROCESSES_2], 0);
}
Esempio n. 9
0
/**
 * shell_mount_operation_get_show_processes_pids:
 * @self: a #ShellMountOperation
 *
 * Returns: (transfer full) (element-type GPid): a #GArray
 */
GArray *
shell_mount_operation_get_show_processes_pids (ShellMountOperation *self)
{
  return g_array_ref (self->priv->pids);
}
Esempio n. 10
0
File: garray.c Progetto: Babelz/SaNi
/**
 * g_byte_array_ref:
 * @array: A #GByteArray
 *
 * Atomically increments the reference count of @array by one.
 * This function is thread-safe and may be called from any thread.
 *
 * Returns: The passed in #GByteArray
 *
 * Since: 2.22
 */
GByteArray*
g_byte_array_ref (GByteArray *array)
{
  return (GByteArray *)g_array_ref ((GArray *)array);
}
Esempio n. 11
0
GST_END_TEST
GST_START_TEST (negotiation_offerer)
{
  GArray *audio_codecs_array, *video_codecs_array;
  gchar *audio_codecs[] = { "OPUS/48000/1", "AMR/8000/1", NULL };
  gchar *video_codecs[] = { "H263-1998/90000", "VP8/90000", NULL };
  GstElement *offerer = gst_element_factory_make ("rtpendpoint", NULL);
  GstElement *answerer = gst_element_factory_make ("rtpendpoint", NULL);
  GstSDPMessage *offer = NULL, *answer = NULL;
  GstSDPMessage *offerer_local_sdp = NULL, *offerer_remote_sdp = NULL;
  gchar *offerer_local_sdp_str, *offerer_remote_sdp_str;
  GstSDPMessage *answerer_local_sdp = NULL, *answerer_remote_sdp = NULL;
  gchar *answerer_local_sdp_str, *answerer_remote_sdp_str;
  gchar *sdp_str = NULL;

  audio_codecs_array = create_codecs_array (audio_codecs);
  video_codecs_array = create_codecs_array (video_codecs);
  g_object_set (offerer, "num-audio-medias", 1, "audio-codecs",
      g_array_ref (audio_codecs_array), "num-video-medias", 1, "video-codecs",
      g_array_ref (video_codecs_array), NULL);
  g_object_set (answerer, "num-audio-medias", 1, "audio-codecs",
      g_array_ref (audio_codecs_array), "num-video-medias", 1, "video-codecs",
      g_array_ref (video_codecs_array), NULL);
  g_array_unref (audio_codecs_array);
  g_array_unref (video_codecs_array);

  g_signal_emit_by_name (offerer, "generate-offer", &offer);
  fail_unless (offer != NULL);
  GST_DEBUG ("Offer:\n%s", (sdp_str = gst_sdp_message_as_text (offer)));
  g_free (sdp_str);
  sdp_str = NULL;

  g_signal_emit_by_name (answerer, "process-offer", offer, &answer);
  fail_unless (answer != NULL);
  GST_DEBUG ("Answer:\n%s", (sdp_str = gst_sdp_message_as_text (answer)));
  g_free (sdp_str);
  sdp_str = NULL;

  g_signal_emit_by_name (offerer, "process-answer", answer);

  gst_sdp_message_free (offer);
  gst_sdp_message_free (answer);

  g_object_get (offerer, "local-sdp", &offerer_local_sdp, NULL);
  fail_unless (offerer_local_sdp != NULL);
  g_object_get (offerer, "remote-sdp", &offerer_remote_sdp, NULL);
  fail_unless (offerer_remote_sdp != NULL);

  g_object_get (answerer, "local-sdp", &answerer_local_sdp, NULL);
  fail_unless (answerer_local_sdp != NULL);
  g_object_get (answerer, "remote-sdp", &answerer_remote_sdp, NULL);
  fail_unless (answerer_remote_sdp != NULL);

  offerer_local_sdp_str = gst_sdp_message_as_text (offerer_local_sdp);
  offerer_remote_sdp_str = gst_sdp_message_as_text (offerer_remote_sdp);

  answerer_local_sdp_str = gst_sdp_message_as_text (answerer_local_sdp);
  answerer_remote_sdp_str = gst_sdp_message_as_text (answerer_remote_sdp);

  GST_DEBUG ("Offerer local SDP\n%s", offerer_local_sdp_str);
  GST_DEBUG ("Offerer remote SDPr\n%s", offerer_remote_sdp_str);
  GST_DEBUG ("Answerer local SDP\n%s", answerer_local_sdp_str);
  GST_DEBUG ("Answerer remote SDP\n%s", answerer_remote_sdp_str);

  fail_unless (g_strcmp0 (offerer_local_sdp_str, answerer_remote_sdp_str) == 0);
  fail_unless (g_strcmp0 (offerer_remote_sdp_str, answerer_local_sdp_str) == 0);

  g_free (offerer_local_sdp_str);
  g_free (offerer_remote_sdp_str);
  g_free (answerer_local_sdp_str);
  g_free (answerer_remote_sdp_str);

  gst_sdp_message_free (offerer_local_sdp);
  gst_sdp_message_free (offerer_remote_sdp);
  gst_sdp_message_free (answerer_local_sdp);
  gst_sdp_message_free (answerer_remote_sdp);

  g_object_unref (offerer);
  g_object_unref (answerer);
}
static void
set_bands_2g (MMIfaceModem *self,
              GArray *bands_array,
              GSimpleAsyncResult *result)
{
    GArray *bands_array_final;
    gchar wavecom_band = '\0';
    guint i;
    gchar *bands_string;
    gchar *cmd;

    /* If the iface properly checked the given list against the supported bands,
     * it's not possible to get an array longer than 4 here. */
    g_assert (bands_array->len <= 4);

    /* The special case of ANY should be treated separately. */
    if (bands_array->len == 1 &&
        g_array_index (bands_array, MMModemBand, 0) == MM_MODEM_BAND_ANY) {
        const WavecomBand2G *all;

        /* All bands is the last element in our 2G bands array */
        all = &bands_2g[G_N_ELEMENTS (bands_2g) - 1];

        /* We build an array with all bands to set; so that we use the same
         * logic to build the cinterion_band, and so that we can log the list of
         * bands being set properly */
        bands_array_final = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), 4);
        g_array_append_vals (bands_array_final, all->mm_bands, all->n_mm_bands);
    } else
        bands_array_final = g_array_ref (bands_array);

    for (i = 0; wavecom_band == '\0' && i < G_N_ELEMENTS (bands_2g); i++) {
        GArray *supported_combination;

        supported_combination = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), bands_2g[i].n_mm_bands);
        g_array_append_vals (supported_combination, bands_2g[i].mm_bands, bands_2g[i].n_mm_bands);

        /* Check if the given array is exactly one of the supported combinations */
        if (mm_common_bands_garray_cmp (bands_array_final, supported_combination))
            wavecom_band = bands_2g[i].wavecom_band;

        g_array_unref (supported_combination);
    }

    bands_string = mm_common_build_bands_string ((MMModemBand *)bands_array_final->data,
                                                 bands_array_final->len);
    g_array_unref (bands_array_final);

    if (wavecom_band == '\0') {
        g_simple_async_result_set_error (result,
                                         MM_CORE_ERROR,
                                         MM_CORE_ERROR_UNSUPPORTED,
                                         "The given band combination is not supported: '%s'",
                                         bands_string);
        g_simple_async_result_complete_in_idle (result);
        g_object_unref (result);
        g_free (bands_string);
        return;
    }

    mm_dbg ("Setting new bands to use: '%s'", bands_string);
    cmd = g_strdup_printf ("+WMBS=%c,1", wavecom_band);
    mm_base_modem_at_command (MM_BASE_MODEM (self),
                              cmd,
                              3,
                              FALSE,
                              (GAsyncReadyCallback)wmbs_set_ready,
                              result);

    g_free (cmd);
    g_free (bands_string);
}
static void
set_bands_3g (MMIfaceModem *self,
              GArray *bands_array,
              GSimpleAsyncResult *result)
{
    GArray *bands_array_final;
    guint wavecom_band = 0;
    guint i;
    gchar *bands_string;
    gchar *cmd;

    /* The special case of ANY should be treated separately. */
    if (bands_array->len == 1 &&
        g_array_index (bands_array, MMModemBand, 0) == MM_MODEM_BAND_ANY) {
        /* We build an array with all bands to set; so that we use the same
         * logic to build the cinterion_band, and so that we can log the list of
         * bands being set properly */
        bands_array_final = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), G_N_ELEMENTS (bands_3g));
        for (i = 0; i < G_N_ELEMENTS (bands_3g); i++)
            g_array_append_val (bands_array_final, bands_3g[i].mm_band);
    } else
        bands_array_final = g_array_ref (bands_array);

    for (i = 0; i < G_N_ELEMENTS (bands_3g); i++) {
        guint j;

        for (j = 0; j < bands_array_final->len; j++) {
            if (g_array_index (bands_array_final, MMModemBand, j) == bands_3g[i].mm_band) {
                wavecom_band |= bands_3g[i].wavecom_band_flag;
                break;
            }
        }
    }

    bands_string = mm_common_build_bands_string ((MMModemBand *)bands_array_final->data,
                                                 bands_array_final->len);
    g_array_unref (bands_array_final);

    if (wavecom_band == 0) {
        g_simple_async_result_set_error (result,
                                         MM_CORE_ERROR,
                                         MM_CORE_ERROR_UNSUPPORTED,
                                         "The given band combination is not supported: '%s'",
                                         bands_string);
        g_simple_async_result_complete_in_idle (result);
        g_object_unref (result);
        g_free (bands_string);
        return;
    }

    mm_dbg ("Setting new bands to use: '%s'", bands_string);
    cmd = g_strdup_printf ("+WMBS=\"%u\",1", wavecom_band);
    mm_base_modem_at_command (MM_BASE_MODEM (self),
                              cmd,
                              3,
                              FALSE,
                              (GAsyncReadyCallback)wmbs_set_ready,
                              result);
    g_free (cmd);
    g_free (bands_string);
}
Esempio n. 14
0
int
main (int argc, char **argv)
{
  gtk_init( &argc, &argv );

  g_type_init ();

  gfx_lib_setup ();

  g_testtex = cogl_texture_new_from_file ("testtex_sr.bmp", COGL_TEXTURE_NONE, COGL_PIXEL_FORMAT_ANY, NULL);
  g_xassert (g_testtex != COGL_INVALID_HANDLE);

  //cogl_ortho (-1.0f, 1.0f, -1.0f, 1.0f, -5.0f, 100.0f);
  cogl_perspective (45.0f, 1.0f, 0.1f, 100.0f);
  cogl_set_source_texture (g_testtex);

  /**
   * WHY IS THIS NOT ENABLED BY DEFAULT
   */
  cogl_set_depth_test_enabled (TRUE);

  /**
   * Enabling this shows polygons actually missing not just culled out?
   * cogl_set_backface_culling_enabled (TRUE);
   */

  /**
   * Initialize g_state
   */
  struct NxState state = {0};
  g_state = g_new0 (struct NxState, 1);
  *g_state = state;

  g_state->dr_n = 1.0f;
  g_state->dr_f = 100.0f;
  g_state->vp_w = 100.0f;
  g_state->vp_h = 100.0f;
  g_state->vp_x = 0.0f;
  g_state->vp_y = 0.0f;

  NxMat z_mat;
  nx_mat_init_identity (&z_mat);
  nx_mat_translate (&z_mat, 0.0f, 0.0f, -30.0f);

  g_state->p_mat = z_mat;
  g_state->w_mat = z_mat;

  MaiModel *model;
  struct aiScene *scene;
  model = mai_model_new_from_file ("../misc/mtest1.dae", &scene);
  aiReleaseImport (scene);

  MaiAnimInstance *mai;
  g_xassert (model->anims->len > 0);
  mai = mai_anim_instance_new_from_anim (
                                         g_mai_anim_ptr_array_index (model->anims, 0),
                                         model->name_node_map,
                                         model->nodes);

  struct SrNodeGraph *sr_model;
  sr_node_graph_from_model (model, &sr_model);

  MaiInfoWin *iw;
  iw = MAI_INFO_WIN (mai_info_win_new ());

  mai_info_win_clear_model (iw);
  mai_info_win_fill_model_from_node_graph (iw, sr_model);
  mai_info_win_fill_model_from_model (iw, model);

  mai_info_win_show (iw);

  int frame;
  for (frame=0; frame<600; ++frame)
    {
      ALLEGRO_KEYBOARD_STATE aks;

      gfx_display_clear ();

      context_switch_allegro ();
      al_get_keyboard_state (&aks);
      sr_update_global_ypr (&aks);
      al_clear_to_color (al_map_rgb (0, 0, 0));

      mai_info_win_iteration (iw, FALSE);

      /**
       * Allegro drawing origin top left.
       * Compensate (Want positive x/y go northwest).
       */
      NxMat comp;
      comp = g_state->w_mat;
      nx_mat_scale (&comp, -1.0f, 1.0f, -1.0f);

      struct SrNodeGraph *sr_model_aux;
      GHashTable *ht;

      sr_node_graph_copy (&sr_model_aux, sr_model);

      sr_skeletal_anim_node_graph (mai, sr_model_aux);
      sr_skeletal_anim_verts (model, mai, sr_model_aux, &ht);

      GList *model_keys;
      model_keys = g_hash_table_get_keys (ht);

      for (GList *k = model_keys; k != NULL; k = k->next)
        {
          char *name;
          GArray *vts_a;
          MaiNode *mn_a;

          name = k->data;

          vts_a = g_hash_table_lookup (ht, name);
          g_xassert (vts_a);
          g_array_ref (vts_a);

          mn_a = g_object_ref (MAI_NODE (
              g_hash_table_lookup (model->name_node_map, name)));
          g_xassert (mn_a);

          sr_skeletal_draw_node_trans (&comp, sr_model_aux,
                                       mn_a, vts_a);

          g_object_unref (mn_a);
          g_array_unref (vts_a);
        }

      g_list_free (model_keys);

      g_hash_table_unref (ht);

      sr_node_graph_free (sr_model_aux);

      mai->current_frame += mai->current_frame == 29 ? -29 : 1;

      gfx_display_transfer ();

      al_rest (0.05f);
    }

  return EXIT_SUCCESS;
}
Esempio n. 15
0
static void
test_audio_sendrecv (const gchar * audio_enc_name,
    GstStaticCaps expected_caps, gchar * codec)
{
  GArray *codecs_array;
  gchar *codecs[] = { codec, NULL };
  HandOffData *hod;
  GMainLoop *loop = g_main_loop_new (NULL, TRUE);
  GstSDPMessage *offer, *answer;
  GstElement *pipeline = gst_pipeline_new (NULL);
  GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
  GstElement *audiotestsrc_offerer =
      gst_element_factory_make ("audiotestsrc", NULL);
  GstElement *audiotestsrc_answerer =
      gst_element_factory_make ("audiotestsrc", NULL);
  GstElement *audio_enc_offerer =
      gst_element_factory_make (audio_enc_name, NULL);
  GstElement *audio_enc_answerer =
      gst_element_factory_make (audio_enc_name, NULL);
  GstElement *rtpendpoint_offerer =
      gst_element_factory_make ("rtpendpoint", NULL);
  GstElement *rtpendpoint_answerer =
      gst_element_factory_make ("rtpendpoint", NULL);
  GstElement *fakesink_offerer = gst_element_factory_make ("fakesink", NULL);
  GstElement *fakesink_answerer = gst_element_factory_make ("fakesink", NULL);

  gst_bus_add_signal_watch (bus);
  g_signal_connect (bus, "message", G_CALLBACK (bus_msg), pipeline);

  codecs_array = create_codecs_array (codecs);
  g_object_set (rtpendpoint_offerer, "num-audio-medias", 1, "audio-codecs",
      g_array_ref (codecs_array), NULL);
  g_object_set (rtpendpoint_answerer, "num-audio-medias", 1, "audio-codecs",
      g_array_ref (codecs_array), NULL);
  g_array_unref (codecs_array);

  hod = g_slice_new (HandOffData);
  hod->expected_caps = expected_caps;
  hod->loop = loop;

  g_object_set (G_OBJECT (fakesink_offerer), "signal-handoffs", TRUE, NULL);
  g_signal_connect (G_OBJECT (fakesink_offerer), "handoff",
      G_CALLBACK (sendrecv_offerer_fakesink_hand_off), hod);
  g_object_set (G_OBJECT (fakesink_answerer), "signal-handoffs", TRUE, NULL);
  g_signal_connect (G_OBJECT (fakesink_answerer), "handoff",
      G_CALLBACK (sendrecv_answerer_fakesink_hand_off), hod);

  /* Add elements */
  gst_bin_add (GST_BIN (pipeline), rtpendpoint_offerer);
  connect_sink_async (rtpendpoint_offerer, audiotestsrc_offerer,
      audio_enc_offerer, NULL, pipeline, "sink_audio");

  gst_bin_add (GST_BIN (pipeline), rtpendpoint_answerer);
  connect_sink_async (rtpendpoint_answerer, audiotestsrc_answerer,
      audio_enc_answerer, NULL, pipeline, "sink_audio");

  gst_element_set_state (pipeline, GST_STATE_PLAYING);

  /* SDP negotiation */
  mark_point ();
  g_signal_emit_by_name (rtpendpoint_offerer, "generate-offer", &offer);
  fail_unless (offer != NULL);

  mark_point ();
  g_signal_emit_by_name (rtpendpoint_answerer, "process-offer", offer, &answer);
  fail_unless (answer != NULL);

  mark_point ();
  g_signal_emit_by_name (rtpendpoint_offerer, "process-answer", answer);
  gst_sdp_message_free (offer);
  gst_sdp_message_free (answer);

  gst_bin_add (GST_BIN (pipeline), fakesink_offerer);
  g_object_set_data (G_OBJECT (rtpendpoint_offerer), AUDIO_SINK,
      fakesink_offerer);
  g_signal_connect (rtpendpoint_offerer, "pad-added",
      G_CALLBACK (connect_sink_on_srcpad_added), NULL);
  fail_unless (kms_element_request_srcpad (rtpendpoint_offerer,
          KMS_ELEMENT_PAD_TYPE_AUDIO));

  gst_bin_add (GST_BIN (pipeline), fakesink_answerer);
  g_object_set_data (G_OBJECT (rtpendpoint_answerer), AUDIO_SINK,
      fakesink_answerer);
  g_signal_connect (rtpendpoint_answerer, "pad-added",
      G_CALLBACK (connect_sink_on_srcpad_added), NULL);
  fail_unless (kms_element_request_srcpad (rtpendpoint_answerer,
          KMS_ELEMENT_PAD_TYPE_AUDIO));

  GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline),
      GST_DEBUG_GRAPH_SHOW_ALL, "test_audio_sendrecv_before_entering_loop");

  mark_point ();
  g_main_loop_run (loop);
  mark_point ();

  GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline),
      GST_DEBUG_GRAPH_SHOW_ALL, "test_audio_sendrecv_end");

  gst_element_set_state (pipeline, GST_STATE_NULL);

  gst_bus_remove_signal_watch (bus);
  g_object_unref (bus);
  g_main_loop_unref (loop);
  g_object_unref (pipeline);
  g_slice_free (HandOffData, hod);
}
Esempio n. 16
0
GST_END_TEST
GST_START_TEST (negotiation_offerer)
{
  GArray *audio_codecs_array, *video_codecs_array;
  gchar *audio_codecs[] = { "OPUS/48000/1", "AMR/8000/1", NULL };
  gchar *video_codecs[] = { "H263-1998/90000", "VP8/90000", NULL };
  gchar *offerer_sess_id, *answerer_sess_id;
  GstElement *offerer = gst_element_factory_make ("rtpendpoint", NULL);
  GstElement *answerer = gst_element_factory_make ("rtpendpoint", NULL);
  GstSDPMessage *offer = NULL, *answer = NULL;
  GstSDPMessage *offerer_local_sdp = NULL, *offerer_remote_sdp = NULL;
  gchar *offerer_local_sdp_str, *offerer_remote_sdp_str;
  GstSDPMessage *answerer_local_sdp = NULL, *answerer_remote_sdp = NULL;
  gchar *answerer_local_sdp_str, *answerer_remote_sdp_str;
  gchar *sdp_str = NULL;
  const GstSDPConnection *connection;
  gboolean answer_ok;

  audio_codecs_array = create_codecs_array (audio_codecs);
  video_codecs_array = create_codecs_array (video_codecs);
  g_object_set (offerer, "num-audio-medias", 1, "audio-codecs",
      g_array_ref (audio_codecs_array), "num-video-medias", 1, "video-codecs",
      g_array_ref (video_codecs_array), NULL);
  g_object_set (answerer, "num-audio-medias", 1, "audio-codecs",
      g_array_ref (audio_codecs_array), "num-video-medias", 1, "video-codecs",
      g_array_ref (video_codecs_array), NULL);
  g_array_unref (audio_codecs_array);
  g_array_unref (video_codecs_array);

  /* Session creation */
  g_signal_emit_by_name (offerer, "create-session", &offerer_sess_id);
  GST_DEBUG_OBJECT (offerer, "Created session with id '%s'", offerer_sess_id);
  g_signal_emit_by_name (answerer, "create-session", &answerer_sess_id);
  GST_DEBUG_OBJECT (answerer, "Created session with id '%s'", answerer_sess_id);

  /* SDP negotiation */
  g_signal_emit_by_name (offerer, "generate-offer", offerer_sess_id, &offer);
  fail_unless (offer != NULL);
  GST_DEBUG ("Offer:\n%s", (sdp_str = gst_sdp_message_as_text (offer)));
  g_free (sdp_str);
  sdp_str = NULL;
  connection = gst_sdp_message_get_connection (offer);

  fail_unless (g_strcmp0 (connection->address, "0.0.0.0"));
  fail_unless (g_strcmp0 (connection->address, "::"));

  g_signal_emit_by_name (answerer, "process-offer", answerer_sess_id, offer,
      &answer);
  fail_unless (answer != NULL);
  GST_DEBUG ("Answer:\n%s", (sdp_str = gst_sdp_message_as_text (answer)));
  g_free (sdp_str);
  sdp_str = NULL;

  g_signal_emit_by_name (offerer, "process-answer", offerer_sess_id, answer,
      &answer_ok);
  fail_unless (answer_ok);

  gst_sdp_message_free (offer);
  gst_sdp_message_free (answer);

  g_signal_emit_by_name (offerer, "get-local-sdp", offerer_sess_id,
      &offerer_local_sdp);
  fail_unless (offerer_local_sdp != NULL);
  g_signal_emit_by_name (offerer, "get-remote-sdp", offerer_sess_id,
      &offerer_remote_sdp);
  fail_unless (offerer_remote_sdp != NULL);

  g_signal_emit_by_name (answerer, "get-local-sdp", answerer_sess_id,
      &answerer_local_sdp);
  fail_unless (answerer_local_sdp != NULL);
  g_signal_emit_by_name (answerer, "get-remote-sdp", answerer_sess_id,
      &answerer_remote_sdp);
  fail_unless (answerer_remote_sdp != NULL);

  offerer_local_sdp_str = gst_sdp_message_as_text (offerer_local_sdp);
  offerer_remote_sdp_str = gst_sdp_message_as_text (offerer_remote_sdp);

  answerer_local_sdp_str = gst_sdp_message_as_text (answerer_local_sdp);
  answerer_remote_sdp_str = gst_sdp_message_as_text (answerer_remote_sdp);

  GST_DEBUG ("Offerer local SDP\n%s", offerer_local_sdp_str);
  GST_DEBUG ("Offerer remote SDPr\n%s", offerer_remote_sdp_str);
  GST_DEBUG ("Answerer local SDP\n%s", answerer_local_sdp_str);
  GST_DEBUG ("Answerer remote SDP\n%s", answerer_remote_sdp_str);

  fail_unless (g_strcmp0 (offerer_local_sdp_str, answerer_remote_sdp_str) == 0);
  fail_unless (g_strcmp0 (offerer_remote_sdp_str, answerer_local_sdp_str) == 0);

  g_free (offerer_local_sdp_str);
  g_free (offerer_remote_sdp_str);
  g_free (answerer_local_sdp_str);
  g_free (answerer_remote_sdp_str);

  gst_sdp_message_free (offerer_local_sdp);
  gst_sdp_message_free (offerer_remote_sdp);
  gst_sdp_message_free (answerer_local_sdp);
  gst_sdp_message_free (answerer_remote_sdp);

  g_object_unref (offerer);
  g_object_unref (answerer);
  g_free (offerer_sess_id);
  g_free (answerer_sess_id);
}