Performed some testing on MpegTs

Now completed testing utilities for mpegts - which looks good. Now I need to look at testing the rtpToTsConverter.
This commit is contained in:
Unknown 2017-12-22 18:42:03 +10:30
parent 01834c4b91
commit b134b874df
2 changed files with 26 additions and 14 deletions

View File

@ -83,9 +83,11 @@ func (p *MpegTsPacket) ToByteSlice() (output []byte) {
} }
//copy(output[4:4+len(p.AF)],p.AF) //copy(output[4:4+len(p.AF)],p.AF)
//headerSize := packetLength-len(p.Payload) //headerSize := packetLength-len(p.Payload)
headerSize := 4 + len(p.AF) fmt.Printf("Length of AF: %v\n", len(p.AF))
for ii := headerSize; ii < packetLength; ii++ { payloadIndex := 4 + len(p.AF)
output[ii] = p.Payload[ii-headerSize] for ii := payloadIndex; ii < packetLength; ii++ {
output[ii] = p.Payload[ii-payloadIndex]
fmt.Println(ii)
} }
fmt.Printf("Packet size: %v\n",len(output)) fmt.Printf("Packet size: %v\n",len(output))
//fmt.Printf("Packet: %v\n",output) //fmt.Printf("Packet: %v\n",output)

View File

@ -292,6 +292,13 @@ Mpegts testing
********************************************************/ ********************************************************/
func TestMpegTsToByteSlice(t *testing.T){ func TestMpegTsToByteSlice(t *testing.T){
afRemainderLength := 180
afField := make([]byte, afRemainderLength+1)
afField[0] = byte(afRemainderLength)
afField[1] = byte(0)
for i := 2; i < len(afField); i++ {
afField[i] = 0xFF
}
tsPkt := MpegTsPacket{ tsPkt := MpegTsPacket{
byte(0x47), // sync byte byte(0x47), // sync byte
bool(false), // TEI bool(false), // TEI
@ -301,12 +308,7 @@ func TestMpegTsToByteSlice(t *testing.T){
byte(0), // TSC byte(0), // TSC
byte(3), // AFC byte(3), // AFC
byte(6), // CC byte(6), // CC
[]byte{ afField, // AF
byte(3), // AF length after this byte 1 + 2*stuffing byte
byte(0), // AF flags for optional fields
0xFF, // stuffing byte 1
0xFF, // stuffing byte 2
},
[]byte{ // data []byte{ // data
0x67, 0x67,
0xB2, 0xB2,
@ -318,7 +320,7 @@ func TestMpegTsToByteSlice(t *testing.T){
0x01, 0x01,
0x00, 0x00,
0x36, 0x36,
0x03, byte(afRemainderLength),
0x00, 0x00,
// this is where stuffing is, expect that to be 0xFF // this is where stuffing is, expect that to be 0xFF
0x67, 0x67,
@ -333,16 +335,24 @@ func TestMpegTsToByteSlice(t *testing.T){
} }
} }
// Check that the stuffing is all there // Check that the stuffing is all there
for ii := 6; ii < 179; ii++ { for ii := 6; ii < 185; ii++ {
if tsPktAsByteSlice[ii] != 0xFF { if tsPktAsByteSlice[ii] != 0xFF {
t.Errorf("Conversion to byte slice bad! Byte: %v Wanted: %v Got: %v", t.Errorf("Conversion to byte slice bad! Byte: %v Wanted: %v Got: %v",
ii, expectedOutput[ii], tsPktAsByteSlice[ii]) ii, byte(0xFF), tsPktAsByteSlice[ii])
} }
} }
for ii := 6; ii < 179; ii++ { for ii := 185; ii < 188; ii++ {
if tsPktAsByteSlice[ii] != 0xFF { if tsPktAsByteSlice[ii] != expectedOutput[ii-185+6] {
t.Errorf("Conversion to byte slice bad! Byte: %v Wanted: %v Got: %v", t.Errorf("Conversion to byte slice bad! Byte: %v Wanted: %v Got: %v",
ii, expectedOutput[ii], tsPktAsByteSlice[ii]) ii, expectedOutput[ii], tsPktAsByteSlice[ii])
} }
} }
} }
/*******************************************************
RtpToTsConverter testing
********************************************************/
func TestRtpToTsConverter(t *testing.T){
}