2011-03-15 12:43:00 +00:00
|
|
|
"
|
|
|
|
(C) 2010-2011 by Holger Hans Peter Freyther
|
|
|
|
All Rights Reserved
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Affero General Public License as
|
|
|
|
published by the Free Software Foundation, either version 3 of the
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
"
|
|
|
|
|
|
|
|
Object subclass: MGCPCommand [
|
2011-06-10 23:17:48 +00:00
|
|
|
| transaction endp params sdp |
|
2011-06-10 10:05:01 +00:00
|
|
|
<comment: 'I am a command send to a MGCP gateway. I know my timeout
|
|
|
|
and such. Each MGCPGateWay can have a MGCPCommand subclass to specify
|
|
|
|
certain things. E.g. the endpoint numbering is different'>
|
|
|
|
<category: 'MGCP-callagent'>
|
2011-03-15 12:43:00 +00:00
|
|
|
|
2011-06-23 12:23:20 +00:00
|
|
|
MGCPCommand class >> create: anEndpoint callId: aCallId [
|
2011-06-10 11:52:31 +00:00
|
|
|
^ (self new)
|
|
|
|
endpoint: anEndpoint;
|
|
|
|
parameterAdd: 'C: ', aCallId asString;
|
|
|
|
yourself
|
|
|
|
]
|
|
|
|
|
2011-06-23 12:23:20 +00:00
|
|
|
MGCPCommand class >> create: anEndpoint [
|
2011-06-10 12:00:23 +00:00
|
|
|
^ (self new)
|
|
|
|
endpoint: anEndpoint;
|
|
|
|
yourself
|
|
|
|
]
|
|
|
|
|
2011-06-10 23:17:48 +00:00
|
|
|
MGCPCommand class >> verb [
|
|
|
|
<category: 'verb'>
|
|
|
|
^ self subclassResponsibility
|
2011-03-15 12:43:00 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
endpoint: anEndpoint [
|
|
|
|
<category: 'private'>
|
|
|
|
endp := anEndpoint.
|
|
|
|
]
|
|
|
|
|
|
|
|
transactionId: anId [
|
|
|
|
<category: 'private'>
|
|
|
|
transaction := anId.
|
|
|
|
]
|
|
|
|
|
2011-06-10 10:26:10 +00:00
|
|
|
parameterAdd: aParam [
|
|
|
|
<category: 'private'>
|
|
|
|
self params add: aParam.
|
|
|
|
]
|
|
|
|
|
|
|
|
params [
|
|
|
|
<category: 'private'>
|
|
|
|
^ params ifNil: [params := OrderedCollection new]
|
|
|
|
]
|
|
|
|
|
2011-06-10 11:12:54 +00:00
|
|
|
sdpAdd: line [
|
|
|
|
<category: 'private'>
|
|
|
|
self sdp add: line.
|
|
|
|
]
|
|
|
|
|
|
|
|
sdp [
|
|
|
|
<category: 'private'>
|
|
|
|
^ sdp ifNil: [sdp := OrderedCollection new]
|
|
|
|
]
|
|
|
|
|
2011-03-15 12:43:00 +00:00
|
|
|
asDatagram [
|
2011-06-10 10:26:10 +00:00
|
|
|
| out |
|
2011-03-15 12:43:00 +00:00
|
|
|
<category: 'networking'>
|
|
|
|
|
2011-06-10 10:26:10 +00:00
|
|
|
out := WriteStream on: (String new).
|
|
|
|
|
|
|
|
"write the header"
|
|
|
|
out
|
2011-06-10 23:17:48 +00:00
|
|
|
nextPutAll: '%1 %2 %3 MGCP 1.0' % {self class verb. transaction. endp};
|
2011-06-10 10:26:10 +00:00
|
|
|
cr; nl.
|
|
|
|
|
|
|
|
"write the parameters"
|
2011-06-10 12:00:23 +00:00
|
|
|
self params do: [:each |
|
2011-06-10 10:26:10 +00:00
|
|
|
out
|
|
|
|
nextPutAll: each;
|
|
|
|
cr; nl.
|
|
|
|
].
|
|
|
|
|
2011-06-10 11:12:54 +00:00
|
|
|
"write optional SDP"
|
|
|
|
sdp ifNotNil: [
|
|
|
|
out
|
|
|
|
cr; nl.
|
|
|
|
|
|
|
|
sdp do: [:each |
|
|
|
|
out
|
|
|
|
nextPutAll: each;
|
|
|
|
cr; nl.
|
|
|
|
].
|
|
|
|
].
|
|
|
|
|
2011-06-10 10:26:10 +00:00
|
|
|
^ out contents
|
2011-03-15 12:43:00 +00:00
|
|
|
]
|
|
|
|
]
|
2011-06-10 11:13:11 +00:00
|
|
|
|
|
|
|
MGCPCommand subclass: MGCPCRCXCommand [
|
|
|
|
<comment: 'I represent a CRCX message'>
|
|
|
|
<category: 'MGCP-callagent'>
|
|
|
|
|
2011-06-10 23:17:48 +00:00
|
|
|
MGCPCRCXCommand class >> verb [
|
|
|
|
<category: 'verb'>
|
|
|
|
^ 'CRCX'
|
|
|
|
]
|
|
|
|
|
2011-06-23 12:23:20 +00:00
|
|
|
MGCPCRCXCommand class >> createCRCX: anEndpoint callId: aCallId [
|
2011-06-10 11:13:11 +00:00
|
|
|
<category: 'factory'>
|
|
|
|
"I create a CRCX command for the given endpoint."
|
|
|
|
|
2011-06-23 12:23:20 +00:00
|
|
|
^ (self create: anEndpoint callId: aCallId)
|
2011-06-10 11:13:11 +00:00
|
|
|
yourself
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
MGCPCommand subclass: MGCPMDCXCommand [
|
|
|
|
<comment: 'I represent a MDCX message'>
|
|
|
|
<category: 'MGCP-Callagent'>
|
|
|
|
|
2011-06-10 23:17:48 +00:00
|
|
|
MGCPMDCXCommand class >> verb [
|
|
|
|
<category: 'verb'>
|
|
|
|
^ 'MDCX'
|
|
|
|
]
|
|
|
|
|
2011-06-23 12:23:20 +00:00
|
|
|
MGCPMDCXCommand class >> createMDCX: anEndpoint callId: aCallId [
|
2011-06-10 11:13:11 +00:00
|
|
|
<category: 'factory'>
|
|
|
|
|
2011-06-23 12:23:20 +00:00
|
|
|
^ (self create: anEndpoint callId: aCallId)
|
2011-06-10 11:13:11 +00:00
|
|
|
yourself
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
MGCPCommand subclass: MGCPDLCXCommand [
|
|
|
|
<comment: 'I represent a DLCX message'>
|
|
|
|
<category: 'MGCP-Callagent'>
|
|
|
|
|
2011-06-10 23:17:48 +00:00
|
|
|
MGCPDLCXCommand class >> verb [
|
|
|
|
<category: 'verb'>
|
|
|
|
^ DLCX
|
|
|
|
]
|
|
|
|
|
2011-06-23 12:23:20 +00:00
|
|
|
MGCPDLCXCommand class >> createDLCX: anEndpoint callId: aCallId [
|
|
|
|
^ (self create: anEndpoint callId: aCallId)
|
2011-06-10 11:13:11 +00:00
|
|
|
yourself
|
|
|
|
]
|
|
|
|
]
|
2011-06-10 12:00:23 +00:00
|
|
|
|
|
|
|
MGCPCommand subclass: MGCPAUEPComamnd [
|
|
|
|
<comment: 'I represent an AUEP message'>
|
|
|
|
<category: 'MGCP-Callagent'>
|
|
|
|
|
2011-06-10 23:17:48 +00:00
|
|
|
MGCPAUEPComamnd class >> verb [
|
|
|
|
<category: 'verb'>
|
|
|
|
^ 'AUEP'
|
|
|
|
]
|
|
|
|
|
2011-06-23 12:23:20 +00:00
|
|
|
MGCPAUEPComamnd class >> createAUEP: anEndpoint [
|
|
|
|
^ (self create: anEndpoint)
|
2011-06-10 12:00:23 +00:00
|
|
|
yourself
|
|
|
|
]
|
|
|
|
]
|