endp: Let a endpoint know its GSM Timeslot and Multiplex
Attempt to deal properly with virtual trunks that have more than 32 items here.
This commit is contained in:
parent
813b227be1
commit
273fa71a2a
|
@ -35,9 +35,20 @@ Object subclass: MGCPEndpoint [
|
|||
]
|
||||
|
||||
endpointName [
|
||||
<category: 'names'>
|
||||
^ trunk endpointName: nr.
|
||||
]
|
||||
|
||||
multiplex [
|
||||
<category: 'names'>
|
||||
^ trunk multiplexFor: nr.
|
||||
]
|
||||
|
||||
timeslot [
|
||||
<category: 'names'>
|
||||
^ trunk timeslotFor: nr.
|
||||
]
|
||||
|
||||
trunk [
|
||||
<category: 'private'>
|
||||
^ trunk
|
||||
|
|
|
@ -64,6 +64,16 @@ Object subclass: MGCPTrunkBase [
|
|||
^ self subclassResponsibility
|
||||
]
|
||||
|
||||
multiplexFor: aNr [
|
||||
<category: 'accessing'>
|
||||
^ self subclassResponsibility.
|
||||
]
|
||||
|
||||
timeslotFor: aNr [
|
||||
<category: 'accessing'>
|
||||
^ self subclassResponsibility.
|
||||
]
|
||||
|
||||
critical: aBlock [
|
||||
<category: 'accessing'>
|
||||
sem critical: aBlock.
|
||||
|
@ -104,8 +114,19 @@ MGCPTrunkBase subclass: MGCPVirtualTrunk [
|
|||
]
|
||||
|
||||
endpointName: aNr [
|
||||
<category: 'accessing'>
|
||||
^ '%1@mgw' % {((aNr radix: 16) copyFrom: 4) asLowercase}
|
||||
]
|
||||
|
||||
multiplexFor: aNr [
|
||||
<category: 'accessing'>
|
||||
^ aNr // 32
|
||||
]
|
||||
|
||||
timeslotFor: aNr [
|
||||
<category: 'accessing'>
|
||||
^ aNr \\ 32
|
||||
]
|
||||
]
|
||||
|
||||
MGCPTrunkBase subclass: MGCPDSTrunk [
|
||||
|
@ -117,7 +138,7 @@ MGCPTrunkBase subclass: MGCPDSTrunk [
|
|||
<category: 'factory'>
|
||||
^ self new
|
||||
destIP: anIP;
|
||||
numbersPorts: 32;
|
||||
numbersPorts: 31;
|
||||
trunkNr: aNr;
|
||||
yourself
|
||||
]
|
||||
|
@ -127,6 +148,15 @@ MGCPTrunkBase subclass: MGCPDSTrunk [
|
|||
]
|
||||
|
||||
endpointName: aNr [
|
||||
<category: 'accessing'>
|
||||
^ 'ds/e1-%1/%2@mgw' % {trunk. aNr}
|
||||
]
|
||||
|
||||
multiplexFor: aNr [
|
||||
^ trunk
|
||||
]
|
||||
|
||||
timeslotFor: aNr [
|
||||
^ aNr \\ 32
|
||||
]
|
||||
]
|
||||
|
|
|
@ -27,7 +27,7 @@ TestCase subclass: MGCPCommandTest [
|
|||
|
||||
trunk [
|
||||
^ trunk ifNil: [
|
||||
trunk := MGCPVirtualTrunk createWithDest: '127.0.0.1' numberPorts: 32]
|
||||
trunk := MGCPVirtualTrunk createWithDest: '127.0.0.1' numberPorts: 31]
|
||||
]
|
||||
|
||||
endpoint [
|
||||
|
@ -67,6 +67,19 @@ TestCase subclass: MGCPCommandTest [
|
|||
self assert: (trunk endpointName: 16rA) = 'ds/e1-1/10@mgw'.
|
||||
]
|
||||
|
||||
testMultiplexTimeslot [
|
||||
| trunk |
|
||||
trunk := MGCPDSTrunk createWithDest: '0.0.0.0' trunkNr: 3.
|
||||
|
||||
self assert: (self trunk endpointAt: 1) multiplex = 0.
|
||||
self assert: (self trunk endpointAt: 1) timeslot = 1.
|
||||
self assert: (self trunk endpointAt: 31) multiplex = 0.
|
||||
self assert: (self trunk endpointAt: 31) timeslot = 31.
|
||||
|
||||
self assert: (trunk endpointAt: 1) multiplex = 3.
|
||||
self assert: (trunk endpointAt: 31) timeslot = 31.
|
||||
]
|
||||
|
||||
tearDown [
|
||||
self callagent stop.
|
||||
]
|
||||
|
|
Reference in New Issue