diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2012-08-05 16:10:32 +0200 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2012-08-05 16:10:32 +0200 |
commit | f42e908cea678cf87fcd7b83469d694921021b33 (patch) | |
tree | 6bdcde84e1b125a99d108ee4ca25cc9bdaeac844 /openbsc/contrib/rtp/rtp_replay_shared.st | |
parent | 602559fd9fa39015043ec6fa2a1f8d2c8e36d062 (diff) |
contrib: Create a script that opens a SIP session before
Use the Smalltalk SIP implementation to create a call
and once the call has been established start the replay
using the commoncode. No patching of RTP occurs yet.
Diffstat (limited to 'openbsc/contrib/rtp/rtp_replay_shared.st')
-rw-r--r-- | openbsc/contrib/rtp/rtp_replay_shared.st | 47 |
1 files changed, 43 insertions, 4 deletions
diff --git a/openbsc/contrib/rtp/rtp_replay_shared.st b/openbsc/contrib/rtp/rtp_replay_shared.st index cfb66bb4d..dd32aed7a 100644 --- a/openbsc/contrib/rtp/rtp_replay_shared.st +++ b/openbsc/contrib/rtp/rtp_replay_shared.st @@ -4,19 +4,58 @@ Simple UDP replay from the state files PackageLoader fileInPackage: #Sockets. +Object subclass: SDPUtils [ + "Look into using PetitParser." + SDPUtils class >> findPort: aSDP [ + aSDP linesDo: [:line | + (line startsWith: 'm=audio ') ifTrue: [ + | stream | + stream := line readStream + skip: 'm=audio ' size; + yourself. + ^ Number readFrom: stream. + ] + ]. + + ^ self error: 'Not found'. + ] + + SDPUtils class >> findHost: aSDP [ + aSDP linesDo: [:line | + (line startsWith: 'c=IN IP4 ') ifTrue: [ + | stream | + ^ stream := line readStream + skip: 'c=IN IP4 ' size; + upToEnd. + ] + ]. + + ^ self error: 'Not found'. + ] +] + Object subclass: RTPReplay [ - | filename | + | filename socket | RTPReplay class >> on: aFile [ ^ self new + initialize; file: aFile; yourself ] + initialize [ + socket := Sockets.DatagramSocket new. + ] + file: aFile [ filename := aFile ] + localPort [ + ^ socket port + ] + streamAudio: aHost port: aPort [ - | file last_time last_image udp_send socket dest | + | file last_time last_image udp_send dest | last_time := nil. last_image := nil. @@ -24,7 +63,6 @@ Object subclass: RTPReplay [ "Send the payload" dest := Sockets.SocketAddress byName: aHost. - socket := Sockets.DatagramSocket new. udp_send := [:payload | | datagram | datagram := Sockets.Datagram data: payload contents address: dest port: aPort. socket nextPut: datagram @@ -57,7 +95,8 @@ Object subclass: RTPReplay [ "How long to wait?" wait_image := last_image + ((time - last_time) * 1000). - [ wait_image > Time millisecondClockValue ] whileTrue: []. + [ wait_image > Time millisecondClockValue ] + whileTrue: [Processor yield]. udp_send value: data. last_time := time. |