Code refactoring for MJPEG source

This commit is contained in:
Alexey Khit
2023-07-23 22:35:24 +03:00
parent 6d82b1ce89
commit a14c87ad60
2 changed files with 13 additions and 6 deletions
+8 -4
View File
@@ -3,15 +3,16 @@ package mjpeg
import ( import (
"bufio" "bufio"
"errors" "errors"
"github.com/AlexxIT/go2rtc/pkg/core"
"github.com/AlexxIT/go2rtc/pkg/tcp"
"github.com/pion/rtp"
"io" "io"
"net/http" "net/http"
"net/textproto" "net/textproto"
"strconv" "strconv"
"strings" "strings"
"time" "time"
"github.com/AlexxIT/go2rtc/pkg/core"
"github.com/AlexxIT/go2rtc/pkg/tcp"
"github.com/pion/rtp"
) )
type Client struct { type Client struct {
@@ -112,7 +113,10 @@ func (c *Client) startMJPEG(boundary string) error {
} }
if c.receiver != nil { if c.receiver != nil {
packet := &rtp.Packet{Header: rtp.Header{Timestamp: now()}, Payload: buf} packet := &rtp.Packet{
Header: rtp.Header{Timestamp: core.Now90000()},
Payload: buf,
}
c.receiver.WriteRTP(packet) c.receiver.WriteRTP(packet)
} }
+5 -2
View File
@@ -3,8 +3,9 @@ package mjpeg
import ( import (
"encoding/json" "encoding/json"
"errors" "errors"
"github.com/AlexxIT/go2rtc/pkg/core"
"strings" "strings"
"github.com/AlexxIT/go2rtc/pkg/core"
) )
func (c *Client) GetMedias() []*core.Media { func (c *Client) GetMedias() []*core.Media {
@@ -14,7 +15,9 @@ func (c *Client) GetMedias() []*core.Media {
Direction: core.DirectionRecvonly, Direction: core.DirectionRecvonly,
Codecs: []*core.Codec{ Codecs: []*core.Codec{
{ {
Name: core.CodecJPEG, ClockRate: 90000, PayloadType: core.PayloadTypeRAW, Name: core.CodecJPEG,
ClockRate: 90000,
PayloadType: core.PayloadTypeRAW,
}, },
}, },
}} }}