flv.bend checks
raw source on the hub · import 0x2355f41b6f5561f50104a75ccca27cf7/flv.bend as Flv
The frames inside RTMP's tags (the forms FLV keeps them in):
video H.264: a codec byte (frame type and 7 for AVC), a packet type, a 24-bit time offset; then either the configuration (the parameter sets, and how many bytes a size takes), or a picture's NAL units, each after its size. H.265, as enhanced RTMP carries it: a byte with its top bit set (frame type and packet type), the four letters "hvc1", and the same two things: the configuration, or a picture, with the time offset (packet type 1) or without (type 3). audio a format byte, then: for AAC (10), a packet type and either the configuration (profile, rate, channels) or one frame; for G.711 (7 the A-law, 8 the mu-law), the samples.
A picture comes out in Annex B form, the parameter sets in front of each key picture; an AAC frame after its ADTS header; G.711 as it is. Times are the tags' (ms, plus the video's offset), from the first one seen, in 90 kHz ticks. Other codecs are passed over.
5 imports
import Base import ./bytes.bend as B import ./rtmp_core.bend as K import ./frame.bend as F import ./audio.bend as U
Types
type Flv source · line 29 · raw
Data
lens: the bytes of a NAL unit's size. sets: the parameter sets. obj, freq, chan: the audio's configuration. sound: the audio's codec once known ("AAC", "PCMA", "PCMU"). base: the first time seen (based: one was). video: the video's codec ("H264" until the stream says "H265").
Flv@lens:U32 -> @sets:List<&2, U32> -> @obj:U32 -> @freq:U32 -> @chan:U32 -> @sound:String -> @base:U32 -> @based:Bool -> @video:String -> Flv
type Out source · line 34 · raw
Data
What a tag gave: its frames (none, or one), and the state after.
Out@frames:List<&2, 0x2355f41b6f5561f50104a75ccca27cf7/frame.Frame> -> @st:Flv -> Out
Definitions
def Flv.new source · line 37 · raw
Flv
def Flv.info source · line 42 · raw
@st:Flv -> 0x2355f41b6f5561f50104a75ccca27cf7/frame.Info
What is known of the stream so far (the audio's configuration comes before the first picture when there is audio).
def Flv.sets.cut source · line 46 · raw
@c:0x2355f41b6f5561f50104a75ccca27cf7/bytes.Cut -> @acc:List<&2, U32> -> @k:(@_:List<&2, U32> -> @_:List<&2, U32> -> List<&2, U32>) -> List<&2, U32>
def Flv.sets source · line 56 · raw
@n:Nat -> @bs:List<&2, U32> -> @acc:List<&2, U32> -> @k:(@_:List<&2, U32> -> @_:List<&2, U32> -> List<&2, U32>) -> List<&2, U32>
count parameter sets, each after a 16-bit size, onto acc in Annex B form, the last first; then what follows them.
def Flv.pps source · line 65 · raw
@bs:List<&2, U32> -> @acc:List<&2, U32> -> List<&2, U32>
def Flv.avcc source · line 75 · raw
@bs:List<&2, U32> -> List<&2, U32>
The parameter sets of an AVCDecoderConfigurationRecord, after its first five bytes: the SPS count in 5 bits, the SPSs, the PPS count, the PPSs.
def Flv.nals.cut source · line 83 · raw
@c:0x2355f41b6f5561f50104a75ccca27cf7/bytes.Cut -> @acc:List<&2, U32> -> @k:(@_:List<&2, U32> -> @_:List<&2, U32> -> List<&2, U32>) -> List<&2, U32>
def Flv.nals.at source · line 91 · raw
@+bs:List<&2, U32> -> @+lens:U32 -> @acc:List<&2, U32> -> @k:(@_:List<&2, U32> -> @_:List<&2, U32> -> List<&2, U32>) -> List<&2, U32>
def Flv.nals source · line 98 · raw
@fuel:Nat -> @+lens:U32 -> @bs:List<&2, U32> -> @acc:List<&2, U32> -> List<&2, U32>
A picture's NAL units, each after its size in lens bytes, onto acc in Annex B form, the last first. Every unit takes at least a byte.
def Flv.ticks source · line 108 · raw
@+ms:U32 -> @+base:U32 -> U32
ms since the base, in 90 kHz ticks; a time before the base (audio and video do not come in strict order) is the base.
def Flv.cts source · line 112 · raw
@a:U32 -> @b:U32 -> @c:U32 -> U32
A 24-bit time offset as a U32 to add: a negative one wraps around.
def Flv.picture source · line 116 · raw
@+key:Bool -> @+ts:U32 -> @cts:U32 -> @+body:List<&2, U32> -> @st:Flv -> Out
def Flv.config source · line 125 · raw
@body:List<&2, U32> -> @st:Flv -> Out
H.264's configuration (an AVCDecoderConfigurationRecord).
def Flv.arrays source · line 136 · raw
@n:Nat -> @bs:List<&2, U32> -> @acc:List<&2, U32> -> List<&2, U32>
The arrays of an HEVCDecoderConfigurationRecord: each a type byte, a 16-bit count, and that many parameter sets (VPS, SPS, PPS).
def Flv.hvcc.at source · line 144 · raw
@bs:List<&2, U32> -> @st:Flv -> Out
def Flv.hvcc source · line 156 · raw
@body:List<&2, U32> -> @st:Flv -> Out
H.265's configuration: after 21 bytes of profile and level, how many bytes a size takes, the number of arrays, and the arrays.
def Flv.timed source · line 159 · raw
@body:List<&2, U32> -> @key:Bool -> @ts:U32 -> @st:Flv -> Out
def Flv.video.kind source · line 166 · raw
@avc:Bool -> @kind:Nat -> @key:Bool -> @ts:U32 -> @body:List<&2, U32> -> @st:Flv -> Out
def Flv.hevc source · line 178 · raw
@hvc1:Bool -> @kind:Nat -> @key:Bool -> @ts:U32 -> @body:List<&2, U32> -> @st:Flv -> Out
An enhanced tag of H.265: packet type 0 is the configuration, 1 a picture after its time offset, 3 a picture with none.
def Flv.video.by source · line 190 · raw
@ex:Bool -> @+b0:U32 -> @rest:List<&2, U32> -> @ts:U32 -> @st:Flv -> Out
def Flv.video source · line 203 · raw
@data:List<&2, U32> -> @ts:U32 -> @st:Flv -> Out
A video tag: the first byte's top bit says it is an enhanced one.
def Flv.sound source · line 210 · raw
@+ts:U32 -> @+body:List<&2, U32> -> @st:Flv -> Out
def Flv.asc source · line 219 · raw
@body:List<&2, U32> -> @st:Flv -> Out
The audio's configuration: 5 bits of object type, 4 of rate index, 4 of channels.
def Flv.aac source · line 229 · raw
@data:List<&2, U32> -> @ts:U32 -> @st:Flv -> Out
def Flv.g711 source · line 239 · raw
@name:String -> @+ts:U32 -> @samples:List<&2, U32> -> @st:Flv -> Out
G.711: the samples as they are, one channel.
def Flv.audio.by source · line 245 · raw
@format:Nat -> @rest:List<&2, U32> -> @ts:U32 -> @st:Flv -> Out
def Flv.audio source · line 257 · raw
@data:List<&2, U32> -> @ts:U32 -> @st:Flv -> Out
An audio tag: the format is the first byte's top 4 bits.
def Flv.typed source · line 264 · raw
@video:Bool -> @audio:Bool -> @data:List<&2, U32> -> @ts:U32 -> @st:Flv -> Out
def Flv.frames source · line 274 · raw
@st:Flv -> @t:0x2355f41b6f5561f50104a75ccca27cf7/rtmp_core.Tag -> Out
A tag into the state: the frame it holds, if it holds one.