mirror of
https://github.com/aler9/gortsplib
synced 2025-10-05 23:26:54 +08:00
rename mpegtsencoder into mpegtsmuxer
This commit is contained in:
@@ -46,7 +46,7 @@ func main() {
|
||||
}
|
||||
|
||||
// setup H264->MPEGTS encoder
|
||||
enc, err := newMPEGTSEncoder(h264track.SafeSPS(), h264track.SafePPS())
|
||||
enc, err := newMPEGTSMuxer(h264track.SafeSPS(), h264track.SafePPS())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@@ -11,8 +11,8 @@ import (
|
||||
"github.com/asticode/go-astits"
|
||||
)
|
||||
|
||||
// mpegtsEncoder allows to save a H264 stream into a MPEG-TS file.
|
||||
type mpegtsEncoder struct {
|
||||
// mpegtsMuxer allows to save a H264 stream into a MPEG-TS file.
|
||||
type mpegtsMuxer struct {
|
||||
sps []byte
|
||||
pps []byte
|
||||
|
||||
@@ -24,8 +24,8 @@ type mpegtsEncoder struct {
|
||||
startDTS time.Duration
|
||||
}
|
||||
|
||||
// newMPEGTSEncoder allocates a mpegtsEncoder.
|
||||
func newMPEGTSEncoder(sps []byte, pps []byte) (*mpegtsEncoder, error) {
|
||||
// newMPEGTSMuxer allocates a mpegtsMuxer.
|
||||
func newMPEGTSMuxer(sps []byte, pps []byte) (*mpegtsMuxer, error) {
|
||||
f, err := os.Create("mystream.ts")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -39,7 +39,7 @@ func newMPEGTSEncoder(sps []byte, pps []byte) (*mpegtsEncoder, error) {
|
||||
})
|
||||
mux.SetPCRPID(256)
|
||||
|
||||
return &mpegtsEncoder{
|
||||
return &mpegtsMuxer{
|
||||
sps: sps,
|
||||
pps: pps,
|
||||
f: f,
|
||||
@@ -48,14 +48,14 @@ func newMPEGTSEncoder(sps []byte, pps []byte) (*mpegtsEncoder, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
// close closes all the mpegtsEncoder resources.
|
||||
func (e *mpegtsEncoder) close() {
|
||||
// close closes all the mpegtsMuxer resources.
|
||||
func (e *mpegtsMuxer) close() {
|
||||
e.b.Flush()
|
||||
e.f.Close()
|
||||
}
|
||||
|
||||
// encode encodes H264 NALUs into MPEG-TS.
|
||||
func (e *mpegtsEncoder) encode(nalus [][]byte, pts time.Duration) error {
|
||||
func (e *mpegtsMuxer) encode(nalus [][]byte, pts time.Duration) error {
|
||||
// prepend an AUD. This is required by some players
|
||||
filteredNALUs := [][]byte{
|
||||
{byte(h264.NALUTypeAccessUnitDelimiter), 240},
|
@@ -19,7 +19,7 @@ type serverHandler struct {
|
||||
stream *gortsplib.ServerStream
|
||||
h264TrackID int
|
||||
h264track *gortsplib.TrackH264
|
||||
mpegtsMuxer *mpegtsEncoder
|
||||
mpegtsMuxer *mpegtsMuxer
|
||||
}
|
||||
|
||||
// called when a connection is opened.
|
||||
@@ -80,7 +80,7 @@ func (sh *serverHandler) OnAnnounce(ctx *gortsplib.ServerHandlerOnAnnounceCtx) (
|
||||
}
|
||||
|
||||
// setup H264->MPEGTS encoder
|
||||
mpegtsMuxer, err := newMPEGTSEncoder(h264track.SafeSPS(), h264track.SafePPS())
|
||||
mpegtsMuxer, err := newMPEGTSMuxer(h264track.SafeSPS(), h264track.SafePPS())
|
||||
if err != nil {
|
||||
return &base.Response{
|
||||
StatusCode: base.StatusBadRequest,
|
||||
|
@@ -11,8 +11,8 @@ import (
|
||||
"github.com/asticode/go-astits"
|
||||
)
|
||||
|
||||
// mpegtsEncoder allows to save a H264 stream into a MPEG-TS file.
|
||||
type mpegtsEncoder struct {
|
||||
// mpegtsMuxer allows to save a H264 stream into a MPEG-TS file.
|
||||
type mpegtsMuxer struct {
|
||||
sps []byte
|
||||
pps []byte
|
||||
|
||||
@@ -24,8 +24,8 @@ type mpegtsEncoder struct {
|
||||
startDTS time.Duration
|
||||
}
|
||||
|
||||
// newMPEGTSEncoder allocates a mpegtsEncoder.
|
||||
func newMPEGTSEncoder(sps []byte, pps []byte) (*mpegtsEncoder, error) {
|
||||
// newMPEGTSMuxer allocates a mpegtsMuxer.
|
||||
func newMPEGTSMuxer(sps []byte, pps []byte) (*mpegtsMuxer, error) {
|
||||
f, err := os.Create("mystream.ts")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -39,7 +39,7 @@ func newMPEGTSEncoder(sps []byte, pps []byte) (*mpegtsEncoder, error) {
|
||||
})
|
||||
mux.SetPCRPID(256)
|
||||
|
||||
return &mpegtsEncoder{
|
||||
return &mpegtsMuxer{
|
||||
sps: sps,
|
||||
pps: pps,
|
||||
f: f,
|
||||
@@ -48,14 +48,14 @@ func newMPEGTSEncoder(sps []byte, pps []byte) (*mpegtsEncoder, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
// close closes all the mpegtsEncoder resources.
|
||||
func (e *mpegtsEncoder) close() {
|
||||
// close closes all the mpegtsMuxer resources.
|
||||
func (e *mpegtsMuxer) close() {
|
||||
e.b.Flush()
|
||||
e.f.Close()
|
||||
}
|
||||
|
||||
// encode encodes H264 NALUs into MPEG-TS.
|
||||
func (e *mpegtsEncoder) encode(nalus [][]byte, pts time.Duration) error {
|
||||
func (e *mpegtsMuxer) encode(nalus [][]byte, pts time.Duration) error {
|
||||
// prepend an AUD. This is required by some players
|
||||
filteredNALUs := [][]byte{
|
||||
{byte(h264.NALUTypeAccessUnitDelimiter), 240},
|
Reference in New Issue
Block a user