Skip to content

Commit d01680e

Browse files
committed
Rename H26xFormat to H26xStreamingFormat and avcc -> RTP.
AVCC is really a format for containers like mp4. And in that format, SPS/PPS is stored in a different section in the container. Technically, they are out-of-band from the stream. NVidia drivers call the length prefixed output mode as RTP_MODE_OUTPUT (https://developer.nvidia.com/docs/drive/drive-os/archives/6.0.3/linux/sdk/api_reference/group__x__h264__encoder__api.html#ggae87dcbde3f31e145bce800e59530f88eae974e3646f6b7daeb3d32f4e610190c1). So, rename AVCC -> RTP
1 parent 250d93d commit d01680e

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

readersampleprovider.go

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,19 @@ const (
4141

4242
// ---------------------------------
4343

44-
type H26xFormat int
44+
type H26xStreamingFormat int
4545

4646
const (
47-
H26xFormatAnnexB H26xFormat = iota
48-
H26xFormatAVCC
47+
H26xStreamingFormatAnnexB H26xStreamingFormat = iota
48+
H26xStreamingFormatRTP
4949
)
5050

51-
func (f H26xFormat) String() string {
51+
func (f H26xStreamingFormat) String() string {
5252
switch f {
53-
case H26xFormatAnnexB:
53+
case H26xStreamingFormatAnnexB:
5454
return "AnnexB"
55-
case H26xFormatAVCC:
56-
return "AVCC"
55+
case H26xStreamingFormatRTP:
56+
return "RTP"
5757
default:
5858
return fmt.Sprintf("Unknown: %d", f)
5959
}
@@ -64,12 +64,12 @@ func (f H26xFormat) String() string {
6464
// ReaderSampleProvider provides samples by reading from an io.ReadCloser implementation
6565
type ReaderSampleProvider struct {
6666
// Configuration
67-
Mime string
68-
FrameDuration time.Duration
69-
OnWriteComplete func()
70-
AudioLevel uint8
71-
trackOpts []LocalTrackOptions
72-
h26xFormat H26xFormat
67+
Mime string
68+
FrameDuration time.Duration
69+
OnWriteComplete func()
70+
AudioLevel uint8
71+
trackOpts []LocalTrackOptions
72+
h26xStreamingFormat H26xStreamingFormat
7373

7474
// Allow various types of ingress
7575
reader io.ReadCloser
@@ -121,9 +121,9 @@ func ReaderTrackWithSampleOptions(opts ...LocalTrackOptions) func(provider *Read
121121
}
122122
}
123123

124-
func ReaderTrackWithH26xFormat(h26xFormat H26xFormat) func(provider *ReaderSampleProvider) {
124+
func ReaderTrackWithH26xStreamingFormat(h26xStreamingFormat H26xStreamingFormat) func(provider *ReaderSampleProvider) {
125125
return func(provider *ReaderSampleProvider) {
126-
provider.h26xFormat = h26xFormat
126+
provider.h26xStreamingFormat = h26xStreamingFormat
127127
}
128128
}
129129

@@ -183,9 +183,9 @@ func NewLocalFileTrack(file string, options ...ReaderSampleProviderOption) (*Loc
183183
// - mime: has to be one of webrtc.MimeType... (e.g. webrtc.MimeTypeOpus)
184184
func NewLocalReaderTrack(in io.ReadCloser, mime string, options ...ReaderSampleProviderOption) (*LocalTrack, error) {
185185
provider := &ReaderSampleProvider{
186-
h26xFormat: H26xFormatAnnexB,
187-
Mime: mime,
188-
reader: in,
186+
h26xStreamingFormat: H26xStreamingFormatAnnexB,
187+
Mime: mime,
188+
reader: in,
189189
// default audio level to be fairly loud
190190
AudioLevel: 15,
191191
}
@@ -228,7 +228,7 @@ func (p *ReaderSampleProvider) OnBind() error {
228228
var err error
229229
switch p.Mime {
230230
case webrtc.MimeTypeH264:
231-
if p.h26xFormat == H26xFormatAnnexB {
231+
if p.h26xStreamingFormat == H26xStreamingFormatAnnexB {
232232
p.h264reader, err = h264reader.NewReader(p.reader)
233233
}
234234
case webrtc.MimeTypeH265:
@@ -275,8 +275,8 @@ func (p *ReaderSampleProvider) NextSample(ctx context.Context) (media.Sample, er
275275
nalUnitData []byte
276276
err error
277277
)
278-
switch p.h26xFormat {
279-
case H26xFormatAVCC:
278+
switch p.h26xStreamingFormat {
279+
case H26xStreamingFormatRTP:
280280
nalUnitType, nalUnitData, err = nextNALH264AVCC(p.reader)
281281
if err != nil {
282282
return sample, err

0 commit comments

Comments
 (0)