Loading...
Searching...
No Matches
janus_mqtt.c File Reference
Transports

Janus MQTT transport plugin. More...

`#include "transport.h"`
`#include <MQTTAsync.h>`
`#include "../debug.h"`
`#include "../config.h"`
`#include "../utils.h"`
Include dependency graph for janus_mqtt.c:

## Data Structures

struct | janus_mqtt_context

## Macros

#define | JANUS_MQTT_VERSION 1
#define | JANUS_MQTT_VERSION_STRING "0.0.1"
#define | JANUS_MQTT_DESCRIPTION "This transport plugin adds MQTT support to the Janus API via Paho client library."
#define | JANUS_MQTT_NAME "JANUS MQTT transport plugin"
#define | JANUS_MQTT_AUTHOR "Andrei Nesterov <ae.nesterov@gmail.com>"
#define | JANUS_MQTT_PACKAGE "janus.transport.mqtt"
#define | JANUS_MQTT_VERSION_3_1 "3.1"
#define | JANUS_MQTT_VERSION_3_1_1 "3.1.1"
#define | JANUS_MQTT_VERSION_5 "5"
#define | JANUS_MQTT_VERSION_DEFAULT JANUS_MQTT_VERSION_3_1_1
#define | JANUS_MQTT_DEFAULT_STATUS_TOPIC "status"
#define | JANUS_MQTT_DEFAULT_STATUS_QOS 1
#define | JANUS_MQTT_ERROR_INVALID_REQUEST 411
#define | JANUS_MQTT_ERROR_MISSING_ELEMENT 412
#define | JANUS_MQTT_ERROR_INVALID_ELEMENT 413
#define | JANUS_MQTT_ERROR_UNKNOWN_ERROR 499

## Typedefs

typedef struct janus_mqtt_context | janus_mqtt_context

## Functions

janus_transport * | create (void)
int | janus_mqtt_init (janus_transport_callbacks *callback, const char *config_path)
void | janus_mqtt_destroy (void)
int | janus_mqtt_get_api_compatibility (void)
int | janus_mqtt_get_version (void)
const char * | janus_mqtt_get_version_string (void)
const char * | janus_mqtt_get_description (void)
const char * | janus_mqtt_get_name (void)
const char * | janus_mqtt_get_author (void)
const char * | janus_mqtt_get_package (void)
gboolean | janus_mqtt_is_janus_api_enabled (void)
gboolean | janus_mqtt_is_admin_api_enabled (void)
int | janus_mqtt_send_message (janus_transport_session *transport, void *request_id, gboolean admin, json_t *message)
void | janus_mqtt_session_created (janus_transport_session *transport, guint64 session_id)
void | janus_mqtt_session_over (janus_transport_session *transport, guint64 session_id, gboolean timeout, gboolean claimed)
void | janus_mqtt_session_claimed (janus_transport_session *transport, guint64 session_id)
json_t * | janus_mqtt_query_transport (json_t *request)
void | janus_mqtt_client_connected (void *context, char *cause)
void | janus_mqtt_client_connection_lost (void *context, char *cause)
int | janus_mqtt_client_message_arrived (void *context, char *topicName, int topicLen, MQTTAsync_message *message)
int | janus_mqtt_client_connect (janus_mqtt_context *ctx)
int | janus_mqtt_client_reconnect (janus_mqtt_context *ctx)
int | janus_mqtt_client_disconnect (janus_mqtt_context *ctx)
int | janus_mqtt_client_subscribe (janus_mqtt_context *ctx, gboolean admin)
int | janus_mqtt_client_publish_status_message (janus_mqtt_context *ctx, char *payload)
void | janus_mqtt_client_destroy_context (janus_mqtt_context **ctx)
void | janus_mqtt_client_connect_failure (void *context, MQTTAsync_failureData *response)
void | janus_mqtt_client_reconnect_success (void *context, MQTTAsync_successData *response)
void | janus_mqtt_client_reconnect_failure (void *context, MQTTAsync_failureData *response)
void | janus_mqtt_client_disconnect_success (void *context, MQTTAsync_successData *response)
void | janus_mqtt_client_disconnect_failure (void *context, MQTTAsync_failureData *response)
void | janus_mqtt_client_subscribe_success (void *context, MQTTAsync_successData *response)
void | janus_mqtt_client_subscribe_failure (void *context, MQTTAsync_failureData *response)
void | janus_mqtt_client_admin_subscribe_success (void *context, MQTTAsync_successData *response)
void | janus_mqtt_client_admin_subscribe_failure (void *context, MQTTAsync_failureData *response)
void | janus_mqtt_client_publish_janus_success (void *context, MQTTAsync_successData *response)
void | janus_mqtt_client_publish_janus_failure (void *context, MQTTAsync_failureData *response)
void | janus_mqtt_client_publish_admin_success (void *context, MQTTAsync_successData *response)
void | janus_mqtt_client_publish_admin_failure (void *context, MQTTAsync_failureData *response)
void | janus_mqtt_client_publish_status_success (void *context, MQTTAsync_successData *response)
void | janus_mqtt_client_publish_status_failure (void *context, MQTTAsync_failureData *response)
int | janus_mqtt_client_publish_message (janus_mqtt_context *ctx, char *payload, gboolean admin)
int | janus_mqtt_client_get_response_code (MQTTAsync_failureData *response)
void | janus_mqtt_client_reconnect_success_impl (void *context)
void | janus_mqtt_client_connect_failure_impl (void *context, int rc)
void | janus_mqtt_client_reconnect_failure_impl (void *context, int rc)
void | janus_mqtt_client_disconnect_success_impl (void *context)
void | janus_mqtt_client_disconnect_failure_impl (void *context, int rc)
void | janus_mqtt_client_subscribe_success_impl (void *context)
void | janus_mqtt_client_subscribe_failure_impl (void *context, int rc)
void | janus_mqtt_client_admin_subscribe_success_impl (void *context)
void | janus_mqtt_client_admin_subscribe_failure_impl (void *context, int rc)
void | janus_mqtt_client_publish_janus_success_impl (char *topic)
void | janus_mqtt_client_publish_janus_failure_impl (int rc)
void | janus_mqtt_client_publish_admin_success_impl (char *topic)
void | janus_mqtt_client_publish_admin_failure_impl (int rc)
void | janus_mqtt_client_publish_status_success_impl (char *topic)
void | janus_mqtt_client_publish_status_failure_impl (int rc)

