From ed3ce5016544caadecd5336ebf192565541c1c78 Mon Sep 17 00:00:00 2001 From: Benjamin Pracht Date: Mon, 14 Aug 2023 17:00:59 -0700 Subject: [PATCH 1/2] WiP --- go.mod | 2 +- pkg/errors/errors.go | 6 +++++- pkg/media/urlpull/source.go | 2 +- pkg/media/whip/appsrc.go | 2 +- pkg/whip/sdk_media_sink.go | 2 +- pkg/whip/whip_track_handler.go | 4 ++-- 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index 721a2735..493c3965 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/livekit/ingress -go 1.18 +go 1.20 replace github.com/tinyzimmer/go-glib => github.com/livekit/go-glib v0.0.0-20230811224737-7bfaa4e57420 diff --git a/pkg/errors/errors.go b/pkg/errors/errors.go index 3facba91..bbf4eda4 100644 --- a/pkg/errors/errors.go +++ b/pkg/errors/errors.go @@ -30,7 +30,7 @@ var ( ErrInvalidAudioPreset = psrpc.NewErrorf(psrpc.InvalidArgument, "invalid audio encoding preset") ErrInvalidVideoPreset = psrpc.NewErrorf(psrpc.InvalidArgument, "invalid video encoding preset") ErrSourceNotReady = psrpc.NewErrorf(psrpc.FailedPrecondition, "source encoder not ready") - ErrUnsupportedDecodeFormat = psrpc.NewErrorf(psrpc.NotAcceptable, "unsupported mime type for the source media") + ErrUnsupportedDecodeFormat = psrpc.NewErrorf(psrpc.NotAcceptable, "unsupported format for the source media") ErrUnsupportedEncodeFormat = psrpc.NewErrorf(psrpc.InvalidArgument, "unsupported mime type for encoder") ErrDuplicateTrack = psrpc.NewErrorf(psrpc.NotAcceptable, "more than 1 track with given media kind") ErrUnableToAddPad = psrpc.NewErrorf(psrpc.Internal, "could not add pads to bin") @@ -68,6 +68,10 @@ func ErrHttpRelayFailure(statusCode int) psrpc.Error { return psrpc.NewErrorf(psrpc.Internal, "HTTP request failed with code %d", statusCode) } +func ErrUnsupportedDecodeMimeType(mimeType string) psrpc.Error { + return psrpc.NewErrorf(psrpc.NotAcceptable, "unsupported mime type (%s) for the source media", mimeType) +} + func ErrorToGstFlowReturn(err error) gst.FlowReturn { switch { case err == nil: diff --git a/pkg/media/urlpull/source.go b/pkg/media/urlpull/source.go index a896046d..339bf87c 100644 --- a/pkg/media/urlpull/source.go +++ b/pkg/media/urlpull/source.go @@ -114,7 +114,7 @@ func (s *URLSource) ValidateCaps(caps *gst.Caps) error { } } - return errors.ErrUnsupportedDecodeFormat + return errors.ErrUnsupportedDecodeMimeType(str.Name()) } func (u *URLSource) Start(ctx context.Context) error { diff --git a/pkg/media/whip/appsrc.go b/pkg/media/whip/appsrc.go index 7f4db351..ff41d1f1 100644 --- a/pkg/media/whip/appsrc.go +++ b/pkg/media/whip/appsrc.go @@ -165,5 +165,5 @@ func getCapsForCodec(mimeType string) (*gst.Caps, error) { return gst.NewCapsFromString("audio/x-opus,channel-mapping-family=0"), nil } - return nil, errors.ErrUnsupportedDecodeFormat + return nil, errors.ErrUnsupportedDecodeMimeType(mimeType) } diff --git a/pkg/whip/sdk_media_sink.go b/pkg/whip/sdk_media_sink.go index 56feff27..129626a1 100644 --- a/pkg/whip/sdk_media_sink.go +++ b/pkg/whip/sdk_media_sink.go @@ -187,7 +187,7 @@ func getVideoParams(mimeType string, s *media.Sample) (uint, uint, error) { case strings.ToLower(webrtc.MimeTypeVP8): return getVP8VideoParams(s) default: - return 0, 0, errors.ErrUnsupportedDecodeFormat + return 0, 0, errors.ErrUnsupportedDecodeMimeType(mimeType) } } diff --git a/pkg/whip/whip_track_handler.go b/pkg/whip/whip_track_handler.go index 392869b5..d7800bda 100644 --- a/pkg/whip/whip_track_handler.go +++ b/pkg/whip/whip_track_handler.go @@ -325,7 +325,7 @@ func (t *whipTrackHandler) createDepacketizer() (rtp.Depacketizer, error) { depacketizer = &codecs.OpusPacket{} default: - return nil, errors.ErrUnsupportedDecodeFormat + return nil, errors.ErrUnsupportedDecodeMimeType(t.remoteTrack.Codec().MimeType) } return depacketizer, nil @@ -354,7 +354,7 @@ func (t *whipTrackHandler) createJitterBuffer() (*jitter.Buffer, error) { // No PLI for audio default: - return nil, errors.ErrUnsupportedDecodeFormat + return nil, errors.ErrUnsupportedDecodeMimeType(t.remoteTrack.Codec().MimeType) } clockRate := t.remoteTrack.Codec().ClockRate From da9f8792788078cb89588c6eafd4a6673436cf5f Mon Sep 17 00:00:00 2001 From: Benjamin Pracht Date: Mon, 14 Aug 2023 17:46:42 -0700 Subject: [PATCH 2/2] Add video/mpegts mime type --- pkg/media/urlpull/source.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/media/urlpull/source.go b/pkg/media/urlpull/source.go index 339bf87c..5881fb89 100644 --- a/pkg/media/urlpull/source.go +++ b/pkg/media/urlpull/source.go @@ -30,6 +30,7 @@ var ( "video/quicktime", "video/x-matroska", "video/webm", + "video/mpegts", "audio/ogg", "application/x-id3", "audio/mpeg",