[asterisk-commits] mjordan: branch mjordan/12-hep r405421 - in /team/mjordan/12-hep: include/ast...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jan 14 10:45:14 CST 2014


Author: mjordan
Date: Tue Jan 14 10:45:11 2014
New Revision: 405421

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=405421
Log:
Rename HEPv3 to HEP; add RTCP/PJSIP modules

Added:
    team/mjordan/12-hep/include/asterisk/res_hep.h
      - copied unchanged from r404723, team/mjordan/12-hep/include/asterisk/res_hepv3.h
    team/mjordan/12-hep/res/res_hep.c
      - copied, changed from r404723, team/mjordan/12-hep/res/res_hepv3.c
    team/mjordan/12-hep/res/res_hep.exports.in
      - copied unchanged from r404723, team/mjordan/12-hep/res/res_hepv3.exports.in
    team/mjordan/12-hep/res/res_hep_pjsip.c
      - copied, changed from r404723, team/mjordan/12-hep/res/res_pjsip_hepv3.c
    team/mjordan/12-hep/res/res_hep_rtcp.c   (with props)
Removed:
    team/mjordan/12-hep/include/asterisk/res_hepv3.h
    team/mjordan/12-hep/res/res_hepv3.c
    team/mjordan/12-hep/res/res_hepv3.exports.in
    team/mjordan/12-hep/res/res_pjsip_hepv3.c
Modified:
    team/mjordan/12-hep/res/res_rtp_asterisk.c

Copied: team/mjordan/12-hep/res/res_hep.c (from r404723, team/mjordan/12-hep/res/res_hepv3.c)
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/12-hep/res/res_hep.c?view=diff&rev=405421&p1=team/mjordan/12-hep/res/res_hepv3.c&r1=404723&p2=team/mjordan/12-hep/res/res_hep.c&r2=405421
==============================================================================
--- team/mjordan/12-hep/res/res_hepv3.c (original)
+++ team/mjordan/12-hep/res/res_hep.c Tue Jan 14 10:45:11 2014
@@ -42,7 +42,7 @@
  ***/
 
 /*** DOCUMENTATION
-	<configInfo name="res_hepv3" language="en_US">
+	<configInfo name="res_hep" language="en_US">
 		<synopsis>Resource for integration with Homer using HEPv3</synopsis>
 		<configFile name="hep.conf">
 			<configObject name="general">
@@ -82,7 +82,7 @@
 #include "asterisk/module.h"
 #include "asterisk/astobj2.h"
 #include "asterisk/config_options.h"
-#include "asterisk/res_hepv3.h"
+#include "asterisk/res_hep.h"
 
 #include <netinet/ip.h>
 #include <netinet/tcp.h>
@@ -218,7 +218,7 @@
 	char *data;
 } __attribute__((packed));
 
-/* Structure of HEP */
+/* HEP structures */
 
 struct hep_generic {
 	struct hep_ctrl         header;
@@ -549,5 +549,5 @@
 	.load = load_module,
 	.unload = unload_module,
 	.reload = reload_module,
-	.load_pri = AST_MODPRI_CHANNEL_DEPEND,
+	.load_pri = AST_MODPRI_APP_DEPEND,
 	);

Copied: team/mjordan/12-hep/res/res_hep_pjsip.c (from r404723, team/mjordan/12-hep/res/res_pjsip_hepv3.c)
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/12-hep/res/res_hep_pjsip.c?view=diff&rev=405421&p1=team/mjordan/12-hep/res/res_pjsip_hepv3.c&r1=404723&p2=team/mjordan/12-hep/res/res_hep_pjsip.c&r2=405421
==============================================================================
--- team/mjordan/12-hep/res/res_pjsip_hepv3.c (original)
+++ team/mjordan/12-hep/res/res_hep_pjsip.c Tue Jan 14 10:45:11 2014
@@ -1,8 +1,33 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 1999 - 2013, Digium, Inc.
+ *
+ * Matt Jordan <mjordan at digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*!
+ * \file
+ * \brief PJSIP logging with Homer
+ *
+ * \author Matt Jordan <mjordan at digium.com>
+ *
+ */
 
 /*** MODULEINFO
 	<depend>pjproject</depend>
 	<depend>res_pjsip</depend>
-	<depend>res_hepv3</depend>
+	<depend>res_hep</depend>
 	<defaultenabled>no</defaultenabled>
 	<support_level>extended</support_level>
  ***/
