Make core atoi func public
This commit is contained in:
+2
-7
@@ -68,7 +68,7 @@ func (c *Codec) Match(remote *Codec) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func UnmarshalCodec(md *sdp.MediaDescription, payloadType string) *Codec {
|
func UnmarshalCodec(md *sdp.MediaDescription, payloadType string) *Codec {
|
||||||
c := &Codec{PayloadType: byte(atoi(payloadType))}
|
c := &Codec{PayloadType: byte(Atoi(payloadType))}
|
||||||
|
|
||||||
for _, attr := range md.Attributes {
|
for _, attr := range md.Attributes {
|
||||||
switch {
|
switch {
|
||||||
@@ -78,7 +78,7 @@ func UnmarshalCodec(md *sdp.MediaDescription, payloadType string) *Codec {
|
|||||||
|
|
||||||
c.Name = strings.ToUpper(ss[0])
|
c.Name = strings.ToUpper(ss[0])
|
||||||
// fix tailing space: `a=rtpmap:96 H264/90000 `
|
// fix tailing space: `a=rtpmap:96 H264/90000 `
|
||||||
c.ClockRate = uint32(atoi(strings.TrimRightFunc(ss[1], unicode.IsSpace)))
|
c.ClockRate = uint32(Atoi(strings.TrimRightFunc(ss[1], unicode.IsSpace)))
|
||||||
|
|
||||||
if len(ss) == 3 && ss[2] == "2" {
|
if len(ss) == 3 && ss[2] == "2" {
|
||||||
c.Channels = 2
|
c.Channels = 2
|
||||||
@@ -120,11 +120,6 @@ func UnmarshalCodec(md *sdp.MediaDescription, payloadType string) *Codec {
|
|||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
func atoi(s string) (i int) {
|
|
||||||
i, _ = strconv.Atoi(s)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func DecodeH264(fmtp string) string {
|
func DecodeH264(fmtp string) string {
|
||||||
if ps := Between(fmtp, "sprop-parameter-sets=", ","); ps != "" {
|
if ps := Between(fmtp, "sprop-parameter-sets=", ","); ps != "" {
|
||||||
if sps, _ := base64.StdEncoding.DecodeString(ps); len(sps) >= 4 {
|
if sps, _ := base64.StdEncoding.DecodeString(ps); len(sps) >= 4 {
|
||||||
|
|||||||
@@ -41,6 +41,11 @@ func Between(s, sub1, sub2 string) string {
|
|||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Atoi(s string) (i int) {
|
||||||
|
i, _ = strconv.Atoi(s)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func Assert(ok bool) {
|
func Assert(ok bool) {
|
||||||
if !ok {
|
if !ok {
|
||||||
_, file, line, _ := runtime.Caller(1)
|
_, file, line, _ := runtime.Caller(1)
|
||||||
|
|||||||
Reference in New Issue
Block a user