[asterisk-commits] kmoore: branch group/bridge_construction r388670 - in /team/group/bridge_cons...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue May 14 08:03:41 CDT 2013


Author: kmoore
Date: Tue May 14 08:03:38 2013
New Revision: 388670

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=388670
Log:
Move JSON event generators into separate modules

This moves the JSON event generators out of the Stasis-HTTP modules and
into standalone JSON-related counterparts so that Stasis-HTTP and
res_stasis can depend on them without creating dependency cycles. This
also provides a future location for Swagger Model validator functions
once the generators for that code are written.

Review: https://reviewboard.asterisk.org/r/2534/
........

Merged revisions 388668 from http://svn.asterisk.org/svn/asterisk/trunk

Added:
    team/group/bridge_construction/res/res_stasis_json_asterisk.c
      - copied unchanged from r388668, trunk/res/res_stasis_json_asterisk.c
    team/group/bridge_construction/res/res_stasis_json_asterisk.exports.in
      - copied unchanged from r388668, trunk/res/res_stasis_json_asterisk.exports.in
    team/group/bridge_construction/res/res_stasis_json_bridges.c
      - copied unchanged from r388668, trunk/res/res_stasis_json_bridges.c
    team/group/bridge_construction/res/res_stasis_json_bridges.exports.in
      - copied unchanged from r388668, trunk/res/res_stasis_json_bridges.exports.in
    team/group/bridge_construction/res/res_stasis_json_channels.c
      - copied unchanged from r388668, trunk/res/res_stasis_json_channels.c
    team/group/bridge_construction/res/res_stasis_json_channels.exports.in
      - copied unchanged from r388668, trunk/res/res_stasis_json_channels.exports.in
    team/group/bridge_construction/res/res_stasis_json_endpoints.c
      - copied unchanged from r388668, trunk/res/res_stasis_json_endpoints.c
    team/group/bridge_construction/res/res_stasis_json_endpoints.exports.in
      - copied unchanged from r388668, trunk/res/res_stasis_json_endpoints.exports.in
    team/group/bridge_construction/res/res_stasis_json_events.c
      - copied, changed from r388668, trunk/res/res_stasis_json_events.c
    team/group/bridge_construction/res/res_stasis_json_events.exports.in
      - copied, changed from r388668, trunk/res/res_stasis_json_events.exports.in
    team/group/bridge_construction/res/res_stasis_json_playback.c
      - copied unchanged from r388668, trunk/res/res_stasis_json_playback.c
    team/group/bridge_construction/res/res_stasis_json_playback.exports.in
      - copied unchanged from r388668, trunk/res/res_stasis_json_playback.exports.in
    team/group/bridge_construction/res/res_stasis_json_recordings.c
      - copied unchanged from r388668, trunk/res/res_stasis_json_recordings.c
    team/group/bridge_construction/res/res_stasis_json_recordings.exports.in
      - copied unchanged from r388668, trunk/res/res_stasis_json_recordings.exports.in
    team/group/bridge_construction/res/res_stasis_json_sounds.c
      - copied unchanged from r388668, trunk/res/res_stasis_json_sounds.c
    team/group/bridge_construction/res/res_stasis_json_sounds.exports.in
      - copied unchanged from r388668, trunk/res/res_stasis_json_sounds.exports.in
    team/group/bridge_construction/res/stasis_json/
      - copied from r388668, trunk/res/stasis_json/
    team/group/bridge_construction/rest-api-templates/res_stasis_json_resource.c.mustache
      - copied, changed from r388668, trunk/rest-api-templates/res_stasis_json_resource.c.mustache
    team/group/bridge_construction/rest-api-templates/res_stasis_json_resource.exports.mustache
      - copied unchanged from r388668, trunk/rest-api-templates/res_stasis_json_resource.exports.mustache
    team/group/bridge_construction/rest-api-templates/stasis_json_resource.h.mustache
      - copied, changed from r388668, trunk/rest-api-templates/stasis_json_resource.h.mustache
Modified:
    team/group/bridge_construction/   (props changed)
    team/group/bridge_construction/res/res_stasis.c
    team/group/bridge_construction/res/res_stasis_http_events.c
    team/group/bridge_construction/res/stasis_http/resource_asterisk.h
    team/group/bridge_construction/res/stasis_http/resource_bridges.h
    team/group/bridge_construction/res/stasis_http/resource_channels.h
    team/group/bridge_construction/res/stasis_http/resource_endpoints.h
    team/group/bridge_construction/res/stasis_http/resource_events.h
    team/group/bridge_construction/res/stasis_http/resource_playback.h
    team/group/bridge_construction/res/stasis_http/resource_recordings.h
    team/group/bridge_construction/res/stasis_http/resource_sounds.h
    team/group/bridge_construction/res/stasis_json/resource_events.h
    team/group/bridge_construction/rest-api-templates/make_stasis_http_stubs.py
    team/group/bridge_construction/rest-api-templates/res_stasis_http_resource.c.mustache
    team/group/bridge_construction/rest-api-templates/stasis_http_resource.h.mustache
    team/group/bridge_construction/tests/test_res_stasis.c

Propchange: team/group/bridge_construction/
------------------------------------------------------------------------------
--- bridge_construction-integrated (original)
+++ bridge_construction-integrated Tue May 14 08:03:38 2013
@@ -1,1 +1,1 @@
-/trunk:1-388652
+/trunk:1-388669

Modified: team/group/bridge_construction/res/res_stasis.c
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/res/res_stasis.c?view=diff&rev=388670&r1=388669&r2=388670
==============================================================================
--- team/group/bridge_construction/res/res_stasis.c (original)
+++ team/group/bridge_construction/res/res_stasis.c Tue May 14 08:03:38 2013
@@ -24,6 +24,7 @@
  */
 
 /*** MODULEINFO
+	<depend>res_stasis_json_events</depend>
 	<support_level>core</support_level>
  ***/
 
@@ -41,7 +42,7 @@
 #include "asterisk/strings.h"
 #include "asterisk/stasis_message_router.h"
 #include "asterisk/callerid.h"
-#include "stasis_http/resource_events.h"
+#include "stasis_json/resource_events.h"
 
 /*! Time to wait for a frame in the application */
 #define MAX_WAIT_MS 200

Modified: team/group/bridge_construction/res/res_stasis_http_events.c
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/res/res_stasis_http_events.c?view=diff&rev=388670&r1=388669&r2=388670
==============================================================================
--- team/group/bridge_construction/res/res_stasis_http_events.c (original)
+++ team/group/bridge_construction/res/res_stasis_http_events.c Tue May 14 08:03:38 2013
@@ -44,8 +44,6 @@
 #include "asterisk/module.h"
 #include "asterisk/stasis_app.h"
 #include "stasis_http/resource_events.h"
-#include "asterisk/stasis_channels.h"
-#include "asterisk/stasis_bridging.h"
 
 /*!
  * \brief Parameter parsing callback for /events.
@@ -80,656 +78,6 @@
 	.children = {  }
 };
 
-struct ast_json *stasis_json_event_channel_userevent_create(
-	struct ast_channel_snapshot *channel_snapshot,
-	struct ast_json *blob
-	)
-{
-	RAII_VAR(struct ast_json *, message, NULL, ast_json_unref);
-	RAII_VAR(struct ast_json *, event, NULL, ast_json_unref);
-	struct ast_json *validator;
-	int ret;
-
-	ast_assert(channel_snapshot != NULL);
-	ast_assert(blob != NULL);
-	ast_assert(ast_json_object_get(blob, "channel") == NULL);
-	ast_assert(ast_json_object_get(blob, "type") == NULL);
-
-	validator = ast_json_object_get(blob, "eventname");
-	if (validator) {
-		/* do validation? XXX */
-	} else {
-		/* fail message generation if the required parameter doesn't exist */
-		return NULL;
-	}
-
-	event = ast_json_deep_copy(blob);
-	if (!event) {
-		return NULL;
-	}
-
-	ret = ast_json_object_set(event,
-		"channel", ast_channel_snapshot_to_json(channel_snapshot));
-	if (ret) {
-		return NULL;
-	}
-
-	message = ast_json_pack("{s: o}", "channel_userevent", ast_json_ref(event));
-	if (!message) {
-		return NULL;
-	}
-
-	return ast_json_ref(message);
-}
-
-struct ast_json *stasis_json_event_bridge_created_create(
-	struct ast_bridge_snapshot *bridge_snapshot
-	)
-{
-	RAII_VAR(struct ast_json *, message, NULL, ast_json_unref);
-	RAII_VAR(struct ast_json *, event, NULL, ast_json_unref);
-	int ret;
-
-	ast_assert(bridge_snapshot != NULL);
-
-	event = ast_json_object_create();
-	if (!event) {
-		return NULL;
-	}
-
-	ret = ast_json_object_set(event,
-		"bridge", ast_bridge_snapshot_to_json(bridge_snapshot));
-	if (ret) {
-		return NULL;
-	}
-
-	message = ast_json_pack("{s: o}", "bridge_created", ast_json_ref(event));
-	if (!message) {
-		return NULL;
-	}
-
-	return ast_json_ref(message);
-}
-
-struct ast_json *stasis_json_event_channel_destroyed_create(
-	struct ast_channel_snapshot *channel_snapshot,
-	struct ast_json *blob
-	)
-{
-	RAII_VAR(struct ast_json *, message, NULL, ast_json_unref);
-	RAII_VAR(struct ast_json *, event, NULL, ast_json_unref);
-	struct ast_json *validator;
-	int ret;
-
-	ast_assert(channel_snapshot != NULL);
-	ast_assert(blob != NULL);
-	ast_assert(ast_json_object_get(blob, "channel") == NULL);
-	ast_assert(ast_json_object_get(blob, "type") == NULL);
-
-	validator = ast_json_object_get(blob, "cause");
-	if (validator) {
-		/* do validation? XXX */
-	} else {
-		/* fail message generation if the required parameter doesn't exist */
-		return NULL;
-	}
-
-	validator = ast_json_object_get(blob, "cause_txt");
-	if (validator) {
-		/* do validation? XXX */
-	} else {
-		/* fail message generation if the required parameter doesn't exist */
-		return NULL;
-	}
-
-	event = ast_json_deep_copy(blob);
-	if (!event) {
-		return NULL;
-	}
-
-	ret = ast_json_object_set(event,
-		"channel", ast_channel_snapshot_to_json(channel_snapshot));
-	if (ret) {
-		return NULL;
-	}
-
-	message = ast_json_pack("{s: o}", "channel_destroyed", ast_json_ref(event));
-	if (!message) {
-		return NULL;
-	}
-
-	return ast_json_ref(message);
-}
-
-struct ast_json *stasis_json_event_channel_snapshot_create(
-	struct ast_channel_snapshot *channel_snapshot
-	)
-{
-	RAII_VAR(struct ast_json *, message, NULL, ast_json_unref);
-	RAII_VAR(struct ast_json *, event, NULL, ast_json_unref);
-	int ret;
-
-	ast_assert(channel_snapshot != NULL);
-
-	event = ast_json_object_create();
-	if (!event) {
-		return NULL;
-	}
-
-	ret = ast_json_object_set(event,
-		"channel", ast_channel_snapshot_to_json(channel_snapshot));
-	if (ret) {
-		return NULL;
-	}
-
-	message = ast_json_pack("{s: o}", "channel_snapshot", ast_json_ref(event));
-	if (!message) {
-		return NULL;
-	}
-
-	return ast_json_ref(message);
-}
-
-struct ast_json *stasis_json_event_channel_caller_id_create(
-	struct ast_channel_snapshot *channel_snapshot,
-	struct ast_json *blob
-	)
-{
-	RAII_VAR(struct ast_json *, message, NULL, ast_json_unref);
-	RAII_VAR(struct ast_json *, event, NULL, ast_json_unref);
-	struct ast_json *validator;
-	int ret;
-
-	ast_assert(channel_snapshot != NULL);
-	ast_assert(blob != NULL);
-	ast_assert(ast_json_object_get(blob, "channel") == NULL);
-	ast_assert(ast_json_object_get(blob, "type") == NULL);
-
-	validator = ast_json_object_get(blob, "caller_presentation_txt");
-	if (validator) {
-		/* do validation? XXX */
-	} else {
-		/* fail message generation if the required parameter doesn't exist */
-		return NULL;
-	}
-
-	validator = ast_json_object_get(blob, "caller_presentation");
-	if (validator) {
-		/* do validation? XXX */
-	} else {
-		/* fail message generation if the required parameter doesn't exist */
-		return NULL;
-	}
-
-	event = ast_json_deep_copy(blob);
-	if (!event) {
-		return NULL;
-	}
-
-	ret = ast_json_object_set(event,
-		"channel", ast_channel_snapshot_to_json(channel_snapshot));
-	if (ret) {
-		return NULL;
-	}
-
-	message = ast_json_pack("{s: o}", "channel_caller_id", ast_json_ref(event));
-	if (!message) {
-		return NULL;
-	}
-
-	return ast_json_ref(message);
-}
-
-struct ast_json *stasis_json_event_channel_hangup_request_create(
-	struct ast_channel_snapshot *channel_snapshot,
-	struct ast_json *blob
-	)
-{
-	RAII_VAR(struct ast_json *, message, NULL, ast_json_unref);
-	RAII_VAR(struct ast_json *, event, NULL, ast_json_unref);
-	struct ast_json *validator;
-	int ret;
-
-	ast_assert(channel_snapshot != NULL);
-	ast_assert(blob != NULL);
-	ast_assert(ast_json_object_get(blob, "channel") == NULL);
-	ast_assert(ast_json_object_get(blob, "type") == NULL);
-
-	validator = ast_json_object_get(blob, "soft");
-	if (validator) {
-		/* do validation? XXX */
-	}
-
-	validator = ast_json_object_get(blob, "cause");
-	if (validator) {
-		/* do validation? XXX */
-	}
-
-	event = ast_json_deep_copy(blob);
-	if (!event) {
-		return NULL;
-	}
-
-	ret = ast_json_object_set(event,
-		"channel", ast_channel_snapshot_to_json(channel_snapshot));
-	if (ret) {
-		return NULL;
-	}
-
-	message = ast_json_pack("{s: o}", "channel_hangup_request", ast_json_ref(event));
-	if (!message) {
-		return NULL;
-	}
-
-	return ast_json_ref(message);
-}
-
-struct ast_json *stasis_json_event_bridge_destroyed_create(
-	struct ast_bridge_snapshot *bridge_snapshot
-	)
-{
-	RAII_VAR(struct ast_json *, message, NULL, ast_json_unref);
-	RAII_VAR(struct ast_json *, event, NULL, ast_json_unref);
-	int ret;
-
-	ast_assert(bridge_snapshot != NULL);
-
-	event = ast_json_object_create();
-	if (!event) {
-		return NULL;
-	}
-
-	ret = ast_json_object_set(event,
-		"bridge", ast_bridge_snapshot_to_json(bridge_snapshot));
-	if (ret) {
-		return NULL;
-	}
-
-	message = ast_json_pack("{s: o}", "bridge_destroyed", ast_json_ref(event));
-	if (!message) {
-		return NULL;
-	}
-
-	return ast_json_ref(message);
-}
-
-struct ast_json *stasis_json_event_application_replaced_create(
-	struct ast_json *blob
-	)
-{
-	RAII_VAR(struct ast_json *, message, NULL, ast_json_unref);
-	RAII_VAR(struct ast_json *, event, NULL, ast_json_unref);
-	struct ast_json *validator;
-
-	ast_assert(blob != NULL);
-	ast_assert(ast_json_object_get(blob, "type") == NULL);
-
-	validator = ast_json_object_get(blob, "application");
-	if (validator) {
-		/* do validation? XXX */
-	} else {
-		/* fail message generation if the required parameter doesn't exist */
-		return NULL;
-	}
-
-	event = ast_json_deep_copy(blob);
-	if (!event) {
-		return NULL;
-	}
-
-	message = ast_json_pack("{s: o}", "application_replaced", ast_json_ref(event));
-	if (!message) {
-		return NULL;
-	}
-
-	return ast_json_ref(message);
-}
-
-struct ast_json *stasis_json_event_channel_varset_create(
-	struct ast_channel_snapshot *channel_snapshot,
-	struct ast_json *blob
-	)
-{
-	RAII_VAR(struct ast_json *, message, NULL, ast_json_unref);
-	RAII_VAR(struct ast_json *, event, NULL, ast_json_unref);
-	struct ast_json *validator;
-	int ret;
-
-	ast_assert(channel_snapshot != NULL);
-	ast_assert(blob != NULL);
-	ast_assert(ast_json_object_get(blob, "channel") == NULL);
-	ast_assert(ast_json_object_get(blob, "type") == NULL);
-
-	validator = ast_json_object_get(blob, "variable");
-	if (validator) {
-		/* do validation? XXX */
-	} else {
-		/* fail message generation if the required parameter doesn't exist */
-		return NULL;
-	}
-
-	validator = ast_json_object_get(blob, "value");
-	if (validator) {
-		/* do validation? XXX */
-	} else {
-		/* fail message generation if the required parameter doesn't exist */
-		return NULL;
-	}
-
-	event = ast_json_deep_copy(blob);
-	if (!event) {
-		return NULL;
-	}
-
-	ret = ast_json_object_set(event,
-		"channel", ast_channel_snapshot_to_json(channel_snapshot));
-	if (ret) {
-		return NULL;
-	}
-
-	message = ast_json_pack("{s: o}", "channel_varset", ast_json_ref(event));
-	if (!message) {
-		return NULL;
-	}
-
-	return ast_json_ref(message);
-}
-
-struct ast_json *stasis_json_event_channel_left_bridge_create(
-	struct ast_bridge_snapshot *bridge_snapshot,
-	struct ast_channel_snapshot *channel_snapshot
-	)
-{
-	RAII_VAR(struct ast_json *, message, NULL, ast_json_unref);
-	RAII_VAR(struct ast_json *, event, NULL, ast_json_unref);
-	int ret;
-
-	ast_assert(channel_snapshot != NULL);
-	ast_assert(bridge_snapshot != NULL);
-
-	event = ast_json_object_create();
-	if (!event) {
-		return NULL;
-	}
-
-	ret = ast_json_object_set(event,
-		"channel", ast_channel_snapshot_to_json(channel_snapshot));
-	if (ret) {
-		return NULL;
-	}
-
-	ret = ast_json_object_set(event,
-		"bridge", ast_bridge_snapshot_to_json(bridge_snapshot));
-	if (ret) {
-		return NULL;
-	}
-
-	message = ast_json_pack("{s: o}", "channel_left_bridge", ast_json_ref(event));
-	if (!message) {
-		return NULL;
-	}
-
-	return ast_json_ref(message);
-}
-
-struct ast_json *stasis_json_event_channel_created_create(
-	struct ast_channel_snapshot *channel_snapshot
-	)
-{
-	RAII_VAR(struct ast_json *, message, NULL, ast_json_unref);
-	RAII_VAR(struct ast_json *, event, NULL, ast_json_unref);
-	int ret;
-
-	ast_assert(channel_snapshot != NULL);
-
-	event = ast_json_object_create();
-	if (!event) {
-		return NULL;
-	}
-
-	ret = ast_json_object_set(event,
-		"channel", ast_channel_snapshot_to_json(channel_snapshot));
-	if (ret) {
-		return NULL;
-	}
-
-	message = ast_json_pack("{s: o}", "channel_created", ast_json_ref(event));
-	if (!message) {
-		return NULL;
-	}
-
-	return ast_json_ref(message);
-}
-
-struct ast_json *stasis_json_event_stasis_start_create(
-	struct ast_channel_snapshot *channel_snapshot,
-	struct ast_json *blob
-	)
-{
-	RAII_VAR(struct ast_json *, message, NULL, ast_json_unref);
-	RAII_VAR(struct ast_json *, event, NULL, ast_json_unref);
-	struct ast_json *validator;
-	int ret;
-
-	ast_assert(channel_snapshot != NULL);
-	ast_assert(blob != NULL);
-	ast_assert(ast_json_object_get(blob, "channel") == NULL);
-	ast_assert(ast_json_object_get(blob, "type") == NULL);
-
-	validator = ast_json_object_get(blob, "args");
-	if (validator) {
-		/* do validation? XXX */
-	} else {
-		/* fail message generation if the required parameter doesn't exist */
-		return NULL;
-	}
-
-	event = ast_json_deep_copy(blob);
-	if (!event) {
-		return NULL;
-	}
-
-	ret = ast_json_object_set(event,
-		"channel", ast_channel_snapshot_to_json(channel_snapshot));
-	if (ret) {
-		return NULL;
-	}
-
-	message = ast_json_pack("{s: o}", "stasis_start", ast_json_ref(event));
-	if (!message) {
-		return NULL;
-	}
-
-	return ast_json_ref(message);
-}
-
-struct ast_json *stasis_json_event_channel_dialplan_create(
-	struct ast_channel_snapshot *channel_snapshot,
-	struct ast_json *blob
-	)
-{
-	RAII_VAR(struct ast_json *, message, NULL, ast_json_unref);
-	RAII_VAR(struct ast_json *, event, NULL, ast_json_unref);
-	struct ast_json *validator;
-	int ret;
-
-	ast_assert(channel_snapshot != NULL);
-	ast_assert(blob != NULL);
-	ast_assert(ast_json_object_get(blob, "channel") == NULL);
-	ast_assert(ast_json_object_get(blob, "type") == NULL);
-
-	validator = ast_json_object_get(blob, "application");
-	if (validator) {
-		/* do validation? XXX */
-	} else {
-		/* fail message generation if the required parameter doesn't exist */
-		return NULL;
-	}
-
-	validator = ast_json_object_get(blob, "application_data");
-	if (validator) {
-		/* do validation? XXX */
-	} else {
-		/* fail message generation if the required parameter doesn't exist */
-		return NULL;
-	}
-
-	event = ast_json_deep_copy(blob);
-	if (!event) {
-		return NULL;
-	}
-
-	ret = ast_json_object_set(event,
-		"channel", ast_channel_snapshot_to_json(channel_snapshot));
-	if (ret) {
-		return NULL;
-	}
-
-	message = ast_json_pack("{s: o}", "channel_dialplan", ast_json_ref(event));
-	if (!message) {
-		return NULL;
-	}
-
-	return ast_json_ref(message);
-}
-
-struct ast_json *stasis_json_event_channel_state_change_create(
-	struct ast_channel_snapshot *channel_snapshot
-	)
-{
-	RAII_VAR(struct ast_json *, message, NULL, ast_json_unref);
-	RAII_VAR(struct ast_json *, event, NULL, ast_json_unref);
-	int ret;
-
-	ast_assert(channel_snapshot != NULL);
-
-	event = ast_json_object_create();
-	if (!event) {
-		return NULL;
-	}
-
-	ret = ast_json_object_set(event,
-		"channel", ast_channel_snapshot_to_json(channel_snapshot));
-	if (ret) {
-		return NULL;
-	}
-
-	message = ast_json_pack("{s: o}", "channel_state_change", ast_json_ref(event));
-	if (!message) {
-		return NULL;
-	}
-
-	return ast_json_ref(message);
-}
-
-struct ast_json *stasis_json_event_channel_entered_bridge_create(
-	struct ast_bridge_snapshot *bridge_snapshot,
-	struct ast_channel_snapshot *channel_snapshot
-	)
-{
-	RAII_VAR(struct ast_json *, message, NULL, ast_json_unref);
-	RAII_VAR(struct ast_json *, event, NULL, ast_json_unref);
-	int ret;
-
-	ast_assert(channel_snapshot != NULL);
-	ast_assert(bridge_snapshot != NULL);
-
-	event = ast_json_object_create();
-	if (!event) {
-		return NULL;
-	}
-
-	ret = ast_json_object_set(event,
-		"channel", ast_channel_snapshot_to_json(channel_snapshot));
-	if (ret) {
-		return NULL;
-	}
-
-	ret = ast_json_object_set(event,
-		"bridge", ast_bridge_snapshot_to_json(bridge_snapshot));
-	if (ret) {
-		return NULL;
-	}
-
-	message = ast_json_pack("{s: o}", "channel_entered_bridge", ast_json_ref(event));
-	if (!message) {
-		return NULL;
-	}
-
-	return ast_json_ref(message);
-}
-
-struct ast_json *stasis_json_event_channel_dtmf_received_create(
-	struct ast_channel_snapshot *channel_snapshot,
-	struct ast_json *blob
-	)
-{
-	RAII_VAR(struct ast_json *, message, NULL, ast_json_unref);
-	RAII_VAR(struct ast_json *, event, NULL, ast_json_unref);
-	struct ast_json *validator;
-	int ret;
-
-	ast_assert(channel_snapshot != NULL);
-	ast_assert(blob != NULL);
-	ast_assert(ast_json_object_get(blob, "channel") == NULL);
-	ast_assert(ast_json_object_get(blob, "type") == NULL);
-
-	validator = ast_json_object_get(blob, "digit");
-	if (validator) {
-		/* do validation? XXX */
-	} else {
-		/* fail message generation if the required parameter doesn't exist */
-		return NULL;
-	}
-
-	event = ast_json_deep_copy(blob);
-	if (!event) {
-		return NULL;
-	}
-
-	ret = ast_json_object_set(event,
-		"channel", ast_channel_snapshot_to_json(channel_snapshot));
-	if (ret) {
-		return NULL;
-	}
-
-	message = ast_json_pack("{s: o}", "channel_dtmf_received", ast_json_ref(event));
-	if (!message) {
-		return NULL;
-	}
-
-	return ast_json_ref(message);
-}
-
-struct ast_json *stasis_json_event_stasis_end_create(
-	struct ast_channel_snapshot *channel_snapshot
-	)
-{
-	RAII_VAR(struct ast_json *, message, NULL, ast_json_unref);
-	RAII_VAR(struct ast_json *, event, NULL, ast_json_unref);
-	int ret;
-
-	ast_assert(channel_snapshot != NULL);
-
-	event = ast_json_object_create();
-	if (!event) {
-		return NULL;
-	}
-
-	ret = ast_json_object_set(event,
-		"channel", ast_channel_snapshot_to_json(channel_snapshot));
-	if (ret) {
-		return NULL;
-	}
-
-	message = ast_json_pack("{s: o}", "stasis_end", ast_json_ref(event));
-	if (!message) {
-		return NULL;
-	}
-
-	return ast_json_ref(message);
-}
-
 static int load_module(void)
 {
 	stasis_app_ref();

Copied: team/group/bridge_construction/res/res_stasis_json_events.c (from r388668, trunk/res/res_stasis_json_events.c)
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/res/res_stasis_json_events.c?view=diff&rev=388670&p1=trunk/res/res_stasis_json_events.c&r1=388668&p2=team/group/bridge_construction/res/res_stasis_json_events.c&r2=388670
==============================================================================
--- trunk/res/res_stasis_json_events.c (original)
+++ team/group/bridge_construction/res/res_stasis_json_events.c Tue May 14 08:03:38 2013
@@ -43,6 +43,128 @@
 #include "asterisk/json.h"
 #include "stasis_json/resource_events.h"
 #include "asterisk/stasis_channels.h"
+#include "asterisk/stasis_bridging.h"
+
+struct ast_json *stasis_json_event_channel_userevent_create(
+	struct ast_channel_snapshot *channel_snapshot,
+	struct ast_json *blob
+	)
+{
+	RAII_VAR(struct ast_json *, message, NULL, ast_json_unref);
+	RAII_VAR(struct ast_json *, event, NULL, ast_json_unref);
+	struct ast_json *validator;
+	int ret;
+
+	ast_assert(channel_snapshot != NULL);
+	ast_assert(blob != NULL);
+	ast_assert(ast_json_object_get(blob, "channel") == NULL);
+	ast_assert(ast_json_object_get(blob, "type") == NULL);
+
+	validator = ast_json_object_get(blob, "eventname");
+	if (validator) {
+		/* do validation? XXX */
+	} else {
+		/* fail message generation if the required parameter doesn't exist */
+		return NULL;
+	}
+
+	event = ast_json_deep_copy(blob);
+	if (!event) {
+		return NULL;
+	}
+
+	ret = ast_json_object_set(event,
+		"channel", ast_channel_snapshot_to_json(channel_snapshot));
+	if (ret) {
+		return NULL;
+	}
+
+	message = ast_json_pack("{s: o}", "channel_userevent", ast_json_ref(event));
+	if (!message) {
+		return NULL;
+	}
+
+	return ast_json_ref(message);
+}
+
+struct ast_json *stasis_json_event_bridge_created_create(
+	struct ast_bridge_snapshot *bridge_snapshot
+	)
+{
+	RAII_VAR(struct ast_json *, message, NULL, ast_json_unref);
+	RAII_VAR(struct ast_json *, event, NULL, ast_json_unref);
+	int ret;
+
+	ast_assert(bridge_snapshot != NULL);
+
+	event = ast_json_object_create();
+	if (!event) {
+		return NULL;
+	}
+
+	ret = ast_json_object_set(event,
+		"bridge", ast_bridge_snapshot_to_json(bridge_snapshot));
+	if (ret) {
+		return NULL;
+	}
+
+	message = ast_json_pack("{s: o}", "bridge_created", ast_json_ref(event));
+	if (!message) {
+		return NULL;
+	}
+
+	return ast_json_ref(message);
+}
+
+struct ast_json *stasis_json_event_channel_destroyed_create(
+	struct ast_channel_snapshot *channel_snapshot,
+	struct ast_json *blob
+	)
+{
+	RAII_VAR(struct ast_json *, message, NULL, ast_json_unref);
+	RAII_VAR(struct ast_json *, event, NULL, ast_json_unref);
+	struct ast_json *validator;
+	int ret;
+
+	ast_assert(channel_snapshot != NULL);
+	ast_assert(blob != NULL);
+	ast_assert(ast_json_object_get(blob, "channel") == NULL);
+	ast_assert(ast_json_object_get(blob, "type") == NULL);
+
+	validator = ast_json_object_get(blob, "cause");
+	if (validator) {
+		/* do validation? XXX */
+	} else {
+		/* fail message generation if the required parameter doesn't exist */
+		return NULL;
+	}
+
+	validator = ast_json_object_get(blob, "cause_txt");
+	if (validator) {
+		/* do validation? XXX */
+	} else {
+		/* fail message generation if the required parameter doesn't exist */
+		return NULL;
+	}
+
+	event = ast_json_deep_copy(blob);
+	if (!event) {
+		return NULL;
+	}
+
+	ret = ast_json_object_set(event,
+		"channel", ast_channel_snapshot_to_json(channel_snapshot));
+	if (ret) {
+		return NULL;
+	}
+
+	message = ast_json_pack("{s: o}", "channel_destroyed", ast_json_ref(event));
+	if (!message) {
+		return NULL;
+	}
+
+	return ast_json_ref(message);
+}
 
 struct ast_json *stasis_json_event_channel_snapshot_create(
 	struct ast_channel_snapshot *channel_snapshot
@@ -73,56 +195,6 @@
 	return ast_json_ref(message);
 }
 
-struct ast_json *stasis_json_event_channel_destroyed_create(
-	struct ast_channel_snapshot *channel_snapshot,
-	struct ast_json *blob
-	)
-{
-	RAII_VAR(struct ast_json *, message, NULL, ast_json_unref);
-	RAII_VAR(struct ast_json *, event, NULL, ast_json_unref);
-	struct ast_json *validator;
-	int ret;
-
-	ast_assert(channel_snapshot != NULL);
-	ast_assert(blob != NULL);
-	ast_assert(ast_json_object_get(blob, "channel") == NULL);
-	ast_assert(ast_json_object_get(blob, "type") == NULL);
-
-	validator = ast_json_object_get(blob, "cause");
-	if (validator) {
-		/* do validation? XXX */
-	} else {
-		/* fail message generation if the required parameter doesn't exist */
-		return NULL;
-	}
-
-	validator = ast_json_object_get(blob, "cause_txt");
-	if (validator) {
-		/* do validation? XXX */
-	} else {
-		/* fail message generation if the required parameter doesn't exist */
-		return NULL;
-	}
-
-	event = ast_json_deep_copy(blob);
-	if (!event) {
-		return NULL;
-	}
-
-	ret = ast_json_object_set(event,
-		"channel", ast_channel_snapshot_to_json(channel_snapshot));
-	if (ret) {
-		return NULL;
-	}
-
-	message = ast_json_pack("{s: o}", "channel_destroyed", ast_json_ref(event));
-	if (!message) {
-		return NULL;
-	}
-
-	return ast_json_ref(message);
-}
-
 struct ast_json *stasis_json_event_channel_caller_id_create(
 	struct ast_channel_snapshot *channel_snapshot,
 	struct ast_json *blob
@@ -217,6 +289,35 @@
 	return ast_json_ref(message);
 }
 
+struct ast_json *stasis_json_event_bridge_destroyed_create(
+	struct ast_bridge_snapshot *bridge_snapshot
+	)
+{
+	RAII_VAR(struct ast_json *, message, NULL, ast_json_unref);
+	RAII_VAR(struct ast_json *, event, NULL, ast_json_unref);
+	int ret;
+
+	ast_assert(bridge_snapshot != NULL);
+
+	event = ast_json_object_create();
+	if (!event) {
+		return NULL;
+	}
+
+	ret = ast_json_object_set(event,
+		"bridge", ast_bridge_snapshot_to_json(bridge_snapshot));
+	if (ret) {
+		return NULL;
+	}
+
+	message = ast_json_pack("{s: o}", "bridge_destroyed", ast_json_ref(event));
+	if (!message) {
+		return NULL;
+	}
+
+	return ast_json_ref(message);
+}
+
 struct ast_json *stasis_json_event_application_replaced_create(
 	struct ast_json *blob
 	)
@@ -299,41 +400,36 @@
 	return ast_json_ref(message);
 }
 
-struct ast_json *stasis_json_event_channel_userevent_create(
-	struct ast_channel_snapshot *channel_snapshot,
-	struct ast_json *blob
-	)
-{
-	RAII_VAR(struct ast_json *, message, NULL, ast_json_unref);
-	RAII_VAR(struct ast_json *, event, NULL, ast_json_unref);
-	struct ast_json *validator;
-	int ret;
-
-	ast_assert(channel_snapshot != NULL);
-	ast_assert(blob != NULL);
-	ast_assert(ast_json_object_get(blob, "channel") == NULL);
-	ast_assert(ast_json_object_get(blob, "type") == NULL);
-
-	validator = ast_json_object_get(blob, "eventname");
-	if (validator) {
-		/* do validation? XXX */
-	} else {
-		/* fail message generation if the required parameter doesn't exist */
-		return NULL;
-	}
-
-	event = ast_json_deep_copy(blob);
-	if (!event) {
-		return NULL;
-	}
-
-	ret = ast_json_object_set(event,
-		"channel", ast_channel_snapshot_to_json(channel_snapshot));
-	if (ret) {
-		return NULL;
-	}
-
-	message = ast_json_pack("{s: o}", "channel_userevent", ast_json_ref(event));
+struct ast_json *stasis_json_event_channel_left_bridge_create(
+	struct ast_bridge_snapshot *bridge_snapshot,
+	struct ast_channel_snapshot *channel_snapshot
+	)
+{
+	RAII_VAR(struct ast_json *, message, NULL, ast_json_unref);
+	RAII_VAR(struct ast_json *, event, NULL, ast_json_unref);
+	int ret;
+
+	ast_assert(channel_snapshot != NULL);
+	ast_assert(bridge_snapshot != NULL);
+
+	event = ast_json_object_create();
+	if (!event) {
+		return NULL;
+	}
+
+	ret = ast_json_object_set(event,
+		"channel", ast_channel_snapshot_to_json(channel_snapshot));
+	if (ret) {
+		return NULL;
+	}
+
+	ret = ast_json_object_set(event,
+		"bridge", ast_bridge_snapshot_to_json(bridge_snapshot));
+	if (ret) {
+		return NULL;
+	}
+
+	message = ast_json_pack("{s: o}", "channel_left_bridge", ast_json_ref(event));
 	if (!message) {
 		return NULL;
 	}
@@ -484,6 +580,43 @@
 	}
 
 	message = ast_json_pack("{s: o}", "channel_state_change", ast_json_ref(event));
+	if (!message) {
+		return NULL;
+	}
+
+	return ast_json_ref(message);
+}
+
+struct ast_json *stasis_json_event_channel_entered_bridge_create(
+	struct ast_bridge_snapshot *bridge_snapshot,
+	struct ast_channel_snapshot *channel_snapshot
+	)
+{
+	RAII_VAR(struct ast_json *, message, NULL, ast_json_unref);
+	RAII_VAR(struct ast_json *, event, NULL, ast_json_unref);
+	int ret;
+
+	ast_assert(channel_snapshot != NULL);
+	ast_assert(bridge_snapshot != NULL);
+
+	event = ast_json_object_create();
+	if (!event) {
+		return NULL;
+	}
+
+	ret = ast_json_object_set(event,
+		"channel", ast_channel_snapshot_to_json(channel_snapshot));
+	if (ret) {
+		return NULL;
+	}
+
+	ret = ast_json_object_set(event,
+		"bridge", ast_bridge_snapshot_to_json(bridge_snapshot));
+	if (ret) {
+		return NULL;
+	}
+
+	message = ast_json_pack("{s: o}", "channel_entered_bridge", ast_json_ref(event));
 	if (!message) {
 		return NULL;
 	}

Copied: team/group/bridge_construction/res/res_stasis_json_events.exports.in (from r388668, trunk/res/res_stasis_json_events.exports.in)
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/res/res_stasis_json_events.exports.in?view=diff&rev=388670&p1=trunk/res/res_stasis_json_events.exports.in&r1=388668&p2=team/group/bridge_construction/res/res_stasis_json_events.exports.in&r2=388670
==============================================================================
--- trunk/res/res_stasis_json_events.exports.in (original)
+++ team/group/bridge_construction/res/res_stasis_json_events.exports.in Tue May 14 08:03:38 2013
@@ -1,16 +1,20 @@
 {
 	global:
+		LINKER_SYMBOL_PREFIXstasis_json_event_channel_userevent_create;
+		LINKER_SYMBOL_PREFIXstasis_json_event_bridge_created_create;
+		LINKER_SYMBOL_PREFIXstasis_json_event_channel_destroyed_create;
 		LINKER_SYMBOL_PREFIXstasis_json_event_channel_snapshot_create;
-		LINKER_SYMBOL_PREFIXstasis_json_event_channel_destroyed_create;
 		LINKER_SYMBOL_PREFIXstasis_json_event_channel_caller_id_create;
 		LINKER_SYMBOL_PREFIXstasis_json_event_channel_hangup_request_create;
+		LINKER_SYMBOL_PREFIXstasis_json_event_bridge_destroyed_create;
 		LINKER_SYMBOL_PREFIXstasis_json_event_application_replaced_create;
 		LINKER_SYMBOL_PREFIXstasis_json_event_channel_varset_create;
-		LINKER_SYMBOL_PREFIXstasis_json_event_channel_userevent_create;
+		LINKER_SYMBOL_PREFIXstasis_json_event_channel_left_bridge_create;
 		LINKER_SYMBOL_PREFIXstasis_json_event_channel_created_create;
 		LINKER_SYMBOL_PREFIXstasis_json_event_stasis_start_create;
 		LINKER_SYMBOL_PREFIXstasis_json_event_channel_dialplan_create;
 		LINKER_SYMBOL_PREFIXstasis_json_event_channel_state_change_create;
+		LINKER_SYMBOL_PREFIXstasis_json_event_channel_entered_bridge_create;
 		LINKER_SYMBOL_PREFIXstasis_json_event_channel_dtmf_received_create;
 		LINKER_SYMBOL_PREFIXstasis_json_event_stasis_end_create;
 	local:

Modified: team/group/bridge_construction/res/stasis_http/resource_asterisk.h
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/res/stasis_http/resource_asterisk.h?view=diff&rev=388670&r1=388669&r2=388670
==============================================================================
--- team/group/bridge_construction/res/stasis_http/resource_asterisk.h (original)
+++ team/group/bridge_construction/res/stasis_http/resource_asterisk.h Tue May 14 08:03:38 2013
@@ -53,10 +53,4 @@
  */
 void stasis_http_get_asterisk_info(struct ast_variable *headers, struct ast_get_asterisk_info_args *args, struct stasis_http_response *response);
 
-/*
- * JSON models
- *
- * AsteriskInfo
- */
-
 #endif /* _ASTERISK_RESOURCE_ASTERISK_H */

Modified: team/group/bridge_construction/res/stasis_http/resource_bridges.h
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/res/stasis_http/resource_bridges.h?view=diff&rev=388670&r1=388669&r2=388670
==============================================================================
--- team/group/bridge_construction/res/stasis_http/resource_bridges.h (original)
+++ team/group/bridge_construction/res/stasis_http/resource_bridges.h Tue May 14 08:03:38 2013
@@ -151,12 +151,4 @@
  */
 void stasis_http_record_bridge(struct ast_variable *headers, struct ast_record_bridge_args *args, struct stasis_http_response *response);
 
-/*
- * JSON models
- *
- * Bridge
- * - channels: List[string] (required)
- * - bridgeType: string (required)
- */
-
 #endif /* _ASTERISK_RESOURCE_BRIDGES_H */

Modified: team/group/bridge_construction/res/stasis_http/resource_channels.h
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/res/stasis_http/resource_channels.h?view=diff&rev=388670&r1=388669&r2=388670
==============================================================================
--- team/group/bridge_construction/res/stasis_http/resource_channels.h (original)
+++ team/group/bridge_construction/res/stasis_http/resource_channels.h Tue May 14 08:03:38 2013
@@ -241,34 +241,4 @@
  */
 void stasis_http_record_channel(struct ast_variable *headers, struct ast_record_channel_args *args, struct stasis_http_response *response);
 
-/*
- * JSON models
- *
- * Originated
- * DialplanCEP
- * - priority: long (required)
- * - exten: string (required)
- * - context: string (required)
- * Channel
- * - accountcode: string (required)
- * - linkedid: string (required)
- * - name: string (required)
- * - userfield: string (required)
- * - caller: CallerID (required)
- * - creationtime: Date (required)
- * - state: string (required)
- * - parkinglot: string (required)
- * - peeraccount: string (required)
- * - appl: string (required)
- * - connected: CallerID (required)
- * - uniqueid: string (required)
- * - hangupsource: string (required)
- * - dialplan: DialplanCEP (required)
- * - data: string (required)
- * CallerID
- * - name: string (required)
- * - number: string (required)
- * Dialed
- */
-
 #endif /* _ASTERISK_RESOURCE_CHANNELS_H */

Modified: team/group/bridge_construction/res/stasis_http/resource_endpoints.h
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/res/stasis_http/resource_endpoints.h?view=diff&rev=388670&r1=388669&r2=388670
==============================================================================
--- team/group/bridge_construction/res/stasis_http/resource_endpoints.h (original)
+++ team/group/bridge_construction/res/stasis_http/resource_endpoints.h Tue May 14 08:03:38 2013
@@ -79,12 +79,4 @@
  */
 void stasis_http_get_endpoint(struct ast_variable *headers, struct ast_get_endpoint_args *args, struct stasis_http_response *response);
 
-/*
- * JSON models
- *
- * Endpoint
- * - resource: string (required)
- * - technology: string (required)
- */
-
 #endif /* _ASTERISK_RESOURCE_ENDPOINTS_H */

Modified: team/group/bridge_construction/res/stasis_http/resource_events.h
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/res/stasis_http/resource_events.h?view=diff&rev=388670&r1=388669&r2=388670
==============================================================================
--- team/group/bridge_construction/res/stasis_http/resource_events.h (original)
+++ team/group/bridge_construction/res/stasis_http/resource_events.h Tue May 14 08:03:38 2013
@@ -55,300 +55,4 @@
  */
 void stasis_http_event_websocket(struct ast_variable *headers, struct ast_event_websocket_args *args, struct stasis_http_response *response);
 
-struct ast_channel_snapshot;
-struct ast_bridge_snapshot;
-
-/*!
- * \brief User-generated event with additional user-defined fields in the object.
- *
- * \param channel The channel that signaled the user event.
- * \param blob JSON blob containing the following parameters:
- * - eventname: string - The name of the user event. (required)
- *
- * \retval NULL on error
- * \retval JSON (ast_json) describing the event
- */
-struct ast_json *stasis_json_event_channel_userevent_create(
-	struct ast_channel_snapshot *channel_snapshot,
-	struct ast_json *blob
-	);
-
-/*!
- * \brief Notification that a bridge has been created.
- *
- * \param bridge The bridge to be used to generate this event
- *
- * \retval NULL on error
- * \retval JSON (ast_json) describing the event
- */
-struct ast_json *stasis_json_event_bridge_created_create(
-	struct ast_bridge_snapshot *bridge_snapshot
-	);
-
-/*!
- * \brief Notification that a channel has been destroyed.
- *
- * \param channel The channel to be used to generate this event
- * \param blob JSON blob containing the following parameters:
- * - cause: integer - Integer representation of the cause of the hangup (required)
- * - cause_txt: string - Text representation of the cause of the hangup (required)
- *
- * \retval NULL on error
- * \retval JSON (ast_json) describing the event
- */
-struct ast_json *stasis_json_event_channel_destroyed_create(
-	struct ast_channel_snapshot *channel_snapshot,
-	struct ast_json *blob
-	);
-
-/*!
- * \brief Some part of channel state changed.
- *
- * \param channel The channel to be used to generate this event
- *
- * \retval NULL on error
- * \retval JSON (ast_json) describing the event
- */
-struct ast_json *stasis_json_event_channel_snapshot_create(
-	struct ast_channel_snapshot *channel_snapshot
-	);
-
-/*!
- * \brief Channel changed Caller ID.
- *
- * \param channel The channel that changed Caller ID.

[... 723 lines stripped ...]



More information about the asterisk-commits mailing list