@@ -14,7 +39,7 @@
 #include <pjsip.h>
 
 #include "asterisk/res_pjsip.h"
-#include "asterisk/res_hepv3.h"
+#include "asterisk/res_hep.h"
 #include "asterisk/module.h"
 #include "asterisk/netsock2.h"
 
@@ -88,5 +113,5 @@
 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "PJSIP HEPv3 Logger",
 		.load = load_module,
 		.unload = unload_module,
-		.load_pri = AST_MODPRI_APP_DEPEND,
+		.load_pri = AST_MODPRI_DEFAULT,
 	       );

Added: team/mjordan/12-hep/res/res_hep_rtcp.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/12-hep/res/res_hep_rtcp.c?view=auto&rev=405421
==============================================================================
--- team/mjordan/12-hep/res/res_hep_rtcp.c (added)
+++ team/mjordan/12-hep/res/res_hep_rtcp.c Tue Jan 14 10:45:11 2014
@@ -1,0 +1,137 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 1999 - 2013, Digium, Inc.
+ *
+ * Matt Jordan <mjordan at digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*!
+ * \file
+ * \brief RTCP logging with Homer
+ *
+ * \author Matt Jordan <mjordan at digium.com>
+ *
+ */
+
+/*** MODULEINFO
+	<depend>res_hep</depend>
+	<defaultenabled>no</defaultenabled>
+	<support_level>extended</support_level>
+ ***/
+
+#include "asterisk.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+
+#include <pjsip.h>
+
+#include "asterisk/res_hep.h"
+#include "asterisk/module.h"
+#include "asterisk/netsock2.h"
+#include "asterisk/stasis.h"
+#include "asterisk/rtp_engine.h"
+#include "asterisk/json.h"
+#include "asterisk/config.h"
+
+static struct stasis_subscription *stasis_rtp_subscription;
+
+static void rtcp_message_handler(struct stasis_message *message)
+{
+
+	RAII_VAR(struct ast_json *, json_payload, NULL, ast_json_unref);
+	struct ast_json *json_blob;
+	struct ast_json *json_channel;
+	struct ast_json *json_rtcp;
+	struct hepv3_capture_info capture_info;
+	struct ast_json *from;
+	struct ast_json *to;
+	struct timeval current_time = ast_tvnow();
+	const char *payload;
+
+	json_payload = stasis_message_to_json(message, NULL);
+	if (!json_payload) {
+		return;
+	}
+
+	json_blob = ast_json_object_get(json_payload, "blob");
+	if (!json_blob) {
+		return;
+	}
+
+	json_channel = ast_json_object_get(json_payload, "channel");
+	if (!json_channel) {
+		return;
+	}
+
+	json_rtcp = ast_json_object_get(json_payload, "rtcp_report");
+	if (!json_rtcp) {
+		return;
+	}
+
+	from = ast_json_object_get(json_blob, "from");
+	to = ast_json_object_get(json_blob, "to");
+	if (!from || !to) {
+		return;
+	}
+
+	ast_sockaddr_parse(&capture_info.src_addr, ast_json_string_get(from), PARSE_PORT_REQUIRE);
+	ast_sockaddr_parse(&capture_info.dst_addr, ast_json_string_get(to), PARSE_PORT_REQUIRE);
+
+	capture_info.uuid = ast_strdupa(ast_json_string_get(ast_json_object_get(json_channel, "name")));
+	capture_info.capture_time.tv_sec = current_time.tv_sec;
+	capture_info.capture_time.tv_usec = current_time.tv_usec;
+	capture_info.capture_type = hepv3_capture_type_rtcp;
+	capture_info.zipped = 0;
+
+	payload = ast_json_string_get(json_rtcp);
+
+	hepv3_send_packet(&capture_info, &payload, strlen(payload));
+}
+
+static void rtp_topic_handler(void *data, struct stasis_subscription *sub, struct stasis_message *message)
+{
+	struct stasis_message_type *message_type = stasis_message_type(message);
+
+	if ((message_type == ast_rtp_rtcp_sent_type()) ||
+		(message_type == ast_rtp_rtcp_received_type())) {
+		rtcp_message_handler(message);
+	}
+}
+
+static int load_module(void)
+{
+
+	stasis_rtp_subscription = stasis_subscribe(ast_rtp_topic(),
+		rtp_topic_handler, NULL);
+	if (!stasis_rtp_subscription) {
+		return AST_MODULE_LOAD_FAILURE;
+	}
+
+	return AST_MODULE_LOAD_SUCCESS;
+}
+
+static int unload_module(void)
+{
+	if (stasis_rtp_subscription) {
+		stasis_rtp_subscription = stasis_unsubscribe(stasis_rtp_subscription);
+	}
+
+	return 0;
+}
+
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "RTCP HEPv3 Logger",
+		.load = load_module,
+		.unload = unload_module,
+		.load_pri = AST_MODPRI_DEFAULT,
+	       );

