github.com/cnotch/ipchub@v1.1.0/av/codec/aac/shortcut.go (about)

     1  // Copyright (c) 2019,CAOHONGJU All rights reserved.
     2  // Use of this source code is governed by a MIT-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package aac
     6  
     7  import "github.com/cnotch/ipchub/av/codec"
     8  
     9  // MetadataIsReady .
    10  func MetadataIsReady(am *codec.AudioMeta) bool {
    11  	config := am.Sps //ParameterSet(ParameterSetConfig)
    12  	if len(config) == 0 {
    13  		return false
    14  	}
    15  	if am.SampleRate == 0 {
    16  		// decode
    17  		var asc AudioSpecificConfig
    18  		if err := asc.Decode(config); err != nil {
    19  			return false
    20  		}
    21  		am.Channels = int(asc.Channels)
    22  		am.SampleRate = asc.SampleRate
    23  		if asc.ExtSampleRate > 0 {
    24  			am.SampleRate = asc.ExtSampleRate
    25  		}
    26  		am.SampleSize = 16
    27  	}
    28  	return true
    29  }