mirror of
https://github.com/aler9/gortsplib
synced 2025-10-04 23:02:45 +08:00
client: remove default client
This commit is contained in:
18
client.go
18
client.go
@@ -17,24 +17,6 @@ import (
|
||||
"github.com/aler9/gortsplib/pkg/headers"
|
||||
)
|
||||
|
||||
// DefaultClient is the default Client.
|
||||
var DefaultClient = &Client{}
|
||||
|
||||
// Dial connects to a server.
|
||||
func Dial(scheme string, host string) (*ClientConn, error) {
|
||||
return DefaultClient.Dial(scheme, host)
|
||||
}
|
||||
|
||||
// DialRead connects to a server and starts reading all tracks.
|
||||
func DialRead(address string) (*ClientConn, error) {
|
||||
return DefaultClient.DialRead(address)
|
||||
}
|
||||
|
||||
// DialPublish connects to a server and starts publishing the tracks.
|
||||
func DialPublish(address string, tracks Tracks) (*ClientConn, error) {
|
||||
return DefaultClient.DialPublish(address, tracks)
|
||||
}
|
||||
|
||||
// Client is a RTSP client.
|
||||
type Client struct {
|
||||
//
|
||||
|
@@ -745,7 +745,9 @@ func TestClientPublishAutomaticProtocol(t *testing.T) {
|
||||
track, err := NewTrackH264(96, &TrackConfigH264{[]byte{0x01, 0x02, 0x03, 0x04}, []byte{0x01, 0x02, 0x03, 0x04}})
|
||||
require.NoError(t, err)
|
||||
|
||||
conn, err := DialPublish("rtsp://localhost:8554/teststream",
|
||||
c := Client{}
|
||||
|
||||
conn, err := c.DialPublish("rtsp://localhost:8554/teststream",
|
||||
Tracks{track})
|
||||
require.NoError(t, err)
|
||||
defer conn.Close()
|
||||
|
@@ -130,7 +130,9 @@ func TestClientReadTracks(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
}()
|
||||
|
||||
conn, err := DialRead("rtsp://localhost:8554/teststream")
|
||||
c := Client{}
|
||||
|
||||
conn, err := c.DialRead("rtsp://localhost:8554/teststream")
|
||||
require.NoError(t, err)
|
||||
defer conn.Close()
|
||||
|
||||
@@ -801,7 +803,9 @@ func TestClientReadNoContentBase(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
}()
|
||||
|
||||
conn, err := DialRead("rtsp://localhost:8554/teststream")
|
||||
c := Client{}
|
||||
|
||||
conn, err := c.DialRead("rtsp://localhost:8554/teststream")
|
||||
require.NoError(t, err)
|
||||
conn.Close()
|
||||
}
|
||||
@@ -1039,7 +1043,9 @@ func TestClientReadAutomaticProtocol(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
}()
|
||||
|
||||
conn, err := DialRead("rtsp://localhost:8554/teststream")
|
||||
c := Client{}
|
||||
|
||||
conn, err := c.DialRead("rtsp://localhost:8554/teststream")
|
||||
require.NoError(t, err)
|
||||
|
||||
frameRecv := make(chan struct{})
|
||||
@@ -1522,7 +1528,9 @@ func TestClientReadRedirect(t *testing.T) {
|
||||
})
|
||||
}()
|
||||
|
||||
conn, err := DialRead("rtsp://localhost:8554/path1")
|
||||
c := Client{}
|
||||
|
||||
conn, err := c.DialRead("rtsp://localhost:8554/path1")
|
||||
require.NoError(t, err)
|
||||
|
||||
frameRecv := make(chan struct{})
|
||||
|
@@ -88,7 +88,9 @@ func TestClientSession(t *testing.T) {
|
||||
u, err := base.ParseURL("rtsp://localhost:8554/stream")
|
||||
require.NoError(t, err)
|
||||
|
||||
conn, err := Dial(u.Scheme, u.Host)
|
||||
c := Client{}
|
||||
|
||||
conn, err := c.Dial(u.Scheme, u.Host)
|
||||
require.NoError(t, err)
|
||||
defer conn.Close()
|
||||
|
||||
@@ -167,7 +169,9 @@ func TestClientAuth(t *testing.T) {
|
||||
u, err := base.ParseURL("rtsp://myuser:mypass@localhost:8554/stream")
|
||||
require.NoError(t, err)
|
||||
|
||||
conn, err := Dial(u.Scheme, u.Host)
|
||||
c := Client{}
|
||||
|
||||
conn, err := c.Dial(u.Scheme, u.Host)
|
||||
require.NoError(t, err)
|
||||
defer conn.Close()
|
||||
|
||||
@@ -229,7 +233,9 @@ func TestClientDescribeCharset(t *testing.T) {
|
||||
u, err := base.ParseURL("rtsp://localhost:8554/teststream")
|
||||
require.NoError(t, err)
|
||||
|
||||
conn, err := Dial(u.Scheme, u.Host)
|
||||
c := Client{}
|
||||
|
||||
conn, err := c.Dial(u.Scheme, u.Host)
|
||||
require.NoError(t, err)
|
||||
defer conn.Close()
|
||||
|
||||
|
@@ -39,8 +39,10 @@ func main() {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
c := gortsplib.Client{}
|
||||
|
||||
// connect to the server and start publishing the track
|
||||
conn, err := gortsplib.DialPublish("rtsp://localhost:8554/mystream",
|
||||
conn, err := c.DialPublish("rtsp://localhost:8554/mystream",
|
||||
gortsplib.Tracks{track})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
@@ -40,8 +40,10 @@ func main() {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
c := gortsplib.Client{}
|
||||
|
||||
// connect to the server and start publishing the track
|
||||
conn, err := gortsplib.DialPublish("rtsp://localhost:8554/mystream",
|
||||
conn, err := c.DialPublish("rtsp://localhost:8554/mystream",
|
||||
gortsplib.Tracks{track})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
@@ -39,8 +39,10 @@ func main() {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
c := gortsplib.Client{}
|
||||
|
||||
// connect to the server and start publishing the track
|
||||
conn, err := gortsplib.DialPublish("rtsp://localhost:8554/mystream",
|
||||
conn, err := c.DialPublish("rtsp://localhost:8554/mystream",
|
||||
gortsplib.Tracks{track})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
@@ -42,8 +42,10 @@ func main() {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
c := gortsplib.Client{}
|
||||
|
||||
// connect to the server and start publishing the track
|
||||
conn, err := gortsplib.DialPublish("rtsp://localhost:8554/mystream",
|
||||
conn, err := c.DialPublish("rtsp://localhost:8554/mystream",
|
||||
gortsplib.Tracks{track})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
@@ -17,7 +17,9 @@ func main() {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
conn, err := gortsplib.Dial(u.Scheme, u.Host)
|
||||
c := gortsplib.Client{}
|
||||
|
||||
conn, err := c.Dial(u.Scheme, u.Host)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@@ -25,8 +25,10 @@ const (
|
||||
)
|
||||
|
||||
func main() {
|
||||
c := gortsplib.Client{}
|
||||
|
||||
// connect to the server and start reading all tracks
|
||||
conn, err := gortsplib.DialRead(inputStream)
|
||||
conn, err := c.DialRead(inputStream)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@@ -14,8 +14,10 @@ import (
|
||||
// 3. get H264 NALUs of that track
|
||||
|
||||
func main() {
|
||||
c := gortsplib.Client{}
|
||||
|
||||
// connect to the server and start reading all tracks
|
||||
conn, err := gortsplib.DialRead("rtsp://localhost:8554/mystream")
|
||||
conn, err := c.DialRead("rtsp://localhost:8554/mystream")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@@ -19,7 +19,9 @@ func main() {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
conn, err := gortsplib.Dial(u.Scheme, u.Host)
|
||||
c := gortsplib.Client{}
|
||||
|
||||
conn, err := c.Dial(u.Scheme, u.Host)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@@ -14,8 +14,10 @@ import (
|
||||
// 4. repeat
|
||||
|
||||
func main() {
|
||||
c := gortsplib.Client{}
|
||||
|
||||
// connect to the server and start reading all tracks
|
||||
conn, err := gortsplib.DialRead("rtsp://localhost:8554/mystream")
|
||||
conn, err := c.DialRead("rtsp://localhost:8554/mystream")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@@ -10,8 +10,10 @@ import (
|
||||
// 1. connect to a RTSP server and read all tracks on a path
|
||||
|
||||
func main() {
|
||||
c := gortsplib.Client{}
|
||||
|
||||
// connect to the server and start reading all tracks
|
||||
conn, err := gortsplib.DialRead("rtsp://localhost:8554/mystream")
|
||||
conn, err := c.DialRead("rtsp://localhost:8554/mystream")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user