mirror of https://bitbucket.org/ausocean/av.git
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:
parent
01834c4b91
commit
b134b874df
|
@ -83,9 +83,11 @@ func (p *MpegTsPacket) ToByteSlice() (output []byte) {
|
|||
}
|
||||
//copy(output[4:4+len(p.AF)],p.AF)
|
||||
//headerSize := packetLength-len(p.Payload)
|
||||
headerSize := 4 + len(p.AF)
|
||||
for ii := headerSize; ii < packetLength; ii++ {
|
||||
output[ii] = p.Payload[ii-headerSize]
|
||||
fmt.Printf("Length of AF: %v\n", len(p.AF))
|
||||
payloadIndex := 4 + len(p.AF)
|
||||
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: %v\n",output)
|
||||
|
|
|
@ -292,6 +292,13 @@ Mpegts testing
|
|||
********************************************************/
|
||||
|
||||
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{
|
||||
byte(0x47), // sync byte
|
||||
bool(false), // TEI
|
||||
|
@ -301,12 +308,7 @@ func TestMpegTsToByteSlice(t *testing.T){
|
|||
byte(0), // TSC
|
||||
byte(3), // AFC
|
||||
byte(6), // CC
|
||||
[]byte{
|
||||
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
|
||||
},
|
||||
afField, // AF
|
||||
[]byte{ // data
|
||||
0x67,
|
||||
0xB2,
|
||||
|
@ -318,7 +320,7 @@ func TestMpegTsToByteSlice(t *testing.T){
|
|||
0x01,
|
||||
0x00,
|
||||
0x36,
|
||||
0x03,
|
||||
byte(afRemainderLength),
|
||||
0x00,
|
||||
// this is where stuffing is, expect that to be 0xFF
|
||||
0x67,
|
||||
|
@ -333,16 +335,24 @@ func TestMpegTsToByteSlice(t *testing.T){
|
|||
}
|
||||
}
|
||||
// Check that the stuffing is all there
|
||||
for ii := 6; ii < 179; ii++ {
|
||||
for ii := 6; ii < 185; ii++ {
|
||||
if tsPktAsByteSlice[ii] != 0xFF {
|
||||
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++ {
|
||||
if tsPktAsByteSlice[ii] != 0xFF {
|
||||
for ii := 185; ii < 188; ii++ {
|
||||
if tsPktAsByteSlice[ii] != expectedOutput[ii-185+6] {
|
||||
t.Errorf("Conversion to byte slice bad! Byte: %v Wanted: %v Got: %v",
|
||||
ii, expectedOutput[ii], tsPktAsByteSlice[ii])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************
|
||||
RtpToTsConverter testing
|
||||
********************************************************/
|
||||
|
||||
func TestRtpToTsConverter(t *testing.T){
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue