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 (
"bufio"
"errors"
"github.com/AlexxIT/go2rtc/pkg/core"
"github.com/AlexxIT/go2rtc/pkg/tcp"
"github.com/pion/rtp"
"io"
"net/http"
"net/textproto"
"strconv"
"strings"
"time"
"github.com/AlexxIT/go2rtc/pkg/core"
"github.com/AlexxIT/go2rtc/pkg/tcp"
"github.com/pion/rtp"
)
type Client struct {
@@ -112,7 +113,10 @@ func (c *Client) startMJPEG(boundary string) error {
}
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)
}
+5 -2
View File
@@ -3,8 +3,9 @@ package mjpeg
import (
"encoding/json"
"errors"
"github.com/AlexxIT/go2rtc/pkg/core"
"strings"
"github.com/AlexxIT/go2rtc/pkg/core"
)
func (c *Client) GetMedias() []*core.Media {
@@ -14,7 +15,9 @@ func (c *Client) GetMedias() []*core.Media {
Direction: core.DirectionRecvonly,
Codecs: []*core.Codec{
{
Name: core.CodecJPEG, ClockRate: 90000, PayloadType: core.PayloadTypeRAW,
Name: core.CodecJPEG,
ClockRate: 90000,
PayloadType: core.PayloadTypeRAW,
},
},
}}