matroskamux: Use nanosecond precision for DateUTC

DateUTC is specified with nanosecond precision in matroska, make use of
that.
This commit is contained in:
Linus Svensson 2018-05-31 11:20:36 +02:00
parent 3bd544418c
commit 0690bd1b21
4 changed files with 9 additions and 7 deletions

View file

@ -22,6 +22,8 @@
#ifndef __GST_EBML_IDS_H__
#define __GST_EBML_IDS_H__
#include <glib.h>
G_BEGIN_DECLS
/* EBML version supported */
@ -46,8 +48,8 @@ G_BEGIN_DECLS
#define GST_EBML_ID_VOID 0xEC
#define GST_EBML_ID_CRC32 0xBF
/* EbmlDate offset from the unix epoch in seconds, 2001/01/01 00:00:00 UTC */
#define GST_EBML_DATE_OFFSET 978307200
/* EbmlDate offset from the unix epoch in nanoseconds, 2001/01/01 00:00:00 UTC */
#define GST_EBML_DATE_OFFSET G_GINT64_CONSTANT (978307200000000000)
G_END_DECLS

View file

@ -628,7 +628,7 @@ gst_ebml_read_utf8 (GstEbmlRead * ebml, guint32 * id, gchar ** str)
/*
* Read the next element as a date.
* Returns the seconds since the unix epoch.
* Returns the nanoseconds since the unix epoch.
*/
GstFlowReturn
@ -641,7 +641,7 @@ gst_ebml_read_date (GstEbmlRead * ebml, guint32 * id, gint64 * date)
if (ret != GST_FLOW_OK)
return ret;
*date = (ebml_date / GST_SECOND) + GST_EBML_DATE_OFFSET;
*date = ebml_date + GST_EBML_DATE_OFFSET;
return ret;
}

View file

@ -721,14 +721,14 @@ gst_ebml_write_utf8 (GstEbmlWrite * ebml, guint32 id, const gchar * str)
* gst_ebml_write_date:
* @ebml: #GstEbmlWrite
* @id: Element ID.
* @date: Date in seconds since the unix epoch.
* @date: Date in nanoseconds since the unix epoch.
*
* Write date element.
*/
void
gst_ebml_write_date (GstEbmlWrite * ebml, guint32 id, gint64 date)
{
gst_ebml_write_sint (ebml, id, (date - GST_EBML_DATE_OFFSET) * GST_SECOND);
gst_ebml_write_sint (ebml, id, date - GST_EBML_DATE_OFFSET);
}
/**

View file

@ -3098,7 +3098,7 @@ gst_matroska_mux_start (GstMatroskaMux * mux, GstMatroskaPad * first_pad,
gst_ebml_write_utf8 (ebml, GST_MATROSKA_ID_WRITINGAPP, mux->writing_app);
}
gst_ebml_write_date (ebml, GST_MATROSKA_ID_DATEUTC,
g_get_real_time () / G_USEC_PER_SEC);
g_get_real_time () * GST_USECOND);
gst_ebml_write_master_finish (ebml, master);
/* tracks */