Commit Diff


commit - 2019fa0504b90a8b3609d4bb69731c916de2c272
commit + 2e4d2483483becc6c7c2bb0350b3693ad7382931
blob - cf1b9737d7b2f1776b4b6afa4aa0ea63c9d56d82
blob + 1abec638603b1258b5b271e7b67ac3d4c8d89408
--- cmd/autx/autx.go
+++ cmd/autx/autx.go
@@ -25,6 +25,7 @@ import (
 	"io"
 	"log"
 	"net"
+	"net/netip"
 	"os"
 	"strconv"
 	"strings"
@@ -54,11 +55,13 @@ func main() {
 	}
 	session.Clock = 44100 // 44.1KHz, not the audio sample rate.
 
-	ipv := "IP4"
-	origin := "127.0.0.1"
+	origin := sdp.Origin{
+		ID:      sdp.Now(),
+		Version: sdp.Now(),
+		Address: netip.AddrFrom4([4]byte{127, 0, 0, 1}),
+	}
 	if strings.HasPrefix(os.Args[1], "[") {
-		ipv = "IP6"
-		origin = "::1"
+		origin.Address = netip.IPv6Loopback()
 	}
 	_, port, err := net.SplitHostPort(os.Args[1])
 	if err != nil {
@@ -72,13 +75,8 @@ func main() {
 	}
 
 	description := sdp.Session{
-		Origin: sdp.Origin{
-			ID:          sdp.Now(),
-			Version:     sdp.Now(),
-			AddressType: ipv,
-			Address:     origin,
-		},
-		Name: "test",
+		Origin: origin,
+		Name:   "test",
 		Media: []sdp.Media{
 			{
 				Type:      sdp.MediaTypeAudio,
blob - b04091695ef1e35d627dde53b8beaaee0a8974fd
blob + 1161b17c48b0bd96c491b61826708adbc5220058
--- sdp/example_test.go
+++ sdp/example_test.go
@@ -4,12 +4,16 @@ import (
 	"fmt"
 	"net/netip"
 
+	"github.com/untangledco/streaming/rtp"
 	"github.com/untangledco/streaming/sdp"
 )
 
-// The simplest Session may be described by setting the mandatory fields Origin and Name.
-// The Session type implements fmt.Stringer.
-// To encode a Session in the SDP text format, use Session.String().
+// A simple Session describing transmission of uncompressed linear PCM
+// audio in RTP starts by setting the mandatory fields Origin and Name.
+// The Media field contains information about the audio such as the sample rate
+// and the number of audio channels.
+// The Session type implements fmt.Stringer;
+// to encode a Session in the SDP text format, use Session.String().
 func Example() {
 	session := sdp.Session{
 		Origin: sdp.Origin{
@@ -18,6 +22,18 @@ func Example() {
 			Address: netip.MustParseAddr("2001:db8::1"),
 		},
 		Name: "A call from me to you",
+		Media: []sdp.Media{
+			{
+				Type:      sdp.MediaTypeAudio,
+				Port:      6969,
+				Transport: sdp.ProtoRTP,
+				Format:    []string{fmt.Sprintf("%d", rtp.PayloadL16Mono)},
+				Attributes: []string{
+					fmt.Sprintf("rtpmap:%d", rtp.PayloadL16Mono),
+					fmt.Sprintf("L16/%d", 22050),
+				},
+			},
+		},
 	}
 	fmt.Printf("%s", session)
 	// Output:
@@ -25,4 +41,6 @@ func Example() {
 	// o=- 3930287268 3930287268 IN IP6 2001:db8::1
 	// s=A call from me to you
 	// t=0 0
+	// m=audio 6969 RTP/AVP 11
+	// a=rtpmap:11 L16/22050
 }