queue2: remove deprecated temp-location use, make it read-only

This commit is contained in:
Tim-Philipp Müller 2012-07-06 10:07:56 +01:00
parent b23185a73a
commit 41a762adb3

View file

@ -46,10 +46,8 @@
* By using this, it will buffer the entire stream data on the file independently * By using this, it will buffer the entire stream data on the file independently
* of the queue size limits, they will only be used for buffering statistics. * of the queue size limits, they will only be used for buffering statistics.
* *
* Since 0.10.24, setting the temp-location property with a filename is deprecated * The temp-location property will be used to notify the application of the
* because it's impossible to securely open a temporary file in this way. The * allocated filename.
* property will still be used to notify the application of the allocated
* filename, though.
* *
* Last reviewed on 2009-07-10 (0.10.24) * Last reviewed on 2009-07-10 (0.10.24)
*/ */
@ -98,7 +96,7 @@ enum
/* other defines */ /* other defines */
#define DEFAULT_BUFFER_SIZE 4096 #define DEFAULT_BUFFER_SIZE 4096
#define QUEUE_IS_USING_TEMP_FILE(queue) ((queue)->temp_location_set || (queue)->temp_template != NULL) #define QUEUE_IS_USING_TEMP_FILE(queue) ((queue)->temp_template != NULL)
#define QUEUE_IS_USING_RING_BUFFER(queue) ((queue)->ring_buffer_max_size != 0) /* for consistency with the above macro */ #define QUEUE_IS_USING_RING_BUFFER(queue) ((queue)->ring_buffer_max_size != 0) /* for consistency with the above macro */
#define QUEUE_IS_USING_QUEUE(queue) (!QUEUE_IS_USING_TEMP_FILE(queue) && !QUEUE_IS_USING_RING_BUFFER (queue)) #define QUEUE_IS_USING_QUEUE(queue) (!QUEUE_IS_USING_TEMP_FILE(queue) && !QUEUE_IS_USING_RING_BUFFER (queue))
@ -334,9 +332,9 @@ gst_queue2_class_init (GstQueue2Class * klass)
g_object_class_install_property (gobject_class, PROP_TEMP_LOCATION, g_object_class_install_property (gobject_class, PROP_TEMP_LOCATION,
g_param_spec_string ("temp-location", "Temporary File Location", g_param_spec_string ("temp-location", "Temporary File Location",
"Location to store temporary files in (Deprecated: Only read this " "Location to store temporary files in (Only read this property, "
"property, use temp-template to configure the name template)", "use temp-template to configure the name template)",
NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); NULL, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
/** /**
* GstQueue2:temp-remove * GstQueue2:temp-remove
@ -451,7 +449,6 @@ gst_queue2_init (GstQueue2 * queue)
/* tempfile related */ /* tempfile related */
queue->temp_template = NULL; queue->temp_template = NULL;
queue->temp_location = NULL; queue->temp_location = NULL;
queue->temp_location_set = FALSE;
queue->temp_remove = DEFAULT_TEMP_REMOVE; queue->temp_remove = DEFAULT_TEMP_REMOVE;
queue->ring_buffer = NULL; queue->ring_buffer = NULL;
@ -1374,45 +1371,34 @@ gst_queue2_open_temp_location_file (GstQueue2 * queue)
GST_DEBUG_OBJECT (queue, "opening temp file %s", queue->temp_template); GST_DEBUG_OBJECT (queue, "opening temp file %s", queue->temp_template);
/* we have two cases: /* If temp_template was set, allocate a filename and open that filen */
* - temp_location was set to something !NULL (Deprecated). in this case we
* open the specified filename.
* - temp_template was set, allocate a filename and open that filename
*/
if (!queue->temp_location_set) {
/* nothing to do */
if (queue->temp_template == NULL)
goto no_directory;
/* make copy of the template, we don't want to change this */ /* nothing to do */
name = g_strdup (queue->temp_template); if (queue->temp_template == NULL)
fd = g_mkstemp (name); goto no_directory;
if (fd == -1)
goto mkstemp_failed;
/* open the file for update/writing */ /* make copy of the template, we don't want to change this */
queue->temp_file = fdopen (fd, "wb+"); name = g_strdup (queue->temp_template);
/* error creating file */ fd = g_mkstemp (name);
if (queue->temp_file == NULL) if (fd == -1)
goto open_failed; goto mkstemp_failed;
g_free (queue->temp_location); /* open the file for update/writing */
queue->temp_location = name; queue->temp_file = fdopen (fd, "wb+");
/* error creating file */
if (queue->temp_file == NULL)
goto open_failed;
GST_QUEUE2_MUTEX_UNLOCK (queue); g_free (queue->temp_location);
queue->temp_location = name;
/* we can't emit the notify with the lock */ GST_QUEUE2_MUTEX_UNLOCK (queue);
g_object_notify (G_OBJECT (queue), "temp-location");
/* we can't emit the notify with the lock */
g_object_notify (G_OBJECT (queue), "temp-location");
GST_QUEUE2_MUTEX_LOCK (queue);
GST_QUEUE2_MUTEX_LOCK (queue);
} else {
/* open the file for update/writing, this is deprecated but we still need to
* support it for API/ABI compatibility */
queue->temp_file = g_fopen (queue->temp_location, "wb+");
/* error creating file */
if (queue->temp_file == NULL)
goto open_failed;
}
GST_DEBUG_OBJECT (queue, "opened temp file %s", queue->temp_template); GST_DEBUG_OBJECT (queue, "opened temp file %s", queue->temp_template);
return TRUE; return TRUE;
@ -3199,13 +3185,6 @@ gst_queue2_set_property (GObject * object,
case PROP_TEMP_TEMPLATE: case PROP_TEMP_TEMPLATE:
gst_queue2_set_temp_template (queue, g_value_get_string (value)); gst_queue2_set_temp_template (queue, g_value_get_string (value));
break; break;
case PROP_TEMP_LOCATION:
g_free (queue->temp_location);
queue->temp_location = g_value_dup_string (value);
/* you can set the property back to NULL to make it use the temp-template
* property. */
queue->temp_location_set = queue->temp_location != NULL;
break;
case PROP_TEMP_REMOVE: case PROP_TEMP_REMOVE:
queue->temp_remove = g_value_get_boolean (value); queue->temp_remove = g_value_get_boolean (value);
break; break;