github.com/bluenviron/mediacommon@v1.9.3/pkg/formats/mpegts/codec_opus.go (about)

     1  package mpegts
     2  
     3  import (
     4  	"github.com/asticode/go-astits"
     5  )
     6  
     7  // CodecOpus is a Opus codec.
     8  type CodecOpus struct {
     9  	ChannelCount int
    10  }
    11  
    12  // IsVideo implements Codec.
    13  func (CodecOpus) IsVideo() bool {
    14  	return false
    15  }
    16  
    17  func (*CodecOpus) isCodec() {}
    18  
    19  func (c CodecOpus) marshal(pid uint16) (*astits.PMTElementaryStream, error) {
    20  	return &astits.PMTElementaryStream{
    21  		ElementaryPID: pid,
    22  		StreamType:    astits.StreamTypePrivateData,
    23  		ElementaryStreamDescriptors: []*astits.Descriptor{
    24  			{
    25  				Length: 4,
    26  				Tag:    astits.DescriptorTagRegistration,
    27  				Registration: &astits.DescriptorRegistration{
    28  					FormatIdentifier: opusIdentifier,
    29  				},
    30  			},
    31  			{
    32  				Length: 2,
    33  				Tag:    astits.DescriptorTagExtension,
    34  				Extension: &astits.DescriptorExtension{
    35  					Tag:     0x80,
    36  					Unknown: &[]uint8{uint8(c.ChannelCount)},
    37  				},
    38  			},
    39  		},
    40  	}, nil
    41  }