smalltalk
/
osmo-st-mgcp
Archived
1
0
Fork 0
This repository has been archived on 2022-02-17. You can view files and clone it, but cannot push or open issues or pull requests.
osmo-st-mgcp/callagent/MGCPCommands.st

78 lines
2.1 KiB
Smalltalk
Raw Normal View History

"
(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 [
| verb transaction endp params sdp|
<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'>
MGCPCommand class >> createCRCX: anEndpoint callId: aCallId transId: aTransId [
<category: 'factory'>
"I create a CRCX command for the given endpoint."
^ (self new)
initialize;
verb: 'CRCX';
transactionId: aTransId;
endpoint: (self endpointNumberToName: anEndpoint);
parameterAdd: 'M: recvonly';
parameterAdd: 'C: ', aCallId;
yourself
]
MGCPCommand class >> endpointNumberToName: aNumber [
| hex |
<category: 'format'>
<comment: 'The IPA MGW assumes endpoint numbers in hex, lowercase'>
hex := ((aNumber radix: 16) copyFrom: 4) asLowercase.
^ hex, '@mgw'
]
initialize [
sdp := OrderedCollection new.
params := OrderedCollection new.
]
verb: aVerb [
<category: 'private'>
verb := aVerb.
]
endpoint: anEndpoint [
<category: 'private'>
endp := anEndpoint.
]
transactionId: anId [
<category: 'private'>
transaction := anId.
]
asDatagram [
| end msg |
<category: 'networking'>
end := Character lf asString, Character nl asString.
msg := verb, ' ', endp, ' MGCP 1.0', end
]
]