mirror of
https://github.com/AlexxIT/go2rtc.git
synced 2025-10-23 16:23:29 +08:00
Compare commits
3 Commits
v0.1-beta.
...
v0.1-beta.
Author | SHA1 | Date | |
---|---|---|---|
![]() |
5460e194e8 | ||
![]() |
e4f565f343 | ||
![]() |
6b274f2a37 |
@@ -26,7 +26,7 @@ func Init() {
|
|||||||
|
|
||||||
app.LoadConfig(&conf)
|
app.LoadConfig(&conf)
|
||||||
|
|
||||||
log = app.GetLogger("api")
|
log = app.GetLogger("hass")
|
||||||
|
|
||||||
// support https://www.home-assistant.io/integrations/rtsp_to_webrtc/
|
// support https://www.home-assistant.io/integrations/rtsp_to_webrtc/
|
||||||
api.HandleFunc("/static", func(w http.ResponseWriter, r *http.Request) {
|
api.HandleFunc("/static", func(w http.ResponseWriter, r *http.Request) {
|
||||||
@@ -78,6 +78,7 @@ func Init() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Info().Str("url", "hass:" + entrie.Title).Msg("[hass] load stream")
|
||||||
//streams.Get("hass:" + entrie.Title)
|
//streams.Get("hass:" + entrie.Title)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -69,7 +69,7 @@ func offerHandler(ctx *api.Context, msg *streamer.Message) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debug().Str("src", src).Msg("[webrtc] new consumer")
|
log.Debug().Str("url", src).Msg("[webrtc] new consumer")
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
@@ -37,32 +37,34 @@ func RTPDepay(track *streamer.Track) streamer.WrapperFunc {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
for {
|
for len(units) > 0 {
|
||||||
i := int(binary.BigEndian.Uint32(units)) + 4
|
i := int(binary.BigEndian.Uint32(units)) + 4
|
||||||
unitAVC := units[:i]
|
unit := units[:i] // NAL Unit with AVC header
|
||||||
|
units = units[i:]
|
||||||
|
|
||||||
unitType := NALUType(unitAVC)
|
unitType := NALUType(unit)
|
||||||
|
//fmt.Printf("[H264] type: %2d, size: %6d\n", unitType, i)
|
||||||
switch unitType {
|
switch unitType {
|
||||||
case NALUTypeSPS:
|
case NALUTypeSPS:
|
||||||
//println("new SPS")
|
//println("new SPS")
|
||||||
sps = unitAVC
|
sps = unit
|
||||||
return nil
|
continue
|
||||||
case NALUTypePPS:
|
case NALUTypePPS:
|
||||||
//println("new PPS")
|
//println("new PPS")
|
||||||
pps = unitAVC
|
pps = unit
|
||||||
return nil
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// ffmpeg with `-tune zerolatency` enable option `-x264opts sliced-threads=1`
|
// ffmpeg with `-tune zerolatency` enable option `-x264opts sliced-threads=1`
|
||||||
// and every NALU will be sliced to multiple NALUs
|
// and every NALU will be sliced to multiple NALUs
|
||||||
if !packet.Marker {
|
if !packet.Marker {
|
||||||
buffer = append(buffer, unitAVC...)
|
buffer = append(buffer, unit...)
|
||||||
return nil
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if buffer != nil {
|
if buffer != nil {
|
||||||
buffer = append(buffer, unitAVC...)
|
buffer = append(buffer, unit...)
|
||||||
unitAVC = buffer
|
unit = buffer
|
||||||
buffer = nil
|
buffer = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,17 +88,13 @@ func RTPDepay(track *streamer.Track) streamer.WrapperFunc {
|
|||||||
|
|
||||||
clone = *packet
|
clone = *packet
|
||||||
clone.Version = RTPPacketVersionAVC
|
clone.Version = RTPPacketVersionAVC
|
||||||
clone.Payload = unitAVC
|
clone.Payload = unit
|
||||||
if err = push(&clone); err != nil {
|
if err = push(&clone); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(units) == i {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
units = units[i:]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user