Add RTSP SDP to stream info JSON
This commit is contained in:
@@ -90,6 +90,7 @@ type Info struct {
|
|||||||
URL string `json:"url,omitempty"`
|
URL string `json:"url,omitempty"`
|
||||||
RemoteAddr string `json:"remote_addr,omitempty"`
|
RemoteAddr string `json:"remote_addr,omitempty"`
|
||||||
UserAgent string `json:"user_agent,omitempty"`
|
UserAgent string `json:"user_agent,omitempty"`
|
||||||
|
SDP string `json:"sdp,omitempty"`
|
||||||
Medias []*Media `json:"medias,omitempty"`
|
Medias []*Media `json:"medias,omitempty"`
|
||||||
Receivers []*Receiver `json:"receivers,omitempty"`
|
Receivers []*Receiver `json:"receivers,omitempty"`
|
||||||
Senders []*Sender `json:"senders,omitempty"`
|
Senders []*Sender `json:"senders,omitempty"`
|
||||||
|
|||||||
+4
-1
@@ -4,7 +4,6 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/AlexxIT/go2rtc/pkg/tcp/websocket"
|
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
@@ -12,6 +11,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/AlexxIT/go2rtc/pkg/tcp/websocket"
|
||||||
|
|
||||||
"github.com/AlexxIT/go2rtc/pkg/core"
|
"github.com/AlexxIT/go2rtc/pkg/core"
|
||||||
"github.com/AlexxIT/go2rtc/pkg/tcp"
|
"github.com/AlexxIT/go2rtc/pkg/tcp"
|
||||||
)
|
)
|
||||||
@@ -139,6 +140,8 @@ func (c *Conn) Describe() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c.sdp = string(res.Body) // for info
|
||||||
|
|
||||||
medias, err := UnmarshalSDP(res.Body)
|
medias, err := UnmarshalSDP(res.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
+6
-4
@@ -4,16 +4,17 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/AlexxIT/go2rtc/pkg/core"
|
|
||||||
"github.com/AlexxIT/go2rtc/pkg/tcp"
|
|
||||||
"github.com/pion/rtcp"
|
|
||||||
"github.com/pion/rtp"
|
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/AlexxIT/go2rtc/pkg/core"
|
||||||
|
"github.com/AlexxIT/go2rtc/pkg/tcp"
|
||||||
|
"github.com/pion/rtcp"
|
||||||
|
"github.com/pion/rtp"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Conn struct {
|
type Conn struct {
|
||||||
@@ -39,6 +40,7 @@ type Conn struct {
|
|||||||
reader *bufio.Reader
|
reader *bufio.Reader
|
||||||
sequence int
|
sequence int
|
||||||
session string
|
session string
|
||||||
|
sdp string
|
||||||
uri string
|
uri string
|
||||||
|
|
||||||
state State
|
state State
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package rtsp
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"github.com/AlexxIT/go2rtc/pkg/core"
|
"github.com/AlexxIT/go2rtc/pkg/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -100,6 +101,7 @@ func (c *Conn) Stop() (err error) {
|
|||||||
func (c *Conn) MarshalJSON() ([]byte, error) {
|
func (c *Conn) MarshalJSON() ([]byte, error) {
|
||||||
info := &core.Info{
|
info := &core.Info{
|
||||||
Type: "RTSP " + c.mode.String(),
|
Type: "RTSP " + c.mode.String(),
|
||||||
|
SDP: c.sdp,
|
||||||
UserAgent: c.UserAgent,
|
UserAgent: c.UserAgent,
|
||||||
Medias: c.Medias,
|
Medias: c.Medias,
|
||||||
Receivers: c.receivers,
|
Receivers: c.receivers,
|
||||||
|
|||||||
+7
-2
@@ -4,12 +4,13 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/AlexxIT/go2rtc/pkg/core"
|
|
||||||
"github.com/AlexxIT/go2rtc/pkg/tcp"
|
|
||||||
"net"
|
"net"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/AlexxIT/go2rtc/pkg/core"
|
||||||
|
"github.com/AlexxIT/go2rtc/pkg/tcp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewServer(conn net.Conn) *Conn {
|
func NewServer(conn net.Conn) *Conn {
|
||||||
@@ -69,6 +70,8 @@ func (c *Conn) Accept() error {
|
|||||||
return errors.New("wrong content type")
|
return errors.New("wrong content type")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c.sdp = string(req.Body) // for info
|
||||||
|
|
||||||
c.Medias, err = UnmarshalSDP(req.Body)
|
c.Medias, err = UnmarshalSDP(req.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -125,6 +128,8 @@ func (c *Conn) Accept() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c.sdp = string(res.Body) // for info
|
||||||
|
|
||||||
if err = c.WriteResponse(res); err != nil {
|
if err = c.WriteResponse(res); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user