codec-parser
Advanced tools
Comparing version 2.1.0 to 2.2.0
@@ -140,2 +140,3 @@ declare type OggMimeType = "application/ogg" | "audio/ogg"; | ||
enableLogging?: boolean; | ||
enableFrameCRC32?: boolean; | ||
} | ||
@@ -142,0 +143,0 @@ |
{ | ||
"name": "codec-parser", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "Library that parses raw data from audio codecs into frames containing data, header values, duration, and other information.", | ||
@@ -39,6 +39,6 @@ "main": "index.js", | ||
"devDependencies": { | ||
"@types/jest": "^28.1.3", | ||
"jest": "^28.1.1", | ||
"@types/jest": "^28.1.6", | ||
"jest": "^28.1.3", | ||
"prettier": "^2.7.1" | ||
} | ||
} |
@@ -174,2 +174,3 @@ # Codec Parser | ||
* `options.enableLogging` *optional* Set to true to enable warning and error messages. | ||
* `options.enableFrameCRC32` *optional* Set to false to disable the crc32 calculation for each frame. This will save a marginal amount of execution time if you don't need this information. | ||
@@ -176,0 +177,0 @@ ### Methods |
@@ -29,3 +29,11 @@ /* Copyright 2020-2022 Ethan Halsall | ||
export default class CodecParser { | ||
constructor(mimeType, { onCodecUpdate, onCodec, enableLogging } = {}) { | ||
constructor( | ||
mimeType, | ||
{ | ||
onCodecUpdate, | ||
onCodec, | ||
enableLogging = false, | ||
enableFrameCRC32 = true, | ||
} = {} | ||
) { | ||
this._inputMimeType = mimeType; | ||
@@ -35,2 +43,3 @@ this._onCodec = onCodec || noOp; | ||
this._enableLogging = enableLogging; | ||
this._crc32 = enableFrameCRC32 ? crc32 : noOp; | ||
@@ -171,3 +180,3 @@ this._generator = this._getGenerator(); | ||
frame.totalDuration = (this._totalSamples / this._sampleRate) * 1000; | ||
frame.crc32 = crc32(frame.data); | ||
frame.crc32 = this._crc32(frame.data); | ||
@@ -174,0 +183,0 @@ this._headerCache.checkCodecUpdate( |
133966
2970
403