package icspacketparser

import (
	"fmt"
	"strconv"
	"strings"

	"gitlab.com/cinnamon/voiceagent/icserror"
)

type SDP struct {
	Version    uint8       // v
	Owner      string      // o
	Session    string      // s
	Connection string      // c
	Timing     string      // t
	Media      *[]SDPMedia // m a
}

func (sd *SDP) setSdpStruct(name string, value string) (icserr *icserror.IcsError) {
	switch strings.ToUpper(name) {
	case "V":
		numValue, err := strconv.ParseUint(value, 10, 64)
		if err != nil {
			return icserror.ICSERRSDPParser
		}
		sd.Version = uint8(numValue)
		return nil
	case "O":
		sd.Owner = value
		return nil
	case "S":
		sd.Session = value
		return nil
	case "C":
		sd.Connection = value
		return nil
	case "T":
		sd.Timing = value
		return nil
	default:
		fmt.Println("SDP~~~~~~~~~~~~~~~~~whoAU~~~~~~~~~~~~~~~~~")
	}
	return nil
}