Ejemplo n.º 1
0
/**
 * pka_manager_remove_encoder:
 * @context: A #PkaContext.
 * @encoder: A #PkaEncoder.
 * @error: A location for a #GError, or %NULL.
 *
 * Removes @encoder from the Perfkit Agent.  If the context does not have
 * permissions, this operation will fail.
 *
 * Returns: %TRUE if succesful; otherwise %FALSE.
 * Side effects: None.
 */
gboolean
pka_manager_remove_encoder (PkaContext  *context, /* IN */
                            PkaEncoder  *encoder, /* IN */
                            GError     **error)   /* OUT */
{
	gint encoder_id;

	g_return_val_if_fail(context != NULL, FALSE);
	g_return_val_if_fail(PKA_IS_ENCODER(encoder), FALSE);

	ENTRY;
	AUTHORIZE_IOCTL(context, REMOVE_ENCODER);
	/*
	 * TODO:
	 *
	 *   1) Enure the encoder is not attached to a running channel.
	 *
	 */
	if (FALSE) {
		encoder_id = pka_encoder_get_id(encoder);
		INFO(Encoder, "Removing encoder %d on behalf of context %d.",
		     encoder_id, pka_context_get_id(context));
		G_LOCK(encoders);
		g_ptr_array_remove(manager.encoders, encoder);
		G_UNLOCK(encoders);
		NOTIFY_LISTENERS(encoder_removed, encoder_id);
		g_object_unref(encoder);
	}
	RETURN(TRUE);
}
Ejemplo n.º 2
0
/**
 * pka_encoder_encode_manifest:
 * @encoder: A #PkaEncoder
 * @manifest: A #PkaManifest
 * @data: A location for a data buffer
 * @data_len: A location for the data buffer length
 *
 * Encodes the manifest into a buffer.  If the encoder is %NULL, the default
 * of copying the buffers will be performed.
 *
 * Returns: %TRUE if successful; otherwise %FALSE.
 */
gboolean
pka_encoder_encode_manifest (PkaEncoder   *encoder,  /* IN */
                             PkaManifest  *manifest, /* IN */
                             guint8      **data,     /* IN */
                             gsize        *data_len) /* IN */
{
	gboolean ret;

	g_return_val_if_fail(!encoder || PKA_IS_ENCODER(encoder), FALSE);
	g_return_val_if_fail(manifest != NULL, FALSE);
	g_return_val_if_fail(data != NULL, FALSE);
	g_return_val_if_fail(data_len != NULL, FALSE);

	ENTRY;
	if (encoder) {
		ret = PKA_ENCODER_GET_INTERFACE(encoder)->
			encode_manifest(encoder, manifest, data, data_len);
	} else {
		ret = pka_encoder_real_encode_manifest(manifest, data, data_len);
	}
	RETURN(ret);
}
Ejemplo n.º 3
0
/**
 * pka_subscription_set_encoder:
 * @subscription: A #PkaSubscription.
 *
 * Sets the encoder to be used for @subscription.  The manifest and sample
 * buffers will be encoded using this before notifying the handlers.
 *
 * Returns: %TRUE if successful; otherwise %FALSE and @error is set.
 * Side effects: None.
 */
gboolean
pka_subscription_set_encoder (PkaSubscription  *subscription, /* IN */
                              PkaContext       *context,      /* IN */
                              PkaEncoder       *encoder,      /* IN */
                              GError          **error)        /* OUT */
{
	gboolean ret = FALSE;

	g_return_val_if_fail(subscription != NULL, FALSE);
	g_return_val_if_fail(context != NULL, FALSE);
	g_return_val_if_fail(!encoder || PKA_IS_ENCODER(encoder), FALSE);

	ENTRY;
	g_static_rw_lock_writer_lock(&subscription->rw_lock);
	if (subscription->encoder) {
		g_object_unref(subscription->encoder);
		subscription->encoder = NULL;
	}
	if (encoder) {
		subscription->encoder = g_object_ref(encoder);
	}
	g_static_rw_lock_writer_unlock(&subscription->rw_lock);
	RETURN(ret);
}