Skip to content

Commit

Permalink
switch to gortsplib/v4
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 committed Aug 24, 2023
1 parent 482266a commit ec279af
Show file tree
Hide file tree
Showing 69 changed files with 1,198 additions and 1,283 deletions.
10 changes: 5 additions & 5 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ linters-settings:
- (github.com/datarhei/gosrt.Conn).Close
- (github.com/datarhei/gosrt.Conn).SetReadDeadline
- (github.com/datarhei/gosrt.Conn).SetWriteDeadline
- (*github.com/bluenviron/gortsplib/v3.Client).Close
- (*github.com/bluenviron/gortsplib/v3.Server).Close
- (*github.com/bluenviron/gortsplib/v3.ServerSession).Close
- (*github.com/bluenviron/gortsplib/v3.ServerStream).Close
- (*github.com/bluenviron/gortsplib/v3.ServerConn).Close
- (*github.com/bluenviron/gortsplib/v4.Client).Close
- (*github.com/bluenviron/gortsplib/v4.Server).Close
- (*github.com/bluenviron/gortsplib/v4.ServerSession).Close
- (*github.com/bluenviron/gortsplib/v4.ServerStream).Close
- (*github.com/bluenviron/gortsplib/v4.ServerConn).Close

govet:
enable-all: true
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

src/internal/hls.min.js is Copyright (c) Dailymotion and is protected by
internal/core/hls.min.js is Copyright (c) Dailymotion and is protected by
its own license (Apache License, Version 2.0) available at

https://github.com/video-dev/hls.js/blob/master/LICENSE
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/abema/go-mp4 v0.12.0
github.com/alecthomas/kong v0.8.0
github.com/bluenviron/gohlslib v1.0.0
github.com/bluenviron/gortsplib/v3 v3.10.0
github.com/bluenviron/gortsplib/v4 v4.0.0-20230824162022-6f961c1bbbd0
github.com/bluenviron/mediacommon v1.0.0
github.com/datarhei/gosrt v0.5.3
github.com/fsnotify/fsnotify v1.6.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ github.com/benburkert/openpgp v0.0.0-20160410205803-c2471f86866c h1:8XZeJrs4+ZYh
github.com/benburkert/openpgp v0.0.0-20160410205803-c2471f86866c/go.mod h1:x1vxHcL/9AVzuk5HOloOEPrtJY0MaalYr78afXZ+pWI=
github.com/bluenviron/gohlslib v1.0.0 h1:UOI7wW7EdXPnnoflPL+WRiUB+bDSyrR9AXtu029n5EY=
github.com/bluenviron/gohlslib v1.0.0/go.mod h1:fwqXogd2G/CJ/0kD6TTALmWI3KAm66nZoI+06O02YKI=
github.com/bluenviron/gortsplib/v3 v3.10.0 h1:E2ytPD1/b6JgzHYVSsyaG2xtXsvaGw9sxTdZ0Wnwsd4=
github.com/bluenviron/gortsplib/v3 v3.10.0/go.mod h1:prNU1aMVBmgmmKwlvLiEdjBbTEpTw4BRsqVcqEARgMY=
github.com/bluenviron/gortsplib/v4 v4.0.0-20230824162022-6f961c1bbbd0 h1:I/GGZB7wxfLj/dOxGh5RXcKvYzDzL7Rgx+aiUZDEEIs=
github.com/bluenviron/gortsplib/v4 v4.0.0-20230824162022-6f961c1bbbd0/go.mod h1:UU9EkvmpvyXdRIDBBUK7zdFt2LsdnV4iz9cHP3JaB8s=
github.com/bluenviron/mediacommon v1.0.0 h1:hKelTQKfetasCmXaXMiL1ihID0GRmItyWZt1/pqiKKk=
github.com/bluenviron/mediacommon v1.0.0/go.mod h1:nt5oKCO0WcZ+AH1oc12gs2ldp67xW2vl88c2StNmPlI=
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
Expand Down
2 changes: 1 addition & 1 deletion internal/conf/auth_method.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"sort"
"strings"

