You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
901 B
Go
39 lines
901 B
Go
package icspacketparser
|
|
|
|
import (
|
|
"fmt"
|
|
"strconv"
|
|
"strings"
|
|
|
|
"gitlab.com/cinnamon/voiceagent/icserror"
|
|
)
|
|
|
|
type SDPMedia struct {
|
|
MediaDescription string // m
|
|
Attributes []string // a
|
|
Payload []string // codec
|
|
}
|
|
|
|
func (sdm *SDPMedia) setSdpMediaStruct(name string, value string) (icserr *icserror.IcsError) {
|
|
switch strings.ToUpper(name) {
|
|
case "M":
|
|
sdm.MediaDescription = value
|
|
spaceSplitValue := strings.Split(value, " ")
|
|
for i, fieldValue := range spaceSplitValue {
|
|
intValue, err := strconv.Atoi(strings.TrimSpace(fieldValue))
|
|
if i >= 3 && err == nil {
|
|
sdm.Payload = append(sdm.Payload, strconv.Itoa(intValue))
|
|
}
|
|
}
|
|
// fmt.Println("sdm.Payload >>>>>>>>>>>", sdm.Payload)
|
|
|
|
return nil
|
|
case "A":
|
|
sdm.Attributes = append(sdm.Attributes, value)
|
|
return nil
|
|
default:
|
|
fmt.Println("SDP Media~~~~~~~~~~~~~~~~~whoAU~~~~~~~~~~~~~~~~~")
|
|
}
|
|
return nil
|
|
}
|