Code refactoring
This commit is contained in:
+12
-12
@@ -1,17 +1,17 @@
|
|||||||
## AAC-LD and AAC-ELD
|
## AAC-LD and AAC-ELD
|
||||||
|
|
||||||
Codec | Rate | QuickTime | ffmpeg | VLC
|
| Codec | Rate | QuickTime | ffmpeg | VLC |
|
||||||
------|------|-----------|--------|----
|
|---------|-------|-----------|--------|-----|
|
||||||
AAC-LD | 8000 | yes | no | no
|
| AAC-LD | 8000 | yes | no | no |
|
||||||
AAC-LD | 16000 | yes | no | no
|
| AAC-LD | 16000 | yes | no | no |
|
||||||
AAC-LD | 22050 | yes | yes | no
|
| AAC-LD | 22050 | yes | yes | no |
|
||||||
AAC-LD | 24000 | yes | yes | no
|
| AAC-LD | 24000 | yes | yes | no |
|
||||||
AAC-LD | 32000 | yes | yes | no
|
| AAC-LD | 32000 | yes | yes | no |
|
||||||
AAC-ELD | 8000 | yes | no | no
|
| AAC-ELD | 8000 | yes | no | no |
|
||||||
AAC-ELD | 16000 | yes | no | no
|
| AAC-ELD | 16000 | yes | no | no |
|
||||||
AAC-ELD | 22050 | yes | yes | yes
|
| AAC-ELD | 22050 | yes | yes | yes |
|
||||||
AAC-ELD | 24000 | yes | yes | yes
|
| AAC-ELD | 24000 | yes | yes | yes |
|
||||||
AAC-ELD | 32000 | yes | yes | yes
|
| AAC-ELD | 32000 | yes | yes | yes |
|
||||||
|
|
||||||
## Useful links
|
## Useful links
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/rs/zerolog/log"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -77,7 +75,6 @@ func Assert(ok bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Caller() string {
|
func Caller() string {
|
||||||
log.Error().Caller(0).Send()
|
|
||||||
_, file, line, _ := runtime.Caller(1)
|
_, file, line, _ := runtime.Caller(1)
|
||||||
return file + ":" + strconv.Itoa(line)
|
return file + ":" + strconv.Itoa(line)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,13 @@ import (
|
|||||||
"github.com/pion/rtp"
|
"github.com/pion/rtp"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type Packet struct {
|
||||||
|
PayloadType uint8
|
||||||
|
Sequence uint16
|
||||||
|
Timestamp uint32
|
||||||
|
Payload []byte
|
||||||
|
}
|
||||||
|
|
||||||
var ErrCantGetTrack = errors.New("can't get track")
|
var ErrCantGetTrack = errors.New("can't get track")
|
||||||
|
|
||||||
type Receiver struct {
|
type Receiver struct {
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package mpegts
|
package mpegts
|
||||||
|
|
||||||
|
// have to create this table manually because it is in another endian
|
||||||
|
// https://github.com/arturvt/TSreader/blob/master/src/br/ufpe/cin/tool/mpegts/CRC32.java
|
||||||
var table = [256]uint32{
|
var table = [256]uint32{
|
||||||
0x00000000, 0xB71DC104, 0x6E3B8209, 0xD926430D, 0xDC760413, 0x6B6BC517,
|
0x00000000, 0xB71DC104, 0x6E3B8209, 0xD926430D, 0xDC760413, 0x6B6BC517,
|
||||||
0xB24D861A, 0x0550471E, 0xB8ED0826, 0x0FF0C922, 0xD6D68A2F, 0x61CB4B2B,
|
0xB24D861A, 0x0550471E, 0xB8ED0826, 0x0FF0C922, 0xD6D68A2F, 0x61CB4B2B,
|
||||||
@@ -46,7 +48,8 @@ var table = [256]uint32{
|
|||||||
0x6D66B4BC, 0xDA7B75B8, 0x035D36B5, 0xB440F7B1,
|
0x6D66B4BC, 0xDA7B75B8, 0x035D36B5, 0xB440F7B1,
|
||||||
}
|
}
|
||||||
|
|
||||||
func calcCRC32(crc uint32, data []byte) uint32 {
|
func checksum(data []byte) uint32 {
|
||||||
|
crc := uint32(0xFFFFFFFF)
|
||||||
for _, b := range data {
|
for _, b := range data {
|
||||||
crc = table[b^byte(crc)] ^ (crc >> 8)
|
crc = table[b^byte(crc)] ^ (crc >> 8)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ func (w *Writer) MarkChecksum() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *Writer) WriteChecksum() {
|
func (w *Writer) WriteChecksum() {
|
||||||
crc := calcCRC32(0xFFFFFFFF, w.b[w.m:])
|
crc := checksum(w.b[w.m:])
|
||||||
w.b = append(w.b, byte(crc), byte(crc>>8), byte(crc>>16), byte(crc>>24))
|
w.b = append(w.b, byte(crc), byte(crc>>8), byte(crc>>16), byte(crc>>24))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user