(data: Uint8Array)
| 104 | }; |
| 105 | |
| 106 | const removeEmulationPreventionBytes = (data: Uint8Array) => { |
| 107 | const result: number[] = []; |
| 108 | const len = data.length; |
| 109 | |
| 110 | for (let i = 0; i < len; i++) { |
| 111 | // Look for the 0x000003 pattern |
| 112 | if (i + 2 < len && data[i] === 0x00 && data[i + 1] === 0x00 && data[i + 2] === 0x03) { |
| 113 | result.push(0x00, 0x00); // Push the first two bytes |
| 114 | i += 2; // Skip the 0x03 byte |
| 115 | } else { |
| 116 | result.push(data[i]); |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | return new Uint8Array(result); |
| 121 | }; |
| 122 | |
| 123 | /** Parses an AVC SPS (Sequence Parameter Set) to extract basic information. */ |
| 124 | export const parseAvcSps = (sps: Uint8Array): AvcSpsInfo | null => { |
no outgoing calls
no test coverage detected