diff --git a/README.md b/README.md index 00d43d09..dbdc1df7 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,7 @@ _rtsp-simple-server_ has been rebranded as _MediaMTX_. The reason is pretty obvi * [Decrease latency](#decrease-latency-1) * [WebRTC protocol](#webrtc-protocol) * [General usage](#general-usage-3) + * [WHIP and WHEP](#whip-and-whep) * [Usage inside a container or behind a NAT](#usage-inside-a-container-or-behind-a-nat) * [Embedding](#embedding-1) * [Standards](#standards) @@ -1198,12 +1199,34 @@ To decrease the latency, you can: ### General usage -Every stream published to the server can be read with WebRTC by visiting: +You can publish a stream from the browser to the server with WebRTC by visiting: + +``` +http://localhost:8889/mystream/publish +``` + +You can read a stream from the browser with WebRTC by visiting: ``` http://localhost:8889/mystream ``` +### WHIP and WHEP + +WHIP and WHEP are two WebRTC extensions that allows to publish and read streams with WebRTC without passing through a web page. This allows to use WebRTC as a general purpose streaming protocol. + +If you are using a software that supports WHIP, you can publish a stream to the server by using this WHIP URL: + +``` +http://localhost:8889/mystream/whip +``` + +If you are using a software that supports WHEP, you can read a stream from the server by using this WHEP URL: + +``` +http://localhost:8889/mystream/whep +``` + ### Usage inside a container or behind a NAT If the server is hosted inside a container or is behind a NAT, additional configuration is required in order to allow the two WebRTC parts (the browser and the server) to establish a connection (WebRTC/ICE connection). diff --git a/internal/core/webrtc_incoming_track.go b/internal/core/webrtc_incoming_track.go index 1489c294..4081f58c 100644 --- a/internal/core/webrtc_incoming_track.go +++ b/internal/core/webrtc_incoming_track.go @@ -2,6 +2,7 @@ package core import ( "fmt" + "strings" "time" "github.com/bluenviron/gortsplib/v3/pkg/formats" @@ -35,49 +36,53 @@ func newWebRTCIncomingTrack( writeRTCP: writeRTCP, } - switch track.Codec().MimeType { - case webrtc.MimeTypeAV1: + switch strings.ToLower(track.Codec().MimeType) { + case strings.ToLower(webrtc.MimeTypeAV1): t.mediaType = media.TypeVideo t.format = &formats.AV1{ PayloadTyp: uint8(track.PayloadType()), } - case webrtc.MimeTypeVP9: + case strings.ToLower(webrtc.MimeTypeVP9): t.mediaType = media.TypeVideo t.format = &formats.VP9{ PayloadTyp: uint8(track.PayloadType()), } - case webrtc.MimeTypeVP8: + case strings.ToLower(webrtc.MimeTypeVP8): t.mediaType = media.TypeVideo t.format = &formats.VP8{ PayloadTyp: uint8(track.PayloadType()), } - case webrtc.MimeTypeH264: + case strings.ToLower(webrtc.MimeTypeH264): t.mediaType = media.TypeVideo t.format = &formats.H264{ PayloadTyp: uint8(track.PayloadType()), PacketizationMode: 1, } - case webrtc.MimeTypeOpus: + case strings.ToLower(webrtc.MimeTypeOpus): t.mediaType = media.TypeAudio t.format = &formats.Opus{ PayloadTyp: uint8(track.PayloadType()), } - case webrtc.MimeTypeG722: + case strings.ToLower(webrtc.MimeTypeG722): t.mediaType = media.TypeAudio t.format = &formats.G722{} - case webrtc.MimeTypePCMU: + case strings.ToLower(webrtc.MimeTypePCMU): t.mediaType = media.TypeAudio - t.format = &formats.G711{MULaw: true} + t.format = &formats.G711{ + MULaw: true, + } - case webrtc.MimeTypePCMA: + case strings.ToLower(webrtc.MimeTypePCMA): t.mediaType = media.TypeAudio - t.format = &formats.G711{MULaw: false} + t.format = &formats.G711{ + MULaw: false, + } default: return nil, fmt.Errorf("unsupported codec: %v", track.Codec())