mirror of
https://gitlab.crans.org/nounous/ghostream.git
synced 2024-12-22 18:32:19 +00:00
Allocate memory for UDP buffers only once
This commit is contained in:
parent
32f877508d
commit
3ce82c5d61
@ -4,15 +4,14 @@ package webrtc
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/pion/rtp"
|
||||||
|
"github.com/pion/webrtc/v3"
|
||||||
|
"gitlab.crans.org/nounous/ghostream/stream/srt"
|
||||||
"gitlab.crans.org/nounous/ghostream/stream/telnet"
|
"gitlab.crans.org/nounous/ghostream/stream/telnet"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
|
||||||
"github.com/pion/rtp"
|
|
||||||
"github.com/pion/webrtc/v3"
|
|
||||||
"gitlab.crans.org/nounous/ghostream/stream/srt"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -124,8 +123,8 @@ func registerStream(srtPacket *srt.Packet) {
|
|||||||
|
|
||||||
// Receive video
|
// Receive video
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
|
||||||
inboundRTPPacket := make([]byte, 1500) // UDP MTU
|
inboundRTPPacket := make([]byte, 1500) // UDP MTU
|
||||||
|
for {
|
||||||
n, _, err := videoListener.ReadFromUDP(inboundRTPPacket)
|
n, _, err := videoListener.ReadFromUDP(inboundRTPPacket)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed to read from UDP: %s", err)
|
log.Printf("Failed to read from UDP: %s", err)
|
||||||
@ -156,8 +155,8 @@ func registerStream(srtPacket *srt.Packet) {
|
|||||||
|
|
||||||
// Receive audio
|
// Receive audio
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
|
||||||
inboundRTPPacket := make([]byte, 1500) // UDP MTU
|
inboundRTPPacket := make([]byte, 1500) // UDP MTU
|
||||||
|
for {
|
||||||
n, _, err := audioListener.ReadFromUDP(inboundRTPPacket)
|
n, _, err := audioListener.ReadFromUDP(inboundRTPPacket)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed to read from UDP: %s", err)
|
log.Printf("Failed to read from UDP: %s", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user