|
|
@ -7,6 +7,7 @@ import (
|
|
|
|
"net"
|
|
|
|
"net"
|
|
|
|
"strconv"
|
|
|
|
"strconv"
|
|
|
|
"strings"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/penggy/EasyGoLib/utils"
|
|
|
|
"github.com/penggy/EasyGoLib/utils"
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -116,8 +117,14 @@ func (s *UDPServer) SetupAudio() (err error) {
|
|
|
|
bufUDP := make([]byte, UDP_BUF_SIZE)
|
|
|
|
bufUDP := make([]byte, UDP_BUF_SIZE)
|
|
|
|
logger.Printf("udp server start listen audio port[%d]", s.APort)
|
|
|
|
logger.Printf("udp server start listen audio port[%d]", s.APort)
|
|
|
|
defer logger.Printf("udp server stop listen audio port[%d]", s.APort)
|
|
|
|
defer logger.Printf("udp server stop listen audio port[%d]", s.APort)
|
|
|
|
|
|
|
|
timer := time.Unix(0, 0)
|
|
|
|
for !s.Stoped {
|
|
|
|
for !s.Stoped {
|
|
|
|
if n, _, err := s.AConn.ReadFromUDP(bufUDP); err == nil {
|
|
|
|
if n, _, err := s.AConn.ReadFromUDP(bufUDP); err == nil {
|
|
|
|
|
|
|
|
elapsed := time.Now().Sub(timer)
|
|
|
|
|
|
|
|
if elapsed >= 30*time.Second {
|
|
|
|
|
|
|
|
logger.Printf("Package recv from AConn.len:%d\n", n)
|
|
|
|
|
|
|
|
timer = time.Now()
|
|
|
|
|
|
|
|
}
|
|
|
|
rtpBytes := make([]byte, n)
|
|
|
|
rtpBytes := make([]byte, n)
|
|
|
|
s.AddInputBytes(n)
|
|
|
|
s.AddInputBytes(n)
|
|
|
|
copy(rtpBytes, bufUDP)
|
|
|
|
copy(rtpBytes, bufUDP)
|
|
|
@ -158,6 +165,7 @@ func (s *UDPServer) SetupAudio() (err error) {
|
|
|
|
defer logger.Printf("udp server stop listen audio control port[%d]", s.AControlPort)
|
|
|
|
defer logger.Printf("udp server stop listen audio control port[%d]", s.AControlPort)
|
|
|
|
for !s.Stoped {
|
|
|
|
for !s.Stoped {
|
|
|
|
if n, _, err := s.AControlConn.ReadFromUDP(bufUDP); err == nil {
|
|
|
|
if n, _, err := s.AControlConn.ReadFromUDP(bufUDP); err == nil {
|
|
|
|
|
|
|
|
//logger.Printf("Package recv from AControlConn.len:%d\n", n)
|
|
|
|
rtpBytes := make([]byte, n)
|
|
|
|
rtpBytes := make([]byte, n)
|
|
|
|
s.AddInputBytes(n)
|
|
|
|
s.AddInputBytes(n)
|
|
|
|
copy(rtpBytes, bufUDP)
|
|
|
|
copy(rtpBytes, bufUDP)
|
|
|
@ -202,8 +210,14 @@ func (s *UDPServer) SetupVideo() (err error) {
|
|
|
|
bufUDP := make([]byte, UDP_BUF_SIZE)
|
|
|
|
bufUDP := make([]byte, UDP_BUF_SIZE)
|
|
|
|
logger.Printf("udp server start listen video port[%d]", s.VPort)
|
|
|
|
logger.Printf("udp server start listen video port[%d]", s.VPort)
|
|
|
|
defer logger.Printf("udp server stop listen video port[%d]", s.VPort)
|
|
|
|
defer logger.Printf("udp server stop listen video port[%d]", s.VPort)
|
|
|
|
|
|
|
|
timer := time.Unix(0, 0)
|
|
|
|
for !s.Stoped {
|
|
|
|
for !s.Stoped {
|
|
|
|
if n, _, err := s.VConn.ReadFromUDP(bufUDP); err == nil {
|
|
|
|
if n, _, err := s.VConn.ReadFromUDP(bufUDP); err == nil {
|
|
|
|
|
|
|
|
elapsed := time.Now().Sub(timer)
|
|
|
|
|
|
|
|
if elapsed >= 30*time.Second {
|
|
|
|
|
|
|
|
logger.Printf("Package recv from VConn.len:%d\n", n)
|
|
|
|
|
|
|
|
timer = time.Now()
|
|
|
|
|
|
|
|
}
|
|
|
|
rtpBytes := make([]byte, n)
|
|
|
|
rtpBytes := make([]byte, n)
|
|
|
|
s.AddInputBytes(n)
|
|
|
|
s.AddInputBytes(n)
|
|
|
|
copy(rtpBytes, bufUDP)
|
|
|
|
copy(rtpBytes, bufUDP)
|
|
|
@ -245,6 +259,7 @@ func (s *UDPServer) SetupVideo() (err error) {
|
|
|
|
defer logger.Printf("udp server stop listen video control port[%d]", s.VControlPort)
|
|
|
|
defer logger.Printf("udp server stop listen video control port[%d]", s.VControlPort)
|
|
|
|
for !s.Stoped {
|
|
|
|
for !s.Stoped {
|
|
|
|
if n, _, err := s.VControlConn.ReadFromUDP(bufUDP); err == nil {
|
|
|
|
if n, _, err := s.VControlConn.ReadFromUDP(bufUDP); err == nil {
|
|
|
|
|
|
|
|
//logger.Printf("Package recv from VControlConn.len:%d\n", n)
|
|
|
|
rtpBytes := make([]byte, n)
|
|
|
|
rtpBytes := make([]byte, n)
|
|
|
|
s.AddInputBytes(n)
|
|
|
|
s.AddInputBytes(n)
|
|
|
|
copy(rtpBytes, bufUDP)
|
|
|
|
copy(rtpBytes, bufUDP)
|
|
|
|