[gnome-shell/gnome-3-6] shell-recorder-src: Set frame duration
- From: Adel Gadllah <agadllah src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/gnome-3-6] shell-recorder-src: Set frame duration
- Date: Mon, 19 Nov 2012 18:28:57 +0000 (UTC)
commit a2b8b969bd15c73e7f6f398138dbf7a8375f5aef
Author: Adel Gadllah <adel gadllah gmail com>
Date: Mon Nov 19 18:50:39 2012 +0100
shell-recorder-src: Set frame duration
We where not setting a duration for the frames, which caused the resulting videos to
have a broken header.
Fix that by making the source a live source and setting the correct frame duration.
https://bugzilla.gnome.org/show_bug.cgi?id=688487
src/shell-recorder-src.c | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/src/shell-recorder-src.c b/src/shell-recorder-src.c
index 5b52b25..5e325cf 100644
--- a/src/shell-recorder-src.c
+++ b/src/shell-recorder-src.c
@@ -14,6 +14,9 @@ struct _ShellRecorderSrc
GMutex mutex_data;
GMutex *mutex;
+ GstClock *clock;
+ GstClockTime last_frame_time;
+
GstCaps *caps;
GAsyncQueue *queue;
gboolean closed;
@@ -41,6 +44,10 @@ static void
shell_recorder_src_init (ShellRecorderSrc *src)
{
gst_base_src_set_format (GST_BASE_SRC (src), GST_FORMAT_TIME);
+ gst_base_src_set_live (GST_BASE_SRC (src), TRUE);
+
+ src->clock = gst_system_clock_obtain ();
+ src->last_frame_time = 0;
src->queue = g_async_queue_new ();
src->mutex = &src->mutex_data;
@@ -89,6 +96,10 @@ shell_recorder_src_create (GstPushSrc *push_src,
return GST_FLOW_EOS;
buffer = g_async_queue_pop (src->queue);
+
+ if (src->last_frame_time == 0)
+ src->last_frame_time = gst_clock_get_time (GST_CLOCK (src->clock));
+
if (buffer == RECORDER_QUEUE_END)
{
/* Returning UNEXPECTED here will cause a EOS message to be sent */
@@ -100,6 +111,9 @@ shell_recorder_src_create (GstPushSrc *push_src,
- (int)(gst_buffer_get_size(buffer) / 1024));
*buffer_out = buffer;
+ GST_BUFFER_DURATION(*buffer_out) = GST_CLOCK_DIFF (src->last_frame_time, gst_clock_get_time (GST_CLOCK (src->clock)));
+
+ src->last_frame_time = gst_clock_get_time (GST_CLOCK (src->clock));
return GST_FLOW_OK;
}
@@ -141,6 +155,8 @@ shell_recorder_src_finalize (GObject *object)
g_mutex_clear (src->mutex);
+ gst_object_unref (src->clock);
+
G_OBJECT_CLASS (shell_recorder_src_parent_class)->finalize (object);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]