add tag
This commit is contained in:
		| @@ -290,6 +290,10 @@ func (self CodecData) SampleFormat() av.SampleFormat { | ||||
| 	return av.FLTP | ||||
| } | ||||
|  | ||||
| func (self CodecData) Tag() string { | ||||
| 	return fmt.Sprintf("mp4a.40.%d", self.Config.ObjectType) | ||||
| } | ||||
|  | ||||
| func (self CodecData) PacketDuration(data []byte) (dur time.Duration, err error) { | ||||
| 	dur = time.Duration(1024) * time.Second / time.Duration(self.Config.SampleRate) | ||||
| 	return | ||||
|   | ||||
| @@ -8,6 +8,7 @@ import ( | ||||
| 	"github.com/deepch/vdk/av" | ||||
| 	"github.com/deepch/vdk/utils/bits" | ||||
| 	"github.com/deepch/vdk/utils/bits/pio" | ||||
| 	"time" | ||||
| ) | ||||
|  | ||||
| const ( | ||||
| @@ -678,6 +679,26 @@ func (self CodecData) Height() int { | ||||
| 	return int(self.SPSInfo.Height) | ||||
| } | ||||
|  | ||||
| func (self CodecData) FPS() int { | ||||
| 	return int(self.SPSInfo.FPS) | ||||
| } | ||||
|  | ||||
| func (self CodecData) Resolution() string { | ||||
| 	return fmt.Sprintf("%vx%v", self.Width(), self.Height()) | ||||
| } | ||||
|  | ||||
| func (self CodecData) Tag() string { | ||||
| 	return fmt.Sprintf("avc1.%02X%02X%02X", self.RecordInfo.AVCProfileIndication, self.RecordInfo.ProfileCompatibility, self.RecordInfo.AVCLevelIndication) | ||||
| } | ||||
|  | ||||
| func (self CodecData) Bandwidth() string { | ||||
| 	return fmt.Sprintf("%v", (int(float64(self.Width())*(float64(1.71)*(30/float64(self.FPS())))))*1000) | ||||
| } | ||||
|  | ||||
| func (self CodecData) PacketDuration(data []byte) time.Duration { | ||||
| 	return time.Duration(1000./float64(self.FPS())) * time.Millisecond | ||||
| } | ||||
|  | ||||
| func NewCodecDataFromAVCDecoderConfRecord(record []byte) (self CodecData, err error) { | ||||
| 	self.Record = record | ||||
| 	if _, err = (&self.RecordInfo).Unmarshal(record); err != nil { | ||||
|   | ||||
| @@ -4,10 +4,10 @@ import ( | ||||
| 	"bytes" | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"github.com/deepch/vdk/av" | ||||
| 	"github.com/deepch/vdk/utils/bits" | ||||
| 	"github.com/deepch/vdk/utils/bits/pio" | ||||
| 	"time" | ||||
| ) | ||||
|  | ||||
| type SPSInfo struct { | ||||
| @@ -34,6 +34,7 @@ type SPSInfo struct { | ||||
| 	generalProfileCompatibilityFlags uint32 | ||||
| 	generalConstraintIndicatorFlags  uint64 | ||||
| 	generalLevelIDC                  uint | ||||
| 	fps                              uint | ||||
| } | ||||
|  | ||||
| const ( | ||||
| @@ -452,6 +453,26 @@ func (self CodecData) Height() int { | ||||
| 	return int(self.SPSInfo.Height) | ||||
| } | ||||
|  | ||||
| func (self CodecData) FPS() int { | ||||
| 	return int(self.SPSInfo.fps) | ||||
| } | ||||
|  | ||||
| func (self CodecData) Resolution() string { | ||||
| 	return fmt.Sprintf("%vx%v", self.Width(), self.Height()) | ||||
| } | ||||
|  | ||||
| func (self CodecData) Tag() string { | ||||
| 	return fmt.Sprintf("hvc1.%02X%02X%02X", self.RecordInfo.AVCProfileIndication, self.RecordInfo.ProfileCompatibility, self.RecordInfo.AVCLevelIndication) | ||||
| } | ||||
|  | ||||
| func (self CodecData) Bandwidth() string { | ||||
| 	return fmt.Sprintf("%v", (int(float64(self.Width())*(float64(1.71)*(30/float64(self.FPS())))))*1000) | ||||
| } | ||||
|  | ||||
| func (self CodecData) PacketDuration(data []byte) time.Duration { | ||||
| 	return time.Duration(1000./float64(self.FPS())) * time.Millisecond | ||||
| } | ||||
|  | ||||
| func NewCodecDataFromAVCDecoderConfRecord(record []byte) (self CodecData, err error) { | ||||
| 	self.Record = record | ||||
| 	if _, err = (&self.RecordInfo).Unmarshal(record); err != nil { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 deepch
					deepch