diff --git a/lib/contribute/container.ts b/lib/contribute/container.ts index a1f853c..eac8683 100644 --- a/lib/contribute/container.ts +++ b/lib/contribute/container.ts @@ -72,7 +72,7 @@ export class Container { } this.#track = this.#mp4.addTrack(options) - if (!this.#track) throw new Error("failed to initialize MP4 track") + if (!this.#track || !this.#mp4.ftyp || !this.#mp4.moov) throw new Error("failed to initialize MP4 track") const buffer = MP4.ISOFile.writeInitializationSegment(this.#mp4.ftyp, this.#mp4.moov, 0, 0) const data = new Uint8Array(buffer) diff --git a/lib/media/mp4/index.ts b/lib/media/mp4/index.ts index f12087c..0625198 100644 --- a/lib/media/mp4/index.ts +++ b/lib/media/mp4/index.ts @@ -27,6 +27,8 @@ MP4.BoxParser.dOpsBox.prototype.write = function (stream: MP4.Stream) { stream.writeInt16(this.OutputGain) stream.writeUint8(this.ChannelMappingFamily) + if (!this.StreamCount || !this.CoupledCount) throw new Error("failed to write dOps box") + if (this.ChannelMappingFamily !== 0) { stream.writeUint8(this.StreamCount) stream.writeUint8(this.CoupledCount) diff --git a/lib/transport/control.ts b/lib/transport/control.ts index ee1c9c8..ae5dd2c 100644 --- a/lib/transport/control.ts +++ b/lib/transport/control.ts @@ -309,6 +309,7 @@ export class Decoder { case Msg.SubscribeError: return this.subscribe_error() case Msg.SubscribeDone: + return this.subscribe_done() case Msg.Unsubscribe: return this.unsubscribe() case Msg.Announce: