tests/contents/utils/patchSegmentWithTimeOffset.js
/**
   * Generate new timestamps for tfdt and change size of boxes above if needed.
   * Try to keep in 32 bits if possible.
   * @param input
   */
Generate new timestamps for tfdt and change size of boxes above if needed.
Try to keep in 32 bits if possible.
@param input
Generate new timestamps for tfdt and change size of boxes above if needed . Try to keep in 32 bits if possible . @param input
function patchTfdt(input) {
    const version = input[8];
    const tfdtOffset = timeOffset;
    let newBaseMediaDecodeTime;
    let output;
    if (version === 0) {
      const baseMediaDecodeTime = be4toi(input, 12);
      newBaseMediaDecodeTime = baseMediaDecodeTime + tfdtOffset;
      if (newBaseMediaDecodeTime < 4294967296) {
        output = concat(input.subarray(0, 12), itobe4(newBaseMediaDecodeTime));
      } else {
        sizeChange = 4;
        output = concat(
          itobe4(be4toi(input, 0) + sizeChange),
          input.subarray(4, 8),
          new Uint8Array([1]),
          input.subarray(9, 12),
          itobe8(newBaseMediaDecodeTime)
        );
      }
    } else { 
      const baseMediaDecodeTime = be8toi(input, 12);
      newBaseMediaDecodeTime = baseMediaDecodeTime + tfdtOffset;
      output = concat(input.subarray(0, 12), itobe8(newBaseMediaDecodeTime));
    }
    return output;
  }
function patchTfdt ( input ) { const version = input [ 8 ] ; const tfdtOffset = timeOffset ; let newBaseMediaDecodeTime ; let output ; if ( version === 0 ) { const baseMediaDecodeTime = be4toi ( input , 12 ) ; newBaseMediaDecodeTime = baseMediaDecodeTime + tfdtOffset ; if ( newBaseMediaDecodeTime < 4294967296 ) { output = concat ( input . subarray ( 0 , 12 ) , itobe4 ( newBaseMediaDecodeTime ) ) ; } else { sizeChange = 4 ; output = concat ( itobe4 ( be4toi ( input , 0 ) + sizeChange ) , input . subarray ( 4 , 8 ) , new Uint8Array ( [ 1 ] ) , input . subarray ( 9 , 12 ) , itobe8 ( newBaseMediaDecodeTime ) ) ; } } else { const baseMediaDecodeTime = be8toi ( input , 12 ) ; newBaseMediaDecodeTime = baseMediaDecodeTime + tfdtOffset ; output = concat ( input . subarray ( 0 , 12 ) , itobe8 ( newBaseMediaDecodeTime ) ) ; } return output ; }
Generate new timestamps for tfdt and change size of boxes above if needed.
Generate new timestamps for tfdt and change size of boxes above if needed .
// 32-bit baseMediaDecodeTime // Forced to change to 64-bit tfdt. // 64-bit