BIG rewrite stream info
This commit is contained in:
+25
-23
@@ -16,7 +16,7 @@ import (
|
||||
)
|
||||
|
||||
type Consumer struct {
|
||||
core.SuperConsumer
|
||||
core.Connection
|
||||
conn net.Conn
|
||||
srtp *srtp.Server
|
||||
|
||||
@@ -29,28 +29,31 @@ type Consumer struct {
|
||||
}
|
||||
|
||||
func NewConsumer(conn net.Conn, server *srtp.Server) *Consumer {
|
||||
return &Consumer{
|
||||
SuperConsumer: core.SuperConsumer{
|
||||
Type: "HomeKit passive consumer",
|
||||
RemoteAddr: conn.RemoteAddr().String(),
|
||||
Medias: []*core.Media{
|
||||
{
|
||||
Kind: core.KindVideo,
|
||||
Direction: core.DirectionSendonly,
|
||||
Codecs: []*core.Codec{
|
||||
{Name: core.CodecH264},
|
||||
},
|
||||
},
|
||||
{
|
||||
Kind: core.KindAudio,
|
||||
Direction: core.DirectionSendonly,
|
||||
Codecs: []*core.Codec{
|
||||
{Name: core.CodecOpus},
|
||||
},
|
||||
},
|
||||
medias := []*core.Media{
|
||||
{
|
||||
Kind: core.KindVideo,
|
||||
Direction: core.DirectionSendonly,
|
||||
Codecs: []*core.Codec{
|
||||
{Name: core.CodecH264},
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
Kind: core.KindAudio,
|
||||
Direction: core.DirectionSendonly,
|
||||
Codecs: []*core.Codec{
|
||||
{Name: core.CodecOpus},
|
||||
},
|
||||
},
|
||||
}
|
||||
return &Consumer{
|
||||
Connection: core.Connection{
|
||||
ID: core.NewID(),
|
||||
FormatName: "homekit",
|
||||
Protocol: "udp",
|
||||
RemoteAddr: conn.RemoteAddr().String(),
|
||||
Medias: medias,
|
||||
Transport: conn,
|
||||
},
|
||||
conn: conn,
|
||||
srtp: server,
|
||||
}
|
||||
@@ -175,11 +178,10 @@ func (c *Consumer) WriteTo(io.Writer) (int64, error) {
|
||||
}
|
||||
|
||||
func (c *Consumer) Stop() error {
|
||||
_ = c.SuperConsumer.Close()
|
||||
if c.deadline != nil {
|
||||
c.deadline.Reset(0)
|
||||
}
|
||||
return c.SuperConsumer.Close()
|
||||
return c.Connection.Stop()
|
||||
}
|
||||
|
||||
func (c *Consumer) srtpEndpoint() *srtp.Endpoint {
|
||||
|
||||
@@ -15,8 +15,9 @@ import (
|
||||
"github.com/pion/rtp"
|
||||
)
|
||||
|
||||
// Deprecated: rename to Producer
|
||||
type Client struct {
|
||||
core.SuperProducer
|
||||
core.Connection
|
||||
|
||||
hap *hap.Client
|
||||
srtp *srtp.Server
|
||||
@@ -52,9 +53,12 @@ func Dial(rawURL string, server *srtp.Server) (*Client, error) {
|
||||
}
|
||||
|
||||
client := &Client{
|
||||
SuperProducer: core.SuperProducer{
|
||||
Type: "HomeKit active producer",
|
||||
URL: conn.URL(),
|
||||
Connection: core.Connection{
|
||||
ID: core.NewID(),
|
||||
FormatName: "homekit",
|
||||
Protocol: "udp",
|
||||
Source: conn.URL(),
|
||||
Transport: conn,
|
||||
},
|
||||
hap: conn,
|
||||
srtp: server,
|
||||
@@ -93,7 +97,6 @@ func (c *Client) GetMedias() []*core.Media {
|
||||
return nil
|
||||
}
|
||||
|
||||
c.URL = c.hap.URL()
|
||||
c.SDP = fmt.Sprintf("%+v\n%+v", c.videoConfig, c.audioConfig)
|
||||
|
||||
c.Medias = []*core.Media{
|
||||
@@ -175,8 +178,6 @@ func (c *Client) Start() error {
|
||||
}
|
||||
|
||||
func (c *Client) Stop() error {
|
||||
_ = c.SuperProducer.Close()
|
||||
|
||||
if c.videoSession != nil && c.videoSession.Remote != nil {
|
||||
c.srtp.DelSession(c.videoSession)
|
||||
}
|
||||
@@ -184,7 +185,7 @@ func (c *Client) Stop() error {
|
||||
c.srtp.DelSession(c.audioSession)
|
||||
}
|
||||
|
||||
return c.hap.Close()
|
||||
return c.Connection.Stop()
|
||||
}
|
||||
|
||||
func (c *Client) trackByKind(kind string) *core.Receiver {
|
||||
Reference in New Issue
Block a user