shithub: mcfs

Download patch

ref: b4251305f9b6bce681362c77600c43190aa42e34
parent: 31d938838631fd5bed124d0d760507530145db48
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Mon Sep 21 18:13:16 EDT 2020

ebml: show mp3 tracks

--- a/common.h
+++ b/common.h
@@ -13,6 +13,7 @@
 	/* fake ones, not supposed to show up in a mp4 */
 	FmtVorbis = 0x766f7262u,
 	FmtSrt = 0x00737274u, /* srt subtitles */
+	FmtMp3 = 0x006d7033u,
 };
 
 typedef struct Ebml Ebml;
@@ -86,9 +87,12 @@
 int ebmlrun(Biobuf *f);
 
 u32int crc32(u32int init, u8int *d, ulong len);
+
 int ivfpacket(Biobuf *out, Packetctx *ctx, Packet *p, int np, uvlong ts);
 int oggpacket(Biobuf *out, Packetctx *ctx, Packet *p, int np, uvlong ts);
 int srtpacket(Biobuf *out, Packetctx *ctx, Packet *p, int np, uvlong ts);
+int mp3packet(Biobuf *out, Packetctx *ctx, Packet *p, int np, uvlong ts);
+
 int ebmlint(Biobuf *f, vlong *out, int isid);
 vlong ebmlel(Biobuf *f, vlong sz, vlong *id, vlong *esz);
 vlong ebmlrawint(Biobuf *f, vlong sz, vlong *dst);
--- a/ebml.c
+++ b/ebml.c
@@ -139,6 +139,9 @@
 	if(e->tracktype == 17){
 		if(strcmp(e->codec.name, "S_TEXT/UTF8") == 0)
 			return "srt";
+	}else if(e->tracktype == 2){
+		if(strcmp(e->codec.name, "A_MPEG/L3") == 0)
+			return "mp3";
 	}
 
 	n = snprint(t, sizeof(t), "%s", e->codec.name+2);
@@ -176,6 +179,11 @@
 		if(strcmp(c, "opus") == 0){
 			e->fmt = FmtOpus;
 			e->fpacket = oggpacket;
+			return 0;
+		}
+		if(strcmp(c, "mp3") == 0){
+			e->fmt = FmtMp3;
+			e->fpacket = mp3packet;
 			return 0;
 		}
 	}else if(e->tracktype == 17){
--- a/mkfile
+++ b/mkfile
@@ -11,6 +11,7 @@
 	iso.$O\
 	ivf.$O\
 	main.$O\
+	mp3.$O\
 	ogg.$O\
 	srt.$O\
 
--- /dev/null
+++ b/mp3.c
@@ -1,0 +1,12 @@
+#include <u.h>
+#include <libc.h>
+#include <bio.h>
+#include "common.h"
+
+int
+mp3packet(Biobuf *out, Packetctx *ctx, Packet *p, int np, uvlong ts)
+{
+	USED(out, ctx, p, np, ts);
+	werrstr("mp3packet not implemented");
+	return -1;
+}