Code refactoring

This commit is contained in:
Alexey Khit
2023-08-28 22:43:07 +03:00
parent c6d5bb4eeb
commit d4444c6257
3 changed files with 6 additions and 6 deletions
+3 -2
View File
@@ -12,6 +12,7 @@ import (
"github.com/AlexxIT/go2rtc/pkg/core"
"github.com/AlexxIT/go2rtc/pkg/h264"
"github.com/AlexxIT/go2rtc/pkg/h264/annexb"
"github.com/AlexxIT/go2rtc/pkg/multipart"
"github.com/AlexxIT/go2rtc/pkg/tcp"
"github.com/pion/rtp"
)
@@ -69,7 +70,7 @@ func (c *Producer) Start() error {
}
for {
header, body, err := tcp.NextMultipart(c.reader)
header, body, err := multipart.Next(c.reader)
if err != nil {
return err
}
@@ -130,7 +131,7 @@ func (c *Producer) probe() error {
timeout := time.Now().Add(core.ProbeTimeout)
for (waitVideo || waitAudio) && time.Now().Before(timeout) {
header, body, err := tcp.NextMultipart(c.reader)
header, body, err := multipart.Next(c.reader)
if err != nil {
return err
}
@@ -1,4 +1,4 @@
package tcp
package multipart
import (
"bufio"
@@ -10,7 +10,7 @@ import (
"strings"
)
func NextMultipart(rd *bufio.Reader) (http.Header, []byte, error) {
func Next(rd *bufio.Reader) (http.Header, []byte, error) {
for {
// search next boundary and skip empty lines
s, err := rd.ReadString('\n')
+1 -2
View File
@@ -6,7 +6,6 @@ import (
"io"
"github.com/AlexxIT/go2rtc/pkg/core"
"github.com/AlexxIT/go2rtc/pkg/tcp"
"github.com/pion/rtp"
)
@@ -46,7 +45,7 @@ func (c *Producer) Start() error {
mjpeg := c.Receivers[0]
for {
_, body, err := tcp.NextMultipart(c.reader)
_, body, err := Next(c.reader)
if err != nil {
return err
}