mirror of
https://github.com/lkmio/lkm.git
synced 2025-09-27 03:26:01 +08:00
feat: rtc拉流支持h265
This commit is contained in:
49
go.mod
49
go.mod
@@ -13,12 +13,13 @@ require (
|
||||
github.com/gorilla/mux v1.8.1
|
||||
github.com/gorilla/websocket v1.5.1
|
||||
github.com/lkmio/avformat v0.0.0
|
||||
github.com/lkmio/g726 v0.1.3
|
||||
github.com/natefinch/lumberjack v2.0.0+incompatible
|
||||
github.com/pion/interceptor v0.1.25
|
||||
github.com/pion/rtcp v1.2.12
|
||||
github.com/pion/rtp v1.8.5
|
||||
github.com/pion/sdp/v3 v3.0.8
|
||||
github.com/pion/webrtc/v3 v3.2.29
|
||||
github.com/pion/interceptor v0.1.40
|
||||
github.com/pion/rtcp v1.2.15
|
||||
github.com/pion/rtp v1.8.21
|
||||
github.com/pion/sdp/v3 v3.0.14
|
||||
github.com/pion/webrtc/v4 v4.1.3
|
||||
github.com/sirupsen/logrus v1.9.3
|
||||
github.com/x-cray/logrus-prefixed-formatter v0.5.2
|
||||
go.uber.org/zap v1.27.0
|
||||
@@ -26,32 +27,30 @@ require (
|
||||
|
||||
require (
|
||||
github.com/BurntSushi/toml v1.3.2 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/google/uuid v1.3.1 // indirect
|
||||
github.com/lkmio/g726 v0.1.3 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.16 // indirect
|
||||
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
|
||||
github.com/pion/datachannel v1.5.5 // indirect
|
||||
github.com/pion/dtls/v2 v2.2.7 // indirect
|
||||
github.com/pion/ice/v2 v2.3.13 // indirect
|
||||
github.com/pion/logging v0.2.2 // indirect
|
||||
github.com/pion/mdns v0.0.12 // indirect
|
||||
github.com/nxadm/tail v1.4.8 // indirect
|
||||
github.com/pion/datachannel v1.5.10 // indirect
|
||||
github.com/pion/dtls/v3 v3.0.6 // indirect
|
||||
github.com/pion/ice/v4 v4.0.10 // indirect
|
||||
github.com/pion/logging v0.2.4 // indirect
|
||||
github.com/pion/mdns/v2 v2.0.7 // indirect
|
||||
github.com/pion/randutil v0.1.0 // indirect
|
||||
github.com/pion/sctp v1.8.12 // indirect
|
||||
github.com/pion/srtp/v2 v2.0.18 // indirect
|
||||
github.com/pion/stun v0.6.1 // indirect
|
||||
github.com/pion/transport/v2 v2.2.3 // indirect
|
||||
github.com/pion/turn/v2 v2.1.3 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/stretchr/testify v1.9.0 // indirect
|
||||
github.com/pion/sctp v1.8.39 // indirect
|
||||
github.com/pion/srtp/v3 v3.0.6 // indirect
|
||||
github.com/pion/stun/v3 v3.0.0 // indirect
|
||||
github.com/pion/transport/v3 v3.0.7 // indirect
|
||||
github.com/pion/turn/v4 v4.0.0 // indirect
|
||||
github.com/wlynxg/anet v0.0.5 // indirect
|
||||
go.uber.org/multierr v1.10.0 // indirect
|
||||
golang.org/x/crypto v0.18.0 // indirect
|
||||
golang.org/x/net v0.20.0 // indirect
|
||||
golang.org/x/sys v0.16.0 // indirect
|
||||
golang.org/x/term v0.16.0 // indirect
|
||||
golang.org/x/crypto v0.33.0 // indirect
|
||||
golang.org/x/net v0.35.0 // indirect
|
||||
golang.org/x/sys v0.30.0 // indirect
|
||||
golang.org/x/term v0.29.0 // indirect
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
)
|
||||
|
||||
replace github.com/lkmio/avformat => ../avformat
|
||||
|
@@ -6,8 +6,8 @@ import (
|
||||
"github.com/lkmio/avformat/utils"
|
||||
"github.com/lkmio/lkm/log"
|
||||
"github.com/lkmio/lkm/stream"
|
||||
"github.com/pion/webrtc/v3"
|
||||
"github.com/pion/webrtc/v3/pkg/media"
|
||||
"github.com/pion/webrtc/v4"
|
||||
"github.com/pion/webrtc/v4/pkg/media"
|
||||
"io"
|
||||
"time"
|
||||
)
|
||||
@@ -96,6 +96,12 @@ func (s *Sink) StartStreaming(transStream stream.TransStream) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// offer的sdp, 应答给http请求
|
||||
if s.cb != nil {
|
||||
log.Sugar.Infof("answer: %s", connection.LocalDescription().SDP)
|
||||
s.cb(connection.LocalDescription().SDP)
|
||||
}
|
||||
|
||||
<-complete
|
||||
connection.OnICEConnectionStateChange(func(state webrtc.ICEConnectionState) {
|
||||
s.state = state
|
||||
@@ -109,10 +115,6 @@ func (s *Sink) StartStreaming(transStream stream.TransStream) error {
|
||||
|
||||
s.peer = connection
|
||||
|
||||
// offer的sdp, 应答给http请求
|
||||
if s.cb != nil {
|
||||
s.cb(connection.LocalDescription().SDP)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@@ -6,7 +6,7 @@ import (
|
||||
"github.com/lkmio/avformat/utils"
|
||||
"github.com/lkmio/lkm/stream"
|
||||
"github.com/pion/interceptor"
|
||||
"github.com/pion/webrtc/v3"
|
||||
"github.com/pion/webrtc/v4"
|
||||
"net"
|
||||
)
|
||||
|
||||
@@ -37,11 +37,6 @@ func (t *transStream) Input(packet *avformat.AVPacket, _ int) ([]*collections.Re
|
||||
t.AppendOutStreamBuffer(collections.NewReferenceCounter(packet.Data))
|
||||
} else if utils.AVMediaTypeVideo == packet.MediaType {
|
||||
avStream := t.FindTrackWithStreamIndex(packet.Index).Stream
|
||||
if packet.Key {
|
||||
extra := avStream.CodecParameters.AnnexBExtraData()
|
||||
t.AppendOutStreamBuffer(collections.NewReferenceCounter(extra))
|
||||
}
|
||||
|
||||
data := avformat.AVCCPacket2AnnexB(avStream, packet)
|
||||
t.AppendOutStreamBuffer(collections.NewReferenceCounter(data))
|
||||
}
|
||||
|
@@ -766,13 +766,13 @@ func (t *transStreamPublisher) ClearGopBuffer(free bool) {
|
||||
if packet.Release() && free {
|
||||
avformat.FreePacket(packet.Get())
|
||||
}
|
||||
|
||||
// 释放annexb和avcc格式转换的缓存
|
||||
if t.bitstreamFilterBuffer != nil {
|
||||
t.bitstreamFilterBuffer.Pop()
|
||||
}
|
||||
})
|
||||
|
||||
// 释放annexb和avcc格式转换的缓存
|
||||
if t.bitstreamFilterBuffer != nil {
|
||||
t.bitstreamFilterBuffer.Clear()
|
||||
}
|
||||
|
||||
// 丢弃转码track中的缓存
|
||||
for _, track := range t.transcodeTracks {
|
||||
track.Clear()
|
||||
|
Reference in New Issue
Block a user