Holger Hans Peter Freyther | f42e908 | 2012-08-05 16:10:32 +0200 | [diff] [blame] | 1 | """ |
| 2 | Create a SIP connection and then stream... |
| 3 | """ |
| 4 | |
| 5 | PackageLoader |
| 6 | fileInPackage: #OsmoSIP. |
| 7 | |
| 8 | "Load for the replay code" |
| 9 | FileStream fileIn: 'rtp_replay_shared.st'. |
| 10 | |
| 11 | |
| 12 | Osmo.SIPCall subclass: StreamCall [ |
| 13 | | sem stream | |
| 14 | |
| 15 | createCall: aSDP [ |
| 16 | | sdp | |
| 17 | stream := RTPReplay on: 'rtp_ssrc6976010.240.240.1_to_10.240.240.50.state'. |
| 18 | sdp := aSDP % {stream localPort}. |
| 19 | ^ super createCall: sdp. |
| 20 | ] |
| 21 | |
| 22 | sem: aSemaphore [ |
| 23 | sem := aSemaphore |
| 24 | ] |
| 25 | |
| 26 | sessionNew [ |
| 27 | | host port | |
| 28 | Transcript nextPutAll: 'The call has started'; nl. |
| 29 | Transcript nextPutAll: sdp_result; nl. |
| 30 | |
| 31 | host := SDPUtils findHost: sdp_result. |
| 32 | port := SDPUtils findPort: sdp_result. |
| 33 | |
| 34 | [ |
| 35 | stream streamAudio: host port: port. |
| 36 | Transcript nextPutAll: 'Streaming has finished.'; nl. |
| 37 | ] fork. |
| 38 | ] |
| 39 | |
| 40 | sessionFailed [ |
| 41 | sem signal |
| 42 | ] |
| 43 | |
| 44 | sessionEnd [ |
| 45 | sem signal |
| 46 | ] |
| 47 | ] |
| 48 | |
| 49 | Eval [ |
| 50 | | transport agent call sem sdp_fr sdp_amr | |
| 51 | |
| 52 | |
| 53 | sdp_fr := (WriteStream on: String new) |
| 54 | nextPutAll: 'v=0'; cr; nl; |
| 55 | nextPutAll: 'o=twinkle 1739517580 1043400482 IN IP4 127.0.0.1'; cr; nl; |
| 56 | nextPutAll: 's=-'; cr; nl; |
| 57 | nextPutAll: 'c=IN IP4 127.0.0.1'; cr; nl; |
| 58 | nextPutAll: 't=0 0'; cr; nl; |
| 59 | nextPutAll: 'm=audio %1 RTP/AVP 0 101'; cr; nl; |
| 60 | nextPutAll: 'a=rtpmap:0 PCMU/8000'; cr; nl; |
| 61 | nextPutAll: 'a=rtpmap:101 telephone-event/8000'; cr; nl; |
| 62 | nextPutAll: 'a=fmtp:101 0-15'; cr; nl; |
| 63 | nextPutAll: 'a=ptime:20'; cr; nl; |
| 64 | contents. |
| 65 | |
| 66 | sem := Semaphore new. |
| 67 | transport := Osmo.SIPUdpTransport |
| 68 | startOn: '0.0.0.0' port: 5066. |
| 69 | agent := Osmo.SIPUserAgent createOn: transport. |
| 70 | transport start. |
| 71 | |
| 72 | call := (StreamCall |
| 73 | fromUser: 'sip:1000@sip.zecke.osmocom.org' |
| 74 | host: '127.0.0.1' |
| 75 | port: 5060 |
| 76 | to: 'sip:123456@127.0.0.1' |
| 77 | on: agent) |
| 78 | sem: sem; yourself. |
| 79 | |
| 80 | call createCall: sdp_fr. |
| 81 | |
| 82 | |
| 83 | "Wait for the stream to have ended" |
| 84 | sem wait. |
| 85 | |
| 86 | (Delay forSeconds: 4) wait. |
| 87 | ] |