mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 01:45:33 +00:00
pcapparse: Support pcap with nanosecond timestamps
https://bugzilla.gnome.org/show_bug.cgi?id=785770
This commit is contained in:
parent
4064683d36
commit
111921ae70
2 changed files with 20 additions and 3 deletions
|
@ -55,6 +55,13 @@
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
const guint GST_PCAPPARSE_MAGIC_MILLISECOND_NO_SWAP_ENDIAN = 0xa1b2c3d4;
|
||||||
|
const guint GST_PCAPPARSE_MAGIC_NANOSECOND_NO_SWAP_ENDIAN = 0xa1b23c4d;
|
||||||
|
const guint GST_PCAPPARSE_MAGIC_MILLISECOND_SWAP_ENDIAN = 0xd4c3b2a1;
|
||||||
|
const guint GST_PCAPPARSE_MAGIC_NANOSECOND_SWAP_ENDIAN = 0x4d3cb2a1;
|
||||||
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
|
@ -309,6 +316,7 @@ gst_pcap_parse_reset (GstPcapParse * self)
|
||||||
{
|
{
|
||||||
self->initialized = FALSE;
|
self->initialized = FALSE;
|
||||||
self->swap_endian = FALSE;
|
self->swap_endian = FALSE;
|
||||||
|
self->nanosecond_timestamp = FALSE;
|
||||||
self->cur_packet_size = -1;
|
self->cur_packet_size = -1;
|
||||||
self->cur_ts = GST_CLOCK_TIME_NONE;
|
self->cur_ts = GST_CLOCK_TIME_NONE;
|
||||||
self->base_ts = GST_CLOCK_TIME_NONE;
|
self->base_ts = GST_CLOCK_TIME_NONE;
|
||||||
|
@ -535,7 +543,9 @@ gst_pcap_parse_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
||||||
gst_adapter_unmap (self->adapter);
|
gst_adapter_unmap (self->adapter);
|
||||||
gst_adapter_flush (self->adapter, 16);
|
gst_adapter_flush (self->adapter, 16);
|
||||||
|
|
||||||
self->cur_ts = ts_sec * GST_SECOND + ts_usec * GST_USECOND;
|
self->cur_ts =
|
||||||
|
ts_sec * GST_SECOND +
|
||||||
|
ts_usec * (self->nanosecond_timestamp ? 1 : GST_USECOND);
|
||||||
self->cur_packet_size = incl_len;
|
self->cur_packet_size = incl_len;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -553,10 +563,16 @@ gst_pcap_parse_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
||||||
linktype = *((guint32 *) (data + 20));
|
linktype = *((guint32 *) (data + 20));
|
||||||
gst_adapter_unmap (self->adapter);
|
gst_adapter_unmap (self->adapter);
|
||||||
|
|
||||||
if (magic == 0xa1b2c3d4) {
|
if (magic == GST_PCAPPARSE_MAGIC_MILLISECOND_NO_SWAP_ENDIAN ||
|
||||||
|
magic == GST_PCAPPARSE_MAGIC_NANOSECOND_NO_SWAP_ENDIAN) {
|
||||||
self->swap_endian = FALSE;
|
self->swap_endian = FALSE;
|
||||||
} else if (magic == 0xd4c3b2a1) {
|
if (magic == GST_PCAPPARSE_MAGIC_NANOSECOND_NO_SWAP_ENDIAN)
|
||||||
|
self->nanosecond_timestamp = TRUE;
|
||||||
|
} else if (magic == GST_PCAPPARSE_MAGIC_MILLISECOND_SWAP_ENDIAN ||
|
||||||
|
magic == GST_PCAPPARSE_MAGIC_NANOSECOND_SWAP_ENDIAN) {
|
||||||
self->swap_endian = TRUE;
|
self->swap_endian = TRUE;
|
||||||
|
if (magic == GST_PCAPPARSE_MAGIC_NANOSECOND_SWAP_ENDIAN)
|
||||||
|
self->nanosecond_timestamp = TRUE;
|
||||||
major_version = GUINT16_SWAP_LE_BE (major_version);
|
major_version = GUINT16_SWAP_LE_BE (major_version);
|
||||||
linktype = GUINT32_SWAP_LE_BE (linktype);
|
linktype = GUINT32_SWAP_LE_BE (linktype);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -78,6 +78,7 @@ struct _GstPcapParse
|
||||||
GstAdapter * adapter;
|
GstAdapter * adapter;
|
||||||
gboolean initialized;
|
gboolean initialized;
|
||||||
gboolean swap_endian;
|
gboolean swap_endian;
|
||||||
|
gboolean nanosecond_timestamp;
|
||||||
gint64 cur_packet_size;
|
gint64 cur_packet_size;
|
||||||
GstClockTime cur_ts;
|
GstClockTime cur_ts;
|
||||||
GstClockTime base_ts;
|
GstClockTime base_ts;
|
||||||
|
|
Loading…
Reference in a new issue