Unmarshal RTP directly instead of using helper functions.
This avoids allocating a new header each time.
This commit is contained in:
1 parent
015699a9cd
commit
9c9748b888
2 files changed
+10
-1
No files matched your search
@@ -18,6 +18,7 @@ import (
|
|||||||
|
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
"github.com/pion/rtcp"
|
"github.com/pion/rtcp"
|
||||||
|
"github.com/pion/rtp"
|
||||||
"github.com/pion/sdp"
|
"github.com/pion/sdp"
|
||||||
"github.com/pion/webrtc/v2"
|
"github.com/pion/webrtc/v2"
|
||||||
)
|
)
|
||||||
@@ -296,6 +297,7 @@ func addUpConn(c *client, id string) (*upConnection, error) {
|
|||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
buf := make([]byte, 1500)
|
buf := make([]byte, 1500)
|
||||||
|
var packet rtp.Packet
|
||||||
for {
|
for {
|
||||||
i, err := remote.Read(buf)
|
i, err := remote.Read(buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -305,7 +307,13 @@ func addUpConn(c *client, id string) (*upConnection, error) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = local.Write(buf[:i])
|
err = packet.Unmarshal(buf[:i])
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("%v", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
err = local.WriteRTP(&packet)
|
||||||
if err != nil && err != io.ErrClosedPipe {
|
if err != nil && err != io.ErrClosedPipe {
|
||||||
log.Printf("%v", err)
|
log.Printf("%v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ go 1.13
|
|||||||
require (
|
require (
|
||||||
github.com/gorilla/websocket v1.4.2
|
github.com/gorilla/websocket v1.4.2
|
||||||
github.com/pion/rtcp v1.2.1
|
github.com/pion/rtcp v1.2.1
|
||||||
|
github.com/pion/rtp v1.4.0
|
||||||
github.com/pion/sdp v1.3.0
|
github.com/pion/sdp v1.3.0
|
||||||
github.com/pion/webrtc/v2 v2.2.5
|
github.com/pion/webrtc/v2 v2.2.5
|
||||||
)
|
)
|
||||||
Reference in new issue
Block a user