diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2012-05-18 18:54:11 +0200 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2012-05-18 18:54:11 +0200 |
commit | 3fab3fdd24024f9b6208cc4b04b5c6b2d9746218 (patch) | |
tree | a3393c348418d8c86fe5105bc9ab042a1d25c900 | |
parent | bea9a1206b18f954a7d3b2de496ab7cbfd0bb3b9 (diff) |
rtp: Add a smalltalk script that can replay the state file.0.11.0
-rw-r--r-- | openbsc/contrib/rtp/rtp_replay.st | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/openbsc/contrib/rtp/rtp_replay.st b/openbsc/contrib/rtp/rtp_replay.st new file mode 100644 index 000000000..929976783 --- /dev/null +++ b/openbsc/contrib/rtp/rtp_replay.st @@ -0,0 +1,56 @@ +" +Simple UDP replay from the state files +" + +PackageLoader fileInPackage: #Sockets. + +Eval [ + | last_time last_image udp_send socket dest | + + last_time := nil. + last_image := nil. + file := FileStream open: 'rtp_ssrc13529910.240.240.1_to_10.240.240.50.state'. + + "Send the payload" + dest := Sockets.SocketAddress byName: '127.0.0.1'. + socket := Sockets.DatagramSocket new. + udp_send := [:payload | | datagram | + datagram := Sockets.Datagram data: payload contents address: dest port: 4000. + socket nextPut: datagram + ]. + + [file atEnd] whileFalse: [ + | lineStream time data now_image | + lineStream := file nextLine readStream. + + "Read the time, skip the blank, parse the data" + time := Number readFrom: lineStream. + lineStream skip: 1. + + data := WriteStream on: (ByteArray new: 30). + [lineStream atEnd] whileFalse: [ + | hex | + hex := lineStream next: 2. + data nextPut: (Number readFrom: hex readStream radix: 16). + ]. + + last_time isNil + ifTrue: [ + "First time, send it right now" + last_time := time. + last_image := Time millisecondClockValue. + udp_send value: data. + ] + ifFalse: [ + | wait_image new_image_time | + + "How long to wait?" + wait_image := last_image + ((time - last_time) * 1000). + [ wait_image > Time millisecondClockValue ] whileTrue: []. + + udp_send value: data. + last_time := time. + last_image := wait_image. + ] + ]. +] |