Last active
January 22, 2018 14:36
-
-
Save nus/0cc2e8d197d4e0832591cf609528ffeb to your computer and use it in GitHub Desktop.
Janus で、Hogeプラグインを書くためのパッチ。d01b9ade585b11549a073672bc4b602cb80b6404 時点。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Makefile.am b/Makefile.am | |
index e477788..e050ed0 100644 | |
--- a/Makefile.am | |
+++ b/Makefile.am | |
@@ -429,6 +429,16 @@ conf_DATA += conf/janus.plugin.textroom.cfg.sample | |
EXTRA_DIST += conf/janus.plugin.textroom.cfg.sample | |
endif | |
+if ENABLE_PLUGIN_HOGE | |
+plugin_LTLIBRARIES += plugins/libjanus_hoge.la | |
+plugins_libjanus_hoge_la_SOURCES = plugins/janus_hoge.c | |
+plugins_libjanus_hoge_la_CFLAGS = $(plugins_cflags) | |
+plugins_libjanus_hoge_la_LDFLAGS = $(plugins_ldflags) | |
+plugins_libjanus_hoge_la_LIBADD = $(plugins_libadd) | |
+conf_DATA += conf/janus.plugin.textroom.cfg.sample | |
+EXTRA_DIST += conf/janus.plugin.textroom.cfg.sample | |
+endif | |
+ | |
## | |
# Post-processing | |
## | |
diff --git a/configure.ac b/configure.ac | |
index c78b888..3fd9f33 100644 | |
--- a/configure.ac | |
+++ b/configure.ac | |
@@ -108,6 +108,8 @@ AC_ARG_ENABLE([all-plugins], | |
[enable_plugin_videoroom=no]) | |
AS_IF([test "x$enable_plugin_voicemail" != "xyes"], | |
[enable_plugin_voicemail=no]) | |
+ AS_IF([test "x$enable_plugin_hoge" != "xyes"], | |
+ [enable_plugin_hoge=no]) | |
], | |
[]) | |
@@ -551,6 +553,12 @@ AC_ARG_ENABLE([plugin-voicemail], | |
[AS_IF([test "x$enable_plugin_voicemail" != "xyes"], | |
[enable_plugin_voicemail=no])], | |
[enable_plugin_voicemail=maybe]) | |
+AC_ARG_ENABLE([plugin-hoge], | |
+ [AS_HELP_STRING([--disable-plugin-hoge], | |
+ [Disable hoge plugin])], | |
+ [AS_IF([test "x$enable_plugin_hoge" != "xyes"], | |
+ [enable_plugin_hoge=no])], | |
+ [enable_plugin_hoge=yes]) | |
PKG_CHECK_MODULES([SOFIA], | |
[sofia-sip-ua], | |
@@ -622,6 +630,7 @@ AM_CONDITIONAL([ENABLE_PLUGIN_VIDEOCALL], [test "x$enable_plugin_videocall" = "x | |
AM_CONDITIONAL([ENABLE_PLUGIN_VIDEOROOM], [test "x$enable_plugin_videoroom" = "xyes"]) | |
AM_CONDITIONAL([ENABLE_PLUGIN_VOICEMAIL], [test "x$enable_plugin_voicemail" = "xyes"]) | |
AM_CONDITIONAL([ENABLE_PLUGIN_TEXTROOM], [test "x$enable_plugin_textroom" = "xyes"]) | |
+AM_CONDITIONAL([ENABLE_PLUGIN_HOGE], [test "x$enable_plugin_hoge" = "xyes"]) | |
## | |
@@ -803,6 +812,9 @@ AM_COND_IF([ENABLE_PLUGIN_RECORDPLAY], | |
AM_COND_IF([ENABLE_PLUGIN_TEXTROOM], | |
[echo " Text Room: yes"], | |
[echo " Text Room: no"]) | |
+AM_COND_IF([ENABLE_PLUGIN_HOGE], | |
+ [echo " Hoge: yes"], | |
+ [echo " Hoge: no"]) | |
echo "Event handlers:" | |
AM_COND_IF([ENABLE_SAMPLEEVH], | |
[echo " Sample event handler: yes"], | |
diff --git a/plugins/janus_hoge.c b/plugins/janus_hoge.c | |
new file mode 100644 | |
index 0000000..86c6881 | |
--- /dev/null | |
+++ b/plugins/janus_hoge.c | |
@@ -0,0 +1,149 @@ | |
+/*! \file janus_hoge.c | |
+ * \author Yota Ichino | |
+ * \copyright GNU General Public License v3 | |
+ * \brief Janus Hoge plugin | |
+ */ | |
+#include "plugin.h" | |
+ | |
+#include <jansson.h> | |
+ | |
+#include "../debug.h" | |
+ | |
+ | |
+/* Plugin information */ | |
+#define JANUS_HOGE_VERSION 1 | |
+#define JANUS_HOGE_VERSION_STRING "0.0.1" | |
+#define JANUS_HOGE_DESCRIPTION "This is a trivial Hoge plugin for Janus, just used to showcase the plugin interface." | |
+#define JANUS_HOGE_NAME "JANUS Hoge plugin" | |
+#define JANUS_HOGE_AUTHOR "Yota Ichino" | |
+#define JANUS_HOGE_PACKAGE "janus.plugin.hoge" | |
+ | |
+/* Plugin methods */ | |
+janus_plugin *create(void); | |
+int janus_hoge_init(janus_callbacks *callback, const char *config_path); | |
+void janus_hoge_destroy(void); | |
+int janus_hoge_get_api_compatibility(void); | |
+int janus_hoge_get_version(void); | |
+const char *janus_hoge_get_version_string(void); | |
+const char *janus_hoge_get_description(void); | |
+const char *janus_hoge_get_name(void); | |
+const char *janus_hoge_get_author(void); | |
+const char *janus_hoge_get_package(void); | |
+void janus_hoge_create_session(janus_plugin_session *handle, int *error); | |
+struct janus_plugin_result *janus_hoge_handle_message(janus_plugin_session *handle, char *transaction, json_t *message, json_t *jsep); | |
+void janus_hoge_setup_media(janus_plugin_session *handle); | |
+void janus_hoge_incoming_rtp(janus_plugin_session *handle, int video, char *buf, int len); | |
+void janus_hoge_incoming_rtcp(janus_plugin_session *handle, int video, char *buf, int len); | |
+void janus_hoge_incoming_data(janus_plugin_session *handle, char *buf, int len); | |
+void janus_hoge_slow_link(janus_plugin_session *handle, int uplink, int video); | |
+void janus_hoge_hangup_media(janus_plugin_session *handle); | |
+void janus_hoge_destroy_session(janus_plugin_session *handle, int *error); | |
+json_t *janus_hoge_query_session(janus_plugin_session *handle); | |
+ | |
+/* Plugin setup */ | |
+static janus_plugin janus_hoge_plugin = | |
+ JANUS_PLUGIN_INIT ( | |
+ .init = janus_hoge_init, | |
+ .destroy = janus_hoge_destroy, | |
+ | |
+ .get_api_compatibility = janus_hoge_get_api_compatibility, | |
+ .get_version = janus_hoge_get_version, | |
+ .get_version_string = janus_hoge_get_version_string, | |
+ .get_description = janus_hoge_get_description, | |
+ .get_name = janus_hoge_get_name, | |
+ .get_author = janus_hoge_get_author, | |
+ .get_package = janus_hoge_get_package, | |
+ | |
+ .create_session = janus_hoge_create_session, | |
+ .handle_message = janus_hoge_handle_message, | |
+ .setup_media = janus_hoge_setup_media, | |
+ .incoming_rtp = janus_hoge_incoming_rtp, | |
+ .incoming_rtcp = janus_hoge_incoming_rtcp, | |
+ .incoming_data = janus_hoge_incoming_data, | |
+ .slow_link = janus_hoge_slow_link, | |
+ .hangup_media = janus_hoge_hangup_media, | |
+ .destroy_session = janus_hoge_destroy_session, | |
+ .query_session = janus_hoge_query_session, | |
+ ); | |
+ | |
+/* Plugin creator */ | |
+janus_plugin *create(void) { | |
+ JANUS_LOG(LOG_VERB, "%s created!\n", JANUS_HOGE_NAME); | |
+ return &janus_hoge_plugin; | |
+} | |
+ | |
+ | |
+/* Plugin implementation */ | |
+int janus_hoge_init(janus_callbacks *callback, const char *config_path) { | |
+ JANUS_LOG(LOG_INFO, "%s initialized!\n", JANUS_HOGE_NAME); | |
+ return 0; | |
+} | |
+ | |
+void janus_hoge_destroy(void) { | |
+ JANUS_LOG(LOG_INFO, "%s destroyed!\n", JANUS_HOGE_NAME); | |
+} | |
+ | |
+int janus_hoge_get_api_compatibility(void) { | |
+ /* Important! This is what your plugin MUST always return: don't lie here or bad things will happen */ | |
+ return JANUS_PLUGIN_API_VERSION; | |
+} | |
+ | |
+int janus_hoge_get_version(void) { | |
+ return JANUS_HOGE_VERSION; | |
+} | |
+ | |
+const char *janus_hoge_get_version_string(void) { | |
+ return JANUS_HOGE_VERSION_STRING; | |
+} | |
+ | |
+const char *janus_hoge_get_description(void) { | |
+ return JANUS_HOGE_DESCRIPTION; | |
+} | |
+ | |
+const char *janus_hoge_get_name(void) { | |
+ return JANUS_HOGE_NAME; | |
+} | |
+ | |
+const char *janus_hoge_get_author(void) { | |
+ return JANUS_HOGE_AUTHOR; | |
+} | |
+ | |
+const char *janus_hoge_get_package(void) { | |
+ return JANUS_HOGE_PACKAGE; | |
+} | |
+ | |
+void janus_hoge_create_session(janus_plugin_session *handle, int *error) { | |
+ return; | |
+} | |
+ | |
+void janus_hoge_destroy_session(janus_plugin_session *handle, int *error) { | |
+ return; | |
+} | |
+ | |
+json_t *janus_hoge_query_session(janus_plugin_session *handle) { | |
+ json_t *info = json_object(); | |
+ return info; | |
+} | |
+ | |
+struct janus_plugin_result *janus_hoge_handle_message(janus_plugin_session *handle, char *transaction, json_t *message, json_t *jsep) { | |
+ return janus_plugin_result_new(JANUS_PLUGIN_OK_WAIT, "I'm taking my time!", NULL); | |
+} | |
+ | |
+void janus_hoge_setup_media(janus_plugin_session *handle) { | |
+ JANUS_LOG(LOG_INFO, "WebRTC media is now available\n"); | |
+} | |
+ | |
+void janus_hoge_incoming_rtp(janus_plugin_session *handle, int video, char *buf, int len) { | |
+} | |
+ | |
+void janus_hoge_incoming_rtcp(janus_plugin_session *handle, int video, char *buf, int len) { | |
+} | |
+ | |
+void janus_hoge_incoming_data(janus_plugin_session *handle, char *buf, int len) { | |
+} | |
+ | |
+void janus_hoge_slow_link(janus_plugin_session *handle, int uplink, int video) { | |
+} | |
+ | |
+void janus_hoge_hangup_media(janus_plugin_session *handle) { | |
+} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment