[asterisk-commits] dlee: branch dlee/playback r388298 - in /team/dlee/playback: include/asterisk...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri May 10 09:01:23 CDT 2013


Author: dlee
Date: Fri May 10 09:01:21 2013
New Revision: 388298

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=388298
Log:
GET on playback resource works

Modified:
    team/dlee/playback/include/asterisk/stasis_app_playback.h
    team/dlee/playback/res/res_stasis_playback.c
    team/dlee/playback/res/stasis_http/resource_channels.c
    team/dlee/playback/res/stasis_http/resource_playback.c

Modified: team/dlee/playback/include/asterisk/stasis_app_playback.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/playback/include/asterisk/stasis_app_playback.h?view=diff&rev=388298&r1=388297&r2=388298
==============================================================================
--- team/dlee/playback/include/asterisk/stasis_app_playback.h (original)
+++ team/dlee/playback/include/asterisk/stasis_app_playback.h Fri May 10 09:01:21 2013
@@ -95,7 +95,7 @@
  * \return Associated \ref stasis_app_playback object.
  * \return \c NULL if \a id not found.
  */
-struct stasis_app_playback *stasis_app_playback_find_by_id(const char *id);
+struct ast_json *stasis_app_playback_find_by_id(const char *id);
 
 /*!
  * \brief Controls the media for a given playback operation.

Modified: team/dlee/playback/res/res_stasis_playback.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/playback/res/res_stasis_playback.c?view=diff&rev=388298&r1=388297&r2=388298
==============================================================================
--- team/dlee/playback/res/res_stasis_playback.c (original)
+++ team/dlee/playback/res/res_stasis_playback.c Fri May 10 09:01:21 2013
@@ -77,7 +77,7 @@
 {
 	struct stasis_app_playback *lhs = obj;
 	struct stasis_app_playback *rhs = arg;
-	const char *rhs_id = flags & OBJ_KEY ? obj : rhs->id;
+	const char *rhs_id = flags & OBJ_KEY ? arg : rhs->id;
 
 	if (strcmp(lhs->id, rhs_id) == 0) {
 		return CMP_MATCH | CMP_STOP;
@@ -107,7 +107,7 @@
 		break;
 	}
 
-	json = ast_json_pack("{s: s, s: s, s: s, s: s, s: s}",
+	json = ast_json_pack("{s: s, s: s, s: s, s: s}",
 		"id", playback->id,
 		"media_uri", playback->media,
 		"language", playback->language,
@@ -246,9 +246,18 @@
 	return control->id;
 }
 
-struct stasis_app_playback *stasis_app_playback_find_by_id(const char *id)
-{
-	return ao2_find(playbacks, id, OBJ_KEY);
+struct ast_json *stasis_app_playback_find_by_id(const char *id)
+{
+	RAII_VAR(struct stasis_app_playback *, playback, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
+
+	playback = ao2_find(playbacks, id, OBJ_KEY);
+	if (playback == NULL) {
+		return NULL;
+	}
+
+	json = playback_to_json(playback);
+	return ast_json_ref(json);
 }
 
 int stasis_app_playback_control(struct stasis_app_playback *playback,

Modified: team/dlee/playback/res/stasis_http/resource_channels.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/playback/res/stasis_http/resource_channels.c?view=diff&rev=388298&r1=388297&r2=388298
==============================================================================
--- team/dlee/playback/res/stasis_http/resource_channels.c (original)
+++ team/dlee/playback/res/stasis_http/resource_channels.c Fri May 10 09:01:21 2013
@@ -149,6 +149,8 @@
 
 	ast_assert(response != NULL);
 
+	ast_verb(1, "%s(%s, %s)\n", __func__, args->channel_id, args->media);
+
 	control = find_control(response, args->channel_id);
 	if (control == NULL) {
 		/* Response filled in by find_control */
@@ -183,6 +185,7 @@
 	}
 
 	stasis_http_response_created(response, playback_url);
+	ast_verb(1, " %s - done\n", __func__);
 }
 void stasis_http_record_channel(struct ast_variable *headers, struct ast_record_channel_args *args, struct stasis_http_response *response)
 {

Modified: team/dlee/playback/res/stasis_http/resource_playback.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/playback/res/stasis_http/resource_playback.c?view=diff&rev=388298&r1=388297&r2=388298
==============================================================================
--- team/dlee/playback/res/stasis_http/resource_playback.c (original)
+++ team/dlee/playback/res/stasis_http/resource_playback.c Fri May 10 09:01:21 2013
@@ -27,11 +27,22 @@
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
+#include "asterisk/stasis_app_playback.h"
 #include "resource_playback.h"
 
-void stasis_http_get_playback(struct ast_variable *headers, struct ast_get_playback_args *args, struct stasis_http_response *response)
+void stasis_http_get_playback(struct ast_variable *headers,
+	struct ast_get_playback_args *args,
+	struct stasis_http_response *response)
 {
-	ast_log(LOG_ERROR, "TODO: stasis_http_get_playback\n");
+	RAII_VAR(struct ast_json *, playback, NULL, ast_json_unref);
+	playback = stasis_app_playback_find_by_id(args->playback_id);
+	if (playback == NULL) {
+		stasis_http_response_error(response, 404, "Not Found",
+			"Playback not found");
+		return;
+	}
+
+	stasis_http_response_ok(response, ast_json_ref(playback));
 }
 void stasis_http_stop_playback(struct ast_variable *headers, struct ast_stop_playback_args *args, struct stasis_http_response *response)
 {




More information about the asterisk-commits mailing list