"github.com/bluenviron/gortsplib/v3/pkg/headers"
"github.com/bluenviron/gortsplib/v4/pkg/headers"
)

// AuthMethods is the authMethods parameter.
Expand Down
4 changes: 2 additions & 2 deletions internal/conf/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"time"

"github.com/bluenviron/gohlslib"
"github.com/bluenviron/gortsplib/v3"
"github.com/bluenviron/gortsplib/v3/pkg/headers"
"github.com/bluenviron/gortsplib/v4"
"github.com/bluenviron/gortsplib/v4/pkg/headers"

"github.com/bluenviron/mediamtx/internal/conf/decrypt"
"github.com/bluenviron/mediamtx/internal/conf/env"
Expand Down
2 changes: 1 addition & 1 deletion internal/conf/conf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"testing"
"time"

"github.com/bluenviron/gortsplib/v3"
"github.com/bluenviron/gortsplib/v4"
"github.com/stretchr/testify/require"
"golang.org/x/crypto/nacl/secretbox"

Expand Down
4 changes: 2 additions & 2 deletions internal/conf/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"strings"
"time"

"github.com/bluenviron/gortsplib/v3/pkg/headers"
"github.com/bluenviron/gortsplib/v3/pkg/url"
"github.com/bluenviron/gortsplib/v4/pkg/headers"
"github.com/bluenviron/gortsplib/v4/pkg/url"
)

var rePathName = regexp.MustCompile(`^[0-9a-zA-Z_\-/\.~]+$`)
Expand Down
2 changes: 1 addition & 1 deletion internal/conf/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"sort"
"strings"

"github.com/bluenviron/gortsplib/v3"
"github.com/bluenviron/gortsplib/v4"
)

// Protocol is a RTSP transport.
Expand Down
2 changes: 1 addition & 1 deletion internal/conf/source_protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"
"fmt"

"github.com/bluenviron/gortsplib/v3"
"github.com/bluenviron/gortsplib/v4"
)

