Statistics
| Branch: | Revision:

janus-gateway / plugins / plugin.c @ 8241c758

History | View | Annotate | Download (1.32 KB)

1 292d035f meetecho
/*! \file   plugin.h
2
 * \author Lorenzo Miniero <lorenzo@meetecho.com>
3
 * \copyright GNU General Public License v3
4
 * \brief  Plugin-Gateway communication (implementation)
5
 * \details  Implementation of the janus_plugin_result stuff: all the
6
 * important things related to the actual plugin API is in plugin.h.
7
 * 
8
 * \ingroup pluginapi
9
 * \ref pluginapi
10
 */
11
12
#include "plugin.h"
13
14 6bb3f34d Nicholas Wylie
#include "../apierror.h"
15
#include "../debug.h"
16
17 dd11fa0a Lorenzo Miniero
janus_plugin_result *janus_plugin_result_new(janus_plugin_result_type type, const char *text, json_t *content) {
18 292d035f meetecho
        JANUS_LOG(LOG_HUGE, "Creating plugin result...\n");
19 1f067658 Lorenzo Miniero
        janus_plugin_result *result = (janus_plugin_result *)g_malloc0(sizeof(janus_plugin_result));
20 292d035f meetecho
        if(result == NULL)
21
                return NULL;
22
        result->type = type;
23 dd11fa0a Lorenzo Miniero
        result->text = text;
24
        result->content = content;
25 292d035f meetecho
        return result;
26
}
27
28
/*! \brief Helper to quickly destroy a janus_plugin_result instance
29
 * @param[in] result The janus_plugin_result instance to destroy
30 dd11fa0a Lorenzo Miniero
 * @note Will decrease the reference counter of the JSON content, if available
31 292d035f meetecho
 * @returns A valid janus_plugin_result instance, if successful, or NULL otherwise */
32
void janus_plugin_result_destroy(janus_plugin_result *result) {
33
        JANUS_LOG(LOG_HUGE, "Destroying plugin result...\n");
34 dd11fa0a Lorenzo Miniero
        result->text = NULL;
35
        if(result->content)
36
                json_decref(result->content);
37
        result->content = NULL;
38 292d035f meetecho
        g_free(result);
39
}