forked from mccoyst/ogg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
header.go
48 lines (40 loc) · 1.06 KB
/
header.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// © 2014 Steve McCoy under the MIT license. See LICENSE for details.
/*
Package ogg implements encoding and decoding of OGG streams as defined in
http://xiph.org/ogg/doc/rfc3533.txt
and
http://xiph.org/ogg/doc/framing.html .
*/
package ogg
import (
"encoding/binary"
"hash/crc32"
)
const MIMEType = "application/ogg"
const headsz = 27
// max segment size
const mss = 255
// max packet size
const mps = mss * 255
// == 65307, per the RFC
const maxPageSize = headsz + mss + mps
var ByteOrder = binary.LittleEndian
type pageHeader struct {
OggS [4]byte // 0-3, always == "OggS"
StreamVersion byte // 4, always == 0
HeaderType byte // 5
Granule int64 // 6-13, codec-specific
Serial uint32 // 14-17, associated with a logical stream
Page uint32 // 18-21, sequence number of page in packet
Crc uint32 // 22-25
Nsegs byte // 26
}
const (
// Continuation of packet
COP byte = 1 + iota
// Beginning of stream
BOS = 1 << iota
// End of stream
EOS = 1 << iota
)
var crcTable = crc32.MakeTable(0x04c11db7)