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 11:12:54 +00:00
|
|
|
| verb 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
|
|
|
|
|
|
|
verb: aVerb [
|
|
|
|
<category: 'private'>
|
|
|
|
verb := aVerb.
|
|
|
|
]
|
|
|
|
|
|
|
|
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
|
|
|
|
nextPutAll: '%1 %2 %3 MGCP 1.0' % {verb. transaction. endp};
|
|
|
|
cr; nl.
|
|
|
|
|
|
|
|
"write the parameters"
|
|
|
|
params do: [:each |
|
|
|
|
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'>
|
|
|
|
|
|
|
|
MGCPCRCXCommand class >> createCRCX: anEndpoint callId: aCallId transId: aTransId [
|
|
|
|
<category: 'factory'>
|
|
|
|
"I create a CRCX command for the given endpoint."
|
|
|
|
|
|
|
|
^ (self new)
|
|
|
|
verb: 'CRCX';
|
|
|
|
transactionId: aTransId;
|
|
|
|
endpoint: anEndpoint;
|
|
|
|
parameterAdd: 'M: recvonly';
|
|
|
|
parameterAdd: 'C: ', aCallId asString;
|
|
|
|
yourself
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
MGCPCommand subclass: MGCPMDCXCommand [
|
|
|
|
<comment: 'I represent a MDCX message'>
|
|
|
|
<category: 'MGCP-Callagent'>
|
|
|
|
|
|
|
|
MGCPMDCXCommand class >> createMDCX: anEndpoint callId: aCallId transId: aTransId [
|
|
|
|
<category: 'factory'>
|
|
|
|
|
|
|
|
^ (self new)
|
|
|
|
verb: 'MDCX';
|
|
|
|
transactionId: aTransId;
|
|
|
|
endpoint: anEndpoint;
|
|
|
|
parameterAdd: 'C: ', aCallId asString;
|
|
|
|
yourself
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
MGCPCommand subclass: MGCPDLCXCommand [
|
|
|
|
<comment: 'I represent a DLCX message'>
|
|
|
|
<category: 'MGCP-Callagent'>
|
|
|
|
|
|
|
|
MGCPDLCXCommand class >> createDLCX: anEndpoint callId: aCallId transId: aTransId [
|
|
|
|
^ (self new)
|
|
|
|
verb: 'DLCX';
|
|
|
|
transactionId: aTransId;
|
|
|
|
endpoint: anEndpoint;
|
|
|
|
parameterAdd: 'C: ', aCallId asString;
|
|
|
|
yourself
|
|
|
|
]
|
|
|
|
]
|