2.2.4.7 TrunBox

The TrunBox field and related fields encapsulate per-sample metadata for the requested fragment. The syntax of TrunBox is a strict subset of the syntax of the Track Fragment Run Box that is defined in [ISO/IEC-14496-12].

TrunBox (variable): The container for per-sample metadata.

TrunBoxLength (4 bytes): The length of the TrunBox field, in bytes, including the TrunBoxLength field. If the value of the TrunBoxLength field is %00.00.00.01, the TrunBoxLongLength field MUST be present.

TrunBoxLongLength (8 bytes): The length of the TrunBox field, in bytes, including the TrunBoxLongLength field.

SampleCount (4 bytes): The number of samples in the fragment.

DataOffset (4 bytes): This field MUST be set. It specifies the offset from the beginning of the MoofBox field (section 2.2.4.1). If only one TrunBox is specified, then the DataOffset field MUST be the sum of the lengths of the MoofBox and all the fields in the MdatBox field (section 2.2.4.8).

FirstSampleFlagsPresent (1 bit): Indicates that the default flags for the first sample are replaced if this field takes the value %b1.

SampleSizePresent (1 bit): Indicates that each sample has its own size if this field takes the value %b1. If this field is not present, the default value that is specified by the DefaultSampleSize field is used.

SampleDurationPresent (1 bit): Indicates that each sample has its own duration if this field takes the value %b1. If this field is not present, the default value that is specified by the DefaultSampleDuration field is used.

SampleFlagsPresent (1 bit): Indicates that each sample has its own flags if this field takes the value %b1. If this field is not present, the default value that is specified by the DefaultSampleFlags field is used.

SampleCompositionTimeOffsetPresent (1 bit): Indicates that each sample has a composition time offset if this field takes the value %b1.

FirstSampleFlags (4 bytes): The value of the SampleFlags field for the first sample. This field MUST be present if and only if the FirstSampleFlagsPresent field takes the value %b1.

SampleSize (4 bytes): The size of each sample, in bytes. This field MUST be present if and only if the SampleSizePresent field takes the value %b1. If this field is not present, its implicit value is the value of the DefaultSampleSize field.

SampleDuration (4 bytes): The duration of each sample, in increments that are defined by the TimeScale for the track. This field MUST be present if and only if the SampleDurationPresent field takes the value %b1. If this field is not present, its implicit value is the value of the DefaultSampleDuration field.

TrunBoxSampleFlags (4 bytes): The sample flags of each sample. This field MUST be present if and only if the SampleFlagsPresent field takes the value %b1. If this field is not present, its implicit value is the value of the DefaultSampleFlags field. If the FirstSampleFlags field is present and this field is omitted, this field's implicit value for the first sample in the fragment MUST be the value of the FirstSampleFlags field.

DataOffsetPresent (1 bit): Specifies whether the DataOffset field is present. This field MUST be set.

SampleCompositionTimeOffset (4 bytes): The Sample Composition Time offset of each sample, as defined in [ISO/IEC-14496-12]. This field MUST be present if and only if the SampleCompositionTimeOffsetPresent field takes the value %b1.

The syntax of the fields that are defined in this section, specified in ABNF [RFC5234], is as follows.

  
 TrunBox = TrunBoxLength TrunBoxType [TrunBoxLongLength] TrunBoxFields                                                          
           TrunBoxChildren                                                          
 TrunBoxType = %d116 %d114 %d117 %d110                                                          
 TrunBoxLength = BoxLength                                                          
 TrunBoxLongLength = LongBoxLength                                                          
 TrunBoxFields = TrunBoxVersion                                                          
                 TrunBoxFlags                                                          
                 SampleCount
                 DataOffset                                                          
                 [ FirstSampleFlags ]                                                           
                 *( TrunBoxPerSampleFields )                                                          
                 ; TrunBoxPerSampleFields MUST be repeated exactly SampleCount times                                                          
 TrunBoxFlags = 12*12RESERVED-BIT                                                           
                SampleCompositionTimeOffsetPresent                                                          
                SampleFlagsPresent                                                          
                SampleSizePresent                                                          
                SampleDurationPresent                                                          
                RESERVED-BIT                                                          
                RESERVED-BIT                                                          
                RESERVED-BIT                                                          
                RESERVED-BIT                                                          
                RESERVED-BIT                                                          
                FirstSampleFlagsPresent                                                          
                RESERVED-BIT                                                          
                RESERVED-BIT
                DataOffsetPresent                                                          
 SampleCompositionTimeOffsetPresent = BIT                                                          
 SampleFlagsPresent = BIT                                                          
 SampleSizePresent = BIT                                                          
 SampleDurationPresent = BIT                                                          
 FirstSampleFlagsPresent = BIT                                                          
 FirstSampleFlags = SampleFlags                                                          
 TrunBoxPerSampleFields = [ SampleDuration ]                                                           
                          [ SampleSize ]                                                           
                          [ TrunBoxSampleFlags ]                                                           
                          [ SampleCompositionTimeOffset ]                                                          
 SampleDuration = UNSIGNED-INT32                                                          
 SampleSize = UNSIGNED-INT32                                                          
 TrunBoxSampleFlags = SampleFlags                                                          
 SampleCompositionTimeOffset = UNSIGNED-INT32                                                          
 TrunBoxChildren = *( VendorExtensionUUIDBox )