BIG rewrite stream info

This commit is contained in:
Alex X
2024-06-15 16:46:03 +03:00
parent ecfe802065
commit 96504e2fb0
88 changed files with 1043 additions and 854 deletions
@@ -8,16 +8,16 @@ import (
"github.com/pion/rtp"
)
type Consumer struct {
core.SuperConsumer
type Backchannel struct {
core.Connection
client *Client
}
func (c *Consumer) GetTrack(media *core.Media, codec *core.Codec) (*core.Receiver, error) {
func (c *Backchannel) GetTrack(media *core.Media, codec *core.Codec) (*core.Receiver, error) {
return nil, core.ErrCantGetTrack
}
func (c *Consumer) Start() error {
func (c *Backchannel) Start() error {
if err := c.client.conn.SetReadDeadline(time.Time{}); err != nil {
return err
}
@@ -30,12 +30,7 @@ func (c *Consumer) Start() error {
}
}
func (c *Consumer) Stop() error {
_ = c.SuperConsumer.Close()
return c.client.Close()
}
func (c *Consumer) AddTrack(media *core.Media, _ *core.Codec, track *core.Receiver) error {
func (c *Backchannel) AddTrack(media *core.Media, _ *core.Codec, track *core.Receiver) error {
if err := c.client.Talk(); err != nil {
return err
}
+11 -6
View File
@@ -8,17 +8,22 @@ func Dial(url string) (core.Producer, error) {
return nil, err
}
conn := core.Connection{
ID: core.NewID(),
FormatName: "dvrip",
Protocol: "tcp",
RemoteAddr: client.conn.RemoteAddr().String(),
Transport: client.conn,
}
if client.stream != "" {
prod := &Producer{client: client}
prod.Type = "DVRIP active producer"
prod := &Producer{Connection: conn, client: client}
if err := prod.probe(); err != nil {
return nil, err
}
return prod, nil
} else {
cons := &Consumer{client: client}
cons.Type = "DVRIP active consumer"
cons.Medias = []*core.Media{
conn.Medias = []*core.Media{
{
Kind: core.KindAudio,
Direction: core.DirectionSendonly,
@@ -29,6 +34,6 @@ func Dial(url string) (core.Producer, error) {
},
},
}
return cons, nil
return &Backchannel{Connection: conn, client: client}, nil
}
}
+1 -5
View File
@@ -15,7 +15,7 @@ import (
)
type Producer struct {
core.SuperProducer
core.Connection
client *Client
@@ -92,10 +92,6 @@ func (c *Producer) Start() error {
}
}
func (c *Producer) Stop() error {
return c.client.Close()
}
func (c *Producer) probe() error {
if err := c.client.Play(); err != nil {
return err