install go2rtc on bob
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
## PTS/DTS/CTS
|
||||
|
||||
```
|
||||
if DTS == 0 {
|
||||
// for I and P frames
|
||||
packet.Timestamp = PTS (presentation time)
|
||||
} else {
|
||||
// for B frames
|
||||
packet.Timestamp = DTS (decode time)
|
||||
CTS = PTS-DTS (composition time)
|
||||
}
|
||||
```
|
||||
|
||||
- MPEG-TS container uses PTS and optional DTS.
|
||||
- MP4 container uses DTS and CTS
|
||||
- RTP container uses PTS
|
||||
|
||||
## MPEG-TS
|
||||
|
||||
FFmpeg:
|
||||
- PMTID=4096
|
||||
- H264: PESID=256, StreamType=27, StreamID=224
|
||||
- H265: PESID=256, StreamType=36, StreamID=224
|
||||
- AAC: PESID=257, StreamType=15, StreamID=192
|
||||
|
||||
Tapo:
|
||||
- PMTID=18
|
||||
- H264: PESID=68, StreamType=27, StreamID=224
|
||||
- AAC: PESID=69, StreamType=144, StreamID=192
|
||||
|
||||
## Useful links
|
||||
|
||||
- https://github.com/theREDspace/video-onboarding/blob/main/MPEGTS%20Knowledge.md
|
||||
- https://en.wikipedia.org/wiki/MPEG_transport_stream
|
||||
- https://en.wikipedia.org/wiki/Program-specific_information
|
||||
@@ -0,0 +1,57 @@
|
||||
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{
|
||||
0x00000000, 0xB71DC104, 0x6E3B8209, 0xD926430D, 0xDC760413, 0x6B6BC517,
|
||||
0xB24D861A, 0x0550471E, 0xB8ED0826, 0x0FF0C922, 0xD6D68A2F, 0x61CB4B2B,
|
||||
0x649B0C35, 0xD386CD31, 0x0AA08E3C, 0xBDBD4F38, 0x70DB114C, 0xC7C6D048,
|
||||
0x1EE09345, 0xA9FD5241, 0xACAD155F, 0x1BB0D45B, 0xC2969756, 0x758B5652,
|
||||
0xC836196A, 0x7F2BD86E, 0xA60D9B63, 0x11105A67, 0x14401D79, 0xA35DDC7D,
|
||||
0x7A7B9F70, 0xCD665E74, 0xE0B62398, 0x57ABE29C, 0x8E8DA191, 0x39906095,
|
||||
0x3CC0278B, 0x8BDDE68F, 0x52FBA582, 0xE5E66486, 0x585B2BBE, 0xEF46EABA,
|
||||
0x3660A9B7, 0x817D68B3, 0x842D2FAD, 0x3330EEA9, 0xEA16ADA4, 0x5D0B6CA0,
|
||||
0x906D32D4, 0x2770F3D0, 0xFE56B0DD, 0x494B71D9, 0x4C1B36C7, 0xFB06F7C3,
|
||||
0x2220B4CE, 0x953D75CA, 0x28803AF2, 0x9F9DFBF6, 0x46BBB8FB, 0xF1A679FF,
|
||||
0xF4F63EE1, 0x43EBFFE5, 0x9ACDBCE8, 0x2DD07DEC, 0x77708634, 0xC06D4730,
|
||||
0x194B043D, 0xAE56C539, 0xAB068227, 0x1C1B4323, 0xC53D002E, 0x7220C12A,
|
||||
0xCF9D8E12, 0x78804F16, 0xA1A60C1B, 0x16BBCD1F, 0x13EB8A01, 0xA4F64B05,
|
||||
0x7DD00808, 0xCACDC90C, 0x07AB9778, 0xB0B6567C, 0x69901571, 0xDE8DD475,
|
||||
0xDBDD936B, 0x6CC0526F, 0xB5E61162, 0x02FBD066, 0xBF469F5E, 0x085B5E5A,
|
||||
0xD17D1D57, 0x6660DC53, 0x63309B4D, 0xD42D5A49, 0x0D0B1944, 0xBA16D840,
|
||||
0x97C6A5AC, 0x20DB64A8, 0xF9FD27A5, 0x4EE0E6A1, 0x4BB0A1BF, 0xFCAD60BB,
|
||||
0x258B23B6, 0x9296E2B2, 0x2F2BAD8A, 0x98366C8E, 0x41102F83, 0xF60DEE87,
|
||||
0xF35DA999, 0x4440689D, 0x9D662B90, 0x2A7BEA94, 0xE71DB4E0, 0x500075E4,
|
||||
0x892636E9, 0x3E3BF7ED, 0x3B6BB0F3, 0x8C7671F7, 0x555032FA, 0xE24DF3FE,
|
||||
0x5FF0BCC6, 0xE8ED7DC2, 0x31CB3ECF, 0x86D6FFCB, 0x8386B8D5, 0x349B79D1,
|
||||
0xEDBD3ADC, 0x5AA0FBD8, 0xEEE00C69, 0x59FDCD6D, 0x80DB8E60, 0x37C64F64,
|
||||
0x3296087A, 0x858BC97E, 0x5CAD8A73, 0xEBB04B77, 0x560D044F, 0xE110C54B,
|
||||
0x38368646, 0x8F2B4742, 0x8A7B005C, 0x3D66C158, 0xE4408255, 0x535D4351,
|
||||
0x9E3B1D25, 0x2926DC21, 0xF0009F2C, 0x471D5E28, 0x424D1936, 0xF550D832,
|
||||
0x2C769B3F, 0x9B6B5A3B, 0x26D61503, 0x91CBD407, 0x48ED970A, 0xFFF0560E,
|
||||
0xFAA01110, 0x4DBDD014, 0x949B9319, 0x2386521D, 0x0E562FF1, 0xB94BEEF5,
|
||||
0x606DADF8, 0xD7706CFC, 0xD2202BE2, 0x653DEAE6, 0xBC1BA9EB, 0x0B0668EF,
|
||||
0xB6BB27D7, 0x01A6E6D3, 0xD880A5DE, 0x6F9D64DA, 0x6ACD23C4, 0xDDD0E2C0,
|
||||
0x04F6A1CD, 0xB3EB60C9, 0x7E8D3EBD, 0xC990FFB9, 0x10B6BCB4, 0xA7AB7DB0,
|
||||
0xA2FB3AAE, 0x15E6FBAA, 0xCCC0B8A7, 0x7BDD79A3, 0xC660369B, 0x717DF79F,
|
||||
0xA85BB492, 0x1F467596, 0x1A163288, 0xAD0BF38C, 0x742DB081, 0xC3307185,
|
||||
0x99908A5D, 0x2E8D4B59, 0xF7AB0854, 0x40B6C950, 0x45E68E4E, 0xF2FB4F4A,
|
||||
0x2BDD0C47, 0x9CC0CD43, 0x217D827B, 0x9660437F, 0x4F460072, 0xF85BC176,
|
||||
0xFD0B8668, 0x4A16476C, 0x93300461, 0x242DC565, 0xE94B9B11, 0x5E565A15,
|
||||
0x87701918, 0x306DD81C, 0x353D9F02, 0x82205E06, 0x5B061D0B, 0xEC1BDC0F,
|
||||
0x51A69337, 0xE6BB5233, 0x3F9D113E, 0x8880D03A, 0x8DD09724, 0x3ACD5620,
|
||||
0xE3EB152D, 0x54F6D429, 0x7926A9C5, 0xCE3B68C1, 0x171D2BCC, 0xA000EAC8,
|
||||
0xA550ADD6, 0x124D6CD2, 0xCB6B2FDF, 0x7C76EEDB, 0xC1CBA1E3, 0x76D660E7,
|
||||
0xAFF023EA, 0x18EDE2EE, 0x1DBDA5F0, 0xAAA064F4, 0x738627F9, 0xC49BE6FD,
|
||||
0x09FDB889, 0xBEE0798D, 0x67C63A80, 0xD0DBFB84, 0xD58BBC9A, 0x62967D9E,
|
||||
0xBBB03E93, 0x0CADFF97, 0xB110B0AF, 0x060D71AB, 0xDF2B32A6, 0x6836F3A2,
|
||||
0x6D66B4BC, 0xDA7B75B8, 0x035D36B5, 0xB440F7B1,
|
||||
}
|
||||
|
||||
func checksum(data []byte) uint32 {
|
||||
crc := uint32(0xFFFFFFFF)
|
||||
for _, b := range data {
|
||||
crc = table[b^byte(crc)] ^ (crc >> 8)
|
||||
}
|
||||
return crc
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
package mpegts
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"github.com/AlexxIT/go2rtc/pkg/aac"
|
||||
"github.com/AlexxIT/go2rtc/pkg/core"
|
||||
"github.com/AlexxIT/go2rtc/pkg/h264"
|
||||
"github.com/AlexxIT/go2rtc/pkg/h265"
|
||||
"github.com/pion/rtp"
|
||||
)
|
||||
|
||||
type Consumer struct {
|
||||
core.Connection
|
||||
muxer *Muxer
|
||||
wr *core.WriteBuffer
|
||||
}
|
||||
|
||||
func NewConsumer() *Consumer {
|
||||
medias := []*core.Media{
|
||||
{
|
||||
Kind: core.KindVideo,
|
||||
Direction: core.DirectionSendonly,
|
||||
Codecs: []*core.Codec{
|
||||
{Name: core.CodecH264},
|
||||
{Name: core.CodecH265},
|
||||
},
|
||||
},
|
||||
{
|
||||
Kind: core.KindAudio,
|
||||
Direction: core.DirectionSendonly,
|
||||
Codecs: []*core.Codec{
|
||||
{Name: core.CodecAAC},
|
||||
},
|
||||
},
|
||||
}
|
||||
wr := core.NewWriteBuffer(nil)
|
||||
return &Consumer{
|
||||
core.Connection{
|
||||
ID: core.NewID(),
|
||||
FormatName: "mpegts",
|
||||
Medias: medias,
|
||||
Transport: wr,
|
||||
},
|
||||
NewMuxer(),
|
||||
wr,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Consumer) AddTrack(media *core.Media, codec *core.Codec, track *core.Receiver) error {
|
||||
sender := core.NewSender(media, track.Codec)
|
||||
|
||||
switch track.Codec.Name {
|
||||
case core.CodecH264:
|
||||
pid := c.muxer.AddTrack(StreamTypeH264)
|
||||
|
||||
sender.Handler = func(pkt *rtp.Packet) {
|
||||
b := c.muxer.GetPayload(pid, pkt.Timestamp, pkt.Payload)
|
||||
if n, err := c.wr.Write(b); err == nil {
|
||||
c.Send += n
|
||||
}
|
||||
}
|
||||
|
||||
if track.Codec.IsRTP() {
|
||||
sender.Handler = h264.RTPDepay(track.Codec, sender.Handler)
|
||||
} else {
|
||||
sender.Handler = h264.RepairAVCC(track.Codec, sender.Handler)
|
||||
}
|
||||
|
||||
case core.CodecH265:
|
||||
pid := c.muxer.AddTrack(StreamTypeH265)
|
||||
|
||||
sender.Handler = func(pkt *rtp.Packet) {
|
||||
b := c.muxer.GetPayload(pid, pkt.Timestamp, pkt.Payload)
|
||||
if n, err := c.wr.Write(b); err == nil {
|
||||
c.Send += n
|
||||
}
|
||||
}
|
||||
|
||||
if track.Codec.IsRTP() {
|
||||
sender.Handler = h265.RTPDepay(track.Codec, sender.Handler)
|
||||
}
|
||||
|
||||
case core.CodecAAC:
|
||||
pid := c.muxer.AddTrack(StreamTypeAAC)
|
||||
|
||||
// convert timestamp to 90000Hz clock
|
||||
dt := 90000 / float64(track.Codec.ClockRate)
|
||||
|
||||
sender.Handler = func(pkt *rtp.Packet) {
|
||||
pts := uint32(float64(pkt.Timestamp) * dt)
|
||||
b := c.muxer.GetPayload(pid, pts, pkt.Payload)
|
||||
if n, err := c.wr.Write(b); err == nil {
|
||||
c.Send += n
|
||||
}
|
||||
}
|
||||
|
||||
if track.Codec.IsRTP() {
|
||||
sender.Handler = aac.RTPToADTS(track.Codec, sender.Handler)
|
||||
} else {
|
||||
sender.Handler = aac.EncodeToADTS(track.Codec, sender.Handler)
|
||||
}
|
||||
}
|
||||
|
||||
sender.HandleRTP(track)
|
||||
c.Senders = append(c.Senders, sender)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Consumer) WriteTo(wr io.Writer) (int64, error) {
|
||||
b := c.muxer.GetHeader()
|
||||
if _, err := wr.Write(b); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return c.wr.WriteTo(wr)
|
||||
}
|
||||
|
||||
//func TimestampFromRTP(rtp *rtp.Packet, codec *core.Codec) {
|
||||
// if codec.ClockRate == ClockRate {
|
||||
// return
|
||||
// }
|
||||
// rtp.Timestamp = uint32(float64(rtp.Timestamp) / float64(codec.ClockRate) * ClockRate)
|
||||
//}
|
||||
@@ -0,0 +1,434 @@
|
||||
package mpegts
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"io"
|
||||
|
||||
"github.com/AlexxIT/go2rtc/pkg/aac"
|
||||
"github.com/AlexxIT/go2rtc/pkg/bits"
|
||||
"github.com/AlexxIT/go2rtc/pkg/h264/annexb"
|
||||
"github.com/pion/rtp"
|
||||
)
|
||||
|
||||
type Demuxer struct {
|
||||
buf [PacketSize]byte // total buf
|
||||
|
||||
byte byte // current byte
|
||||
bits byte // bits left in byte
|
||||
pos byte // current pos in buf
|
||||
end byte // end position
|
||||
|
||||
pmtID uint16 // Program Map Table (PMT) PID
|
||||
pes map[uint16]*PES
|
||||
}
|
||||
|
||||
func NewDemuxer() *Demuxer {
|
||||
return &Demuxer{}
|
||||
}
|
||||
|
||||
const skipRead = 0xFF
|
||||
|
||||
func (d *Demuxer) ReadPacket(rd io.Reader) (*rtp.Packet, error) {
|
||||
for {
|
||||
if d.pos != skipRead {
|
||||
if _, err := io.ReadFull(rd, d.buf[:]); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
pid, start, err := d.readPacketHeader()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if d.pes == nil {
|
||||
switch pid {
|
||||
case 0: // PAT ID
|
||||
d.readPAT() // PAT: Program Association Table
|
||||
case d.pmtID:
|
||||
d.readPMT() // PMT : Program Map Table
|
||||
|
||||
pkt := &rtp.Packet{
|
||||
Payload: make([]byte, 0, len(d.pes)),
|
||||
}
|
||||
for _, pes := range d.pes {
|
||||
pkt.Payload = append(pkt.Payload, pes.StreamType)
|
||||
}
|
||||
return pkt, nil
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
if pkt := d.readPES(pid, start); pkt != nil {
|
||||
return pkt, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (d *Demuxer) readPacketHeader() (pid uint16, start bool, err error) {
|
||||
d.reset()
|
||||
|
||||
sb := d.readByte() // Sync byte
|
||||
if sb != SyncByte {
|
||||
return 0, false, errors.New("mpegts: wrong sync byte")
|
||||
}
|
||||
|
||||
_ = d.readBit() // Transport error indicator (TEI)
|
||||
pusi := d.readBit() // Payload unit start indicator (PUSI)
|
||||
_ = d.readBit() // Transport priority
|
||||
pid = d.readBits16(13) // PID
|
||||
|
||||
_ = d.readBits(2) // Transport scrambling control (TSC)
|
||||
af := d.readBit() // Adaptation field
|
||||
_ = d.readBit() // Payload
|
||||
_ = d.readBits(4) // Continuity counter
|
||||
|
||||
if af != 0 {
|
||||
adSize := d.readByte() // Adaptation field length
|
||||
if adSize > PacketSize-6 {
|
||||
return 0, false, errors.New("mpegts: wrong adaptation size")
|
||||
}
|
||||
d.skip(adSize)
|
||||
}
|
||||
|
||||
return pid, pusi != 0, nil
|
||||
}
|
||||
|
||||
func (d *Demuxer) skip(i byte) {
|
||||
d.pos += i
|
||||
}
|
||||
|
||||
func (d *Demuxer) readBytes(i byte) []byte {
|
||||
d.pos += i
|
||||
return d.buf[d.pos-i : d.pos]
|
||||
}
|
||||
|
||||
func (d *Demuxer) readPSIHeader() {
|
||||
// https://en.wikipedia.org/wiki/Program-specific_information#Table_Sections
|
||||
pointer := d.readByte() // Pointer field
|
||||
d.skip(pointer) // Pointer filler bytes
|
||||
|
||||
_ = d.readByte() // Table ID
|
||||
_ = d.readBit() // Section syntax indicator
|
||||
_ = d.readBit() // Private bit
|
||||
_ = d.readBits(2) // Reserved bits
|
||||
_ = d.readBits(2) // Section length unused bits
|
||||
size := d.readBits(10) // Section length
|
||||
d.setSize(byte(size))
|
||||
|
||||
_ = d.readBits(16) // Table ID extension
|
||||
_ = d.readBits(2) // Reserved bits
|
||||
_ = d.readBits(5) // Version number
|
||||
_ = d.readBit() // Current/next indicator
|
||||
_ = d.readByte() // Section number
|
||||
_ = d.readByte() // Last section number
|
||||
}
|
||||
|
||||
// ReadPAT (Program Association Table)
|
||||
func (d *Demuxer) readPAT() {
|
||||
// https://en.wikipedia.org/wiki/Program-specific_information#PAT_(Program_Association_Table)
|
||||
d.readPSIHeader()
|
||||
|
||||
const CRCSize = 4
|
||||
for d.left() > CRCSize {
|
||||
num := d.readBits(16) // Program num
|
||||
_ = d.readBits(3) // Reserved bits
|
||||
pid := d.readBits16(13) // Program map PID
|
||||
if num != 0 {
|
||||
d.pmtID = pid
|
||||
}
|
||||
}
|
||||
|
||||
d.skip(4) // CRC32
|
||||
}
|
||||
|
||||
// ReadPMT (Program map specific data)
|
||||
func (d *Demuxer) readPMT() {
|
||||
// https://en.wikipedia.org/wiki/Program-specific_information#PMT_(Program_map_specific_data)
|
||||
d.readPSIHeader()
|
||||
|
||||
_ = d.readBits(3) // Reserved bits
|
||||
_ = d.readBits(13) // PCR PID
|
||||
_ = d.readBits(4) // Reserved bits
|
||||
_ = d.readBits(2) // Program info length unused bits
|
||||
size := d.readBits(10) // Program info length
|
||||
d.skip(byte(size))
|
||||
|
||||
d.pes = map[uint16]*PES{}
|
||||
|
||||
const CRCSize = 4
|
||||
for d.left() > CRCSize {
|
||||
streamType := d.readByte() // Stream type
|
||||
_ = d.readBits(3) // Reserved bits
|
||||
pid := d.readBits16(13) // Elementary PID
|
||||
_ = d.readBits(4) // Reserved bits
|
||||
_ = d.readBits(2) // ES Info length unused bits
|
||||
size = d.readBits(10) // ES Info length
|
||||
info := d.readBytes(byte(size))
|
||||
|
||||
if streamType == StreamTypePrivate && bytes.HasPrefix(info, opusInfo) {
|
||||
streamType = StreamTypePrivateOPUS
|
||||
}
|
||||
|
||||
d.pes[pid] = &PES{StreamType: streamType}
|
||||
}
|
||||
|
||||
d.skip(4) // CRC32
|
||||
}
|
||||
|
||||
func (d *Demuxer) readPES(pid uint16, start bool) *rtp.Packet {
|
||||
pes := d.pes[pid]
|
||||
if pes == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// if new payload beging
|
||||
if start {
|
||||
if len(pes.Payload) != 0 {
|
||||
d.pos = skipRead
|
||||
return pes.GetPacket() // finish previous packet
|
||||
}
|
||||
|
||||
// https://en.wikipedia.org/wiki/Packetized_elementary_stream
|
||||
// Packet start code prefix
|
||||
if d.readByte() != 0 || d.readByte() != 0 || d.readByte() != 1 {
|
||||
return nil
|
||||
}
|
||||
|
||||
pes.StreamID = d.readByte() // Stream id
|
||||
packetSize := d.readBits16(16) // PES Packet length
|
||||
|
||||
_ = d.readBits(2) // Marker bits
|
||||
_ = d.readBits(2) // Scrambling control
|
||||
_ = d.readBit() // Priority
|
||||
_ = d.readBit() // Data alignment indicator
|
||||
_ = d.readBit() // Copyright
|
||||
_ = d.readBit() // Original or Copy
|
||||
|
||||
ptsi := d.readBit() // PTS indicator
|
||||
dtsi := d.readBit() // DTS indicator
|
||||
_ = d.readBit() // ESCR flag
|
||||
_ = d.readBit() // ES rate flag
|
||||
_ = d.readBit() // DSM trick mode flag
|
||||
_ = d.readBit() // Additional copy info flag
|
||||
_ = d.readBit() // CRC flag
|
||||
_ = d.readBit() // extension flag
|
||||
|
||||
headerSize := d.readByte() // PES header length
|
||||
|
||||
if packetSize != 0 {
|
||||
packetSize -= uint16(3 + headerSize)
|
||||
}
|
||||
|
||||
if ptsi != 0 {
|
||||
pes.PTS = d.readTime()
|
||||
headerSize -= 5
|
||||
} else {
|
||||
pes.PTS = 0
|
||||
}
|
||||
|
||||
if dtsi != 0 {
|
||||
pes.DTS = d.readTime()
|
||||
headerSize -= 5
|
||||
} else {
|
||||
pes.DTS = 0
|
||||
}
|
||||
|
||||
d.skip(headerSize)
|
||||
|
||||
pes.SetBuffer(packetSize, d.bytes())
|
||||
} else {
|
||||
pes.AppendBuffer(d.bytes())
|
||||
}
|
||||
|
||||
if pes.Size != 0 && len(pes.Payload) >= pes.Size {
|
||||
return pes.GetPacket() // finish current packet
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *Demuxer) reset() {
|
||||
d.pos = 0
|
||||
d.end = PacketSize
|
||||
d.bits = 0
|
||||
}
|
||||
|
||||
//goland:noinspection GoStandardMethods
|
||||
func (d *Demuxer) readByte() byte {
|
||||
if d.bits != 0 {
|
||||
return byte(d.readBits(8))
|
||||
}
|
||||
|
||||
b := d.buf[d.pos]
|
||||
d.pos++
|
||||
return b
|
||||
}
|
||||
|
||||
func (d *Demuxer) readBit() byte {
|
||||
if d.bits == 0 {
|
||||
d.byte = d.readByte()
|
||||
d.bits = 7
|
||||
} else {
|
||||
d.bits--
|
||||
}
|
||||
|
||||
return (d.byte >> d.bits) & 0b1
|
||||
}
|
||||
|
||||
func (d *Demuxer) readBits(n byte) (res uint32) {
|
||||
for i := n - 1; i != 255; i-- {
|
||||
res |= uint32(d.readBit()) << i
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (d *Demuxer) readBits16(n byte) (res uint16) {
|
||||
for i := n - 1; i != 255; i-- {
|
||||
res |= uint16(d.readBit()) << i
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (d *Demuxer) readTime() uint32 {
|
||||
// https://en.wikipedia.org/wiki/Packetized_elementary_stream
|
||||
// xxxxAAAx BBBBBBBB BBBBBBBx CCCCCCCC CCCCCCCx
|
||||
_ = d.readBits(4) // 0010b or 0011b or 0001b
|
||||
ts := d.readBits(3) << 30
|
||||
_ = d.readBits(1) // 1b
|
||||
ts |= d.readBits(15) << 15
|
||||
_ = d.readBits(1) // 1b
|
||||
ts |= d.readBits(15)
|
||||
_ = d.readBits(1) // 1b
|
||||
return ts
|
||||
}
|
||||
|
||||
func (d *Demuxer) bytes() []byte {
|
||||
return d.buf[d.pos:PacketSize]
|
||||
}
|
||||
|
||||
func (d *Demuxer) left() byte {
|
||||
return d.end - d.pos
|
||||
}
|
||||
|
||||
func (d *Demuxer) setSize(size byte) {
|
||||
d.end = d.pos + size
|
||||
}
|
||||
|
||||
const (
|
||||
PacketSize = 188
|
||||
SyncByte = 0x47 // Uppercase G
|
||||
ClockRate = 90000 // fixed clock rate for PTS/DTS of any type
|
||||
)
|
||||
|
||||
// https://en.wikipedia.org/wiki/Program-specific_information#Elementary_stream_types
|
||||
const (
|
||||
StreamTypeMetadata = 0 // Reserved
|
||||
StreamTypePrivate = 0x06 // PCMU or PCMA or FLAC from FFmpeg
|
||||
StreamTypeAAC = 0x0F
|
||||
StreamTypeH264 = 0x1B
|
||||
StreamTypeH265 = 0x24
|
||||
StreamTypePCMATapo = 0x90
|
||||
StreamTypePCMUTapo = 0x91
|
||||
StreamTypePrivateOPUS = 0xEB
|
||||
)
|
||||
|
||||
// PES - Packetized Elementary Stream
|
||||
type PES struct {
|
||||
StreamID byte // from each PES header
|
||||
StreamType byte // from PMT table
|
||||
Sequence uint16 // manual
|
||||
Timestamp uint32 // manual
|
||||
PTS uint32 // from extra header, always 90000Hz
|
||||
DTS uint32
|
||||
Payload []byte // from PES body
|
||||
Size int // from PES header, can be 0
|
||||
|
||||
wr *bits.Writer
|
||||
}
|
||||
|
||||
func (p *PES) SetBuffer(size uint16, b []byte) {
|
||||
p.Payload = make([]byte, 0, size)
|
||||
p.Payload = append(p.Payload, b...)
|
||||
p.Size = int(size)
|
||||
}
|
||||
|
||||
func (p *PES) AppendBuffer(b []byte) {
|
||||
p.Payload = append(p.Payload, b...)
|
||||
}
|
||||
|
||||
func (p *PES) GetPacket() (pkt *rtp.Packet) {
|
||||
switch p.StreamType {
|
||||
case StreamTypeH264, StreamTypeH265:
|
||||
pkt = &rtp.Packet{
|
||||
Header: rtp.Header{
|
||||
PayloadType: p.StreamType,
|
||||
},
|
||||
Payload: annexb.EncodeToAVCC(p.Payload),
|
||||
}
|
||||
|
||||
if p.DTS != 0 {
|
||||
pkt.Timestamp = p.DTS
|
||||
// wrong place for CTS, but we don't have another one
|
||||
pkt.ExtensionProfile = uint16(p.PTS - p.DTS)
|
||||
} else {
|
||||
pkt.Timestamp = p.PTS
|
||||
}
|
||||
|
||||
case StreamTypeAAC:
|
||||
p.Sequence++
|
||||
|
||||
pkt = &rtp.Packet{
|
||||
Header: rtp.Header{
|
||||
Version: 2,
|
||||
Marker: true,
|
||||
PayloadType: p.StreamType,
|
||||
SequenceNumber: p.Sequence,
|
||||
Timestamp: p.PTS,
|
||||
//Timestamp: p.Timestamp,
|
||||
},
|
||||
Payload: aac.ADTStoRTP(p.Payload),
|
||||
}
|
||||
|
||||
//p.Timestamp += aac.RTPTimeSize(pkt.Payload) // update next timestamp!
|
||||
|
||||
case StreamTypePCMATapo, StreamTypePCMUTapo:
|
||||
p.Sequence++
|
||||
|
||||
pkt = &rtp.Packet{
|
||||
Header: rtp.Header{
|
||||
Version: 2,
|
||||
Marker: true,
|
||||
PayloadType: p.StreamType,
|
||||
SequenceNumber: p.Sequence,
|
||||
Timestamp: p.PTS,
|
||||
//Timestamp: p.Timestamp,
|
||||
},
|
||||
Payload: p.Payload,
|
||||
}
|
||||
|
||||
//p.Timestamp += uint32(len(p.Payload)) // update next timestamp!
|
||||
|
||||
case StreamTypePrivateOPUS:
|
||||
p.Sequence++
|
||||
|
||||
pkt = &rtp.Packet{
|
||||
Header: rtp.Header{
|
||||
Version: 2,
|
||||
Marker: true,
|
||||
PayloadType: p.StreamType,
|
||||
SequenceNumber: p.Sequence,
|
||||
Timestamp: p.PTS,
|
||||
},
|
||||
}
|
||||
|
||||
pkt.Payload, p.Payload = CutOPUSPacket(p.Payload)
|
||||
p.PTS += opusDT
|
||||
return
|
||||
}
|
||||
|
||||
p.Payload = nil
|
||||
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,226 @@
|
||||
package mpegts
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
|
||||
"github.com/AlexxIT/go2rtc/pkg/bits"
|
||||
"github.com/AlexxIT/go2rtc/pkg/h264/annexb"
|
||||
)
|
||||
|
||||
type Muxer struct {
|
||||
pes map[uint16]*PES
|
||||
}
|
||||
|
||||
func NewMuxer() *Muxer {
|
||||
return &Muxer{
|
||||
pes: map[uint16]*PES{},
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Muxer) AddTrack(streamType byte) (pid uint16) {
|
||||
pes := &PES{StreamType: streamType}
|
||||
|
||||
// Audio streams (0xC0-0xDF), Video streams (0xE0-0xEF)
|
||||
switch streamType {
|
||||
case StreamTypeH264, StreamTypeH265:
|
||||
pes.StreamID = 0xE0
|
||||
case StreamTypeAAC, StreamTypePCMATapo:
|
||||
pes.StreamID = 0xC0
|
||||
}
|
||||
|
||||
pid = pes0PID + uint16(len(m.pes))
|
||||
m.pes[pid] = pes
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (m *Muxer) GetHeader() []byte {
|
||||
bw := bits.NewWriter(nil)
|
||||
m.writePAT(bw)
|
||||
m.writePMT(bw)
|
||||
return bw.Bytes()
|
||||
}
|
||||
|
||||
// GetPayload - safe to run concurently with different pid
|
||||
func (m *Muxer) GetPayload(pid uint16, timestamp uint32, payload []byte) []byte {
|
||||
pes := m.pes[pid]
|
||||
|
||||
switch pes.StreamType {
|
||||
case StreamTypeH264, StreamTypeH265:
|
||||
payload = annexb.DecodeAVCCWithAUD(payload)
|
||||
}
|
||||
|
||||
if pes.Timestamp != 0 {
|
||||
pes.PTS += timestamp - pes.Timestamp
|
||||
}
|
||||
pes.Timestamp = timestamp
|
||||
|
||||
// min header size (3 byte) + adv header size (PES)
|
||||
size := 3 + 5 + len(payload)
|
||||
|
||||
b := make([]byte, 6+3+5)
|
||||
|
||||
b[0], b[1], b[2] = 0, 0, 1 // Packet start code prefix
|
||||
b[3] = pes.StreamID // Stream ID
|
||||
|
||||
// PES Packet length (zero value OK for video)
|
||||
if size <= 0xFFFF {
|
||||
binary.BigEndian.PutUint16(b[4:], uint16(size))
|
||||
}
|
||||
|
||||
// Optional PES header:
|
||||
b[6] = 0x80 // Marker bits (binary)
|
||||
b[7] = 0x80 // PTS indicator
|
||||
b[8] = 5 // PES header length
|
||||
|
||||
WriteTime(b[9:], pes.PTS)
|
||||
|
||||
pes.Payload = append(b, payload...)
|
||||
pes.Size = 1 // set PUSI in first PES
|
||||
|
||||
if pes.wr == nil {
|
||||
pes.wr = bits.NewWriter(nil)
|
||||
} else {
|
||||
pes.wr.Reset()
|
||||
}
|
||||
|
||||
for len(pes.Payload) > 0 {
|
||||
m.writePES(pes.wr, pid, pes)
|
||||
pes.Sequence++
|
||||
pes.Size = 0
|
||||
}
|
||||
|
||||
return pes.wr.Bytes()
|
||||
}
|
||||
|
||||
const patPID = 0
|
||||
const pmtPID = 0x1000
|
||||
const pes0PID = 0x100
|
||||
|
||||
func (m *Muxer) writePAT(wr *bits.Writer) {
|
||||
m.writeHeader(wr, patPID)
|
||||
i := wr.Len() + 1 // start for CRC32
|
||||
m.writePSIHeader(wr, 0, 4)
|
||||
|
||||
wr.WriteUint16(1) // Program num
|
||||
wr.WriteBits8(0b111, 3) // Reserved bits (all to 1)
|
||||
wr.WriteBits16(pmtPID, 13) // Program map PID
|
||||
|
||||
crc := checksum(wr.Bytes()[i:])
|
||||
wr.WriteBytes(byte(crc), byte(crc>>8), byte(crc>>16), byte(crc>>24)) // CRC32 (little endian)
|
||||
|
||||
m.WriteTail(wr)
|
||||
}
|
||||
|
||||
func (m *Muxer) writePMT(wr *bits.Writer) {
|
||||
m.writeHeader(wr, pmtPID)
|
||||
i := wr.Len() + 1 // start for CRC32
|
||||
m.writePSIHeader(wr, 2, 4+uint16(len(m.pes))*5) // 4 bytes below + 5 bytes each PES
|
||||
|
||||
wr.WriteBits8(0b111, 3) // Reserved bits (all to 1)
|
||||
wr.WriteBits16(0x1FFF, 13) // Program map PID (not used)
|
||||
|
||||
wr.WriteBits8(0b1111, 4) // Reserved bits (all to 1)
|
||||
wr.WriteBits8(0, 2) // Program info length unused bits (all to 0)
|
||||
wr.WriteBits16(0, 10) // Program info length
|
||||
|
||||
for pid := uint16(pes0PID); ; pid++ {
|
||||
pes, ok := m.pes[pid]
|
||||
if !ok {
|
||||
break
|
||||
}
|
||||
wr.WriteByte(pes.StreamType) // Stream type
|
||||
wr.WriteBits8(0b111, 3) // Reserved bits (all to 1)
|
||||
wr.WriteBits16(pid, 13) // Elementary PID
|
||||
wr.WriteBits8(0b1111, 4) // Reserved bits (all to 1)
|
||||
wr.WriteBits(0, 2) // ES Info length unused bits
|
||||
wr.WriteBits16(0, 10) // ES Info length
|
||||
}
|
||||
|
||||
crc := checksum(wr.Bytes()[i:])
|
||||
wr.WriteBytes(byte(crc), byte(crc>>8), byte(crc>>16), byte(crc>>24)) // CRC32 (little endian)
|
||||
|
||||
m.WriteTail(wr)
|
||||
}
|
||||
|
||||
func (m *Muxer) writePES(wr *bits.Writer, pid uint16, pes *PES) {
|
||||
const flagPUSI = 0b01000000_00000000
|
||||
const flagAdaptation = 0b00100000
|
||||
const flagPayload = 0b00010000
|
||||
|
||||
wr.WriteByte(SyncByte)
|
||||
|
||||
if pes.Size != 0 {
|
||||
pid |= flagPUSI // Payload unit start indicator (PUSI)
|
||||
}
|
||||
|
||||
wr.WriteUint16(pid)
|
||||
|
||||
counter := byte(pes.Sequence) & 0xF
|
||||
|
||||
if size := len(pes.Payload); size < PacketSize-4 {
|
||||
wr.WriteByte(flagAdaptation | flagPayload | counter) // adaptation + payload
|
||||
|
||||
// for 183 payload will be zero
|
||||
adSize := PacketSize - 4 - 1 - byte(size)
|
||||
wr.WriteByte(adSize)
|
||||
wr.WriteBytes(make([]byte, adSize)...)
|
||||
|
||||
wr.WriteBytes(pes.Payload...)
|
||||
pes.Payload = nil
|
||||
} else {
|
||||
wr.WriteByte(flagPayload | counter) // only payload
|
||||
|
||||
wr.WriteBytes(pes.Payload[:PacketSize-4]...)
|
||||
pes.Payload = pes.Payload[PacketSize-4:]
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Muxer) writeHeader(wr *bits.Writer, pid uint16) {
|
||||
wr.WriteByte(SyncByte)
|
||||
|
||||
wr.WriteBit(0) // Transport error indicator (TEI)
|
||||
wr.WriteBit(1) // Payload unit start indicator (PUSI)
|
||||
wr.WriteBit(0) // Transport priority
|
||||
wr.WriteBits16(pid, 13) // PID
|
||||
|
||||
wr.WriteBits8(0, 2) // Transport scrambling control (TSC)
|
||||
wr.WriteBit(0) // Adaptation field
|
||||
wr.WriteBit(1) // Payload
|
||||
wr.WriteBits8(0, 4) // Continuity counter
|
||||
}
|
||||
|
||||
func (m *Muxer) writePSIHeader(wr *bits.Writer, tableID byte, size uint16) {
|
||||
wr.WriteByte(0) // Pointer field
|
||||
|
||||
wr.WriteByte(tableID) // Table ID
|
||||
|
||||
wr.WriteBit(1) // Section syntax indicator
|
||||
wr.WriteBit(0) // Private bit
|
||||
wr.WriteBits8(0b11, 2) // Reserved bits (all to 1)
|
||||
wr.WriteBits8(0, 2) // Section length unused bits (all to 0)
|
||||
wr.WriteBits16(5+size+4, 10) // Section length (5 bytes below + content + 4 bytes CRC32)
|
||||
|
||||
wr.WriteUint16(1) // Table ID extension
|
||||
wr.WriteBits8(0b11, 2) // Reserved bits (all to 1)
|
||||
wr.WriteBits8(0, 5) // Version number
|
||||
wr.WriteBit(1) // Current/next indicator
|
||||
|
||||
wr.WriteByte(0) // Section number
|
||||
wr.WriteByte(0) // Last section number
|
||||
}
|
||||
|
||||
func (m *Muxer) WriteTail(wr *bits.Writer) {
|
||||
size := PacketSize - wr.Len()%PacketSize
|
||||
wr.WriteBytes(make([]byte, size)...)
|
||||
}
|
||||
|
||||
func WriteTime(b []byte, t uint32) {
|
||||
_ = b[4] // bounds
|
||||
const onlyPTS = 0x20
|
||||
b[0] = onlyPTS | byte(t>>(32-3)) | 1
|
||||
b[1] = byte(t >> (24 - 2))
|
||||
b[2] = byte(t>>(16-2)) | 1
|
||||
b[3] = byte(t >> (8 - 1))
|
||||
b[4] = byte(t<<1) | 1 // t>>(0-1)
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package mpegts
|
||||
|
||||
import (
|
||||
"github.com/AlexxIT/go2rtc/pkg/bits"
|
||||
)
|
||||
|
||||
// opusDT - each AU from FFmpeg has 5 OPUS packets. Each packet len = 960 in the 48000 clock.
|
||||
const opusDT = 960 * ClockRate / 48000
|
||||
|
||||
// https://opus-codec.org/docs/
|
||||
var opusInfo = []byte{ // registration_descriptor
|
||||
0x05, // descriptor_tag
|
||||
0x04, // descriptor_length
|
||||
'O', 'p', 'u', 's', // format_identifier
|
||||
}
|
||||
|
||||
//goland:noinspection GoSnakeCaseUsage
|
||||
func CutOPUSPacket(b []byte) (packet []byte, left []byte) {
|
||||
r := bits.NewReader(b)
|
||||
|
||||
size := opus_control_header(r)
|
||||
if size == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
packet = r.ReadBytes(size)
|
||||
left = r.Left()
|
||||
return
|
||||
}
|
||||
|
||||
//goland:noinspection GoSnakeCaseUsage
|
||||
func opus_control_header(r *bits.Reader) int {
|
||||
control_header_prefix := r.ReadBits(11)
|
||||
if control_header_prefix != 0x3FF {
|
||||
return 0
|
||||
}
|
||||
|
||||
start_trim_flag := r.ReadBit()
|
||||
end_trim_flag := r.ReadBit()
|
||||
control_extension_flag := r.ReadBit()
|
||||
_ = r.ReadBits(2) // reserved
|
||||
|
||||
var payload_size int
|
||||
for {
|
||||
i := r.ReadByte()
|
||||
payload_size += int(i)
|
||||
if i < 255 {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if start_trim_flag != 0 {
|
||||
_ = r.ReadBits(3)
|
||||
_ = r.ReadBits(13)
|
||||
}
|
||||
if end_trim_flag != 0 {
|
||||
_ = r.ReadBits(3)
|
||||
_ = r.ReadBits(13)
|
||||
}
|
||||
if control_extension_flag != 0 {
|
||||
control_extension_length := r.ReadByte()
|
||||
_ = r.ReadBytes(int(control_extension_length)) // reserved
|
||||
}
|
||||
|
||||
return payload_size
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
package mpegts
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"time"
|
||||
|
||||
"github.com/AlexxIT/go2rtc/pkg/aac"
|
||||
"github.com/AlexxIT/go2rtc/pkg/core"
|
||||
"github.com/AlexxIT/go2rtc/pkg/h264"
|
||||
"github.com/AlexxIT/go2rtc/pkg/h265"
|
||||
"github.com/pion/rtp"
|
||||
)
|
||||
|
||||
type Producer struct {
|
||||
core.Connection
|
||||
rd *core.ReadBuffer
|
||||
}
|
||||
|
||||
func Open(rd io.Reader) (*Producer, error) {
|
||||
prod := &Producer{
|
||||
Connection: core.Connection{
|
||||
ID: core.NewID(),
|
||||
FormatName: "mpegts",
|
||||
Transport: rd,
|
||||
},
|
||||
rd: core.NewReadBuffer(rd),
|
||||
}
|
||||
if err := prod.probe(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return prod, nil
|
||||
}
|
||||
|
||||
func (c *Producer) GetTrack(media *core.Media, codec *core.Codec) (*core.Receiver, error) {
|
||||
receiver, _ := c.Connection.GetTrack(media, codec)
|
||||
receiver.ID = StreamType(codec)
|
||||
return receiver, nil
|
||||
}
|
||||
|
||||
func (c *Producer) Start() error {
|
||||
rd := NewDemuxer()
|
||||
|
||||
for {
|
||||
pkt, err := rd.ReadPacket(c.rd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c.Recv += len(pkt.Payload)
|
||||
|
||||
//log.Printf("[mpegts] size: %6d, muxer: %10d, pt: %2d", len(pkt.Payload), pkt.Timestamp, pkt.PayloadType)
|
||||
|
||||
for _, receiver := range c.Receivers {
|
||||
if receiver.ID == pkt.PayloadType {
|
||||
TimestampToRTP(pkt, receiver.Codec)
|
||||
receiver.WriteRTP(pkt)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Producer) probe() error {
|
||||
c.rd.BufferSize = core.ProbeSize
|
||||
defer c.rd.Reset()
|
||||
|
||||
rd := NewDemuxer()
|
||||
|
||||
// Strategy:
|
||||
// 1. Wait packet with metadata, init other packets for wait
|
||||
// 2. Wait other packets
|
||||
// 3. Stop after timeout
|
||||
waitType := []byte{StreamTypeMetadata}
|
||||
timeout := time.Now().Add(core.ProbeTimeout)
|
||||
|
||||
for len(waitType) != 0 && time.Now().Before(timeout) {
|
||||
pkt, err := rd.ReadPacket(c.rd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// check if we wait this type
|
||||
if i := bytes.IndexByte(waitType, pkt.PayloadType); i < 0 {
|
||||
continue
|
||||
} else {
|
||||
waitType = append(waitType[:i], waitType[i+1:]...)
|
||||
}
|
||||
|
||||
switch pkt.PayloadType {
|
||||
case StreamTypeMetadata:
|
||||
for _, streamType := range pkt.Payload {
|
||||
switch streamType {
|
||||
case StreamTypeH264, StreamTypeH265, StreamTypeAAC, StreamTypePrivateOPUS, StreamTypePCMATapo:
|
||||
waitType = append(waitType, streamType)
|
||||
}
|
||||
}
|
||||
|
||||
case StreamTypeH264:
|
||||
codec := h264.AVCCToCodec(pkt.Payload)
|
||||
media := &core.Media{
|
||||
Kind: core.KindVideo,
|
||||
Direction: core.DirectionRecvonly,
|
||||
Codecs: []*core.Codec{codec},
|
||||
}
|
||||
c.Medias = append(c.Medias, media)
|
||||
|
||||
case StreamTypeH265:
|
||||
codec := h265.AVCCToCodec(pkt.Payload)
|
||||
media := &core.Media{
|
||||
Kind: core.KindVideo,
|
||||
Direction: core.DirectionRecvonly,
|
||||
Codecs: []*core.Codec{codec},
|
||||
}
|
||||
c.Medias = append(c.Medias, media)
|
||||
|
||||
case StreamTypeAAC:
|
||||
codec := aac.RTPToCodec(pkt.Payload)
|
||||
media := &core.Media{
|
||||
Kind: core.KindAudio,
|
||||
Direction: core.DirectionRecvonly,
|
||||
Codecs: []*core.Codec{codec},
|
||||
}
|
||||
c.Medias = append(c.Medias, media)
|
||||
|
||||
case StreamTypePrivateOPUS:
|
||||
codec := &core.Codec{
|
||||
Name: core.CodecOpus,
|
||||
ClockRate: 48000,
|
||||
Channels: 2,
|
||||
}
|
||||
media := &core.Media{
|
||||
Kind: core.KindAudio,
|
||||
Direction: core.DirectionRecvonly,
|
||||
Codecs: []*core.Codec{codec},
|
||||
}
|
||||
c.Medias = append(c.Medias, media)
|
||||
|
||||
case StreamTypePCMATapo:
|
||||
codec := &core.Codec{
|
||||
Name: core.CodecPCMA,
|
||||
ClockRate: 8000,
|
||||
}
|
||||
media := &core.Media{
|
||||
Kind: core.KindAudio,
|
||||
Direction: core.DirectionRecvonly,
|
||||
Codecs: []*core.Codec{codec},
|
||||
}
|
||||
c.Medias = append(c.Medias, media)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func StreamType(codec *core.Codec) uint8 {
|
||||
switch codec.Name {
|
||||
case core.CodecH264:
|
||||
return StreamTypeH264
|
||||
case core.CodecH265:
|
||||
return StreamTypeH265
|
||||
case core.CodecAAC:
|
||||
return StreamTypeAAC
|
||||
case core.CodecPCMA:
|
||||
return StreamTypePCMATapo
|
||||
case core.CodecOpus:
|
||||
return StreamTypePrivateOPUS
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func TimestampToRTP(rtp *rtp.Packet, codec *core.Codec) {
|
||||
if codec.ClockRate == ClockRate {
|
||||
return
|
||||
}
|
||||
rtp.Timestamp = uint32(float64(rtp.Timestamp) * float64(codec.ClockRate) / ClockRate)
|
||||
}
|
||||
Reference in New Issue
Block a user