shithub: riscv

Download patch

ref: 7fbd3fd4fea60d3d0252dcceb20deed7cdca3873
parent: 06786f2a71cb5330e63cf50ba7eed8278b31c07f
author: Alex Musolino <alex@musolino.id.au>
date: Fri Nov 1 08:05:11 EDT 2019

file: add (very) basic support for detecting mpeg4 formats

--- a/sys/src/cmd/file.c
+++ b/sys/src/cmd/file.c
@@ -152,6 +152,7 @@
 int	islimbo(void);
 int	istga(void);
 int	ismp3(void);
+int	ismp4(void);
 int	ismung(void);
 int	isp9bit(void);
 int	isp9font(void);
@@ -201,6 +202,7 @@
 	isface,		/* ascii face file */
 	istga,
 	ismp3,
+	ismp4,
 
 	/* last resorts */
 	ismung,		/* entropy compressed/encrypted */
@@ -1238,6 +1240,24 @@
 			return 1;
 		}
 		p++;
+	}
+	return 0;
+}
+
+int
+ismp4(void)
+{
+	if(nbuf <= 12)
+		return 0;
+	if(memcmp(&buf[4], "ftyp", 4) != 0)
+		return 0;
+	if(memcmp(&buf[8], "isom", 4) == 0){
+		print("%s\n", mime ? "video/mp4" : "mp4 video");
+		return 1;
+	}
+	if(memcmp(&buf[8], "M4A ", 4) == 0){
+		print("%s\n", mime ? "audio/m4a" : "m4a audio");
+		return 1;
 	}
 	return 0;
 }