mirror of
https://github.com/aler9/gortsplib
synced 2025-10-04 23:02:45 +08:00
update docs
This commit is contained in:
@@ -12,7 +12,7 @@ import (
|
|||||||
// This example shows how to
|
// This example shows how to
|
||||||
// 1. set additional client options
|
// 1. set additional client options
|
||||||
// 2. generate RTP/H264 frames from a file with Gstreamer
|
// 2. generate RTP/H264 frames from a file with Gstreamer
|
||||||
// 3. connect to a RTSP server, announce a H264 track
|
// 3. connect to a RTSP server, announce an H264 track
|
||||||
// 4. write the frames to the server
|
// 4. write the frames to the server
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -35,7 +35,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
fmt.Println("stream connected")
|
fmt.Println("stream connected")
|
||||||
|
|
||||||
// create a H264 track
|
// create an H264 track
|
||||||
track, err := gortsplib.NewTrackH264(96, &gortsplib.TrackConfigH264{sps, pps})
|
track, err := gortsplib.NewTrackH264(96, &gortsplib.TrackConfigH264{sps, pps})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
@@ -11,7 +11,7 @@ import (
|
|||||||
|
|
||||||
// This example shows how to
|
// This example shows how to
|
||||||
// 1. generate RTP/H264 frames from a file with Gstreamer
|
// 1. generate RTP/H264 frames from a file with Gstreamer
|
||||||
// 2. connect to a RTSP server, announce a H264 track
|
// 2. connect to a RTSP server, announce an H264 track
|
||||||
// 3. write the frames to the server for 5 seconds
|
// 3. write the frames to the server for 5 seconds
|
||||||
// 4. pause for 5 seconds
|
// 4. pause for 5 seconds
|
||||||
// 5. repeat
|
// 5. repeat
|
||||||
@@ -36,7 +36,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
fmt.Println("stream connected")
|
fmt.Println("stream connected")
|
||||||
|
|
||||||
// create a H264 track
|
// create an H264 track
|
||||||
track, err := gortsplib.NewTrackH264(96, &gortsplib.TrackConfigH264{sps, pps})
|
track, err := gortsplib.NewTrackH264(96, &gortsplib.TrackConfigH264{sps, pps})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
@@ -10,7 +10,7 @@ import (
|
|||||||
|
|
||||||
// This example shows how to
|
// This example shows how to
|
||||||
// 1. generate RTP/H264 frames from a file with Gstreamer
|
// 1. generate RTP/H264 frames from a file with Gstreamer
|
||||||
// 2. connect to a RTSP server, announce a H264 track
|
// 2. connect to a RTSP server, announce an H264 track
|
||||||
// 3. write the frames to the server
|
// 3. write the frames to the server
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -33,7 +33,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
fmt.Println("stream connected")
|
fmt.Println("stream connected")
|
||||||
|
|
||||||
// create a H264 track
|
// create an H264 track
|
||||||
track, err := gortsplib.NewTrackH264(96, &gortsplib.TrackConfigH264{sps, pps})
|
track, err := gortsplib.NewTrackH264(96, &gortsplib.TrackConfigH264{sps, pps})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
@@ -9,7 +9,7 @@ import (
|
|||||||
|
|
||||||
// This example shows how to
|
// This example shows how to
|
||||||
// 1. connect to a RTSP server and read all tracks on a path
|
// 1. connect to a RTSP server and read all tracks on a path
|
||||||
// 2. check whether there's a H264 track
|
// 2. check whether there's an H264 track
|
||||||
// 3. get H264 NALUs of that track
|
// 3. get H264 NALUs of that track
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
8
track.go
8
track.go
@@ -140,7 +140,7 @@ func (t *Track) ClockRate() (int, error) {
|
|||||||
return 0, fmt.Errorf("attribute 'rtpmap' not found")
|
return 0, fmt.Errorf("attribute 'rtpmap' not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewTrackH264 initializes an H264 track from a SPS and PPS.
|
// NewTrackH264 initializes an H264 track.
|
||||||
func NewTrackH264(payloadType uint8, conf *TrackConfigH264) (*Track, error) {
|
func NewTrackH264(payloadType uint8, conf *TrackConfigH264) (*Track, error) {
|
||||||
spropParameterSets := base64.StdEncoding.EncodeToString(conf.SPS) +
|
spropParameterSets := base64.StdEncoding.EncodeToString(conf.SPS) +
|
||||||
"," + base64.StdEncoding.EncodeToString(conf.PPS)
|
"," + base64.StdEncoding.EncodeToString(conf.PPS)
|
||||||
@@ -171,7 +171,7 @@ func NewTrackH264(payloadType uint8, conf *TrackConfigH264) (*Track, error) {
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsH264 checks whether the track is a H264 track.
|
// IsH264 checks whether the track is an H264 track.
|
||||||
func (t *Track) IsH264() bool {
|
func (t *Track) IsH264() bool {
|
||||||
if t.Media.MediaName.Media != "video" {
|
if t.Media.MediaName.Media != "video" {
|
||||||
return false
|
return false
|
||||||
@@ -190,7 +190,7 @@ func (t *Track) IsH264() bool {
|
|||||||
return vals[1] == "H264/90000"
|
return vals[1] == "H264/90000"
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExtractConfigH264 extracts the configuration from an H264 track.
|
// ExtractConfigH264 extracts the configuration of an H264 track.
|
||||||
func (t *Track) ExtractConfigH264() (*TrackConfigH264, error) {
|
func (t *Track) ExtractConfigH264() (*TrackConfigH264, error) {
|
||||||
v, ok := t.Media.Attribute("fmtp")
|
v, ok := t.Media.Attribute("fmtp")
|
||||||
if !ok {
|
if !ok {
|
||||||
@@ -302,7 +302,7 @@ func (t *Track) IsAAC() bool {
|
|||||||
return strings.HasPrefix(strings.ToLower(vals[1]), "mpeg4-generic/")
|
return strings.HasPrefix(strings.ToLower(vals[1]), "mpeg4-generic/")
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExtractConfigAAC extracts the configuration from an AAC track.
|
// ExtractConfigAAC extracts the configuration of an AAC track.
|
||||||
func (t *Track) ExtractConfigAAC() (*TrackConfigAAC, error) {
|
func (t *Track) ExtractConfigAAC() (*TrackConfigAAC, error) {
|
||||||
v, ok := t.Media.Attribute("fmtp")
|
v, ok := t.Media.Attribute("fmtp")
|
||||||
if !ok {
|
if !ok {
|
||||||
|
Reference in New Issue
Block a user