5 changed files with 55 additions and 56 deletions
@ -0,0 +1,51 @@
@@ -0,0 +1,51 @@
|
||||
package main |
||||
|
||||
import ( |
||||
"fmt" |
||||
"net" |
||||
) |
||||
|
||||
func parseIpCidrList(in []string) ([]interface{}, error) { |
||||
if len(in) == 0 { |
||||
return nil, nil |
||||
} |
||||
|
||||
var ret []interface{} |
||||
for _, t := range in { |
||||
_, ipnet, err := net.ParseCIDR(t) |
||||
if err == nil { |
||||
ret = append(ret, ipnet) |
||||
continue |
||||
} |
||||
|
||||
ip := net.ParseIP(t) |
||||
if ip != nil { |
||||
ret = append(ret, ip) |
||||
continue |
||||
} |
||||
|
||||
return nil, fmt.Errorf("unable to parse ip/network '%s'", t) |
||||
} |
||||
return ret, nil |
||||
} |
||||
|
||||
type trackFlowType int |
||||
|
||||
const ( |
||||
_TRACK_FLOW_RTP trackFlowType = iota |
||||
_TRACK_FLOW_RTCP |
||||
) |
||||
|
||||
func interleavedChannelToTrack(channel uint8) (int, trackFlowType) { |
||||
if (channel % 2) == 0 { |
||||
return int(channel / 2), _TRACK_FLOW_RTP |
||||
} |
||||
return int((channel - 1) / 2), _TRACK_FLOW_RTCP |
||||
} |
||||
|
||||
func trackToInterleavedChannel(id int, trackFlowType trackFlowType) uint8 { |
||||
if trackFlowType == _TRACK_FLOW_RTP { |
||||
return uint8(id * 2) |
||||
} |
||||
return uint8((id * 2) + 1) |
||||
} |
||||
Loading…
Reference in new issue