mirror of https://bitbucket.org/ausocean/av.git
protocol/rtp/rtp.go: renamed Pkt type to Packet.
This commit is contained in:
parent
c9aa43394b
commit
aa7553947a
|
@ -106,7 +106,7 @@ func TestReceive(t *testing.T) {
|
|||
}
|
||||
|
||||
// Create expected data and apply operation if there is one.
|
||||
expect := (&Pkt{V: rtpVer, Payload: []byte{byte(packetsReceived)}}).Bytes(nil)
|
||||
expect := (&Packet{V: rtpVer, Payload: []byte{byte(packetsReceived)}}).Bytes(nil)
|
||||
|
||||
// Compare.
|
||||
got := buf[:n]
|
||||
|
@ -134,7 +134,7 @@ func TestReceive(t *testing.T) {
|
|||
|
||||
// Send packets to the client.
|
||||
for i := 0; i < packetsToSend; i++ {
|
||||
p := (&Pkt{V: rtpVer, Payload: []byte{byte(i)}}).Bytes(nil)
|
||||
p := (&Packet{V: rtpVer, Payload: []byte{byte(i)}}).Bytes(nil)
|
||||
_, err := conn.Write(p)
|
||||
if err != nil {
|
||||
serverErr <- fmt.Errorf("could not write packet to conn, failed with err: %v\n", err)
|
||||
|
|
|
@ -97,7 +97,7 @@ func min(a, b int) int {
|
|||
// Encode takes a nalu unit and encodes it into an rtp packet and
|
||||
// writes to the io.Writer given in NewEncoder
|
||||
func (e *Encoder) Encode(payload []byte) error {
|
||||
pkt := Pkt{
|
||||
pkt := Packet{
|
||||
V: rtpVer, // version
|
||||
X: false, // header extension
|
||||
CC: 0, // CSRC count
|
||||
|
|
|
@ -35,7 +35,7 @@ import (
|
|||
// TestVersion checks that we can correctly get the version from an RTP packet.
|
||||
func TestVersion(t *testing.T) {
|
||||
const expect = 1
|
||||
got := version((&Pkt{V: expect}).Bytes(nil))
|
||||
got := version((&Packet{V: expect}).Bytes(nil))
|
||||
if got != expect {
|
||||
t.Errorf("unexpected version for RTP packet. Got: %v\n Want: %v\n", got, expect)
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ func TestVersion(t *testing.T) {
|
|||
func TestCsrcCount(t *testing.T) {
|
||||
const ver, expect = 2, 2
|
||||
|
||||
pkt := (&Pkt{
|
||||
pkt := (&Packet{
|
||||
V: ver,
|
||||
CC: expect,
|
||||
CSRC: make([][4]byte, expect),
|
||||
|
@ -64,7 +64,7 @@ func TestHasExt(t *testing.T) {
|
|||
const ver = 2
|
||||
|
||||
// First check for when there is an extension field.
|
||||
pkt := &Pkt{
|
||||
pkt := &Packet{
|
||||
V: ver,
|
||||
X: true,
|
||||
Extension: ExtensionHeader{
|
||||
|
@ -93,19 +93,19 @@ func TestPayload(t *testing.T) {
|
|||
expect := []byte{0x01, 0x02, 0x03, 0x04, 0x05}
|
||||
|
||||
testPkts := [][]byte{
|
||||
(&Pkt{
|
||||
(&Packet{
|
||||
V: ver,
|
||||
Payload: expect,
|
||||
}).Bytes(nil),
|
||||
|
||||
(&Pkt{
|
||||
(&Packet{
|
||||
V: ver,
|
||||
CC: 3,
|
||||
CSRC: make([][4]byte, 3),
|
||||
Payload: expect,
|
||||
}).Bytes(nil),
|
||||
|
||||
(&Pkt{
|
||||
(&Packet{
|
||||
V: ver,
|
||||
X: true,
|
||||
Extension: ExtensionHeader{
|
||||
|
@ -115,7 +115,7 @@ func TestPayload(t *testing.T) {
|
|||
Payload: expect,
|
||||
}).Bytes(nil),
|
||||
|
||||
(&Pkt{
|
||||
(&Packet{
|
||||
V: ver,
|
||||
CC: 3,
|
||||
CSRC: make([][4]byte, 3),
|
||||
|
|
|
@ -46,7 +46,7 @@ const (
|
|||
|
||||
// Pkt provides fields consistent with RFC3550 definition of an rtp packet
|
||||
// The padding indicator does not need to be set manually, only the padding length
|
||||
type Pkt struct {
|
||||
type Packet struct {
|
||||
V uint8 // Version (currently 2).
|
||||
p bool // Padding indicator (0 => padding, 1 => padding).
|
||||
X bool // Extension header indicator.
|
||||
|
@ -69,7 +69,7 @@ type ExtensionHeader struct {
|
|||
}
|
||||
|
||||
// Bytes provides a byte slice of the packet
|
||||
func (p *Pkt) Bytes(buf []byte) []byte {
|
||||
func (p *Packet) Bytes(buf []byte) []byte {
|
||||
// Calculate the required length for the RTP packet.
|
||||
headerExtensionLen := 0
|
||||
if p.X {
|
||||
|
|
|
@ -35,13 +35,13 @@ import (
|
|||
// TODO (saxon): add more tests
|
||||
var rtpTests = []struct {
|
||||
num int
|
||||
pkt Pkt
|
||||
pkt Packet
|
||||
want []byte
|
||||
}{
|
||||
// No padding, no CSRC and no extension.
|
||||
{
|
||||
num: 1,
|
||||
pkt: Pkt{
|
||||
pkt: Packet{
|
||||
V: 2,
|
||||
p: false,
|
||||
X: false,
|
||||
|
@ -67,7 +67,7 @@ var rtpTests = []struct {
|
|||
// With padding.
|
||||
{
|
||||
num: 2,
|
||||
pkt: Pkt{
|
||||
pkt: Packet{
|
||||
V: 2,
|
||||
p: true,
|
||||
X: false,
|
||||
|
@ -101,7 +101,7 @@ var rtpTests = []struct {
|
|||
// With padding and CSRC.
|
||||
{
|
||||
num: 3,
|
||||
pkt: Pkt{
|
||||
pkt: Packet{
|
||||
V: 2,
|
||||
p: true,
|
||||
X: false,
|
||||
|
@ -141,7 +141,7 @@ var rtpTests = []struct {
|
|||
// With padding, CSRC and extension.
|
||||
{
|
||||
num: 4,
|
||||
pkt: Pkt{
|
||||
pkt: Packet{
|
||||
V: 2,
|
||||
p: true,
|
||||
X: true,
|
||||
|
|
Loading…
Reference in New Issue