import { RtcpPacketConverter } from "../../src" ; import { RtcpSourceDescriptionPacket , SourceDescriptionChunk , SourceDescriptionItem , } from "../../src/rtcp/sdes" ; describe ( "rtcp/sdes" , ( ) => { test ( "two items" , ( ) => { const data = Buffer . from ( [ 0x81 , 0xca , 0x00 , 0x03 , 0x10 , 0x00 , 0x00 , 0x00 , 0x01 , 0x01 , 0x41 , 0x04 , 0x01 , 0x42 , 0x00 , 0x00 , ] ) ; const [ sdes ] = RtcpPacketConverter . deSerialize ( data ) as [ RtcpSourceDescriptionPacket ] ; expect ( sdes ) . toEqual ( new RtcpSourceDescriptionPacket ( { chunks : [ new SourceDescriptionChunk ( { source : 0x10000000 , items : [ new SourceDescriptionItem ( { type : 1 , text : "A" } ) , new SourceDescriptionItem ( { type : 4 , text : "B" } ) , ] , } ) , ] , } ) ) ; const d = sdes . serialize ( ) ; expect ( d ) . toEqual ( data ) ; } ) ; test ( "two chunks" , ( ) => { const data = Buffer . from ( [ 0x82 , 0xca , 0x00 , 0x05 , 0x01 , 0x02 , 0x03 , 0x04 , 0x01 , 0x01 , 0x41 , 0x00 , 0x05 , 0x06 , 0x07 , 0x08 , 0x01 , 0x03 , 0x42 , 0x43 , 0x44 , 0x00 , 0x00 , 0x00 , ] ) ; const [ sdes ] = RtcpPacketConverter . deSerialize ( data ) as [ RtcpSourceDescriptionPacket ] ; expect ( sdes ) . toEqual ( new RtcpSourceDescriptionPacket ( { chunks : [ new SourceDescriptionChunk ( { source : 0x01020304 , items : [ new SourceDescriptionItem ( { type : 1 , text : "A" } ) ] , } ) , new SourceDescriptionChunk ( { source : 0x05060708 , items : [ new SourceDescriptionItem ( { type : 1 , text : "BCD" } ) ] , } ) , ] , } ) ) ; const to = sdes . serialize ( ) ; expect ( to ) . toEqual ( data ) ; } ) ; } ) ;