wiretap: Add MP4 reader
Allows opening MP4 (ISO/IEC 14496-12) media files in Wireshark and viewing their structure. Change-Id: Ie20b8b89dc69bb52d6faa890e547d90317adecf6 Reviewed-on: https://code.wireshark.org/review/35804 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
parent
5b861d84f8
commit
ce8e6e1c95
|
@ -812,6 +812,7 @@ proto_reg_handoff_mp4(void)
|
|||
dissector_handle_t mp4_handle = create_dissector_handle(dissect_mp4, proto_mp4);
|
||||
dissector_add_string("media_type", "video/mp4", mp4_handle);
|
||||
dissector_add_string("media_type", "audio/mp4", mp4_handle);
|
||||
dissector_add_uint("wtap_encap", WTAP_ENCAP_MP4, mp4_handle);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@ set(WIRETAP_NONGENERATED_FILES
|
|||
logcat.c
|
||||
logcat_text.c
|
||||
merge.c
|
||||
mp4.c
|
||||
mpeg.c
|
||||
mplog.c
|
||||
mime_file.c
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include "k12.h"
|
||||
#include "ber.h"
|
||||
#include "catapult_dct2000.h"
|
||||
#include "mp4.h"
|
||||
#include "mp2t.h"
|
||||
#include "mpeg.h"
|
||||
#include "netscreen.h"
|
||||
|
@ -152,6 +153,7 @@ static const struct file_extension_info file_type_extensions_base[] = {
|
|||
{ "Transport-Neutral Encapsulation Format", FALSE, "tnef" },
|
||||
{ "JPEG/JFIF files", FALSE, "jpg;jpeg;jfif" },
|
||||
{ "JavaScript Object Notation file", FALSE, "json" },
|
||||
{ "MP4 file", FALSE, "mp4" },
|
||||
};
|
||||
|
||||
#define N_FILE_TYPE_EXTENSIONS (sizeof file_type_extensions_base / sizeof file_type_extensions_base[0])
|
||||
|
@ -430,6 +432,7 @@ static const struct open_info open_info_base[] = {
|
|||
{ "Ruby Marshal Object", OPEN_INFO_HEURISTIC, ruby_marshal_open, "", NULL, NULL },
|
||||
{ "Systemd Journal", OPEN_INFO_HEURISTIC, systemd_journal_open, "log;jnl;journal", NULL, NULL },
|
||||
{ "3gpp phone log", OPEN_INFO_MAGIC, log3gpp_open, "log", NULL, NULL },
|
||||
{ "MP4 media file", OPEN_INFO_MAGIC, mp4_open, "mp4", NULL, NULL },
|
||||
|
||||
};
|
||||
|
||||
|
@ -1665,6 +1668,11 @@ static const struct file_type_subtype_info dump_open_table_base[] = {
|
|||
/* WTAP_FILE_TYPE_SUBTYPE_LOG_3GPP */
|
||||
{ "3GPP Log", "3gpp_log", "*.log", NULL,
|
||||
TRUE, FALSE, 0,
|
||||
NULL, NULL, NULL },
|
||||
|
||||
/* WTAP_FILE_TYPE_SUBTYPE_MP4 */
|
||||
{ "MP4 media", "mp4", "mp4", NULL,
|
||||
FALSE, FALSE, 0,
|
||||
NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
/* mp4.c
|
||||
*
|
||||
* MP4 (ISO/IEC 14496-12) file format decoder for the Wiretap library.
|
||||
*
|
||||
* Wiretap Library
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "mp4.h"
|
||||
|
||||
#include "file_wrappers.h"
|
||||
#include "wtap-int.h"
|
||||
|
||||
static const guint8 mp4_magic[] = { 'f', 't', 'y', 'p' };
|
||||
|
||||
wtap_open_return_val
|
||||
mp4_open(wtap *wth, int *err, gchar **err_info)
|
||||
{
|
||||
char magic_buf[8];
|
||||
int bytes_read;
|
||||
|
||||
bytes_read = file_read(magic_buf, sizeof (magic_buf), wth->fh);
|
||||
|
||||
if (bytes_read < 0) {
|
||||
*err = file_error(wth->fh, err_info);
|
||||
return WTAP_OPEN_ERROR;
|
||||
}
|
||||
if (bytes_read == 0)
|
||||
return WTAP_OPEN_NOT_MINE;
|
||||
|
||||
if (bytes_read == sizeof (magic_buf) &&
|
||||
memcmp(magic_buf + 4, mp4_magic, sizeof (mp4_magic)))
|
||||
return WTAP_OPEN_NOT_MINE;
|
||||
|
||||
if (file_seek(wth->fh, 0, SEEK_SET, err) == -1)
|
||||
return WTAP_OPEN_ERROR;
|
||||
|
||||
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_MP4;
|
||||
wth->file_encap = WTAP_ENCAP_MP4;
|
||||
wth->file_tsprec = WTAP_TSPREC_SEC;
|
||||
wth->subtype_read = wtap_full_file_read;
|
||||
wth->subtype_seek_read = wtap_full_file_seek_read;
|
||||
wth->snapshot_length = 0;
|
||||
|
||||
return WTAP_OPEN_MINE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines - https://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
* Local variables:
|
||||
* c-basic-offset: 8
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*
|
||||
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
|
||||
* :indentSize=8:tabSize=8:noTabs=false:
|
||||
*/
|
|
@ -0,0 +1,16 @@
|
|||
/* mp4.h
|
||||
*
|
||||
* MP4 (ISO/IEC 14496-12) file format decoder for the Wiretap library.
|
||||
*
|
||||
* Wiretap Library
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef __W_MP4_H__
|
||||
#define __W_MP4_H__
|
||||
|
||||
#include "wtap.h"
|
||||
|
||||
wtap_open_return_val mp4_open(wtap *wth, int *err, gchar **err_info);
|
||||
|
||||
#endif
|
|
@ -289,6 +289,7 @@ extern "C" {
|
|||
#define WTAP_ENCAP_IEEE802_15_4_TAP 206
|
||||
#define WTAP_ENCAP_LOG_3GPP 207
|
||||
#define WTAP_ENCAP_USB_2_0 208
|
||||
#define WTAP_ENCAP_MP4 209
|
||||
|
||||
/* After adding new item here, please also add new item to encap_table_base array */
|
||||
|
||||
|
@ -385,6 +386,7 @@ extern "C" {
|
|||
#define WTAP_FILE_TYPE_SUBTYPE_RUBY_MARSHAL 83
|
||||
#define WTAP_FILE_TYPE_SUBTYPE_SYSTEMD_JOURNAL 84
|
||||
#define WTAP_FILE_TYPE_SUBTYPE_LOG_3GPP 85
|
||||
#define WTAP_FILE_TYPE_SUBTYPE_MP4 86
|
||||
|
||||
#define WTAP_NUM_FILE_TYPES_SUBTYPES wtap_get_num_file_types_subtypes()
|
||||
|
||||
|
|
Loading…
Reference in New Issue