| 46 | } |
| 47 | |
| 48 | _parseNalUnit(index) { |
| 49 | const firstByte = this._data[index]; |
| 50 | if (firstByte & 0x80) { |
| 51 | throw new Error('H264 parsing sanity check failed, forbidden zero bit is set'); |
| 52 | } |
| 53 | const unitType = firstByte & 0x1f; |
| 54 | |
| 55 | switch (unitType) { |
| 56 | case 1: // coded slice, non-idr |
| 57 | return { slice: true }; |
| 58 | case 5: // coded slice, idr |
| 59 | return { slice: true, key: true }; |
| 60 | case 6: // sei |
| 61 | return {}; |
| 62 | case 7: // sps |
| 63 | this._parseSps(index + 1); |
| 64 | return {}; |
| 65 | case 8: // pps |
| 66 | return {}; |
| 67 | default: |
| 68 | Log.Warn("Unhandled unit type: ", unitType); |
| 69 | break; |
| 70 | } |
| 71 | return {}; |
| 72 | } |
| 73 | |
| 74 | parse() { |
| 75 | const startIndex = this._index; |