优化目录

This commit is contained in:
Harvey Zack committed 2018-12-21 14:53:36 +08:00
1 parent 32b2f4792a
commit a2125a2634
7 files changed
+15 -18

No files matched your search

@@ -10,7 +10,7 @@ export default function getMetaData(scripTag) {
errorHandle(amf1.type === 2, `AMF: [amf1] type expect 2, but got ${amf1.type}`);
amf1.size = getUint8Sum(readScripTag(2));
amf1.string = bin2String(readScripTag(amf1.size));
[amf2.type] = readScripTag(1);
errorHandle(amf2.type === 8, `AMF: [amf1] type expect 8, but got ${amf2.type}`);
amf2.size = getUint8Sum(readScripTag(4));
@@ -78,6 +78,7 @@ export default function getMetaData(scripTag) {
break;
}
default:
console.log(readScripTag(scripTag.body.length - readScripTag.index - 1));
errorHandle(false, `AMF: Unknown metaData type: ${type}`);
break;
}
@@ -85,8 +85,6 @@ export default class FlvParse {
this.flv.emit('flvParseTag', tag);
}
this.flv.emit('flvParseTags', this.tags);
if (this.tags.length > 1 && this.tags[0].tagType === 18 && !this.metadata) {
this.metadata = getMetaData(this.tags[0]);
this.flv.emit('parseMetadata', this.metadata);
@@ -1,5 +1,4 @@
export default function readFile(flv, file) {
console.log(file);
flv.emit('flvFetchStart');
const { proxy } = flv.events;
const reader = new FileReader();
@@ -0,0 +1,9 @@
export default class FlvError extends Error {
constructor(message, context) {
super(message);
if (typeof Error.captureStackTrace === 'function') {
Error.captureStackTrace(this, context || this.constructor);
}
this.name = 'FlvError';
}
}
@@ -1,12 +1,4 @@
export class FlvError extends Error {
constructor(message, context) {
super(message);
if (typeof Error.captureStackTrace === 'function') {
Error.captureStackTrace(this, context || this.constructor);
}
this.name = 'FlvError';
}
}
import FlvError from './flvError';
export function errorHandle(condition, msg) {
if (!condition) {