[asterisk-commits] dlee: branch dlee/record r389955 - in /team/dlee/record: include/asterisk/ ma...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue May 28 14:46:22 CDT 2013


Author: dlee
Date: Tue May 28 14:46:19 2013
New Revision: 389955

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=389955
Log:
Recording mostly working. Needs appending

Modified:
    team/dlee/record/include/asterisk/lock.h
    team/dlee/record/include/asterisk/stasis_app_recording.h
    team/dlee/record/main/file.c
    team/dlee/record/res/res_stasis_http_recordings.c
    team/dlee/record/res/res_stasis_recording.c
    team/dlee/record/res/stasis_http/resource_channels.c
    team/dlee/record/res/stasis_http/resource_recordings.c
    team/dlee/record/res/stasis_http/resource_recordings.h
    team/dlee/record/rest-api/api-docs/recordings.json

Modified: team/dlee/record/include/asterisk/lock.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/record/include/asterisk/lock.h?view=diff&rev=389955&r1=389954&r2=389955
==============================================================================
--- team/dlee/record/include/asterisk/lock.h (original)
+++ team/dlee/record/include/asterisk/lock.h Tue May 28 14:46:19 2013
@@ -601,7 +601,7 @@
 #define SCOPED_LOCK(varname, lock, lockfunc, unlockfunc) \
 	auto void _dtor_ ## varname (typeof((lock)) * v); \
 	auto void _dtor_ ## varname (typeof((lock)) * v) { unlockfunc(*v); } \
