From 7130fbc1c98e7949f4f4f5f7e4bb90b72292b494 Mon Sep 17 00:00:00 2001 From: Santiago Souto Date: Tue, 12 Nov 2024 15:47:14 -0300 Subject: [PATCH] Fix types causing errors on metadata view and publish --- packages/millicast-sdk/src/View.ts | 5 +++-- packages/millicast-sdk/src/utils/Codecs.ts | 2 +- packages/millicast-sdk/src/workers/TransformWorker.worker.ts | 5 +++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/millicast-sdk/src/View.ts b/packages/millicast-sdk/src/View.ts index 2a96587e..c99236c9 100644 --- a/packages/millicast-sdk/src/View.ts +++ b/packages/millicast-sdk/src/View.ts @@ -29,6 +29,7 @@ import { } from './types/View.types.js' import { DRMProfile } from './types/Director.types' import { DecodedJWT, Media } from './types/BaseWebRTC.types' +import { VideoCodec } from './types/Codecs.types' const logger = Logger.get('View') logger.setLevel(Logger.DEBUG) @@ -486,7 +487,7 @@ export default class View extends BaseWebRTC { trackEvent.receiver.transform = new RTCRtpScriptTransform(this.worker, { name: 'receiverTransform', payloadTypeCodec: { ...this.payloadTypeCodec }, - codec: this.options.metadata && 'h264', + codec: this.options.metadata && VideoCodec.H264, mid: trackEvent.transceiver?.mid, }) } else if (supportsInsertableStreams) { @@ -496,7 +497,7 @@ export default class View extends BaseWebRTC { { action: 'insertable-streams-receiver', payloadTypeCodec: { ...this.payloadTypeCodec }, - codec: this.options.metadata && 'h264', + codec: this.options.metadata && VideoCodec.H264, mid: trackEvent.transceiver?.mid, readable, writable, diff --git a/packages/millicast-sdk/src/utils/Codecs.ts b/packages/millicast-sdk/src/utils/Codecs.ts index 54c308b5..d19adb06 100644 --- a/packages/millicast-sdk/src/utils/Codecs.ts +++ b/packages/millicast-sdk/src/utils/Codecs.ts @@ -653,7 +653,7 @@ function numberToByteArray(num: number) { if (!isNaN(num)) { const bigint = BigInt(num) for (let i = 0; i < Math.ceil(Math.floor(Math.log2(num) + 1) / 8); i++) { - array.unshift(((bigint >> BigInt(8 * i)) & BigInt(255)) as unknown as number) + array.unshift(Number((bigint >> BigInt(8 * i)) & BigInt(255))) } } return new Uint8Array(array) diff --git a/packages/millicast-sdk/src/workers/TransformWorker.worker.ts b/packages/millicast-sdk/src/workers/TransformWorker.worker.ts index b15af890..4fb2b0f6 100644 --- a/packages/millicast-sdk/src/workers/TransformWorker.worker.ts +++ b/packages/millicast-sdk/src/workers/TransformWorker.worker.ts @@ -26,8 +26,8 @@ function createReceiverTransform(mid: string) { // eslint-disable-next-line no-undef if (encodedFrame instanceof RTCEncodedVideoFrame) { const payloadType = encodedFrame.getMetadata().payloadType - const frameCodec = payloadType ? payloadTypeCodec[payloadType] : codec - if (frameCodec === 'H264') { + const frameCodec = payloadType ? payloadTypeCodec[payloadType].toLowerCase() : codec + if (frameCodec === VideoCodec.H264) { const metadata = extractH26xMetadata(encodedFrame, frameCodec as VideoCodec) if ( metadata.timecode || @@ -96,6 +96,7 @@ function createSenderTransform(): TransformStream { if (metadata[0].uuid === DOLBY_SDK_TIMESTAMP_UUID) { metadata[0].timecode = Date.now() } + console.log('Metadata:', metadata[0]) addH26xSEI(metadata[0], encodedFrame) synchronizationSourcesWithMetadata.push(newSyncSource) } catch (error) {