Skip to content

Commit

Permalink
Fix types causing errors on metadata view and publish
Browse files Browse the repository at this point in the history
  • Loading branch information
Santiago-Souto committed Nov 12, 2024
1 parent e70294f commit 7130fbc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions packages/millicast-sdk/src/View.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion packages/millicast-sdk/src/utils/Codecs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions packages/millicast-sdk/src/workers/TransformWorker.worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 7130fbc

Please sign in to comment.