Documentation
¶
Overview ¶
Package rtcmedia is the media half of WebRTC for Sweef: it turns raw capture frames and PCM into RTP (VP8 and Opus, with the feedback machinery real services expect) and RTP back into decoded frames and PCM. It sits on pion/webrtc but does not know about the browser engine; internal/engine binds it to MediaStreamTracks and to <video> elements.
Send path: capture.VideoSource -> scale -> internal/media/vp8enc -> VP8 payload descriptor -> pacer -> pion (NACK responder, TWCC, RTCP reports). Congestion control is pion's GCC estimator plus REMB and RTCP loss, driving the encoder bitrate, resolution and frame rate. Receive path: pion (NACK generator, TWCC feedback) -> reorder/jitter buffer -> VP8 depacketiser -> internal/media/vp8 -> FrameSink; Opus with a small adaptive jitter buffer and concealment -> AudioSink.
Index ¶
- Constants
- Variables
- func Codecs(kind webrtc.RTPCodecType) []webrtc.RTPCodecParameters
- func FillBlack(f *capture.Frame)
- func HeaderExtensions(kind webrtc.RTPCodecType) []string
- func LayerBitrates(px int) (desired, minimum int)
- func NewFrame(w, h int) *capture.Frame
- func RunRTCP(rs *webrtc.RTPSender, h func([]rtcp.Packet))
- func RunRTCPRID(rs *webrtc.RTPSender, rid string, h func([]rtcp.Packet))
- type API
- type AudioProcessor
- type AudioReceiver
- func (a *AudioReceiver) AddTap(f func(pcm []int16, rate, channels int))
- func (a *AudioReceiver) Close()
- func (a *AudioReceiver) SetHook(f FrameHook)
- func (a *AudioReceiver) SetMinDelay(sec float64)
- func (a *AudioReceiver) SetProcessor(p AudioProcessor)
- func (a *AudioReceiver) SetSink(s AudioSink)
- func (a *AudioReceiver) Sources() (ssrc uint32, last time.Time, rtpTS uint32, level float64, ok bool)
- func (a *AudioReceiver) Stats() AudioRecvStats
- func (a *AudioReceiver) Wait()
- type AudioRecvStats
- type AudioSendStats
- type AudioSender
- func (a *AudioSender) Close()
- func (a *AudioSender) HandleRTCP(pkts []rtcp.Packet)
- func (a *AudioSender) SetActive(on bool)
- func (a *AudioSender) SetBitrate(bps int)
- func (a *AudioSender) SetDTX(on bool)
- func (a *AudioSender) SetEnabled(on bool)
- func (a *AudioSender) SetHook(f FrameHook)
- func (a *AudioSender) SetSource(src capture.AudioSource, c capture.AudioConstraints) error
- func (a *AudioSender) Stats() AudioSendStats
- type AudioSink
- type Branch
- type EncodedFrame
- type FanOut
- type FrameHook
- type FrameSink
- type LocalTrack
- func (t *LocalTrack) Bind(ctx webrtc.TrackLocalContext) (webrtc.RTPCodecParameters, error)
- func (t *LocalTrack) ID() string
- func (t *LocalTrack) Kind() webrtc.RTPCodecType
- func (t *LocalTrack) Negotiated() Negotiated
- func (t *LocalTrack) OnBind(f func(Negotiated))
- func (t *LocalTrack) RID() string
- func (t *LocalTrack) Ready() bool
- func (t *LocalTrack) ReadyWhenConnected(rs *webrtc.RTPSender)
- func (t *LocalTrack) SetMidFunc(f func() string)
- func (t *LocalTrack) SetReadyFunc(f func() bool)
- func (t *LocalTrack) SetRetransmitBudget(bps int)
- func (t *LocalTrack) SetRetransmitLimiter(c *RTXCounter)
- func (t *LocalTrack) StreamID() string
- func (t *LocalTrack) Unbind(ctx webrtc.TrackLocalContext) error
- func (t *LocalTrack) Write(h *rtp.Header, payload []byte, o WriteOpts) (int, error)
- type Negotiated
- type NullSink
- type RTXCounter
- type RecordSink
- type Resampler
- type Scaler
- type SendParams
- type VideoCallbacks
- type VideoReceiver
- func (r *VideoReceiver) AddSink(s FrameSink)
- func (r *VideoReceiver) Close()
- func (r *VideoReceiver) Muted() bool
- func (r *VideoReceiver) RemoveSink(s FrameSink)
- func (r *VideoReceiver) RequestKeyFrame()
- func (r *VideoReceiver) SetHook(f FrameHook)
- func (r *VideoReceiver) SetMinDelay(sec float64)
- func (r *VideoReceiver) Size() (int, int)
- func (r *VideoReceiver) Sources() (ssrc uint32, last time.Time, rtpTS uint32, ok bool)
- func (r *VideoReceiver) Stats() VideoRecvStats
- func (r *VideoReceiver) Wait()
- type VideoRecvStats
- type VideoSendStats
- type VideoSender
- func (s *VideoSender) Close()
- func (s *VideoSender) HandleRTCP(pkts []rtcp.Packet)
- func (s *VideoSender) Params() SendParams
- func (s *VideoSender) RequestKeyFrame()
- func (s *VideoSender) SetEnabled(on bool)
- func (s *VideoSender) SetHook(f FrameHook)
- func (s *VideoSender) SetParams(p SendParams)
- func (s *VideoSender) SetShare(f func(total int) int)
- func (s *VideoSender) SetSource(src capture.VideoSource, c capture.VideoConstraints) error
- func (s *VideoSender) Source() capture.VideoSource
- func (s *VideoSender) SourceSize() (int, int)
- func (s *VideoSender) Stats() VideoSendStats
- func (s *VideoSender) Target() int
- type WriteOpts
Constants ¶
const ( ExtMid = sdp.SDESMidURI ExtRID = sdp.SDESRTPStreamIDURI ExtRepairedRID = sdp.SDESRepairRTPStreamIDURI ExtTransportCC = sdp.TransportCCURI ExtAbsSendTime = "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time" ExtAudioLevel = "urn:ietf:params:rtp-hdrext:ssrc-audio-level" ExtVideoOrient = "urn:3gpp:video-orientation" )
Header extension URIs offered in SDP.
const ( PTVP8 = 96 PTRTX = 97 PTOpus = 111 PTTelEv = 126 )
Payload types offered (the numbers Chrome uses for the same codecs).
const InitialBitrate = 1_000_000
InitialBitrate is where the congestion controller starts before feedback arrives.
Variables ¶
var ErrNotBound = errors.New("rtcmedia: track is not bound to a transport")
ErrNotBound is returned by Write before negotiation is complete.
Functions ¶
func Codecs ¶
func Codecs(kind webrtc.RTPCodecType) []webrtc.RTPCodecParameters
Codecs returns the codecs the media engine offers for a kind, in preference order.
func HeaderExtensions ¶
func HeaderExtensions(kind webrtc.RTPCodecType) []string
HeaderExtensions lists the header extension URIs offered for a kind.
func LayerBitrates ¶
LayerBitrates gives the bitrate a simulcast layer of px pixels wants (what the layer is given when the estimate allows) and the least it needs to be worth sending at all. Chrome's simulcast tables are of the same shape: a 720p layer wants a couple of Mbit/s, a 180p layer a couple of hundred kbit/s.
func NewFrame ¶
NewFrame allocates an I420 frame of the given size (width and height are rounded up to even).
Types ¶
type API ¶
type API struct {
*webrtc.API
// Estimator receives the peer's bandwidth estimator when the PeerConnection is created.
Estimator <-chan cc.BandwidthEstimator
// Stats gives the per-SSRC RTP/RTCP statistics of the peer (outbound and remote-inbound included,
// which pion's own getStats does not report), once the PeerConnection exists.
Stats <-chan stats.Getter
// Retransmits counts what the NACK responder resent.
Retransmits *RTXCounter
// contains filtered or unexported fields
}
API is a pion API configured for browser-style calls.
type AudioProcessor ¶
type AudioProcessor interface {
AnalyzeFarEnd(pcm []int16, rate, channels int)
ProcessNearEnd(pcm []int16)
}
AudioProcessor is the hook for acoustic echo cancellation and noise suppression. Sweef ships none (use headphones); an implementation receives the far-end signal (what is about to be played) and cleans the near-end signal (what the microphone captured) in place, 20 ms at a time at 48 kHz mono.
type AudioReceiver ¶
type AudioReceiver struct {
// contains filtered or unexported fields
}
AudioReceiver reorders and decodes a received Opus stream and plays it into an AudioSink: a small adaptive jitter buffer, packet loss concealment (in-band FEC when the next packet carries it, else the decoder's PLC) and level metering.
func NewAudioReceiver ¶
func NewAudioReceiver(track *webrtc.TrackRemote, rcv *webrtc.RTPReceiver, sink AudioSink, onMute func(muted bool)) (*AudioReceiver, error)
NewAudioReceiver starts receiving a remote audio track into sink (nil: discard). onMute is called when packets stop or resume (from a receiver goroutine).
func (*AudioReceiver) AddTap ¶
func (a *AudioReceiver) AddTap(f func(pcm []int16, rate, channels int))
AddTap calls f with every decoded 20 ms block (interleaved stereo, 48 kHz) after it went to the sink: what a MediaStreamTrackProcessor or a Web Audio MediaStreamAudioSourceNode reads. The slice must not be kept or changed.
func (*AudioReceiver) Close ¶
func (a *AudioReceiver) Close()
Close stops playout; Wait waits for the RTP and RTCP readers, which end when the transport closes.
func (*AudioReceiver) SetHook ¶
func (a *AudioReceiver) SetHook(f FrameHook)
SetHook installs (nil removes) the encoded-frame transform: it sees each packet's payload before it is buffered.
func (*AudioReceiver) SetMinDelay ¶
func (a *AudioReceiver) SetMinDelay(sec float64)
SetMinDelay sets the least jitter buffer depth in seconds (RTCRtpReceiver.jitterBufferTarget; 0 removes it).
func (*AudioReceiver) SetProcessor ¶
func (a *AudioReceiver) SetProcessor(p AudioProcessor)
SetProcessor installs the echo cancellation hook, which sees the far-end signal before playback.
func (*AudioReceiver) SetSink ¶
func (a *AudioReceiver) SetSink(s AudioSink)
SetSink changes where audio goes (nil: discard).
func (*AudioReceiver) Sources ¶
func (a *AudioReceiver) Sources() (ssrc uint32, last time.Time, rtpTS uint32, level float64, ok bool)
Sources returns what getSynchronizationSources reports.
func (*AudioReceiver) Stats ¶
func (a *AudioReceiver) Stats() AudioRecvStats
Stats returns a snapshot.
func (*AudioReceiver) Wait ¶
func (a *AudioReceiver) Wait()
Wait blocks until the readers have ended (after the peer connection was closed).
type AudioRecvStats ¶
type AudioRecvStats struct {
PacketsReceived, PacketsDiscarded, BytesReceived uint64
SamplesReceived, ConcealedSamples, SilentConcealedSamples, ConcealmentEvents uint64
InsertedSamplesForDeceleration, RemovedSamplesForAcceleration uint64
TotalSamplesDuration, TotalAudioEnergy, AudioLevel float64
JitterBufferDelay float64
JitterBufferEmittedCount uint64
JitterBufferTarget float64
FECRecovered uint64
LastPacketTime time.Time
LastRTPTimestamp uint32
SSRC uint32
Muted bool
DecodeErrors uint64
}
AudioRecvStats is the receiver's contribution to getStats().
type AudioSendStats ¶
type AudioSendStats struct {
FramesEncoded uint64
AudioLevel float64
TotalAudioEnergy float64
TotalSamplesDuration float64
Underruns, Overruns uint64
PacketsSent uint64
BytesSent uint64
RTT float64
FractionLost float64
Active bool
}
AudioSendStats is the sender's contribution to getStats().
type AudioSender ¶
type AudioSender struct {
// Processor is the optional echo cancellation / noise suppression hook.
Processor AudioProcessor
// contains filtered or unexported fields
}
AudioSender encodes PCM from a capture.AudioSource to Opus (48 kHz, mono, 20 ms frames, in-band FEC) and sends it. Capture timing is decoupled from RTP timing by a small FIFO that a 20 ms clock drains.
func NewAudioSender ¶
func NewAudioSender(track *LocalTrack) (*AudioSender, error)
NewAudioSender starts the audio send machinery for a track.
func (*AudioSender) HandleRTCP ¶
func (a *AudioSender) HandleRTCP(pkts []rtcp.Packet)
HandleRTCP processes RTCP read from the RTPSender: receiver reports give the round trip time and the loss that sets the encoder's packet loss expectation (and with it the in-band FEC).
func (*AudioSender) SetActive ¶
func (a *AudioSender) SetActive(on bool)
SetActive is RTCRtpEncodingParameters.active.
func (*AudioSender) SetBitrate ¶
func (a *AudioSender) SetBitrate(bps int)
SetBitrate sets the Opus bitrate (bits per second, 6000 to 128000).
func (*AudioSender) SetDTX ¶
func (a *AudioSender) SetDTX(on bool)
SetDTX turns discontinuous transmission on or off.
func (*AudioSender) SetEnabled ¶
func (a *AudioSender) SetEnabled(on bool)
SetEnabled implements MediaStreamTrack.enabled: a disabled track sends silence.
func (*AudioSender) SetHook ¶
func (a *AudioSender) SetHook(f FrameHook)
SetHook installs (nil removes) the encoded-frame transform of the sender.
func (*AudioSender) SetSource ¶
func (a *AudioSender) SetSource(src capture.AudioSource, c capture.AudioConstraints) error
SetSource attaches (or with nil detaches) the audio source; the previous one is stopped.
type AudioSink ¶
AudioSink consumes decoded PCM (interleaved signed 16-bit). internal/audioout adapts its output to this. Write must copy what it keeps and should not block for long.
type Branch ¶
type Branch struct {
// contains filtered or unexported fields
}
Branch is one consumer's view of a FanOut.
func (*Branch) Info ¶
func (b *Branch) Info() capture.DeviceInfo
type EncodedFrame ¶
type EncodedFrame struct {
Video bool
Key bool
Timestamp uint32 // RTP timestamp
SSRC uint32
PayloadType uint8
Width int // video only; 0 when unknown
Height int
Data []byte
}
EncodedFrame is one encoded media frame on its way between the codec and the RTP layer: the VP8 frame or the Opus packet before packetisation on the send side, and as reassembled from RTP before decoding on the receive side. It is what RTCRtpScriptTransform and createEncodedStreams hand to a page.
type FanOut ¶
type FanOut struct {
// contains filtered or unexported fields
}
FanOut shares one capture source between several consumers (the layers of a simulcast sender). A capture.VideoSource can only be started once, so each consumer gets a Branch: a VideoSource of its own that receives every frame of the root. The root starts with the first branch and stops when the last one stops. A slow consumer never delays the others: a branch whose channel is full drops its oldest frame. Frames are shared, read-only.
func NewFanOut ¶
func NewFanOut(src capture.VideoSource) *FanOut
NewFanOut wraps src (not yet started).
type FrameHook ¶
type FrameHook func(f *EncodedFrame) (data []byte, ok bool)
FrameHook processes one encoded frame. It runs on the media goroutine and may block (the engine waits for the page's transform to answer); it returns the payload to use instead, or ok=false to drop the frame (a transform that failed, e.g. could not decrypt). A nil hook leaves frames alone.
type FrameSink ¶
type FrameSink interface {
// PushFrame delivers a frame. img is never modified afterwards, so a sink may keep it.
PushFrame(img *image.YCbCr)
}
FrameSink receives decoded video frames at their playout time.
type LocalTrack ¶
type LocalTrack struct {
// contains filtered or unexported fields
}
LocalTrack is the webrtc.TrackLocal the senders write RTP into. It stays bound to one RTPSender for its whole life, so replaceTrack only swaps the media source and the RTP stream (SSRC, sequence numbers, timestamps) continues without a gap.
func NewLocalTrack ¶
func NewLocalTrack(kind webrtc.RTPCodecType, id, streamID string) *LocalTrack
NewLocalTrack creates a track of a kind ("audio" or "video") with its msid track and stream ids.
func NewLocalTrackRID ¶
func NewLocalTrackRID(kind webrtc.RTPCodecType, id, streamID, rid string) *LocalTrack
NewLocalTrackRID creates one simulcast layer: a track with an RTP stream id (rid). Layers of one sender share the track and stream ids.
func (*LocalTrack) Bind ¶
func (t *LocalTrack) Bind(ctx webrtc.TrackLocalContext) (webrtc.RTPCodecParameters, error)
Bind implements webrtc.TrackLocal.
func (*LocalTrack) ID ¶
func (t *LocalTrack) ID() string
func (*LocalTrack) Kind ¶
func (t *LocalTrack) Kind() webrtc.RTPCodecType
func (*LocalTrack) Negotiated ¶
func (t *LocalTrack) Negotiated() Negotiated
Negotiated returns the current negotiation result.
func (*LocalTrack) OnBind ¶
func (t *LocalTrack) OnBind(f func(Negotiated))
OnBind registers f to be called whenever the track is (re)bound to a transport.
func (*LocalTrack) RID ¶
func (t *LocalTrack) RID() string
func (*LocalTrack) Ready ¶
func (t *LocalTrack) Ready() bool
Ready reports whether media can be sent now.
func (*LocalTrack) ReadyWhenConnected ¶
func (t *LocalTrack) ReadyWhenConnected(rs *webrtc.RTPSender)
ReadyWhenConnected makes the track ready once the sender's DTLS transport is connected.
func (*LocalTrack) SetMidFunc ¶
func (t *LocalTrack) SetMidFunc(f func() string)
func (*LocalTrack) SetReadyFunc ¶
func (t *LocalTrack) SetReadyFunc(f func() bool)
SetReadyFunc sets the check that the transport can carry media (the DTLS handshake is done); packets written before that are silently discarded by pion, so senders wait for it instead.
func (*LocalTrack) SetRetransmitBudget ¶
func (t *LocalTrack) SetRetransmitBudget(bps int)
SetRetransmitBudget limits the NACK retransmissions of the track to bps bits per second.
func (*LocalTrack) SetRetransmitLimiter ¶
func (t *LocalTrack) SetRetransmitLimiter(c *RTXCounter)
SetRetransmitLimiter attaches the counter that enforces the retransmission budget of this track.
func (*LocalTrack) StreamID ¶
func (t *LocalTrack) StreamID() string
func (*LocalTrack) Unbind ¶
func (t *LocalTrack) Unbind(ctx webrtc.TrackLocalContext) error
Unbind implements webrtc.TrackLocal.
type Negotiated ¶
type Negotiated struct {
Bound bool
PT uint8
RTXPT uint8
SSRC uint32
RTXSSRC uint32
TWCC bool // transport-wide congestion control feedback (extension and feedback type)
REMB bool
NACK bool
PLI bool
FIR bool
MidID uint8
}
Negotiated describes what the remote end agreed to for a sender.
type RTXCounter ¶
type RTXCounter struct {
// contains filtered or unexported fields
}
RTXCounter is an interceptor, placed just above the network, that sees every retransmission the NACK responder sends (packets on the RTX stream). It counts them per media SSRC for the statistics and holds them to a bit rate budget: without one a lossy path makes retransmissions of retransmissions that fill the link they are meant to repair.
func NewRTXCounter ¶
func NewRTXCounter() *RTXCounter
NewRTXCounter returns an empty counter; register it with the interceptor registry.
func (*RTXCounter) Get ¶
func (c *RTXCounter) Get(ssrc uint32) (packets, bytes, dropped uint64)
Get returns the retransmitted packets and payload bytes sent for a media SSRC and the number held back.
func (*RTXCounter) NewInterceptor ¶
func (c *RTXCounter) NewInterceptor(string) (interceptor.Interceptor, error)
NewInterceptor implements interceptor.Factory.
func (*RTXCounter) SetBudget ¶
func (c *RTXCounter) SetBudget(ssrc uint32, bps int)
SetBudget limits the retransmission rate of a media SSRC to bps bits per second.
type RecordSink ¶
type RecordSink struct {
Max int // maximum samples kept (interleaved); 0 means 10 seconds at 48 kHz stereo
// contains filtered or unexported fields
}
RecordSink keeps the most recent audio in memory (tests, diagnostics).
func (*RecordSink) Snapshot ¶
func (r *RecordSink) Snapshot() (pcm []int16, rate, channels int)
Snapshot returns a copy of the kept samples and their format.
func (*RecordSink) Total ¶
func (r *RecordSink) Total() int
Total is the number of interleaved samples written so far.
func (*RecordSink) Write ¶
func (r *RecordSink) Write(pcm []int16, rate, channels int)
type Resampler ¶
type Resampler struct {
// contains filtered or unexported fields
}
Resampler converts mono float32 audio between sample rates with a windowed-sinc kernel, keeping its state across calls.
func NewResampler ¶
NewResampler returns a resampler from rate in to rate out.
type Scaler ¶
type Scaler struct {
// contains filtered or unexported fields
}
Scaler converts frames to another size (bilinear, with a box-filter pre-step for large reductions).
type SendParams ¶
type SendParams struct {
Active bool
MaxBitrate int // bits per second; 0 means the default ceiling
MaxFramerate float64 // frames per second; 0 means the source rate
ScaleDownBy float64 // >= 1
}
SendParams mirrors the fields of RTCRtpEncodingParameters that matter to a single-layer sender.
func DefaultSendParams ¶
func DefaultSendParams() SendParams
DefaultSendParams is an active, unconstrained encoding.
type VideoCallbacks ¶
type VideoCallbacks struct {
OnResize func(w, h int)
OnMute func(muted bool) // true when packets stop arriving, false when they (re)start
OnFrame func() // after a frame was pushed to the sinks
}
VideoCallbacks are called from receiver goroutines; keep them quick.
type VideoReceiver ¶
type VideoReceiver struct {
// contains filtered or unexported fields
}
VideoReceiver reassembles, decodes and plays out a received VP8 stream.
func NewVideoReceiver ¶
func NewVideoReceiver(track *webrtc.TrackRemote, rcv *webrtc.RTPReceiver, writeRTCP func([]rtcp.Packet) error, cb VideoCallbacks) *VideoReceiver
NewVideoReceiver starts receiving the remote track. writeRTCP sends RTCP to the remote (PLI).
func (*VideoReceiver) AddSink ¶
func (r *VideoReceiver) AddSink(s FrameSink)
AddSink adds a frame consumer; the most recent frame (if any) is delivered at once.
func (*VideoReceiver) Close ¶
func (r *VideoReceiver) Close()
Close stops decoding and playout. The two reader goroutines end when the peer connection (or the transceiver) closes; Wait waits for them.
func (*VideoReceiver) Muted ¶
func (r *VideoReceiver) Muted() bool
Muted reports whether packets are currently arriving.
func (*VideoReceiver) RemoveSink ¶
func (r *VideoReceiver) RemoveSink(s FrameSink)
RemoveSink removes a consumer.
func (*VideoReceiver) RequestKeyFrame ¶
func (r *VideoReceiver) RequestKeyFrame()
RequestKeyFrame asks the sender for a key frame (a PLI), as RTCRtpScriptTransformer.sendKeyFrameRequest does.
func (*VideoReceiver) SetHook ¶
func (r *VideoReceiver) SetHook(f FrameHook)
SetHook installs (nil removes) the encoded-frame transform: it sees each reassembled frame before decoding.
func (*VideoReceiver) SetMinDelay ¶
func (r *VideoReceiver) SetMinDelay(sec float64)
SetMinDelay sets the least jitter buffer delay in seconds (RTCRtpReceiver.jitterBufferTarget; 0 removes it).
func (*VideoReceiver) Size ¶
func (r *VideoReceiver) Size() (int, int)
Size returns the size of the last decoded frame (0, 0 before the first).
func (*VideoReceiver) Sources ¶
Sources returns what getSynchronizationSources reports for this stream.
func (*VideoReceiver) Stats ¶
func (r *VideoReceiver) Stats() VideoRecvStats
Stats returns a snapshot.
func (*VideoReceiver) Wait ¶
func (r *VideoReceiver) Wait()
Wait blocks until the RTP and RTCP readers have ended (after the peer connection was closed).
type VideoRecvStats ¶
type VideoRecvStats struct {
FramesReceived, FramesDecoded, FramesDropped, KeyFramesDecoded uint64
TotalDecodeTime float64
FrameWidth, FrameHeight int
FramesPerSecond float64
JitterBufferDelay float64
JitterBufferEmittedCount uint64
JitterBufferTarget float64
FreezeCount uint32
TotalFreezesDuration float64
PLICount, NACKCount, FIRCount uint32
PacketsDiscarded uint64
BytesReceived uint64
PacketsReceived uint64
LastPacketTime time.Time
Muted bool
SSRC uint32
LastRTPTimestamp uint32
DecodeErrors uint64
}
VideoRecvStats is the receiver's contribution to getStats().
type VideoSendStats ¶
type VideoSendStats struct {
FramesEncoded, KeyFramesEncoded, FramesDroppedByEncoder uint64
FramesCaptured uint64
TotalEncodeTime float64
TotalEncodedBytes uint64
FrameWidth, FrameHeight int
FramesPerSecond float64
TargetBitrate float64
QualityLimitationReason string
QualityLimitationDurations map[string]float64
QualityLimitationResolutionChanges uint32
PLICount, FIRCount, NACKCount uint32
RTT float64
FractionLost float64
Q int
QPSum uint64
Active bool
HugeFramesSent uint64
PacerQueueDelay float64
PacketsSent uint64
BytesSent uint64
}
VideoSendStats is the sender's contribution to getStats().
type VideoSender ¶
type VideoSender struct {
// OnQuality is called (from the sender goroutine) when the quality limitation reason changes.
OnQuality func(reason string)
// contains filtered or unexported fields
}
VideoSender pulls frames from a capture.VideoSource, encodes them to VP8 at a rate the network allows and sends them as RTP through a LocalTrack.
func NewVideoSender ¶
func NewVideoSender(track *LocalTrack, est cc.BandwidthEstimator) *VideoSender
NewVideoSender starts the send machinery for a track; est may be nil. The RTCP read from the RTPSender is passed to HandleRTCP (see RunRTCP).
func (*VideoSender) Close ¶
func (s *VideoSender) Close()
Close stops the sender; it does not close the source's owner, only stops the source.
func (*VideoSender) HandleRTCP ¶
func (s *VideoSender) HandleRTCP(pkts []rtcp.Packet)
HandleRTCP processes RTCP read from the RTPSender: PLI and FIR request a key frame, REMB and receiver reports feed the bandwidth decision and the round trip time.
func (*VideoSender) Params ¶
func (s *VideoSender) Params() SendParams
Params returns the current parameters.
func (*VideoSender) RequestKeyFrame ¶
func (s *VideoSender) RequestKeyFrame()
RequestKeyFrame makes the next encoded frame a key frame (what a PLI or FIR does).
func (*VideoSender) SetEnabled ¶
func (s *VideoSender) SetEnabled(on bool)
SetEnabled implements MediaStreamTrack.enabled: a disabled track sends black frames.
func (*VideoSender) SetHook ¶
func (s *VideoSender) SetHook(f FrameHook)
SetHook installs (nil removes) the encoded-frame transform of the sender.
func (*VideoSender) SetParams ¶
func (s *VideoSender) SetParams(p SendParams)
SetParams applies RTCRtpSender.setParameters values.
func (*VideoSender) SetShare ¶
func (s *VideoSender) SetShare(f func(total int) int)
SetShare installs the allocation function of a simulcast layer: it receives the connection's total target bitrate and returns the bits per second this layer may use, or 0 to pause the layer (no frames are encoded or sent). nil restores the single-layer behaviour (the whole estimate).
func (*VideoSender) SetSource ¶
func (s *VideoSender) SetSource(src capture.VideoSource, c capture.VideoConstraints) error
SetSource attaches (or with nil detaches) the media source. The previous source is stopped.
func (*VideoSender) Source ¶
func (s *VideoSender) Source() capture.VideoSource
Source returns the active source (nil when none).
func (*VideoSender) SourceSize ¶
func (s *VideoSender) SourceSize() (int, int)
SourceSize is the size of the last captured frame (0, 0 before the first one).
func (*VideoSender) Stats ¶
func (s *VideoSender) Stats() VideoSendStats
Stats returns a snapshot of the counters.
func (*VideoSender) Target ¶
func (s *VideoSender) Target() int
Target returns the current target bitrate in bits per second.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package audioproc is the voice processing of a call: acoustic echo cancellation (a partitioned-block frequency domain adaptive filter with delay tracking and a residual echo suppressor), noise suppression (spectral gain with a minimum-statistics noise estimate) and automatic gain control.
|
Package audioproc is the voice processing of a call: acoustic echo cancellation (a partitioned-block frequency domain adaptive filter with delay tracking and a residual echo suppressor), noise suppression (spectral gain with a minimum-statistics noise estimate) and automatic gain control. |
|
Package testsrc provides deterministic synthetic capture sources for tests and for the engine's fake devices: a moving test pattern with a frame counter drawn into the picture, and a sine tone.
|
Package testsrc provides deterministic synthetic capture sources for tests and for the engine's fake devices: a moving test pattern with a frame counter drawn into the picture, and a sine tone. |