Skip to content

Commit

Permalink
Code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Aug 28, 2023
1 parent c6d5bb4 commit d4444c6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
5 changes: 3 additions & 2 deletions pkg/kasa/producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/tcp/multipart.go → pkg/multipart/multipart.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tcp
package multipart

import (
"bufio"
Expand All @@ -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')
Expand Down
3 changes: 1 addition & 2 deletions pkg/multipart/producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"io"

"github.com/AlexxIT/go2rtc/pkg/core"
"github.com/AlexxIT/go2rtc/pkg/tcp"
"github.com/pion/rtp"
)

Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit d4444c6

Please sign in to comment.