diff --git a/BSSMAP.st b/BSSMAP.st index 865c8f9..c04ced6 100644 --- a/BSSMAP.st +++ b/BSSMAP.st @@ -461,25 +461,55 @@ GSM0808IE subclass: GSM0808ChosenEncrIE [ GSM0808IE subclass: GSM0808ChannelTypeIE [ | type preferred codecs | + + GSM0808ChannelTypeIE class >> speechSpeech [ ^ 1 ] GSM0808ChannelTypeIE class >> speechData [ ^ 2 ] GSM0808ChannelTypeIE class >> speechSignalling [ ^ 3 ] "TODO: provide defs for the 3.2.2.11 ChannelType rate" + GSM0808ChannelTypeIE class [ + chanSpeechFullBm [ ^ 2r1000 ] + chanSpeechHalfLm [ ^ 2r1001 ] + chanSpeechFullPref [ ^ 2r1010 ] + chanSpeechHalfPref [ ^ 2r1011 ] + chanSpeechFullPrefNoChange [ ^ 2r11010 ] + chanSpeechHalfPrefNoChange [ ^ 2r11011 ] + chanSpeechAny [ ^ 2r1111 ] + chanSpeechAnyNoChange [ ^ 2r11111 ] + + speechFullRateVersion1 [ ^ 2r000001 ] + speechFullRateVersion2 [ ^ 2r010001 ] + speechFullRateVersion3 [ ^ 2r100001 ] + speechHalfRateVersion1 [ ^ 2r000101 ] + speechHalfRateVersion2 [ ^ 2r010101 ] + speechHalfRateVersion3 [ ^ 2r100101 ] + + buildPermittedSpeechList: aList [ + | out | + out := aList asByteArray copy. + + 1 to: out size - 1 do: [:pos | + out at: pos put: ((out at: pos) bitOr: 16r80) + ]. + + ^ out + ] + ] GSM0808ChannelTypeIE class >> elementId [ ^ 11 ] - GSM0808ChannelTypeIE class >> initWith: aType audio: anAudioType codecs: codecs [ + GSM0808ChannelTypeIE class >> initWith: aType audio: anAudioType [ ^ self new type: aType; preferred: anAudioType; - audioCodecs: codecs; yourself ] GSM0808ChannelTypeIE class >> parseFrom: aByteArray [ - ^ self initWith: (aByteArray at: 3) - audio: (aByteArray at: 4) - codecs: (aByteArray copyFrom: 5) + ^ (self initWith: (aByteArray at: 3) + audio: (aByteArray at: 4)) + audioCodecs: (aByteArray copyFrom: 5); + yourself ] type [ ^ type ] @@ -490,10 +520,15 @@ GSM0808IE subclass: GSM0808ChannelTypeIE [ preferred [ ^ preferred ] preferred: aPreferred [ preferred := aPreferred ] + audioCodecs: aList [ + + self audioCodecsData: (self class buildPermittedSpeechList: aList). + ] + "TODO: This should decode/encode the codecs" - audioCodecs [ ^ codecs ] - audioCodecs: aCodecs [ codecs := aCodecs. ] + audioCodecsData [ ^ codecs ] + audioCodecsData: aCodecs [ codecs := aCodecs. ] writeOnDirect: aMsg [ aMsg putByte: 2 + codecs size. diff --git a/Tests.st b/Tests.st index 36dfc85..87006bb 100644 --- a/Tests.st +++ b/Tests.st @@ -104,6 +104,22 @@ TestCase subclass: GSM0808Test [ res := (GSM0808CICIE initWithMultiplex: 1 timeslot: 20) toMessage asByteArray. self assert: res = #(1 0 52) asByteArray. ] + + testChanIE [ + | res | + res := (GSM0808ChannelTypeIE buildPermittedSpeechList: + {GSM0808ChannelTypeIE speechFullRateVersion3. + GSM0808ChannelTypeIE speechHalfRateVersion3}). + self assert: res = #(161 37) asByteArray. + + res := ((GSM0808ChannelTypeIE + initWith: (GSM0808ChannelTypeIE speechSpeech) + audio: (GSM0808ChannelTypeIE chanSpeechHalfPrefNoChange)) + audioCodecs: {GSM0808ChannelTypeIE speechFullRateVersion3. + GSM0808ChannelTypeIE speechHalfRateVersion3}; + yourself). + self assert: res toMessage asByteArray = #(11 4 1 27 161 37) asByteArray. + ] ] TestCase subclass: BSSAPTest [