// SourceProtocol is the sourceProtocol parameter.
Expand Down
100 changes: 52 additions & 48 deletions internal/core/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import (
"testing"
"time"

"github.com/bluenviron/gortsplib/v3"
"github.com/bluenviron/gortsplib/v3/pkg/formats"
"github.com/bluenviron/gortsplib/v3/pkg/media"
"github.com/bluenviron/gortsplib/v4"
"github.com/bluenviron/gortsplib/v4/pkg/description"
"github.com/bluenviron/gortsplib/v4/pkg/format"
"github.com/bluenviron/mediacommon/pkg/codecs/mpeg4audio"
"github.com/bluenviron/mediacommon/pkg/formats/mpegts"
"github.com/datarhei/gosrt"
Expand All @@ -27,7 +27,7 @@ import (
"github.com/bluenviron/mediamtx/internal/rtmp"
)

var testFormatH264 = &formats.H264{
var testFormatH264 = &format.H264{
PayloadTyp: 96,
SPS: []byte{ // 1920x1080 baseline
0x67, 0x42, 0xc0, 0x28, 0xd9, 0x00, 0x78, 0x02,
Expand All @@ -38,9 +38,9 @@ var testFormatH264 = &formats.H264{
PacketizationMode: 1,
}

var testMediaH264 = &media.Media{
Type: media.TypeVideo,
Formats: []formats.Format{testFormatH264},
var testMediaH264 = &description.Media{
Type: description.MediaTypeVideo,
Formats: []format.Format{testFormatH264},
}

func httpRequest(t *testing.T, hc *http.Client, method string, ur string, in interface{}, out interface{}) {
Expand Down Expand Up @@ -245,11 +245,11 @@ func TestAPIPathsList(t *testing.T) {
source := gortsplib.Client{}
err := source.StartRecording(
"rtsp://localhost:8554/mypath",
media.Medias{
&description.Session{Medias: []*description.Media{
media0,
{
Type: media.TypeAudio,
Formats: []formats.Format{&formats.MPEG4Audio{
Type: description.MediaTypeAudio,
Formats: []format.Format{&format.MPEG4Audio{
PayloadTyp: 96,
Config: &mpeg4audio.Config{
Type: 2,
Expand All @@ -261,7 +261,7 @@ func TestAPIPathsList(t *testing.T) {
IndexDeltaLength: 3,
}},
},
})
}})
require.NoError(t, err)
defer source.Close()

Expand All @@ -270,7 +270,7 @@ func TestAPIPathsList(t *testing.T) {
Version: 2,
PayloadType: 96,
},
Payload: []byte{0x01, 0x02, 0x03, 0x04},
Payload: []byte{5, 1, 2, 3, 4},
})
require.NoError(t, err)

Expand All @@ -286,7 +286,7 @@ func TestAPIPathsList(t *testing.T) {
},
Ready: true,
Tracks: []string{"H264", "MPEG-4 Audio"},
BytesReceived: 16,
BytesReceived: 17,
}},
}, out)
})
Expand All @@ -311,29 +311,28 @@ func TestAPIPathsList(t *testing.T) {

hc := &http.Client{Transport: &http.Transport{}}

medias := media.Medias{
{
Type: media.TypeVideo,
Formats: []formats.Format{testFormatH264},
},
{
Type: media.TypeAudio,
Formats: []formats.Format{&formats.MPEG4Audio{
PayloadTyp: 97,
Config: &mpeg4audio.Config{
Type: 2,
SampleRate: 44100,
ChannelCount: 2,
},
SizeLength: 13,
IndexLength: 3,
IndexDeltaLength: 3,
}},
},
}

source := gortsplib.Client{TLSConfig: &tls.Config{InsecureSkipVerify: true}}
err = source.StartRecording("rtsps://localhost:8322/mypath", medias)
err = source.StartRecording("rtsps://localhost:8322/mypath",
&description.Session{Medias: []*description.Media{
{
Type: description.MediaTypeVideo,
Formats: []format.Format{testFormatH264},
},
{
Type: description.MediaTypeAudio,
Formats: []format.Format{&format.MPEG4Audio{
PayloadTyp: 97,
Config: &mpeg4audio.Config{
Type: 2,
SampleRate: 44100,
ChannelCount: 2,
},
SizeLength: 13,
IndexLength: 3,
IndexDeltaLength: 3,
}},
},
}})
require.NoError(t, err)
defer source.Close()

Expand Down Expand Up @@ -471,7 +470,8 @@ func TestAPIPathsGet(t *testing.T) {

if ca == "ok" || ca == "ok-nested" {
source := gortsplib.Client{}
err := source.StartRecording("rtsp://localhost:8554/"+pathName, media.Medias{testMediaH264})
err := source.StartRecording("rtsp://localhost:8554/"+pathName,
&description.Session{Medias: []*description.Media{testMediaH264}})
require.NoError(t, err)
defer source.Close()

Expand Down Expand Up @@ -546,7 +546,8 @@ func TestAPIProtocolList(t *testing.T) {
case "rtsp conns", "rtsp sessions":
source := gortsplib.Client{}

err := source.StartRecording("rtsp://localhost:8554/mypath", media.Medias{medi})
err := source.StartRecording("rtsp://localhost:8554/mypath",
&description.Session{Medias: []*description.Media{medi}})
require.NoError(t, err)
defer source.Close()

Expand All @@ -555,7 +556,8 @@ func TestAPIProtocolList(t *testing.T) {
TLSConfig: &tls.Config{InsecureSkipVerify: true},
}

err := source.StartRecording("rtsps://localhost:8322/mypath", media.Medias{medi})
err := source.StartRecording("rtsps://localhost:8322/mypath",
&description.Session{Medias: []*description.Media{medi}})
require.NoError(t, err)
defer source.Close()

Expand Down Expand Up @@ -590,7 +592,7 @@ func TestAPIProtocolList(t *testing.T) {
case "hls":
source := gortsplib.Client{}
err := source.StartRecording("rtsp://localhost:8554/mypath",
media.Medias{medi})
&description.Session{Medias: []*description.Media{medi}})
require.NoError(t, err)
defer source.Close()

Expand Down Expand Up @@ -647,7 +649,7 @@ func TestAPIProtocolList(t *testing.T) {
case "webrtc":
source := gortsplib.Client{}
err := source.StartRecording("rtsp://localhost:8554/mypath",
media.Medias{medi})
&description.Session{Medias: []*description.Media{medi}})
require.NoError(t, err)
defer source.Close()

Expand All @@ -665,7 +667,7 @@ func TestAPIProtocolList(t *testing.T) {
Timestamp: 45343,
SSRC: 563423,
},
Payload: []byte{0x01, 0x02, 0x03, 0x04},
Payload: []byte{5, 1, 2, 3, 4},
})
require.NoError(t, err)

Expand Down Expand Up @@ -830,7 +832,8 @@ func TestAPIProtocolGet(t *testing.T) {
case "rtsp conns", "rtsp sessions":
source := gortsplib.Client{}

err := source.StartRecording("rtsp://localhost:8554/mypath", media.Medias{medi})
err := source.StartRecording("rtsp://localhost:8554/mypath",
&description.Session{Medias: []*description.Media{medi}})
require.NoError(t, err)
defer source.Close()

Expand All @@ -839,7 +842,8 @@ func TestAPIProtocolGet(t *testing.T) {
TLSConfig: &tls.Config{InsecureSkipVerify: true},
}

err := source.StartRecording("rtsps://localhost:8322/mypath", media.Medias{medi})
err := source.StartRecording("rtsps://localhost:8322/mypath",
&description.Session{Medias: []*description.Media{medi}})
require.NoError(t, err)
defer source.Close()

Expand Down Expand Up @@ -874,7 +878,7 @@ func TestAPIProtocolGet(t *testing.T) {
case "hls":
source := gortsplib.Client{}
err := source.StartRecording("rtsp://localhost:8554/mypath",
media.Medias{medi})
&description.Session{Medias: []*description.Media{medi}})
require.NoError(t, err)
defer source.Close()

Expand Down Expand Up @@ -931,7 +935,7 @@ func TestAPIProtocolGet(t *testing.T) {
case "webrtc":
source := gortsplib.Client{}
err := source.StartRecording("rtsp://localhost:8554/mypath",
media.Medias{medi})
&description.Session{Medias: []*description.Media{medi}})
require.NoError(t, err)
defer source.Close()

Expand All @@ -949,7 +953,7 @@ func TestAPIProtocolGet(t *testing.T) {
Timestamp: 45343,
SSRC: 563423,
},
Payload: []byte{0x01, 0x02, 0x03, 0x04},
Payload: []byte{5, 1, 2, 3, 4},
})
require.NoError(t, err)

Expand Down Expand Up @@ -1196,7 +1200,7 @@ func TestAPIProtocolKick(t *testing.T) {
source := gortsplib.Client{}

err := source.StartRecording("rtsp://localhost:8554/mypath",
media.Medias{medi})
&description.Session{Medias: []*description.Media{medi}})
require.NoError(t, err)
defer source.Close()

Expand All @@ -1206,7 +1210,7 @@ func TestAPIProtocolKick(t *testing.T) {
}

err := source.StartRecording("rtsps://localhost:8322/mypath",
media.Medias{medi})
&description.Session{Medias: []*description.Media{medi}})
require.NoError(t, err)
defer source.Close()

Expand Down
8 changes: 4 additions & 4 deletions internal/core/authentication.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import (
"net/http"
"strings"

"github.com/bluenviron/gortsplib/v3/pkg/auth"
"github.com/bluenviron/gortsplib/v3/pkg/base"
"github.com/bluenviron/gortsplib/v3/pkg/headers"
"github.com/bluenviron/gortsplib/v3/pkg/url"
"github.com/bluenviron/gortsplib/v4/pkg/auth"
"github.com/bluenviron/gortsplib/v4/pkg/base"
"github.com/bluenviron/gortsplib/v4/pkg/headers"
"github.com/bluenviron/gortsplib/v4/pkg/url"
"github.com/google/uuid"

"github.com/bluenviron/mediamtx/internal/conf"
Expand Down
Loading

0 comments on commit ec279af

Please sign in to comment.