## Detailed Description

Janus MQTT transport plugin.

Author
  Andrei Nesterov ae.ne.nosp@m.ster.nosp@m.ov@gm.nosp@m.ail..nosp@m.com

Copyright
  GNU General Public License v3

This is an implementation of a MQTT transport for the Janus API, using the Eclipse Paho C Client library (https://eclipse.org/paho/clients/c). This means that this module adds support for MQTT based messaging as an alternative "transport" for API requests, responses and notifications. This is only useful when you're handling the communication with clients your own way. Right now, you can only configure the address of the MQTT broker to use, and the queues to make use of to receive (to-janus) and send (from-janus) messages from/to an external application. As with WebSockets, considering that requests wouldn't include a path to address some mandatory information, these requests addressed to Janus should include as part of their payload, when needed, additional pieces of information like `session_id` and `handle_id`. That is, where you'd send a Janus request related to a specific session to the `/janus/<session>` path, with MQTT you'd have to send the same request with an additional `session_id` field in the JSON payload.

Note
  When you create a session using MQTT, a subscription to the events related to it is done automatically through the outgoing queue, so no need for an explicit request as the GET in the plain HTTP API.

transports

## Macro Definition Documentation

## JANUS_MQTT_AUTHOR

#define JANUS_MQTT_AUTHOR "Andrei Nesterov <ae.nesterov@gmail.com>"

## JANUS_MQTT_DEFAULT_STATUS_QOS

#define JANUS_MQTT_DEFAULT_STATUS_QOS 1

## JANUS_MQTT_DEFAULT_STATUS_TOPIC

#define JANUS_MQTT_DEFAULT_STATUS_TOPIC "status"

## JANUS_MQTT_DESCRIPTION

#define JANUS_MQTT_DESCRIPTION "This transport plugin adds MQTT support to the Janus API via Paho client library."

## JANUS_MQTT_ERROR_INVALID_ELEMENT

#define JANUS_MQTT_ERROR_INVALID_ELEMENT 413

## JANUS_MQTT_ERROR_INVALID_REQUEST

#define JANUS_MQTT_ERROR_INVALID_REQUEST 411

## JANUS_MQTT_ERROR_MISSING_ELEMENT

#define JANUS_MQTT_ERROR_MISSING_ELEMENT 412

## JANUS_MQTT_ERROR_UNKNOWN_ERROR

#define JANUS_MQTT_ERROR_UNKNOWN_ERROR 499

## JANUS_MQTT_NAME

#define JANUS_MQTT_NAME "JANUS MQTT transport plugin"

## JANUS_MQTT_PACKAGE

#define JANUS_MQTT_PACKAGE "janus.transport.mqtt"

## JANUS_MQTT_VERSION

#define JANUS_MQTT_VERSION 1

## JANUS_MQTT_VERSION_3_1

#define JANUS_MQTT_VERSION_3_1 "3.1"

## JANUS_MQTT_VERSION_3_1_1

#define JANUS_MQTT_VERSION_3_1_1 "3.1.1"

## JANUS_MQTT_VERSION_5

#define JANUS_MQTT_VERSION_5 "5"

## JANUS_MQTT_VERSION_DEFAULT

#define JANUS_MQTT_VERSION_DEFAULT JANUS_MQTT_VERSION_3_1_1

## JANUS_MQTT_VERSION_STRING

#define JANUS_MQTT_VERSION_STRING "0.0.1"

## Typedef Documentation

## janus_mqtt_context

typedef struct janus_mqtt_context janus_mqtt_context

## Function Documentation

## create()

janus_transport * create | ( | void |  | ) |

## janus_mqtt_client_admin_subscribe_failure()

void janus_mqtt_client_admin_subscribe_failure | ( | void * | context,
|  | MQTTAsync_failureData * | response
| ) |  |

## janus_mqtt_client_admin_subscribe_failure_impl()

void janus_mqtt_client_admin_subscribe_failure_impl | ( | void * | context,
|  | int | rc
| ) |  |

## janus_mqtt_client_admin_subscribe_success()

void janus_mqtt_client_admin_subscribe_success | ( | void * | context,
|  | MQTTAsync_successData * | response
| ) |  |

## janus_mqtt_client_admin_subscribe_success_impl()

void janus_mqtt_client_admin_subscribe_success_impl | ( | void * | context | ) |

## janus_mqtt_client_connect()

int janus_mqtt_client_connect | ( | janus_mqtt_context * | ctx | ) |

## janus_mqtt_client_connect_failure()

void janus_mqtt_client_connect_failure | ( | void * | context,
|  | MQTTAsync_failureData * | response
| ) |  |

## janus_mqtt_client_connect_failure_impl()

void janus_mqtt_client_connect_failure_impl | ( | void * | context,
|  | int | rc
| ) |  |

## janus_mqtt_client_connected()

void janus_mqtt_client_connected | ( | void * | context,
|  | char * | cause
| ) |  |

## janus_mqtt_client_connection_lost()

void janus_mqtt_client_connection_lost | ( | void * | context,
|  | char * | cause
| ) |  |

## janus_mqtt_client_destroy_context()

void janus_mqtt_client_destroy_context | ( | janus_mqtt_context ** | ctx | ) |

## janus_mqtt_client_disconnect()

int janus_mqtt_client_disconnect | ( | janus_mqtt_context * | ctx | ) |

## janus_mqtt_client_disconnect_failure()

void janus_mqtt_client_disconnect_failure | ( | void * | context,
|  | MQTTAsync_failureData * | response
| ) |  |

## janus_mqtt_client_disconnect_failure_impl()

void janus_mqtt_client_disconnect_failure_impl | ( | void * | context,
|  | int | rc
| ) |  |

## janus_mqtt_client_disconnect_success()

void janus_mqtt_client_disconnect_success | ( | void * | context,
|  | MQTTAsync_successData * | response
| ) |  |

## janus_mqtt_client_disconnect_success_impl()

void janus_mqtt_client_disconnect_success_impl | ( | void * | context | ) |

## janus_mqtt_client_get_response_code()

int janus_mqtt_client_get_response_code | ( | MQTTAsync_failureData * | response | ) |

## janus_mqtt_client_message_arrived()

int janus_mqtt_client_message_arrived | ( | void * | context,
|  | char * | topicName,
|  | int | topicLen,
|  | MQTTAsync_message * | message
| ) |  |

## janus_mqtt_client_publish_admin_failure()

void janus_mqtt_client_publish_admin_failure | ( | void * | context,
|  | MQTTAsync_failureData * | response
| ) |  |

## janus_mqtt_client_publish_admin_failure_impl()

void janus_mqtt_client_publish_admin_failure_impl | ( | int | rc | ) |

## janus_mqtt_client_publish_admin_success()

void janus_mqtt_client_publish_admin_success | ( | void * | context,
|  | MQTTAsync_successData * | response
| ) |  |

## janus_mqtt_client_publish_admin_success_impl()

void janus_mqtt_client_publish_admin_success_impl | ( | char * | topic | ) |

## janus_mqtt_client_publish_janus_failure()

void janus_mqtt_client_publish_janus_failure | ( | void * | context,
|  | MQTTAsync_failureData * | response
| ) |  |

## janus_mqtt_client_publish_janus_failure_impl()

void janus_mqtt_client_publish_janus_failure_impl | ( | int | rc | ) |

## janus_mqtt_client_publish_janus_success()

void janus_mqtt_client_publish_janus_success | ( | void * | context,
|  | MQTTAsync_successData * | response
| ) |  |

## janus_mqtt_client_publish_janus_success_impl()

void janus_mqtt_client_publish_janus_success_impl | ( | char * | topic | ) |

## janus_mqtt_client_publish_message()

int janus_mqtt_client_publish_message | ( | janus_mqtt_context * | ctx,
|  | char * | payload,
|  | gboolean | admin
| ) |  |

## janus_mqtt_client_publish_status_failure()

void janus_mqtt_client_publish_status_failure | ( | void * | context,
|  | MQTTAsync_failureData * | response
| ) |  |

## janus_mqtt_client_publish_status_failure_impl()

void janus_mqtt_client_publish_status_failure_impl | ( | int | rc | ) |

## janus_mqtt_client_publish_status_message()

int janus_mqtt_client_publish_status_message | ( | janus_mqtt_context * | ctx,
|  | char * | payload
| ) |  |

## janus_mqtt_client_publish_status_success()

void janus_mqtt_client_publish_status_success | ( | void * | context,
|  | MQTTAsync_successData * | response
| ) |  |

## janus_mqtt_client_publish_status_success_impl()

void janus_mqtt_client_publish_status_success_impl | ( | char * | topic | ) |

## janus_mqtt_client_reconnect()

int janus_mqtt_client_reconnect | ( | janus_mqtt_context * | ctx | ) |

## janus_mqtt_client_reconnect_failure()

void janus_mqtt_client_reconnect_failure | ( | void * | context,
|  | MQTTAsync_failureData * | response
| ) |  |

## janus_mqtt_client_reconnect_failure_impl()

void janus_mqtt_client_reconnect_failure_impl | ( | void * | context,
|  | int | rc
| ) |  |

## janus_mqtt_client_reconnect_success()

void janus_mqtt_client_reconnect_success | ( | void * | context,
|  | MQTTAsync_successData * | response
| ) |  |

## janus_mqtt_client_reconnect_success_impl()

void janus_mqtt_client_reconnect_success_impl | ( | void * | context | ) |

## janus_mqtt_client_subscribe()

int janus_mqtt_client_subscribe | ( | janus_mqtt_context * | ctx,
|  | gboolean | admin
| ) |  |

## janus_mqtt_client_subscribe_failure()

void janus_mqtt_client_subscribe_failure | ( | void * | context,
|  | MQTTAsync_failureData * | response
| ) |  |

## janus_mqtt_client_subscribe_failure_impl()

void janus_mqtt_client_subscribe_failure_impl | ( | void * | context,
|  | int | rc
| ) |  |

## janus_mqtt_client_subscribe_success()

void janus_mqtt_client_subscribe_success | ( | void * | context,
|  | MQTTAsync_successData * | response
| ) |  |

## janus_mqtt_client_subscribe_success_impl()

void janus_mqtt_client_subscribe_success_impl | ( | void * | context | ) |

## janus_mqtt_destroy()

void janus_mqtt_destroy | ( | void |  | ) |

## janus_mqtt_get_api_compatibility()

int janus_mqtt_get_api_compatibility | ( | void |  | ) |

## janus_mqtt_get_author()

const char * janus_mqtt_get_author | ( | void |  | ) |

## janus_mqtt_get_description()

const char * janus_mqtt_get_description | ( | void |  | ) |

## janus_mqtt_get_name()

const char * janus_mqtt_get_name | ( | void |  | ) |

## janus_mqtt_get_package()

const char * janus_mqtt_get_package | ( | void |  | ) |

## janus_mqtt_get_version()

int janus_mqtt_get_version | ( | void |  | ) |

## janus_mqtt_get_version_string()

const char * janus_mqtt_get_version_string | ( | void |  | ) |

## janus_mqtt_init()

int janus_mqtt_init | ( | janus_transport_callbacks * | callback,
|  | const char * | config_path
| ) |  |

## janus_mqtt_is_admin_api_enabled()

gboolean janus_mqtt_is_admin_api_enabled | ( | void |  | ) |

## janus_mqtt_is_janus_api_enabled()

gboolean janus_mqtt_is_janus_api_enabled | ( | void |  | ) |

## janus_mqtt_query_transport()

json_t * janus_mqtt_query_transport | ( | json_t * | request | ) |

## janus_mqtt_send_message()

int janus_mqtt_send_message | ( | janus_transport_session * | transport,
|  | void * | request_id,
|  | gboolean | admin,
|  | json_t * | message
| ) |  |

## janus_mqtt_session_claimed()

void janus_mqtt_session_claimed | ( | janus_transport_session * | transport,
|  | guint64 | session_id
| ) |  |

## janus_mqtt_session_created()

void janus_mqtt_session_created | ( | janus_transport_session * | transport,
|  | guint64 | session_id
| ) |  |

## janus_mqtt_session_over()

void janus_mqtt_session_over | ( | janus_transport_session * | transport,
|  | guint64 | session_id,
|  | gboolean | timeout,
|  | gboolean | claimed
| ) |  |