-	typeof((lock)) varname __attribute__((cleanup(_dtor_ ## varname))) = lock; lockfunc((lock))
+	typeof((lock)) varname __attribute__((cleanup(_dtor_ ## varname))) = (lockfunc((lock)), (lock))
 
 /*!
  * \brief scoped lock specialization for mutexes

Modified: team/dlee/record/include/asterisk/stasis_app_recording.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/record/include/asterisk/stasis_app_recording.h?view=diff&rev=389955&r1=389954&r2=389955
==============================================================================
--- team/dlee/record/include/asterisk/stasis_app_recording.h (original)
+++ team/dlee/record/include/asterisk/stasis_app_recording.h Tue May 28 14:46:19 2013
@@ -91,6 +91,11 @@
 /*!
  * \brief Record media from a channel.
  *
+ * On error, \c errno is set to indicate the failure reason.
+ *  - \c EINVAL: Invalid input.
+ *  - \c EEXIST: A recording with that name is in session.
+ *  - \c ENOMEM: Out of memory.
+ *
  * \param control Control for \c res_stasis.
  * \return Recording control object.
  * \return \c NULL on error.
@@ -109,23 +114,23 @@
 	struct stasis_app_recording *recording);
 
 /*!
- * \brief Gets the unique id of a recording object.
+ * \brief Gets the unique name of a recording object.
  *
  * \param recording Recording control object.
- * \return \a recording's id.
+ * \return \a recording's name.
  * \return \c NULL if \a recording ic \c NULL
  */
-const char *stasis_app_recording_get_id(
+const char *stasis_app_recording_get_name(
 	struct stasis_app_recording *recording);
 
 /*!
- * \brief Finds the recording object with the given id.
+ * \brief Finds the recording object with the given name.
  *
- * \param id Id of the recording object to find.
+ * \param name Name of the recording object to find.
  * \return Associated \ref stasis_app_recording object.
- * \return \c NULL if \a id not found.
+ * \return \c NULL if \a name not found.
  */
-struct stasis_app_recording *stasis_app_recording_find_by_id(const char *id);
+struct stasis_app_recording *stasis_app_recording_find_by_name(const char *name);
 
 struct ast_json *stasis_app_recording_to_json(
 	const struct stasis_app_recording *recording);

Modified: team/dlee/record/main/file.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/record/main/file.c?view=diff&rev=389955&r1=389954&r2=389955
==============================================================================
--- team/dlee/record/main/file.c (original)
+++ team/dlee/record/main/file.c Tue May 28 14:46:19 2013
@@ -967,6 +967,9 @@
 	 * We close the stream in order to quit queuing frames now, because we might
 	 * change the writeformat, which could result in a subsequent write error, if
 	 * the format is different. */
+	if (f == NULL) {
+		return 0;
+	}
 	filestream_close(f);
 	ao2_ref(f, -1);
 	return 0;

Modified: team/dlee/record/res/res_stasis_http_recordings.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/record/res/res_stasis_http_recordings.c?view=diff&rev=389955&r1=389954&r2=389955
==============================================================================
--- team/dlee/record/res/res_stasis_http_recordings.c (original)
+++ team/dlee/record/res/res_stasis_http_recordings.c Tue May 28 14:46:19 2013
@@ -74,7 +74,7 @@
 	stasis_http_get_stored_recordings(headers, &args, response);
 }
 /*!
- * \brief Parameter parsing callback for /recordings/stored/{recordingId}.
+ * \brief Parameter parsing callback for /recordings/stored/{recordingName}.
  * \param get_params GET parameters in the HTTP request.
  * \param path_vars Path variables extracted from the request.
  * \param headers HTTP headers.
@@ -88,15 +88,15 @@
 	struct ast_variable *i;
 
 	for (i = path_vars; i; i = i->next) {
-		if (strcmp(i->name, "recordingId") == 0) {
-			args.recording_id = (i->value);
+		if (strcmp(i->name, "recordingName") == 0) {
+			args.recording_name = (i->value);
 		} else
 		{}
 	}
 	stasis_http_get_stored_recording(headers, &args, response);
 }
 /*!
- * \brief Parameter parsing callback for /recordings/stored/{recordingId}.
+ * \brief Parameter parsing callback for /recordings/stored/{recordingName}.
  * \param get_params GET parameters in the HTTP request.
  * \param path_vars Path variables extracted from the request.
  * \param headers HTTP headers.
@@ -110,8 +110,8 @@
 	struct ast_variable *i;
 
 	for (i = path_vars; i; i = i->next) {
-		if (strcmp(i->name, "recordingId") == 0) {
-			args.recording_id = (i->value);
+		if (strcmp(i->name, "recordingName") == 0) {
+			args.recording_name = (i->value);
 		} else
 		{}
 	}
@@ -132,7 +132,7 @@
 	stasis_http_get_live_recordings(headers, &args, response);
 }
 /*!
- * \brief Parameter parsing callback for /recordings/live/{recordingId}.
+ * \brief Parameter parsing callback for /recordings/live/{recordingName}.
  * \param get_params GET parameters in the HTTP request.
  * \param path_vars Path variables extracted from the request.
  * \param headers HTTP headers.
@@ -146,15 +146,15 @@
 	struct ast_variable *i;
 
 	for (i = path_vars; i; i = i->next) {
-		if (strcmp(i->name, "recordingId") == 0) {
-			args.recording_id = (i->value);
+		if (strcmp(i->name, "recordingName") == 0) {
+			args.recording_name = (i->value);
 		} else
 		{}
 	}
 	stasis_http_get_live_recording(headers, &args, response);
 }
 /*!
- * \brief Parameter parsing callback for /recordings/live/{recordingId}.
+ * \brief Parameter parsing callback for /recordings/live/{recordingName}.
  * \param get_params GET parameters in the HTTP request.
  * \param path_vars Path variables extracted from the request.
  * \param headers HTTP headers.
@@ -168,15 +168,15 @@
 	struct ast_variable *i;
 
 	for (i = path_vars; i; i = i->next) {
-		if (strcmp(i->name, "recordingId") == 0) {
-			args.recording_id = (i->value);
+		if (strcmp(i->name, "recordingName") == 0) {
+			args.recording_name = (i->value);
 		} else
 		{}
 	}
 	stasis_http_cancel_recording(headers, &args, response);
 }
 /*!
- * \brief Parameter parsing callback for /recordings/live/{recordingId}/stop.
+ * \brief Parameter parsing callback for /recordings/live/{recordingName}/stop.
  * \param get_params GET parameters in the HTTP request.
  * \param path_vars Path variables extracted from the request.
  * \param headers HTTP headers.
@@ -190,15 +190,15 @@
 	struct ast_variable *i;
 
 	for (i = path_vars; i; i = i->next) {
-		if (strcmp(i->name, "recordingId") == 0) {
-			args.recording_id = (i->value);
+		if (strcmp(i->name, "recordingName") == 0) {
+			args.recording_name = (i->value);
 		} else
 		{}
 	}
 	stasis_http_stop_recording(headers, &args, response);
 }
 /*!
- * \brief Parameter parsing callback for /recordings/live/{recordingId}/pause.
+ * \brief Parameter parsing callback for /recordings/live/{recordingName}/pause.
  * \param get_params GET parameters in the HTTP request.
  * \param path_vars Path variables extracted from the request.
  * \param headers HTTP headers.
@@ -212,15 +212,15 @@
 	struct ast_variable *i;
 
 	for (i = path_vars; i; i = i->next) {
-		if (strcmp(i->name, "recordingId") == 0) {
-			args.recording_id = (i->value);
+		if (strcmp(i->name, "recordingName") == 0) {
+			args.recording_name = (i->value);
 		} else
 		{}
 	}
 	stasis_http_pause_recording(headers, &args, response);
 }
 /*!
- * \brief Parameter parsing callback for /recordings/live/{recordingId}/unpause.
+ * \brief Parameter parsing callback for /recordings/live/{recordingName}/unpause.
  * \param get_params GET parameters in the HTTP request.
  * \param path_vars Path variables extracted from the request.
  * \param headers HTTP headers.
@@ -234,15 +234,15 @@
 	struct ast_variable *i;
 
 	for (i = path_vars; i; i = i->next) {
-		if (strcmp(i->name, "recordingId") == 0) {
-			args.recording_id = (i->value);
+		if (strcmp(i->name, "recordingName") == 0) {
+			args.recording_name = (i->value);
 		} else
 		{}
 	}
 	stasis_http_unpause_recording(headers, &args, response);
 }
 /*!
- * \brief Parameter parsing callback for /recordings/live/{recordingId}/mute.
+ * \brief Parameter parsing callback for /recordings/live/{recordingName}/mute.
  * \param get_params GET parameters in the HTTP request.
  * \param path_vars Path variables extracted from the request.
  * \param headers HTTP headers.
@@ -256,15 +256,15 @@
 	struct ast_variable *i;
 
 	for (i = path_vars; i; i = i->next) {
-		if (strcmp(i->name, "recordingId") == 0) {
-			args.recording_id = (i->value);
+		if (strcmp(i->name, "recordingName") == 0) {
+			args.recording_name = (i->value);
 		} else
 		{}
 	}
 	stasis_http_mute_recording(headers, &args, response);
 }
 /*!
- * \brief Parameter parsing callback for /recordings/live/{recordingId}/unmute.
+ * \brief Parameter parsing callback for /recordings/live/{recordingName}/unmute.
  * \param get_params GET parameters in the HTTP request.
  * \param path_vars Path variables extracted from the request.
  * \param headers HTTP headers.
@@ -278,8 +278,8 @@
 	struct ast_variable *i;
 
 	for (i = path_vars; i; i = i->next) {
-		if (strcmp(i->name, "recordingId") == 0) {
-			args.recording_id = (i->value);
+		if (strcmp(i->name, "recordingName") == 0) {
+			args.recording_name = (i->value);
 		} else
 		{}
 	}
@@ -287,8 +287,8 @@
 }
 
 /*! \brief REST handler for /api-docs/recordings.{format} */
-static struct stasis_rest_handlers recordings_stored_recordingId = {
-	.path_segment = "recordingId",
+static struct stasis_rest_handlers recordings_stored_recordingName = {
+	.path_segment = "recordingName",
 	.is_wildcard = 1,
 	.callbacks = {
 		[AST_HTTP_GET] = stasis_http_get_stored_recording_cb,
@@ -304,10 +304,10 @@
 		[AST_HTTP_GET] = stasis_http_get_stored_recordings_cb,
 	},
 	.num_children = 1,
-	.children = { &recordings_stored_recordingId, }
-};
-/*! \brief REST handler for /api-docs/recordings.{format} */
-static struct stasis_rest_handlers recordings_live_recordingId_stop = {
+	.children = { &recordings_stored_recordingName, }
+};
+/*! \brief REST handler for /api-docs/recordings.{format} */
+static struct stasis_rest_handlers recordings_live_recordingName_stop = {
 	.path_segment = "stop",
 	.callbacks = {
 		[AST_HTTP_POST] = stasis_http_stop_recording_cb,
@@ -316,7 +316,7 @@
 	.children = {  }
 };
 /*! \brief REST handler for /api-docs/recordings.{format} */
-static struct stasis_rest_handlers recordings_live_recordingId_pause = {
+static struct stasis_rest_handlers recordings_live_recordingName_pause = {
 	.path_segment = "pause",
 	.callbacks = {
 		[AST_HTTP_POST] = stasis_http_pause_recording_cb,
@@ -325,7 +325,7 @@
 	.children = {  }
 };
 /*! \brief REST handler for /api-docs/recordings.{format} */
-static struct stasis_rest_handlers recordings_live_recordingId_unpause = {
+static struct stasis_rest_handlers recordings_live_recordingName_unpause = {
 	.path_segment = "unpause",
 	.callbacks = {
 		[AST_HTTP_POST] = stasis_http_unpause_recording_cb,
@@ -334,7 +334,7 @@
 	.children = {  }
 };
 /*! \brief REST handler for /api-docs/recordings.{format} */
-static struct stasis_rest_handlers recordings_live_recordingId_mute = {
+static struct stasis_rest_handlers recordings_live_recordingName_mute = {
 	.path_segment = "mute",
 	.callbacks = {
 		[AST_HTTP_POST] = stasis_http_mute_recording_cb,
@@ -343,7 +343,7 @@
 	.children = {  }
 };
 /*! \brief REST handler for /api-docs/recordings.{format} */
-static struct stasis_rest_handlers recordings_live_recordingId_unmute = {
+static struct stasis_rest_handlers recordings_live_recordingName_unmute = {
 	.path_segment = "unmute",
 	.callbacks = {
 		[AST_HTTP_POST] = stasis_http_unmute_recording_cb,
@@ -352,15 +352,15 @@
 	.children = {  }
 };
 /*! \brief REST handler for /api-docs/recordings.{format} */
-static struct stasis_rest_handlers recordings_live_recordingId = {
-	.path_segment = "recordingId",
+static struct stasis_rest_handlers recordings_live_recordingName = {
+	.path_segment = "recordingName",
 	.is_wildcard = 1,
 	.callbacks = {
 		[AST_HTTP_GET] = stasis_http_get_live_recording_cb,
 		[AST_HTTP_DELETE] = stasis_http_cancel_recording_cb,
 	},
 	.num_children = 5,
-	.children = { &recordings_live_recordingId_stop,&recordings_live_recordingId_pause,&recordings_live_recordingId_unpause,&recordings_live_recordingId_mute,&recordings_live_recordingId_unmute, }
+	.children = { &recordings_live_recordingName_stop,&recordings_live_recordingName_pause,&recordings_live_recordingName_unpause,&recordings_live_recordingName_mute,&recordings_live_recordingName_unmute, }
 };
 /*! \brief REST handler for /api-docs/recordings.{format} */
 static struct stasis_rest_handlers recordings_live = {
@@ -369,7 +369,7 @@
 		[AST_HTTP_GET] = stasis_http_get_live_recordings_cb,
 	},
 	.num_children = 1,
-	.children = { &recordings_live_recordingId, }
+	.children = { &recordings_live_recordingName, }
 };
 /*! \brief REST handler for /api-docs/recordings.{format} */
 static struct stasis_rest_handlers recordings = {

Modified: team/dlee/record/res/res_stasis_recording.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/record/res/res_stasis_recording.c?view=diff&rev=389955&r1=389954&r2=389955
==============================================================================
--- team/dlee/record/res/res_stasis_recording.c (original)
+++ team/dlee/record/res/res_stasis_recording.c Tue May 28 14:46:19 2013
@@ -37,7 +37,6 @@
 #include "asterisk/stasis_app_impl.h"
 #include "asterisk/stasis_app_recording.h"
 #include "asterisk/stasis_channels.h"
-#include "asterisk/uuid.h"
 
 /*! Number of hash buckets for recording container. Keep it prime! */
 #define RECORDING_BUCKETS 127
@@ -49,7 +48,6 @@
 
 struct stasis_app_recording {
 	AST_DECLARE_STRING_FIELDS(
-		AST_STRING_FIELD(id);	/*!< Recording unique id */
 		AST_STRING_FIELD(name);
 		AST_STRING_FIELD(format);
 		);
@@ -72,7 +70,7 @@
 static int recording_hash(const void *obj, int flags)
 {
 	const struct stasis_app_recording *recording = obj;
-	const char *id = flags & OBJ_KEY ? obj : recording->id;
+	const char *id = flags & OBJ_KEY ? obj : recording->name;
 	return ast_str_hash(id);
 }
 
@@ -80,9 +78,9 @@
 {
 	struct stasis_app_recording *lhs = obj;
 	struct stasis_app_recording *rhs = arg;
-	const char *rhs_id = flags & OBJ_KEY ? arg : rhs->id;
-
-	if (strcmp(lhs->id, rhs_id) == 0) {
+	const char *rhs_id = flags & OBJ_KEY ? arg : rhs->name;
+
+	if (strcmp(lhs->name, rhs_id) == 0) {
 		return CMP_MATCH | CMP_STOP;
 	} else {
 		return 0;
@@ -113,7 +111,7 @@
 		return STASIS_APP_RECORDING_TERMINATE_NONE;
 	}
 
-	if (strcmp(str, "none")) {
+	if (strcmp(str, "none") == 0) {
 		return STASIS_APP_RECORDING_TERMINATE_NONE;
 	}
 
@@ -182,11 +180,18 @@
 	return res;
 }
 
+static void recording_cleanup(struct stasis_app_recording *recording)
+{
+	ao2_unlink_flags(recordings, recording,
+		OBJ_POINTER | OBJ_UNLINK | OBJ_NODATA);
+}
+
 static void *record_file(struct stasis_app_control *control,
 	struct ast_channel *chan, void *data)
 {
-	struct stasis_app_recording *recording = data;
-	struct ast_filestream *s;
+	RAII_VAR(struct stasis_app_recording *, recording,
+		NULL, recording_cleanup);
+	RAII_VAR(struct ast_filestream *, s, NULL, ast_closestream);
 	int res;
 	struct timeval start;
 	int ms;
@@ -194,8 +199,8 @@
 	int ioflags;
 	const char *comment = "Stasis recording";
 	int check = 0;
-	int terminated = 0;
-
+
+	recording = data;
 	ast_assert(recording != NULL);
 
 	ao2_lock(recording);
@@ -231,19 +236,26 @@
 	maxms = recording->max_duration_seconds * 1000;
 	start = ast_tvnow();
 	while ((ms = ast_remaining_ms(start, maxms))) {
+		int terminated = 0;
 		RAII_VAR(struct ast_frame *, f, NULL, ast_frame_dtor);
 
-		res = ast_waitfor(chan, ms);
-		if (res < 0) {
-			break;
-		}
-
-		if (maxms > 0 && res == 0) {
+		ms = ast_waitfor(chan, ms);
+		if (ms < 0) {
+			ast_debug(3, "%s: Error waiting for channel\n",
+				ast_channel_uniqueid(chan));
+			break;
+		}
+
+		if (maxms > 0 && ms == 0) {
+			ast_debug(3, "%s: Recording timed out\n",
+				ast_channel_uniqueid(chan));
 			break;
 		}
 
 		f = ast_read(chan);
 		if (!f) {
+			ast_debug(3, "%s: Error reading frame\n",
+				ast_channel_uniqueid(chan));
 			break;
 		}
 
@@ -264,18 +276,28 @@
 		}
 
 		if (terminated) {
+			ast_debug(3, "%s: Terminating recording\n",
+				ast_channel_uniqueid(chan));
 			break;
 		}
 
 		if (res != 0) {
-			break;
-		}
-	}
+			ast_debug(3, "%s: Error writing recording\n",
+				ast_channel_uniqueid(chan));
+			break;
+		}
+	}
+
+
+	ast_debug(3, "%s: Recording complete\n", ast_channel_uniqueid(chan));
 
 	ao2_lock(recording);
 	recording->state = STASIS_APP_RECORDING_STATE_COMPLETE;
 	recording_publish(recording);
 	ao2_unlock(recording);
+
+	ast_play_sound(chan, "beep"); /* TEMP - indication that recording is done */
+
 	return NULL;
 }
 
@@ -291,13 +313,15 @@
 	const struct stasis_app_recording_options *options)
 {
 	RAII_VAR(struct stasis_app_recording *, recording, NULL, ao2_cleanup);
-	char id[AST_UUID_STR_LEN];
+
+	errno = 0;
 
 	if (options == NULL ||
 		ast_strlen_zero(options->name) ||
 		ast_strlen_zero(options->format) ||
 		options->max_silence_seconds < 0 ||
 		options->max_duration_seconds < 0) {
+		errno = EINVAL;
 		return NULL;
 	}
 
@@ -307,12 +331,11 @@
 
 	recording = ao2_alloc(sizeof(*recording), recording_dtor);
 	if (!recording || ast_string_field_init(recording, 128)) {
-		return NULL;
-	}
-
-	ast_uuid_generate_str(id, sizeof(id));
+		errno = ENOMEM;
+		return NULL;
+	}
+
 	recording->control = control;
-	ast_string_field_set(recording, id, id);
 	ast_string_field_set(recording, name, options->name);
 	ast_string_field_set(recording, format, options->format);
 	recording->max_silence_seconds = options->max_silence_seconds;
@@ -320,9 +343,25 @@
 	recording->terminate_on = options->terminate_on;
 	recording->append = options->append;
 	recording->no_beep = options->no_beep;
-	ao2_link(recordings, recording);
-
 	recording->state = STASIS_APP_RECORDING_STATE_QUEUED;
+
+	{
+		RAII_VAR(struct stasis_app_recording *, old_recording, NULL,
+			ao2_cleanup);
+
+		SCOPED_AO2LOCK(lock, recordings);
+
+		old_recording = ao2_find(recordings, options->name,
+			OBJ_KEY | OBJ_NOLOCK);
+		if (old_recording) {
+			ast_log(LOG_WARNING,
+				"Recording %s already in progress\n",
+				recording->name);
+			errno = EEXIST;
+			return NULL;
+		}
+		ao2_link(recordings, recording);
+	}
 
 	/* A ref is kept in the recordings container; no need to bump */
 	stasis_app_send_command_async(control, record_file, recording);
@@ -338,17 +377,17 @@
 	return recording->state;
 }
 
-const char *stasis_app_recording_get_id(
+const char *stasis_app_recording_get_name(
 	struct stasis_app_recording *recording)
 {
-	return recording->id;
-}
-
-struct stasis_app_recording *stasis_app_recording_find_by_id(const char *id)
+	return recording->name;
+}
+
+struct stasis_app_recording *stasis_app_recording_find_by_name(const char *name)
 {
 	RAII_VAR(struct stasis_app_recording *, recording, NULL, ao2_cleanup);
 
-	recording = ao2_find(recordings, id, OBJ_KEY);
+	recording = ao2_find(recordings, name, OBJ_KEY);
 	if (recording == NULL) {
 		return NULL;
 	}
@@ -366,8 +405,7 @@
 		return NULL;
 	}
 
-	json = ast_json_pack("{s: s, s: s, s: s, s: s}",
-		"id", recording->id,
+	json = ast_json_pack("{s: s, s: s, s: s}",
 		"name", recording->name,
 		"format", recording->format,
 		"state", state_to_string(recording->state));

Modified: team/dlee/record/res/stasis_http/resource_channels.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/record/res/stasis_http/resource_channels.c?view=diff&rev=389955&r1=389954&r2=389955
==============================================================================
--- team/dlee/record/res/stasis_http/resource_channels.c (original)
+++ team/dlee/record/res/stasis_http/resource_channels.c Tue May 28 14:46:19 2013
@@ -220,6 +220,8 @@
 	RAII_VAR(char *, recording_url, NULL, ast_free);
 	RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
 	struct stasis_app_recording_options options = {};
+	RAII_VAR(char *, uri_encoded_name, NULL, ast_free);
+	size_t uri_name_maxlen;
 
 	ast_assert(response != NULL);
 
@@ -247,6 +249,7 @@
 	options.format = args->format;
 	options.max_silence_seconds = args->max_silence_seconds;
 	options.max_duration_seconds = args->max_duration_seconds;
+	options.append = args->append;
 	options.terminate_on =
 		stasis_app_recording_termination_parse(args->terminate_on);
 
@@ -265,8 +268,18 @@
 		return;
 	}
 
-	ast_asprintf(&recording_url, "/recording/%s",
-		stasis_app_recording_get_id(recording));
+	uri_name_maxlen = strlen(args->name) * 3;
+	uri_encoded_name = ast_malloc(uri_name_maxlen);
+	if (!uri_encoded_name) {
+		stasis_http_response_error(
+			response, 500, "Internal Server Error",
+			"Out of memory");
+		return;
+	}
+	ast_uri_encode(args->name, uri_encoded_name, uri_name_maxlen,
+		ast_uri_http);
+
+	ast_asprintf(&recording_url, "/recordings/live/%s", uri_encoded_name);
 	if (!recording_url) {
 		stasis_http_response_error(
 			response, 500, "Internal Server Error",

Modified: team/dlee/record/res/stasis_http/resource_recordings.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/record/res/stasis_http/resource_recordings.c?view=diff&rev=389955&r1=389954&r2=389955
==============================================================================
--- team/dlee/record/res/stasis_http/resource_recordings.c (original)
+++ team/dlee/record/res/stasis_http/resource_recordings.c Tue May 28 14:46:19 2013
@@ -58,7 +58,7 @@
 	RAII_VAR(struct stasis_app_recording *, recording, NULL, ao2_cleanup);
 	RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
 
-	recording = stasis_app_recording_find_by_id(args->recording_id);
+	recording = stasis_app_recording_find_by_name(args->recording_name);
 	if (recording == NULL) {
 		stasis_http_response_error(response, 404, "Not Found",
 			"Recording not found");

Modified: team/dlee/record/res/stasis_http/resource_recordings.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/record/res/stasis_http/resource_recordings.h?view=diff&rev=389955&r1=389954&r2=389955
==============================================================================
--- team/dlee/record/res/stasis_http/resource_recordings.h (original)
+++ team/dlee/record/res/stasis_http/resource_recordings.h Tue May 28 14:46:19 2013
@@ -63,8 +63,8 @@
 void stasis_http_get_stored_recordings(struct ast_variable *headers, struct ast_get_stored_recordings_args *args, struct stasis_http_response *response);
 /*! \brief Argument struct for stasis_http_get_stored_recording() */
 struct ast_get_stored_recording_args {
-	/*! \brief Recording's id */
-	const char *recording_id;
+	/*! \brief The name of the recording */
+	const char *recording_name;
 };
 /*!
  * \brief Get a stored recording's details.
@@ -76,8 +76,8 @@
 void stasis_http_get_stored_recording(struct ast_variable *headers, struct ast_get_stored_recording_args *args, struct stasis_http_response *response);
 /*! \brief Argument struct for stasis_http_delete_stored_recording() */
 struct ast_delete_stored_recording_args {
-	/*! \brief Recording's id */
-	const char *recording_id;
+	/*! \brief The name of the recording */
+	const char *recording_name;
 };
 /*!
  * \brief Delete a stored recording.
@@ -100,8 +100,8 @@
 void stasis_http_get_live_recordings(struct ast_variable *headers, struct ast_get_live_recordings_args *args, struct stasis_http_response *response);
 /*! \brief Argument struct for stasis_http_get_live_recording() */
 struct ast_get_live_recording_args {
-	/*! \brief Recording's id */
-	const char *recording_id;
+	/*! \brief The name of the recording */
+	const char *recording_name;
 };
 /*!
  * \brief List live recordings.
@@ -113,8 +113,8 @@
 void stasis_http_get_live_recording(struct ast_variable *headers, struct ast_get_live_recording_args *args, struct stasis_http_response *response);
 /*! \brief Argument struct for stasis_http_cancel_recording() */
 struct ast_cancel_recording_args {
-	/*! \brief Recording's id */
-	const char *recording_id;
+	/*! \brief The name of the recording */
+	const char *recording_name;
 };
 /*!
  * \brief Stop a live recording and discard it.
@@ -126,8 +126,8 @@
 void stasis_http_cancel_recording(struct ast_variable *headers, struct ast_cancel_recording_args *args, struct stasis_http_response *response);
 /*! \brief Argument struct for stasis_http_stop_recording() */
 struct ast_stop_recording_args {
-	/*! \brief Recording's id */
-	const char *recording_id;
+	/*! \brief The name of the recording */
+	const char *recording_name;
 };
 /*!
  * \brief Stop a live recording and store it.
@@ -139,8 +139,8 @@
 void stasis_http_stop_recording(struct ast_variable *headers, struct ast_stop_recording_args *args, struct stasis_http_response *response);
 /*! \brief Argument struct for stasis_http_pause_recording() */
 struct ast_pause_recording_args {
-	/*! \brief Recording's id */
-	const char *recording_id;
+	/*! \brief The name of the recording */
+	const char *recording_name;
 };
 /*!
  * \brief Pause a live recording.
@@ -152,8 +152,8 @@
 void stasis_http_pause_recording(struct ast_variable *headers, struct ast_pause_recording_args *args, struct stasis_http_response *response);
 /*! \brief Argument struct for stasis_http_unpause_recording() */
 struct ast_unpause_recording_args {
-	/*! \brief Recording's id */
-	const char *recording_id;
+	/*! \brief The name of the recording */
+	const char *recording_name;
 };
 /*!
  * \brief Unpause a live recording.
@@ -165,8 +165,8 @@
 void stasis_http_unpause_recording(struct ast_variable *headers, struct ast_unpause_recording_args *args, struct stasis_http_response *response);
 /*! \brief Argument struct for stasis_http_mute_recording() */
 struct ast_mute_recording_args {
-	/*! \brief Recording's id */
-	const char *recording_id;
+	/*! \brief The name of the recording */
+	const char *recording_name;
 };
 /*!
  * \brief Mute a live recording.
@@ -178,8 +178,8 @@
 void stasis_http_mute_recording(struct ast_variable *headers, struct ast_mute_recording_args *args, struct stasis_http_response *response);
 /*! \brief Argument struct for stasis_http_unmute_recording() */
 struct ast_unmute_recording_args {
-	/*! \brief Recording's id */
-	const char *recording_id;
+	/*! \brief The name of the recording */
+	const char *recording_name;
 };
 /*!
  * \brief Unmute a live recording.

Modified: team/dlee/record/rest-api/api-docs/recordings.json
URL: http://svnview.digium.com/svn/asterisk/team/dlee/record/rest-api/api-docs/recordings.json?view=diff&rev=389955&r1=389954&r2=389955
==============================================================================
--- team/dlee/record/rest-api/api-docs/recordings.json (original)
+++ team/dlee/record/rest-api/api-docs/recordings.json Tue May 28 14:46:19 2013
@@ -32,7 +32,7 @@
 			]
 		},
 		{
-			"path": "/recordings/stored/{recordingId}",
+			"path": "/recordings/stored/{recordingName}",
 			"description": "Individual recording",
 			"operations": [
 				{
@@ -42,8 +42,8 @@
 					"responseClass": "StoredRecording",
 					"parameters": [
 						{
-							"name": "recordingId",
-							"description": "Recording's id",
+							"name": "recordingName",
+							"description": "The name of the recording",
 							"paramType": "path",
 							"required": true,
 							"allowMultiple": false,
@@ -58,8 +58,8 @@
 					"responseClass": "void",
 					"parameters": [
 						{
-							"name": "recordingId",
-							"description": "Recording's id",
+							"name": "recordingName",
+							"description": "The name of the recording",
 							"paramType": "path",
 							"required": true,
 							"allowMultiple": false,
@@ -82,7 +82,7 @@
 			]
 		},
 		{
-			"path": "/recordings/live/{recordingId}",
+			"path": "/recordings/live/{recordingName}",
 			"description": "A recording that is in progress",
 			"operations": [
 				{
@@ -92,8 +92,8 @@
 					"responseClass": "LiveRecording",
 					"parameters": [
 						{
-							"name": "recordingId",
-							"description": "Recording's id",
+							"name": "recordingName",
+							"description": "The name of the recording",
 							"paramType": "path",
 							"required": true,
 							"allowMultiple": false,
@@ -108,19 +108,19 @@
 					"responseClass": "void",
 					"parameters": [
 						{
-							"name": "recordingId",
-							"description": "Recording's id",
-							"paramType": "path",
-							"required": true,
-							"allowMultiple": false,
-							"dataType": "string"
-						}
-					]
-				}
-			]
-		},
-		{
-			"path": "/recordings/live/{recordingId}/stop",
+							"name": "recordingName",
+							"description": "The name of the recording",
+							"paramType": "path",
+							"required": true,
+							"allowMultiple": false,
+							"dataType": "string"
+						}
+					]
+				}
+			]
+		},
+		{
+			"path": "/recordings/live/{recordingName}/stop",
 			"operations": [
 				{
 					"httpMethod": "POST",
@@ -129,19 +129,19 @@
 					"responseClass": "void",
 					"parameters": [
 						{
-							"name": "recordingId",
-							"description": "Recording's id",
-							"paramType": "path",
-							"required": true,
-							"allowMultiple": false,
-							"dataType": "string"
-						}
-					]
-				}
-			]
-		},
-		{
-			"path": "/recordings/live/{recordingId}/pause",
+							"name": "recordingName",
+							"description": "The name of the recording",
+							"paramType": "path",
+							"required": true,
+							"allowMultiple": false,
+							"dataType": "string"
+						}
+					]
+				}
+			]
+		},
+		{
+			"path": "/recordings/live/{recordingName}/pause",
 			"operations": [
 				{
 					"httpMethod": "POST",
@@ -150,19 +150,19 @@
 					"responseClass": "void",
 					"parameters": [
 						{
-							"name": "recordingId",
-							"description": "Recording's id",
-							"paramType": "path",
-							"required": true,
-							"allowMultiple": false,
-							"dataType": "string"
-						}
-					]
-				}
-			]
-		},
-		{
-			"path": "/recordings/live/{recordingId}/unpause",
+							"name": "recordingName",
+							"description": "The name of the recording",
+							"paramType": "path",
+							"required": true,
+							"allowMultiple": false,
+							"dataType": "string"
+						}
+					]
+				}
+			]
+		},
+		{
+			"path": "/recordings/live/{recordingName}/unpause",
 			"operations": [
 				{
 					"httpMethod": "POST",
@@ -171,19 +171,19 @@
 					"responseClass": "void",
 					"parameters": [
 						{
-							"name": "recordingId",
-							"description": "Recording's id",
-							"paramType": "path",
-							"required": true,
-							"allowMultiple": false,
-							"dataType": "string"
-						}
-					]
-				}
-			]
-		},
-		{
-			"path": "/recordings/live/{recordingId}/mute",
+							"name": "recordingName",
+							"description": "The name of the recording",
+							"paramType": "path",
+							"required": true,
+							"allowMultiple": false,
+							"dataType": "string"
+						}
+					]
+				}
+			]
+		},
+		{
+			"path": "/recordings/live/{recordingName}/mute",
 			"operations": [
 				{
 					"httpMethod": "POST",
@@ -192,19 +192,19 @@
 					"responseClass": "void",
 					"parameters": [
 						{
-							"name": "recordingId",
-							"description": "Recording's id",
-							"paramType": "path",
-							"required": true,
-							"allowMultiple": false,
-							"dataType": "string"
-						}
-					]
-				}
-			]
-		},
-		{
-			"path": "/recordings/live/{recordingId}/unmute",
+							"name": "recordingName",
+							"description": "The name of the recording",
+							"paramType": "path",
+							"required": true,
+							"allowMultiple": false,
+							"dataType": "string"
+						}
+					]
+				}
+			]
+		},
+		{
+			"path": "/recordings/live/{recordingName}/unmute",
 			"operations": [
 				{
 					"httpMethod": "POST",
@@ -213,8 +213,8 @@
 					"responseClass": "void",
 					"parameters": [
 						{
-							"name": "recordingId",
-							"description": "Recording's id",
+							"name": "recordingName",
+							"description": "The name of the recording",
 							"paramType": "path",
 							"required": true,
 							"allowMultiple": false,




More information about the asterisk-commits mailing list