Skip to content

Commit

Permalink
fix: Metadata types causing errors upon publish and subscribe (#477)
Browse files Browse the repository at this point in the history
  • Loading branch information
Santiago Souto authored Nov 18, 2024
1 parent e70294f commit 0cfb5af
Show file tree
Hide file tree
Showing 3 changed files with 6 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
4 changes: 2 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

0 comments on commit 0cfb5af

Please sign in to comment.