aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/mpeg.c
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2014-05-08 22:59:19 -0400
committerMichael Mann <mmann78@netscape.net>2014-05-09 03:04:39 +0000
commit1abeb277f5e6bd27fbaebfecc8184e37ba9d008a (patch)
tree8cc6eaa5a6982454a00adc600fa4aab02bec3d73 /wiretap/mpeg.c
parentaa3a968eb6e85c47014a4cec4a2b955357b0e77f (diff)
Refactor Wiretap
Start of refactoring Wiretap and breaking structures down into "generally useful fields for dissection" and "capture specific". Since this in intended as a "base" for Wiretap and Filetap, the "wft" prefix is used for "common" functionality. The "architectural" changes can be found in cfile.h, wtap.h, wtap-int.h and (new file) wftap-int.h. Most of the other (painstaking) changes were really just the result of compiling those new architecture changes. bug:9607 Change-Id: Ife858a61760d7a8a03be073546c0e7e582cab2ae Reviewed-on: https://code.wireshark.org/review/1485 Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'wiretap/mpeg.c')
-rw-r--r--wiretap/mpeg.c43
1 files changed, 23 insertions, 20 deletions
diff --git a/wiretap/mpeg.c b/wiretap/mpeg.c
index abe87a37fe..2d7404700b 100644
--- a/wiretap/mpeg.c
+++ b/wiretap/mpeg.c
@@ -33,6 +33,7 @@
#include "mpeg.h"
#include "wsutil/mpeg-audio.h"
+#include "wftap-int.h"
#include "wtap-int.h"
#include "buffer.h"
#include "file_wrappers.h"
@@ -92,10 +93,10 @@ mpeg_read_header(FILE_T fh, int *err, gchar **err_info, guint32 *n)
#define SCRHZ 27000000
static gboolean
-mpeg_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
+mpeg_read_packet(wftap *wfth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
gboolean is_random, int *err, gchar **err_info)
{
- mpeg_t *mpeg = (mpeg_t *)wth->priv;
+ mpeg_t *mpeg = (mpeg_t *)wfth->priv;
guint32 n;
int bytes_read;
unsigned int packet_size;
@@ -221,23 +222,25 @@ mpeg_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
}
static gboolean
-mpeg_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
+mpeg_read(wftap *wfth, int *err, gchar **err_info, gint64 *data_offset)
{
- *data_offset = file_tell(wth->fh);
+ wtap* wth = (wtap*)wfth->tap_specific_data;
+ *data_offset = file_tell(wfth->fh);
- return mpeg_read_packet(wth, wth->fh, &wth->phdr, wth->frame_buffer,
+ return mpeg_read_packet(wfth, wfth->fh, &wth->phdr, wfth->frame_buffer,
FALSE, err, err_info);
}
static gboolean
-mpeg_seek_read(wtap *wth, gint64 seek_off,
- struct wtap_pkthdr *phdr, Buffer *buf,
+mpeg_seek_read(wftap *wfth, gint64 seek_off,
+ void* header, Buffer *buf,
int *err, gchar **err_info)
{
- if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
+ struct wtap_pkthdr *phdr = (struct wtap_pkthdr *)header;
+ if (file_seek(wfth->random_fh, seek_off, SEEK_SET, err) == -1)
return FALSE;
- if (!mpeg_read_packet(wth, wth->random_fh, phdr, buf, TRUE, err,
+ if (!mpeg_read_packet(wfth, wfth->random_fh, phdr, buf, TRUE, err,
err_info)) {
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
@@ -258,7 +261,7 @@ struct _mpeg_magic {
};
int
-mpeg_open(wtap *wth, int *err, gchar **err_info)
+mpeg_open(wftap *wfth, int *err, gchar **err_info)
{
int bytes_read;
char magic_buf[16];
@@ -266,9 +269,9 @@ mpeg_open(wtap *wth, int *err, gchar **err_info)
mpeg_t *mpeg;
errno = WTAP_ERR_CANT_READ;
- bytes_read = file_read(magic_buf, sizeof magic_buf, wth->fh);
+ bytes_read = file_read(magic_buf, sizeof magic_buf, wfth->fh);
if (bytes_read != (int) sizeof magic_buf) {
- *err = file_error(wth->fh, err_info);
+ *err = file_error(wfth->fh, err_info);
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
return -1;
return 0;
@@ -283,18 +286,18 @@ mpeg_open(wtap *wth, int *err, gchar **err_info)
good_magic:
/* This appears to be a file with MPEG data. */
- if (file_seek(wth->fh, 0, SEEK_SET, err) == -1)
+ if (file_seek(wfth->fh, 0, SEEK_SET, err) == -1)
return -1;
- wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_MPEG;
- wth->file_encap = WTAP_ENCAP_MPEG;
- wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
- wth->subtype_read = mpeg_read;
- wth->subtype_seek_read = mpeg_seek_read;
- wth->snapshot_length = 0;
+ wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_MPEG;
+ wfth->file_encap = WTAP_ENCAP_MPEG;
+ wfth->tsprecision = WTAP_FILE_TSPREC_NSEC;
+ wfth->subtype_read = mpeg_read;
+ wfth->subtype_seek_read = mpeg_seek_read;
+ wfth->snapshot_length = 0;
mpeg = (mpeg_t *)g_malloc(sizeof(mpeg_t));
- wth->priv = (void *)mpeg;
+ wfth->priv = (void *)mpeg;
mpeg->now.secs = 0;
mpeg->now.nsecs = 0;
mpeg->t0 = mpeg->now.secs;