Propchange: team/mjordan/12-hep/res/res_hep_rtcp.c
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/mjordan/12-hep/res/res_hep_rtcp.c
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/mjordan/12-hep/res/res_hep_rtcp.c
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: team/mjordan/12-hep/res/res_rtp_asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/12-hep/res/res_rtp_asterisk.c?view=diff&rev=405421&r1=405420&r2=405421
==============================================================================
--- team/mjordan/12-hep/res/res_rtp_asterisk.c (original)
+++ team/mjordan/12-hep/res/res_rtp_asterisk.c Tue Jan 14 10:45:11 2014
@@ -2294,6 +2294,7 @@
 	int ice;
 	int header_offset = 0;
 	struct ast_sockaddr remote_address = { {0,} };
+	struct ast_sockaddr local_address = { {0,} };
 	struct ast_rtp_rtcp_report_block *report_block;
 	RAII_VAR(struct ast_rtp_rtcp_report *, rtcp_report,
 			ast_rtp_rtcp_report_alloc(1),
@@ -2414,8 +2415,10 @@
 		ast_verbose("    DLSR: %4.4f (sec)\n\n", (double)(report_block->dlsr / 65536.0));
 	}
 
-	message_blob = ast_json_pack("{s: s}",
-			"to", ast_sockaddr_stringify(&remote_address));
+	ast_rtp_instance_get_local_address(instance, &local_address);
+	message_blob = ast_json_pack("{s: s, s: s}",
+			"to", ast_sockaddr_stringify(&remote_address),
+			"from", ast_sockaddr_stringify(&local_address));
 	ast_rtp_publish_rtcp_message(instance, ast_rtp_rtcp_sent_type(),
 			rtcp_report,
 			message_blob);
@@ -3237,6 +3240,7 @@
 	int report_counter = 0;
 	struct ast_rtp_rtcp_report_block *report_block;
 	struct ast_frame *f = &ast_null_frame;
+	struct ast_sockaddr local_address = { {0,} };
 
 	/* Read in RTCP data from the socket */
 	if ((res = rtcp_recvfrom(instance, rtcpdata + AST_FRIENDLY_OFFSET,
@@ -3292,6 +3296,8 @@
 	}
 
 	ast_debug(1, "Got RTCP report of %d bytes\n", res);
+
+	ast_rtp_instance_get_local_address(instance, &local_address);
 
 	while (position < packetwords) {
 		int i, pt, rc;
@@ -3415,8 +3421,9 @@
 			/* If and when we handle more than one report block, this should occur outside
 			 * this loop.
 			 */
-			message_blob = ast_json_pack("{s: s, s: f}",
+			message_blob = ast_json_pack("{s: s, s: s, s: f}",
 					"from", ast_sockaddr_stringify(&addr),
+					"to", ast_sockaddr_stringify(&local_address),
 					"rtt", rtp->rtcp->rtt);
 			ast_rtp_publish_rtcp_message(instance, ast_rtp_rtcp_received_type(),
 					rtcp_report,




More information about the asterisk-commits mailing list