Fix info for WS/MP4
This commit is contained in:
+5
-1
@@ -71,7 +71,11 @@ func handlerWSMP4(tr *api.Transport, msg *api.Message) error {
|
|||||||
return errors.New(api.StreamNotFound)
|
return errors.New(api.StreamNotFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
cons := &mp4.Segment{OnlyKeyframe: true}
|
cons := &mp4.Segment{
|
||||||
|
RemoteAddr: tr.Request.RemoteAddr,
|
||||||
|
UserAgent: tr.Request.UserAgent(),
|
||||||
|
OnlyKeyframe: true,
|
||||||
|
}
|
||||||
|
|
||||||
if codecs, ok := msg.Value.(string); ok {
|
if codecs, ok := msg.Value.(string); ok {
|
||||||
log.Trace().Str("codecs", codecs).Msgf("[mp4] new WS/MP4 consumer")
|
log.Trace().Str("codecs", codecs).Msgf("[mp4] new WS/MP4 consumer")
|
||||||
|
|||||||
+21
-1
@@ -1,18 +1,25 @@
|
|||||||
package mp4
|
package mp4
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"github.com/AlexxIT/go2rtc/pkg/h264"
|
"github.com/AlexxIT/go2rtc/pkg/h264"
|
||||||
"github.com/AlexxIT/go2rtc/pkg/h265"
|
"github.com/AlexxIT/go2rtc/pkg/h265"
|
||||||
"github.com/AlexxIT/go2rtc/pkg/streamer"
|
"github.com/AlexxIT/go2rtc/pkg/streamer"
|
||||||
"github.com/pion/rtp"
|
"github.com/pion/rtp"
|
||||||
|
"sync/atomic"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Segment struct {
|
type Segment struct {
|
||||||
streamer.Element
|
streamer.Element
|
||||||
|
|
||||||
Medias []*streamer.Media
|
Medias []*streamer.Media
|
||||||
|
UserAgent string
|
||||||
|
RemoteAddr string
|
||||||
|
|
||||||
MimeType string
|
MimeType string
|
||||||
OnlyKeyframe bool
|
OnlyKeyframe bool
|
||||||
|
|
||||||
|
send uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Segment) GetMedias() []*streamer.Media {
|
func (c *Segment) GetMedias() []*streamer.Media {
|
||||||
@@ -56,6 +63,7 @@ func (c *Segment) AddTrack(media *streamer.Media, track *streamer.Track) *stream
|
|||||||
}
|
}
|
||||||
|
|
||||||
buf := muxer.Marshal(0, packet)
|
buf := muxer.Marshal(0, packet)
|
||||||
|
atomic.AddUint32(&c.send, uint32(len(buf)))
|
||||||
c.Fire(append(init, buf...))
|
c.Fire(append(init, buf...))
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -73,6 +81,7 @@ func (c *Segment) AddTrack(media *streamer.Media, track *streamer.Track) *stream
|
|||||||
buf = append(buf, b...)
|
buf = append(buf, b...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
atomic.AddUint32(&c.send, uint32(len(buf)))
|
||||||
c.Fire(buf)
|
c.Fire(buf)
|
||||||
|
|
||||||
buf = buf[:0]
|
buf = buf[:0]
|
||||||
@@ -106,6 +115,7 @@ func (c *Segment) AddTrack(media *streamer.Media, track *streamer.Track) *stream
|
|||||||
}
|
}
|
||||||
|
|
||||||
buf := muxer.Marshal(0, packet)
|
buf := muxer.Marshal(0, packet)
|
||||||
|
atomic.AddUint32(&c.send, uint32(len(buf)))
|
||||||
c.Fire(append(init, buf...))
|
c.Fire(append(init, buf...))
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -121,3 +131,13 @@ func (c *Segment) AddTrack(media *streamer.Media, track *streamer.Track) *stream
|
|||||||
|
|
||||||
panic("unsupported codec")
|
panic("unsupported codec")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Segment) MarshalJSON() ([]byte, error) {
|
||||||
|
info := &streamer.Info{
|
||||||
|
Type: "WS/MP4 client",
|
||||||
|
RemoteAddr: c.RemoteAddr,
|
||||||
|
UserAgent: c.UserAgent,
|
||||||
|
Send: atomic.LoadUint32(&c.send),
|
||||||
|
}
|
||||||
|
return json.Marshal(info)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user