-2

I have a stream of incoming RTP packet and I have two goals to accomplish which I am finding difficult in a high level language like Python.

1 ) Strip away the header from the rtp packet, i.e remove the redundant section of the rtp packet that isn't audio

2 ) Once I have the data, change it from big endian to little endian.

Note : I have been told about struct.pack , but that deals with a section or one number. How do I change the entire data?

memeKing
  • 113
  • 2
  • 10
  • What is the problem you are running into? [How to create a Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) In python 2.7, strings are byte sequences and byte sequences are strings. In Python3 byte objects store sequences of bytes; see also https://docs.python.org/3/glossary.html#term-bytes-like-object – cowbert Jan 08 '18 at 22:16
  • Endianess doesn't apply to an entire packet, just to words within the packet. For example, a packet consisting of 2 4-byte words `0102030405060708` would become `0403020108070605`, the two words staying in the same order but the bytes in each word being reversed. You'll probably need to use `struct.unpack` and `struct.pack` to tease the packet apart, then reassemble it. – chepner Jan 08 '18 at 22:16
  • @chepner ohh I see, thanks.I am trying to attach an incoming RTP packet with big endian, into the little endian audio section of a wav file which shown <- http://soundfile.sapp.org/doc/WaveFormat/ -> takes little endian (Last section). – memeKing Jan 08 '18 at 22:20
  • Take a look at Scapy http://www.secdev.org/projects/scapy/ - very helpful for modifying network data – Peter Gibson Jan 08 '18 at 22:26
  • @chepner couldn't he just slice the packet along the word boundaries into bytearray, and b''.join(reversed(barray))? – cowbert Jan 08 '18 at 22:29

1 Answers1

0

Ending up just chucking it into a bytearray, indexing it and then doing bitwise opreations.

memeKing
  • 113
  • 2
  • 10