Documentation
¶
Overview ¶
Package ffi provides purego-based FFI bindings to the libwebrtc shim library. This file contains device capture FFI bindings.
Package ffi provides FFI bindings to the libwebrtc shim library. It supports both purego (default) and CGO backends via build tags.
Index ¶
- Constants
- Variables
- func AudioDecoderDecodeInto(decoder uintptr, src []byte, samplesDst []byte) (numSamples int, err error)
- func AudioDecoderDestroy(decoder uintptr)
- func AudioEncoderDestroy(encoder uintptr)
- func AudioEncoderEncodeInto(encoder uintptr, samples []byte, numSamples int, dst []byte) (int, error)
- func AudioEncoderSetBitrate(encoder uintptr, bitrate uint32) error
- func AudioTrackSourceCreate(pc uintptr, sampleRate, channels int) uintptr
- func AudioTrackSourceDestroy(source uintptr)
- func AudioTrackSourcePushFrame(source uintptr, samples []int16, numSamples int, timestampUs int64) error
- func BoolPtr(p *int32) uintptr
- func ByteArrayToString(b []byte) string
- func ByteSlicePtr(b []byte) uintptr
- func CString(s string) []byte
- func CStringToGo(b []byte) string
- func CheckCameraPermission() bool
- func CheckMicrophonePermission() bool
- func CheckVersion() error
- func Close() error
- func CopyBytesFromC(ptr uintptr, size int) []byte
- func CopyInt16FromC(ptr uintptr, length int) []int16
- func CopyStructFromC[T any](ptr uintptr) (T, bool)
- func CreateAudioDecoder(sampleRate, channels int) (uintptr, error)
- func CreateAudioEncoder(config *AudioEncoderConfig) (uintptr, error)
- func CreateDepacketizer(codec CodecType) uintptr
- func CreatePacketizer(config *PacketizerConfig) uintptr
- func CreatePeerConnection(config *PeerConnectionConfig) (uintptr, error)
- func CreateVideoDecoder(codec CodecType) (uintptr, error)
- func CreateVideoEncoder(codec CodecType, config *VideoEncoderConfig) (uintptr, error)
- func DataChannelClose(dc uintptr)
- func DataChannelDestroy(dc uintptr)
- func DataChannelLabel(dc uintptr) string
- func DataChannelReadyState(dc uintptr) int
- func DataChannelSend(dc uintptr, data []byte, isBinary bool) error
- func DataChannelSetOnClose(dc uintptr, cb OnDataChannelStateCallback)
- func DataChannelSetOnMessage(dc uintptr, cb OnDataChannelMessageCallback)
- func DataChannelSetOnOpen(dc uintptr, cb OnDataChannelStateCallback)
- func DepacketizerDestroy(depacketizer uintptr)
- func DepacketizerPopInto(depacketizer uintptr, dst []byte) (size int, timestamp uint32, isKeyframe bool, err error)
- func DepacketizerPush(depacketizer uintptr, packet []byte) error
- func GetAudioSinkCallbackPtr() uintptr
- func GetVideoSinkCallbackPtr() uintptr
- func GoBytes(ptr uintptr, size int) []byte
- func GoInt16Slice(ptr uintptr, numSamples int) []int16
- func GoString(ptr unsafe.Pointer) string
- func GoStringFromC(ptr uintptr) string
- func Int16SlicePtr(s []int16) uintptr
- func Int32Ptr(p *int32) uintptr
- func Int32SlicePtr(s []int32) uintptr
- func IntPtr(p *int) uintptr
- func IsCodecSupported(mimeType string) bool
- func IsLoaded() bool
- func LibWebRTCVersion() string
- func LoadLibrary() error
- func MustLoadLibrary()
- func PacketizerDestroy(packetizer uintptr)
- func PacketizerPacketizeInto(packetizer uintptr, data []byte, timestamp uint32, isKeyframe bool, dst []byte, ...) (int, error)
- func PacketizerSequenceNumber(packetizer uintptr) uint16
- func PeerConnectionAddAudioTrackFromSource(pc, source uintptr, trackID, streamID string) uintptr
- func PeerConnectionAddICECandidate(pc uintptr, candidate, sdpMid string, sdpMLineIndex int) error
- func PeerConnectionAddTrack(pc uintptr, codec CodecType, trackID, streamID string) uintptr
- func PeerConnectionAddTransceiver(pc uintptr, kind MediaKind, direction TransceiverDirection, ...) uintptr
- func PeerConnectionAddVideoTrackFromSource(pc, source uintptr, trackID, streamID string) uintptr
- func PeerConnectionClose(pc uintptr)
- func PeerConnectionConnectionState(pc uintptr) int
- func PeerConnectionCreateAnswer(pc uintptr, sdpBuf []byte, options *webrtc.AnswerOptions) (int, error)
- func PeerConnectionCreateDataChannel(pc uintptr, label string, ordered bool, maxPacketLifeTime int, ...) uintptr
- func PeerConnectionCreateOffer(pc uintptr, sdpBuf []byte, options *webrtc.OfferOptions) (int, error)
- func PeerConnectionDestroy(pc uintptr)
- func PeerConnectionGetReceivers(pc uintptr, maxReceivers int) ([]uintptr, error)
- func PeerConnectionGetSenders(pc uintptr, maxSenders int) ([]uintptr, error)
- func PeerConnectionGetStatsJSON(pc uintptr) ([]byte, error)
- func PeerConnectionGetTransceivers(pc uintptr, maxTransceivers int) ([]uintptr, error)
- func PeerConnectionICEConnectionState(pc uintptr) int
- func PeerConnectionICEGatheringState(pc uintptr) int
- func PeerConnectionRemoveTrack(pc uintptr, sender uintptr) error
- func PeerConnectionRestartICE(pc uintptr) error
- func PeerConnectionSetLocalDescription(pc uintptr, sdpType int, sdp string) error
- func PeerConnectionSetOnBandwidthEstimate(pc uintptr, cb BandwidthEstimateCallback) error
- func PeerConnectionSetOnConnectionStateChange(pc uintptr, cb ConnectionStateCallback)
- func PeerConnectionSetOnDataChannel(pc uintptr, cb OnDataChannelCallback)
- func PeerConnectionSetOnICECandidate(pc uintptr, cb OnICECandidateCallback)
- func PeerConnectionSetOnICEConnectionStateChange(pc uintptr, cb ICEConnectionStateCallback)
- func PeerConnectionSetOnICEGatheringStateChange(pc uintptr, cb ICEGatheringStateCallback)
- func PeerConnectionSetOnNegotiationNeeded(pc uintptr, cb NegotiationNeededCallback)
- func PeerConnectionSetOnSignalingStateChange(pc uintptr, cb SignalingStateCallback)
- func PeerConnectionSetOnTrack(pc uintptr, cb OnTrackCallback)
- func PeerConnectionSetRemoteDescription(pc uintptr, sdpType int, sdp string) error
- func PeerConnectionSignalingState(pc uintptr) int
- func PtrAt(base uintptr, offset uintptr) uintptr
- func RTPReceiverGetTrack(receiver uintptr) uintptr
- func RTPReceiverSetJitterBufferMinDelay(receiver uintptr, minDelayMs int) error
- func RTPSenderDestroy(sender uintptr)
- func RTPSenderGetActiveLayers(sender uintptr) (spatial, temporal int, err error)
- func RTPSenderGetScalabilityMode(sender uintptr) (string, error)
- func RTPSenderGetTrack(sender uintptr) uintptr
- func RTPSenderReplaceTrack(sender uintptr, track uintptr) error
- func RTPSenderSetBitrate(sender uintptr, bitrate uint32) error
- func RTPSenderSetLayerActive(sender uintptr, rid string, active bool) error
- func RTPSenderSetLayerBitrate(sender uintptr, rid string, maxBitrate uint32) error
- func RTPSenderSetOnRTCPFeedback(sender uintptr, cb RTCPFeedbackCallback) error
- func RTPSenderSetParameters(sender uintptr, params *RTPSendParameters) error
- func RTPSenderSetPreferredCodec(sender uintptr, mimeType string, payloadType int) error
- func RTPSenderSetScalabilityMode(sender uintptr, mode string) error
- func ReadFloat64FromC(ptr uintptr) float64
- func ReadInt32FromC(ptr uintptr) int32
- func ReadUint32FromC(ptr uintptr) uint32
- func ReadUintptrFromC(ptr uintptr) uintptr
- func RegisterAudioCallback(trackID uintptr, cb AudioFrameCallback)
- func RegisterVideoCallback(trackID uintptr, cb VideoFrameCallback)
- func RequestCameraPermission() bool
- func RequestMicrophonePermission() bool
- func ResetForTesting()
- func ShimError(code int32) error
- func ShimVersion() string
- func TrackID(track uintptr) string
- func TrackKind(track uintptr) string
- func TrackRemoveAudioSink(track uintptr)
- func TrackRemoveVideoSink(track uintptr)
- func TrackSetAudioSink(track uintptr, callback uintptr, ctx uintptr) error
- func TrackSetVideoSink(track uintptr, callback uintptr, ctx uintptr) error
- func TransceiverGetReceiver(transceiver uintptr) uintptr
- func TransceiverGetSender(transceiver uintptr) uintptr
- func TransceiverMid(transceiver uintptr) string
- func TransceiverSetCodecPreferences(transceiver uintptr, codecs []CodecCapability) error
- func TransceiverSetDirection(transceiver uintptr, direction TransceiverDirection) error
- func TransceiverStop(transceiver uintptr) error
- func Uint32Ptr(p *uint32) uintptr
- func UintptrFromSlice[T any](s []T) uintptr
- func UintptrPtr(p *uintptr) uintptr
- func UintptrSlicePtr(s []uintptr) uintptr
- func UnregisterAudioCallback(trackID uintptr)
- func UnregisterBandwidthEstimateCallback(pc uintptr)
- func UnregisterConnectionStateCallback(pc uintptr)
- func UnregisterDataChannelCallbacks(dc uintptr)
- func UnregisterICEConnectionStateCallback(pc uintptr)
- func UnregisterICEGatheringStateCallback(pc uintptr)
- func UnregisterNegotiationNeededCallback(pc uintptr)
- func UnregisterOnDataChannelCallback(pc uintptr)
- func UnregisterOnICECandidateCallback(pc uintptr)
- func UnregisterOnTrackCallback(pc uintptr)
- func UnregisterRTCPFeedbackCallback(sender uintptr)
- func UnregisterSignalingStateCallback(pc uintptr)
- func UnregisterVideoCallback(trackID uintptr)
- func UnsafePointerFromC(ptr uintptr) unsafe.Pointer
- func VideoDecoderDecodeInto(decoder uintptr, src []byte, timestamp uint32, isKeyframe bool, ...) (width, height, yStride, uStride, vStride int, err error)
- func VideoDecoderDestroy(decoder uintptr)
- func VideoEncoderDestroy(encoder uintptr)
- func VideoEncoderEncodeInto(encoder uintptr, yPlane, uPlane, vPlane []byte, yStride, uStride, vStride int, ...) (n int, isKeyframe bool, err error)
- func VideoEncoderGetLastDependencyDescriptor(encoder uintptr, dst []byte) (int, error)
- func VideoEncoderRequestKeyframe(encoder uintptr) error
- func VideoEncoderSetBitrate(encoder uintptr, bitrate uint32) error
- func VideoEncoderSetFramerate(encoder uintptr, framerate float32) error
- func VideoTrackSourceCreate(pc uintptr, width, height int) uintptr
- func VideoTrackSourceDestroy(source uintptr)
- func VideoTrackSourcePushFrame(source uintptr, yPlane, uPlane, vPlane []byte, yStride, uStride, vStride int, ...) error
- type AudioCapture
- type AudioCaptureCallback
- type AudioEncoderConfig
- type AudioFrameCallback
- type BandwidthEstimate
- type BandwidthEstimateCallback
- type CapturedAudioFrame
- type CapturedVideoFrame
- type CodecCapability
- type CodecType
- type ConnectionStateCallback
- type DependencyReport
- type DeviceInfo
- type DeviceKind
- type DiagnosticStatus
- type ICEConnectionStateCallback
- type ICEGatheringStateCallback
- type ICEServerConfig
- type MediaKind
- type NegotiationNeededCallback
- type OnDataChannelCallback
- type OnDataChannelMessageCallback
- type OnDataChannelStateCallback
- type OnICECandidateCallback
- type OnTrackCallback
- type PacketizerConfig
- type PeerConnectionConfig
- type RTCPFeedbackCallback
- type RTCStats
- type RTPEncodingParameters
- type RTPHeaderExtensionParameter
- type RTPSendParameters
- type RuntimeDiagnosticsReport
- type ScreenCapture
- type ScreenInfo
- type ShimErrorBuffer
- type ShimErrorWithMessage
- type SignalingStateCallback
- type TransceiverDirection
- type VideoCapture
- type VideoCaptureCallback
- type VideoEncoderConfig
- type VideoFrameCallback
Constants ¶
const ( RTLD_NOW = C.RTLD_NOW RTLD_GLOBAL = C.RTLD_GLOBAL )
RTLD flags for dlopen - using C constants from dlfcn.h
const ( ShimOK int32 = 0 ShimErrInvalidParam int32 = -1 ShimErrInitFailed int32 = -2 ShimErrEncodeFailed int32 = -3 ShimErrDecodeFailed int32 = -4 ShimErrOutOfMemory int32 = -5 ShimErrNotSupported int32 = -6 ShimErrNeedMoreData int32 = -7 ShimErrBufferTooSmall int32 = -8 ShimErrNotFound int32 = -9 ShimErrRenegotiationNeeded int32 = -10 )
Error codes from shim (int32 to match C int)
const ( QualityLimitationNone = 0 QualityLimitationCPU = 1 QualityLimitationBandwidth = 2 QualityLimitationOther = 3 )
Quality limitation reason constants
const ExpectedLibWebRTCVersion = "M141"
ExpectedLibWebRTCVersion is the libwebrtc version this Go code expects. Must match kLibWebRTCVersion in shim/shim_common.cc.
const ExpectedShimVersion = "0.5.1"
ExpectedShimVersion is the shim API version this Go code expects. Must match kShimVersion in shim/shim_common.cc.
const MaxErrorMsgLen = 512
MaxErrorMsgLen matches SHIM_MAX_ERROR_MSG_LEN in shim.h
Variables ¶
var ( // ErrLibraryNotLoaded is returned when the shim library hasn't been loaded. ErrLibraryNotLoaded = errors.New("libwebrtc_shim library not loaded") // ErrLibraryNotFound is returned when the shim library cannot be found. ErrLibraryNotFound = errors.New("libwebrtc_shim library not found") // FFI error sentinels - these match shim error codes and support errors.Is(). ErrInvalidParam = errors.New("invalid parameter") ErrInitFailed = errors.New("initialization failed") ErrEncodeFailed = errors.New("encode failed") ErrDecodeFailed = errors.New("decode failed") ErrOutOfMemory = errors.New("out of memory") ErrNotSupported = errors.New("not supported") ErrNeedMoreData = errors.New("need more data") ErrBufferTooSmall = errors.New("buffer too small") ErrNotFound = errors.New("not found") ErrRenegotiationNeeded = errors.New("renegotiation needed") )
var ErrCaptureAlreadyStarted = errors.New("capture already started")
ErrCaptureAlreadyStarted is returned when trying to start a capture that's already running.
var ErrCaptureNotStarted = errors.New("capture not started")
ErrCaptureNotStarted is returned when trying to stop a capture that wasn't started.
var ErrVersionMismatch = errors.New("shim version mismatch")
ErrVersionMismatch is returned when the shim version doesn't match.
Functions ¶
func AudioDecoderDecodeInto ¶
func AudioDecoderDecodeInto(decoder uintptr, src []byte, samplesDst []byte) (numSamples int, err error)
AudioDecoderDecodeInto decodes encoded audio into a pre-allocated buffer. samplesDst must be pre-allocated (as bytes, will hold int16 samples). Returns the number of samples per channel decoded.
func AudioDecoderDestroy ¶
func AudioDecoderDestroy(decoder uintptr)
AudioDecoderDestroy destroys an audio decoder.
func AudioEncoderDestroy ¶
func AudioEncoderDestroy(encoder uintptr)
AudioEncoderDestroy destroys an audio encoder.
func AudioEncoderEncodeInto ¶
func AudioEncoderEncodeInto(encoder uintptr, samples []byte, numSamples int, dst []byte) (int, error)
AudioEncoderEncodeInto encodes audio samples into a pre-allocated buffer. Returns the number of bytes written.
func AudioEncoderSetBitrate ¶
AudioEncoderSetBitrate updates the encoder bitrate.
func AudioTrackSourceCreate ¶
AudioTrackSourceCreate creates an audio track source for frame injection.
func AudioTrackSourceDestroy ¶
func AudioTrackSourceDestroy(source uintptr)
AudioTrackSourceDestroy destroys an audio track source.
func AudioTrackSourcePushFrame ¶
func AudioTrackSourcePushFrame(source uintptr, samples []int16, numSamples int, timestampUs int64) error
AudioTrackSourcePushFrame pushes interleaved audio samples to the audio track source. numSamples is the number of samples per channel.
func ByteArrayToString ¶
ByteArrayToString converts a fixed-size byte array to a Go string, stopping at the first null byte.
func ByteSlicePtr ¶
ByteSlicePtr returns a uintptr to the first element of a byte slice. Returns 0 if the slice is empty.
func CString ¶
CString allocates a null-terminated C string from a Go string. The caller is responsible for keeping the returned byte slice alive for as long as the C code needs it.
func CStringToGo ¶
CStringToGo converts a null-terminated C string to a Go string.
func CheckCameraPermission ¶
func CheckCameraPermission() bool
CheckCameraPermission checks if camera access is authorized. Returns true if authorized, false otherwise.
func CheckMicrophonePermission ¶
func CheckMicrophonePermission() bool
CheckMicrophonePermission checks if microphone access is authorized. Returns true if authorized, false otherwise.
func CheckVersion ¶
func CheckVersion() error
CheckVersion verifies the shim version matches what this Go code expects. Returns nil if versions match, ErrVersionMismatch otherwise.
func CopyBytesFromC ¶
CopyBytesFromC copies bytes from C memory to a new Go slice. Returns nil if ptr is 0 or size <= 0.
func CopyInt16FromC ¶
CopyInt16FromC copies int16 values from C memory to a new Go slice. Returns nil if ptr is 0 or length <= 0.
func CopyStructFromC ¶
CopyStructFromC copies a value of type T from C memory.
func CreateAudioDecoder ¶
CreateAudioDecoder creates an audio decoder.
func CreateAudioEncoder ¶
func CreateAudioEncoder(config *AudioEncoderConfig) (uintptr, error)
CreateAudioEncoder creates an audio encoder.
func CreateDepacketizer ¶
CreateDepacketizer creates an RTP depacketizer.
func CreatePacketizer ¶
func CreatePacketizer(config *PacketizerConfig) uintptr
CreatePacketizer creates an RTP packetizer.
func CreatePeerConnection ¶
func CreatePeerConnection(config *PeerConnectionConfig) (uintptr, error)
CreatePeerConnection creates a new PeerConnection.
func CreateVideoDecoder ¶
CreateVideoDecoder creates a video decoder for the specified codec.
func CreateVideoEncoder ¶
func CreateVideoEncoder(codec CodecType, config *VideoEncoderConfig) (uintptr, error)
CreateVideoEncoder creates a video encoder for the specified codec.
func DataChannelDestroy ¶
func DataChannelDestroy(dc uintptr)
DataChannelDestroy destroys a data channel.
func DataChannelLabel ¶
DataChannelLabel returns the label of a data channel.
func DataChannelReadyState ¶
DataChannelReadyState returns the ready state of a data channel.
func DataChannelSend ¶
DataChannelSend sends data on a data channel.
func DataChannelSetOnClose ¶
func DataChannelSetOnClose(dc uintptr, cb OnDataChannelStateCallback)
DataChannelSetOnClose sets the close callback for a data channel.
func DataChannelSetOnMessage ¶
func DataChannelSetOnMessage(dc uintptr, cb OnDataChannelMessageCallback)
DataChannelSetOnMessage sets the message callback for a data channel.
func DataChannelSetOnOpen ¶
func DataChannelSetOnOpen(dc uintptr, cb OnDataChannelStateCallback)
DataChannelSetOnOpen sets the open callback for a data channel.
func DepacketizerDestroy ¶
func DepacketizerDestroy(depacketizer uintptr)
DepacketizerDestroy destroys a depacketizer.
func DepacketizerPopInto ¶
func DepacketizerPopInto(depacketizer uintptr, dst []byte) (size int, timestamp uint32, isKeyframe bool, err error)
DepacketizerPopInto pops a complete frame into a pre-allocated buffer.
func DepacketizerPush ¶
DepacketizerPush pushes an RTP packet for reassembly.
func GetAudioSinkCallbackPtr ¶
func GetAudioSinkCallbackPtr() uintptr
GetAudioSinkCallbackPtr returns the purego callback pointer for audio sinks.
func GetVideoSinkCallbackPtr ¶
func GetVideoSinkCallbackPtr() uintptr
GetVideoSinkCallbackPtr returns the purego callback pointer for video sinks.
func GoInt16Slice ¶
GoInt16Slice copies C int16 array to a Go slice and frees the C memory.
func GoStringFromC ¶
GoStringFromC converts a C string pointer (as uintptr) to a Go string. This is a convenience function that combines UnsafePointerFromC and GoString.
func Int16SlicePtr ¶
Int16SlicePtr returns a uintptr to the first element of an int16 slice.
func Int32SlicePtr ¶
Int32SlicePtr returns a uintptr to the first element of an int32 slice.
func IsCodecSupported ¶
IsCodecSupported checks if a specific codec is supported.
func IsLoaded ¶
func IsLoaded() bool
IsLoaded returns true if the shim library is loaded. Thread-safe due to atomic.Bool.
func LibWebRTCVersion ¶
func LibWebRTCVersion() string
LibWebRTCVersion returns the libwebrtc version the shim was built with. Returns empty string if library is not loaded.
func LoadLibrary ¶
func LoadLibrary() error
LoadLibrary loads the libwebrtc_shim shared library. It resolves the library in the following order: 1. Exact path specified by LIBWEBRTC_SHIM_PATH (authoritative if set) 2. ./lib/{os}_{arch}/ (module-relative) 3. Auto-download from GitHub Releases (unless disabled) 4. System library paths
func MustLoadLibrary ¶
func MustLoadLibrary()
MustLoadLibrary loads the library and panics on failure.
func PacketizerDestroy ¶
func PacketizerDestroy(packetizer uintptr)
PacketizerDestroy destroys a packetizer.
func PacketizerPacketizeInto ¶
func PacketizerPacketizeInto( packetizer uintptr, data []byte, timestamp uint32, isKeyframe bool, dst []byte, offsets []int32, sizes []int32, maxPackets int, ) (int, error)
PacketizerPacketizeInto packetizes encoded data into RTP packets. Writes packets into dst buffer, returns packet count.
func PacketizerSequenceNumber ¶
PacketizerSequenceNumber returns the current sequence number.
func PeerConnectionAddAudioTrackFromSource ¶
PeerConnectionAddAudioTrackFromSource adds an audio track using a source.
func PeerConnectionAddICECandidate ¶
PeerConnectionAddICECandidate adds an ICE candidate.
func PeerConnectionAddTrack ¶
PeerConnectionAddTrack adds a track to the peer connection.
func PeerConnectionAddTransceiver ¶
func PeerConnectionAddTransceiver(pc uintptr, kind MediaKind, direction TransceiverDirection, paramsConfig *RTPSendParameters) uintptr
PeerConnectionAddTransceiver adds a transceiver with the specified kind and direction.
func PeerConnectionAddVideoTrackFromSource ¶
PeerConnectionAddVideoTrackFromSource adds a video track using a source.
func PeerConnectionClose ¶
func PeerConnectionClose(pc uintptr)
PeerConnectionClose closes the peer connection.
func PeerConnectionConnectionState ¶
PeerConnectionConnectionState returns the connection state.
func PeerConnectionCreateAnswer ¶
func PeerConnectionCreateAnswer(pc uintptr, sdpBuf []byte, options *webrtc.AnswerOptions) (int, error)
PeerConnectionCreateAnswer creates an SDP answer.
func PeerConnectionCreateDataChannel ¶
func PeerConnectionCreateDataChannel( pc uintptr, label string, ordered bool, maxPacketLifeTime int, maxRetransmits int, protocol string, negotiated bool, id int, ) uintptr
PeerConnectionCreateDataChannel creates a data channel.
func PeerConnectionCreateOffer ¶
func PeerConnectionCreateOffer(pc uintptr, sdpBuf []byte, options *webrtc.OfferOptions) (int, error)
PeerConnectionCreateOffer creates an SDP offer. Returns the SDP string written to the provided buffer.
func PeerConnectionDestroy ¶
func PeerConnectionDestroy(pc uintptr)
PeerConnectionDestroy destroys a PeerConnection.
func PeerConnectionGetReceivers ¶
PeerConnectionGetReceivers gets all receivers associated with a PeerConnection.
func PeerConnectionGetSenders ¶
PeerConnectionGetSenders gets all senders associated with a PeerConnection.
func PeerConnectionGetStatsJSON ¶
PeerConnectionGetStatsJSON gets a structured stats report serialized as JSON.
func PeerConnectionGetTransceivers ¶
PeerConnectionGetTransceivers gets all transceivers associated with a PeerConnection.
func PeerConnectionICEConnectionState ¶
PeerConnectionICEConnectionState returns the ICE connection state.
func PeerConnectionICEGatheringState ¶
PeerConnectionICEGatheringState returns the ICE gathering state.
func PeerConnectionRemoveTrack ¶
PeerConnectionRemoveTrack removes a track from the peer connection.
func PeerConnectionRestartICE ¶
PeerConnectionRestartICE triggers an ICE restart on the next offer.
func PeerConnectionSetLocalDescription ¶
PeerConnectionSetLocalDescription sets the local SDP description.
func PeerConnectionSetOnBandwidthEstimate ¶
func PeerConnectionSetOnBandwidthEstimate(pc uintptr, cb BandwidthEstimateCallback) error
PeerConnectionSetOnBandwidthEstimate sets the bandwidth estimate callback. The current shim does not implement this surface and returns ErrNotSupported.
func PeerConnectionSetOnConnectionStateChange ¶
func PeerConnectionSetOnConnectionStateChange(pc uintptr, cb ConnectionStateCallback)
PeerConnectionSetOnConnectionStateChange sets the connection state change callback.
func PeerConnectionSetOnDataChannel ¶
func PeerConnectionSetOnDataChannel(pc uintptr, cb OnDataChannelCallback)
PeerConnectionSetOnDataChannel sets the on data channel callback.
func PeerConnectionSetOnICECandidate ¶
func PeerConnectionSetOnICECandidate(pc uintptr, cb OnICECandidateCallback)
PeerConnectionSetOnICECandidate sets the on ICE candidate callback.
func PeerConnectionSetOnICEConnectionStateChange ¶
func PeerConnectionSetOnICEConnectionStateChange(pc uintptr, cb ICEConnectionStateCallback)
PeerConnectionSetOnICEConnectionStateChange sets the ICE connection state change callback.
func PeerConnectionSetOnICEGatheringStateChange ¶
func PeerConnectionSetOnICEGatheringStateChange(pc uintptr, cb ICEGatheringStateCallback)
PeerConnectionSetOnICEGatheringStateChange sets the ICE gathering state change callback.
func PeerConnectionSetOnNegotiationNeeded ¶
func PeerConnectionSetOnNegotiationNeeded(pc uintptr, cb NegotiationNeededCallback)
PeerConnectionSetOnNegotiationNeeded sets the negotiation needed callback.
func PeerConnectionSetOnSignalingStateChange ¶
func PeerConnectionSetOnSignalingStateChange(pc uintptr, cb SignalingStateCallback)
PeerConnectionSetOnSignalingStateChange sets the signaling state change callback.
func PeerConnectionSetOnTrack ¶
func PeerConnectionSetOnTrack(pc uintptr, cb OnTrackCallback)
PeerConnectionSetOnTrack sets the on track callback.
func PeerConnectionSetRemoteDescription ¶
PeerConnectionSetRemoteDescription sets the remote SDP description.
func PeerConnectionSignalingState ¶
PeerConnectionSignalingState returns the signaling state.
func RTPReceiverGetTrack ¶
RTPReceiverGetTrack gets the track associated with a receiver.
func RTPReceiverSetJitterBufferMinDelay ¶
RTPReceiverSetJitterBufferMinDelay sets the minimum jitter buffer delay. This sets a floor for libwebrtc's adaptive jitter buffer. The actual delay may be higher based on network conditions, but won't go below this value. Pass 0 to let libwebrtc's adaptive algorithm decide without a minimum floor.
func RTPSenderDestroy ¶
func RTPSenderDestroy(sender uintptr)
RTPSenderDestroy destroys an RTP sender.
func RTPSenderGetActiveLayers ¶
RTPSenderGetActiveLayers gets the number of active layers.
func RTPSenderGetScalabilityMode ¶
RTPSenderGetScalabilityMode gets the current scalability mode for a sender.
func RTPSenderGetTrack ¶
RTPSenderGetTrack gets the track associated with a sender.
func RTPSenderReplaceTrack ¶
RTPSenderReplaceTrack replaces the track on an RTP sender.
func RTPSenderSetBitrate ¶
RTPSenderSetBitrate sets the bitrate for an RTP sender.
func RTPSenderSetLayerActive ¶
RTPSenderSetLayerActive enables or disables a simulcast layer.
func RTPSenderSetLayerBitrate ¶
RTPSenderSetLayerBitrate sets the maximum bitrate for a layer.
func RTPSenderSetOnRTCPFeedback ¶
func RTPSenderSetOnRTCPFeedback(sender uintptr, cb RTCPFeedbackCallback) error
RTPSenderSetOnRTCPFeedback sets the RTCP feedback callback. The current shim does not implement this surface and returns ErrNotSupported.
func RTPSenderSetParameters ¶
func RTPSenderSetParameters(sender uintptr, params *RTPSendParameters) error
RTPSenderSetParameters sets the RTP send parameters.
func RTPSenderSetPreferredCodec ¶
RTPSenderSetPreferredCodec sets the preferred codec for a sender. Returns ErrNotFound if the codec was not negotiated. Returns ErrRenegotiationNeeded if SetParameters rejected the change.
func RTPSenderSetScalabilityMode ¶
RTPSenderSetScalabilityMode sets the scalability mode for a sender.
func ReadFloat64FromC ¶
ReadFloat64FromC reads a float64 value from C memory at the given address.
func ReadInt32FromC ¶
ReadInt32FromC reads an int32 value from C memory at the given address.
func ReadUint32FromC ¶
ReadUint32FromC reads a uint32 value from C memory at the given address.
func ReadUintptrFromC ¶
ReadUintptrFromC reads a uintptr value from C memory at the given address.
func RegisterAudioCallback ¶
func RegisterAudioCallback(trackID uintptr, cb AudioFrameCallback)
RegisterAudioCallback registers an audio frame callback for a track. The trackID should be the track handle pointer value.
func RegisterVideoCallback ¶
func RegisterVideoCallback(trackID uintptr, cb VideoFrameCallback)
RegisterVideoCallback registers a video frame callback for a track. The trackID should be the track handle pointer value.
func RequestCameraPermission ¶
func RequestCameraPermission() bool
RequestCameraPermission requests camera access permission. On macOS, this shows the system permission dialog if needed. Returns true if authorized, false if denied. Note: This is a blocking call that may show a system dialog.
func RequestMicrophonePermission ¶
func RequestMicrophonePermission() bool
RequestMicrophonePermission requests microphone access permission. On macOS, this shows the system permission dialog if needed. Returns true if authorized, false if denied. Note: This is a blocking call that may show a system dialog.
func ResetForTesting ¶
func ResetForTesting()
ResetForTesting clears all callback registries. This should only be used in tests to ensure test isolation.
func ShimError ¶
ShimError converts a shim error code to a Go error. Returns sentinel errors that support errors.Is() comparisons.
func ShimVersion ¶
func ShimVersion() string
ShimVersion returns the shim library version. Returns empty string if library is not loaded.
func TrackRemoveAudioSink ¶
func TrackRemoveAudioSink(track uintptr)
TrackRemoveAudioSink removes an audio sink from a track.
func TrackRemoveVideoSink ¶
func TrackRemoveVideoSink(track uintptr)
TrackRemoveVideoSink removes a video sink from a track.
func TrackSetAudioSink ¶
TrackSetAudioSink sets an audio frame callback on a remote track.
func TrackSetVideoSink ¶
TrackSetVideoSink sets a video frame callback on a remote track.
func TransceiverGetReceiver ¶
TransceiverGetReceiver gets the receiver associated with a transceiver.
func TransceiverGetSender ¶
TransceiverGetSender gets the sender associated with a transceiver.
func TransceiverMid ¶
TransceiverMid gets the mid of a transceiver.
func TransceiverSetCodecPreferences ¶
func TransceiverSetCodecPreferences(transceiver uintptr, codecs []CodecCapability) error
TransceiverSetCodecPreferences sets which codecs are negotiated for this transceiver. Must be called before creating offer/answer.
func TransceiverSetDirection ¶
func TransceiverSetDirection(transceiver uintptr, direction TransceiverDirection) error
TransceiverSetDirection sets the direction of a transceiver.
func TransceiverStop ¶
TransceiverStop stops the transceiver.
func UintptrFromSlice ¶
UintptrFromSlice returns a uintptr to the first element of any slice.
func UintptrPtr ¶
UintptrPtr returns a uintptr to a uintptr variable.
func UintptrSlicePtr ¶
UintptrSlicePtr returns a uintptr to the first element of a uintptr slice.
func UnregisterAudioCallback ¶
func UnregisterAudioCallback(trackID uintptr)
UnregisterAudioCallback removes an audio frame callback for a track.
func UnregisterBandwidthEstimateCallback ¶
func UnregisterBandwidthEstimateCallback(pc uintptr)
UnregisterBandwidthEstimateCallback removes the bandwidth estimate callback for a PC.
func UnregisterConnectionStateCallback ¶
func UnregisterConnectionStateCallback(pc uintptr)
UnregisterConnectionStateCallback removes the connection state callback for a PC.
func UnregisterDataChannelCallbacks ¶
func UnregisterDataChannelCallbacks(dc uintptr)
UnregisterDataChannelCallbacks removes all callbacks for a data channel.
func UnregisterICEConnectionStateCallback ¶
func UnregisterICEConnectionStateCallback(pc uintptr)
UnregisterICEConnectionStateCallback removes the ICE connection state callback for a PC.
func UnregisterICEGatheringStateCallback ¶
func UnregisterICEGatheringStateCallback(pc uintptr)
UnregisterICEGatheringStateCallback removes the ICE gathering state callback for a PC.
func UnregisterNegotiationNeededCallback ¶
func UnregisterNegotiationNeededCallback(pc uintptr)
UnregisterNegotiationNeededCallback removes the negotiation needed callback for a PC.
func UnregisterOnDataChannelCallback ¶
func UnregisterOnDataChannelCallback(pc uintptr)
UnregisterOnDataChannelCallback removes the on data channel callback for a PC.
func UnregisterOnICECandidateCallback ¶
func UnregisterOnICECandidateCallback(pc uintptr)
UnregisterOnICECandidateCallback removes the on ICE candidate callback for a PC.
func UnregisterOnTrackCallback ¶
func UnregisterOnTrackCallback(pc uintptr)
UnregisterOnTrackCallback removes the on track callback for a PC.
func UnregisterRTCPFeedbackCallback ¶
func UnregisterRTCPFeedbackCallback(sender uintptr)
UnregisterRTCPFeedbackCallback removes the RTCP feedback callback for a sender.
func UnregisterSignalingStateCallback ¶
func UnregisterSignalingStateCallback(pc uintptr)
UnregisterSignalingStateCallback removes the signaling state callback for a PC.
func UnregisterVideoCallback ¶
func UnregisterVideoCallback(trackID uintptr)
UnregisterVideoCallback removes a video frame callback for a track.
func UnsafePointerFromC ¶
UnsafePointerFromC converts a uintptr from C to unsafe.Pointer. This is used for C string pointers returned by FFI functions.
func VideoDecoderDecodeInto ¶
func VideoDecoderDecodeInto( decoder uintptr, src []byte, timestamp uint32, isKeyframe bool, yDst, uDst, vDst []byte, ) (width, height, yStride, uStride, vStride int, err error)
VideoDecoderDecodeInto decodes encoded video data into pre-allocated buffers. yDst, uDst, vDst must be pre-allocated with sufficient space. Returns the actual dimensions decoded.
func VideoDecoderDestroy ¶
func VideoDecoderDestroy(decoder uintptr)
VideoDecoderDestroy destroys a video decoder.
func VideoEncoderDestroy ¶
func VideoEncoderDestroy(encoder uintptr)
VideoEncoderDestroy destroys a video encoder.
func VideoEncoderEncodeInto ¶
func VideoEncoderEncodeInto( encoder uintptr, yPlane, uPlane, vPlane []byte, yStride, uStride, vStride int, timestamp uint32, forceKeyframe bool, dst []byte, ) (n int, isKeyframe bool, err error)
VideoEncoderEncodeInto encodes a video frame into a pre-allocated buffer. Returns the number of bytes written, isKeyframe flag, and error. This is the allocation-free version - data is written directly to dst.
func VideoEncoderGetLastDependencyDescriptor ¶
VideoEncoderGetLastDependencyDescriptor returns the serialized dependency descriptor payload for the most recent encoded frame, if available.
func VideoEncoderRequestKeyframe ¶
VideoEncoderRequestKeyframe requests the encoder to produce a keyframe.
func VideoEncoderSetBitrate ¶
VideoEncoderSetBitrate updates the encoder bitrate.
func VideoEncoderSetFramerate ¶
VideoEncoderSetFramerate updates the encoder framerate.
func VideoTrackSourceCreate ¶
VideoTrackSourceCreate creates a video track source for frame injection.
func VideoTrackSourceDestroy ¶
func VideoTrackSourceDestroy(source uintptr)
VideoTrackSourceDestroy destroys a video track source.
Types ¶
type AudioCapture ¶
type AudioCapture struct {
// contains filtered or unexported fields
}
AudioCapture wraps a native audio capture device.
func NewAudioCapture ¶
func NewAudioCapture(deviceID string, sampleRate, channels int) (*AudioCapture, error)
NewAudioCapture creates a new audio capture device. deviceID can be empty to use the default device.
func (*AudioCapture) Close ¶
func (c *AudioCapture) Close()
Close releases the audio capture device.
func (*AudioCapture) IsRunning ¶
func (c *AudioCapture) IsRunning() bool
IsRunning returns true if capture is active.
func (*AudioCapture) Start ¶
func (c *AudioCapture) Start(callback AudioCaptureCallback) error
Start begins audio capture with the given callback.
type AudioCaptureCallback ¶
type AudioCaptureCallback func(frame *CapturedAudioFrame)
AudioCaptureCallback is called for each captured audio frame.
type AudioEncoderConfig ¶
AudioEncoderConfig matches ShimAudioEncoderConfig in shim.h
func (*AudioEncoderConfig) Ptr ¶
func (c *AudioEncoderConfig) Ptr() uintptr
Ptr returns a pointer to the config as uintptr for FFI calls.
type AudioFrameCallback ¶
AudioFrameCallback is called when audio samples are received from a remote track.
type BandwidthEstimate ¶
type BandwidthEstimate struct {
TimestampUs int64
TargetBitrateBps int64
AvailableSendBps int64
AvailableRecvBps int64
PacingRateBps int64
CongestionWindow int32
LossRate float64
// contains filtered or unexported fields
}
BandwidthEstimate matches ShimBandwidthEstimate in shim.h.
func PeerConnectionGetBandwidthEstimate ¶
func PeerConnectionGetBandwidthEstimate(pc uintptr) (*BandwidthEstimate, error)
PeerConnectionGetBandwidthEstimate gets the current bandwidth estimate. The current shim does not implement this surface and returns ErrNotSupported.
func ReadBandwidthEstimateFromC ¶
func ReadBandwidthEstimateFromC(ptr uintptr) *BandwidthEstimate
ReadBandwidthEstimateFromC copies a BandwidthEstimate from C memory.
type BandwidthEstimateCallback ¶
type BandwidthEstimateCallback func(estimate *BandwidthEstimate)
BandwidthEstimateCallback is called when the bandwidth estimate changes.
type CapturedAudioFrame ¶
type CapturedAudioFrame struct {
Samples []int16
NumChannels int32
SampleRate int32
TimestampUs int64
}
CapturedAudioFrame represents an audio frame captured from a device. Samples are S16LE interleaved. NOTE: int32 fields match C ABI (int = 32-bit)
type CapturedVideoFrame ¶
type CapturedVideoFrame struct {
YPlane []byte
UPlane []byte
VPlane []byte
Width int32
Height int32
YStride int32
UStride int32
VStride int32
TimestampUs int64
}
CapturedVideoFrame represents a video frame captured from a device. The frame data is in I420 (YUV420P) format. NOTE: int32 fields match C ABI (int = 32-bit)
type CodecCapability ¶
type CodecCapability struct {
MimeType [64]byte
ClockRate int32
Channels int32
SDPFmtpLine [256]byte
PayloadType int32
}
CodecCapability matches ShimCodecCapability in shim.h.
func GetSupportedAudioCodecs ¶
func GetSupportedAudioCodecs() ([]CodecCapability, error)
GetSupportedAudioCodecs returns a list of supported audio codecs.
func GetSupportedVideoCodecs ¶
func GetSupportedVideoCodecs() ([]CodecCapability, error)
GetSupportedVideoCodecs returns a list of supported video codecs.
func RTPSenderGetNegotiatedCodecs ¶
func RTPSenderGetNegotiatedCodecs(sender uintptr) ([]CodecCapability, error)
RTPSenderGetNegotiatedCodecs returns the list of codecs negotiated for a sender.
func TransceiverGetCodecPreferences ¶
func TransceiverGetCodecPreferences(transceiver uintptr) ([]CodecCapability, error)
TransceiverGetCodecPreferences gets the codec preferences for this transceiver.
type CodecType ¶
type CodecType int32
CodecType matches ShimCodecType in shim.h (int32 to match C int)
type ConnectionStateCallback ¶
type ConnectionStateCallback func(state int)
ConnectionStateCallback is called when the connection state changes.
type DependencyReport ¶
type DependencyReport struct {
Name string
Path string
Source string
CacheDir string
Available bool
DownloadDisabled bool
ExpectedVersion string
ActualVersion string
ExpectedLibWebRTCVersion string
ActualLibWebRTCVersion string
VersionStatus DiagnosticStatus
ExpectedSHA256 string
ActualSHA256 string
ChecksumStatus DiagnosticStatus
BlockingIssues []string
Warnings []string
}
DependencyReport summarizes the runtime state for a dependency used by libgowebrtc.
type DeviceInfo ¶
type DeviceInfo struct {
DeviceID string
Label string
Kind DeviceKind
}
DeviceInfo represents information about a media device.
func EnumerateDevices ¶
func EnumerateDevices() ([]DeviceInfo, error)
EnumerateDevices returns a list of available media devices.
type DeviceKind ¶
type DeviceKind int
DeviceKind represents the type of media device.
const ( // DeviceKindVideoInput represents a camera/video input device. DeviceKindVideoInput DeviceKind = 0 // DeviceKindAudioInput represents a microphone/audio input device. DeviceKindAudioInput DeviceKind = 1 // DeviceKindAudioOutput represents a speaker/audio output device. DeviceKindAudioOutput DeviceKind = 2 )
func (DeviceKind) String ¶
func (k DeviceKind) String() string
String returns a string representation of the device kind.
type DiagnosticStatus ¶
type DiagnosticStatus string
DiagnosticStatus describes the outcome of a runtime diagnostic check.
const ( DiagnosticStatusUnknown DiagnosticStatus = "unknown" DiagnosticStatusOK DiagnosticStatus = "ok" DiagnosticStatusMissing DiagnosticStatus = "missing" DiagnosticStatusMismatch DiagnosticStatus = "mismatch" DiagnosticStatusUnverified DiagnosticStatus = "unverified" )
type ICEConnectionStateCallback ¶
type ICEConnectionStateCallback func(state int)
ICEConnectionStateCallback is called when the ICE connection state changes.
type ICEGatheringStateCallback ¶
type ICEGatheringStateCallback func(state int)
ICEGatheringStateCallback is called when the ICE gathering state changes.
type ICEServerConfig ¶
type ICEServerConfig struct {
URLs uintptr // Pointer to array of C strings
URLCount int32
Username *byte // C string
Credential *byte // C string
}
ICEServerConfig matches ShimICEServer in shim.h
func (*ICEServerConfig) Ptr ¶
func (c *ICEServerConfig) Ptr() uintptr
Ptr returns a pointer to the config as uintptr for FFI calls.
type NegotiationNeededCallback ¶
type NegotiationNeededCallback func()
NegotiationNeededCallback is called when negotiation is needed.
type OnDataChannelCallback ¶
type OnDataChannelCallback func(dc uintptr)
OnDataChannelCallback is called when a data channel is received.
type OnDataChannelMessageCallback ¶
DataChannel callback types
type OnDataChannelStateCallback ¶
type OnDataChannelStateCallback func()
type OnICECandidateCallback ¶
OnICECandidateCallback is called when an ICE candidate is generated.
type OnTrackCallback ¶
OnTrackCallback is called when a remote track is received.
type PacketizerConfig ¶
type PacketizerConfig struct {
Codec int32
SSRC uint32
PayloadType uint8
MTU uint16
ClockRate uint32
// contains filtered or unexported fields
}
PacketizerConfig matches ShimPacketizerConfig in shim.h C layout: codec(4) + ssrc(4) + pt(1) + pad(1) + mtu(2) + clockrate(4) = 16 bytes
func (*PacketizerConfig) Ptr ¶
func (c *PacketizerConfig) Ptr() uintptr
Ptr returns a pointer to the config as uintptr for FFI calls.
type PeerConnectionConfig ¶
type PeerConnectionConfig struct {
ICEServers uintptr // Pointer to array of ICEServerConfig
ICEServerCount int32
ICECandidatePoolSize int32
ICETransportPolicy *byte // C string
BundlePolicy *byte // C string
RTCPMuxPolicy *byte // C string
SDPSemantics *byte // C string
}
PeerConnectionConfig matches ShimPeerConnectionConfig in shim.h
func (*PeerConnectionConfig) Ptr ¶
func (c *PeerConnectionConfig) Ptr() uintptr
Ptr returns a pointer to the config as uintptr for FFI calls.
type RTCPFeedbackCallback ¶
RTCPFeedbackCallback describes the future RTCP feedback callback surface.
type RTCStats ¶
type RTCStats struct {
TimestampUs int64
BytesSent int64
BytesReceived int64
PacketsSent int64
PacketsReceived int64
PacketsLost int64
RoundTripTimeMs float64
JitterMs float64
AvailableOutgoingBitrate float64
AvailableIncomingBitrate float64
CurrentRTTMs int64
TotalRTTMs int64
ResponsesReceived int64
FramesEncoded int32
FramesDecoded int32
FramesDropped int32
KeyFramesEncoded int32
KeyFramesDecoded int32
NACKCount int32
PLICount int32
FIRCount int32
QPSum int32
AudioLevel float64
TotalAudioEnergy float64
ConcealmentEvents int32
// SCTP/DataChannel stats
DataChannelsOpened int64
DataChannelsClosed int64
MessagesSent int64
MessagesReceived int64
BytesSentDataChannel int64
BytesReceivedDataChannel int64
// Quality limitation
QualityLimitationReason int32 // 0=none, 1=cpu, 2=bandwidth, 3=other
QualityLimitationDurationMs int32
// Remote inbound/outbound RTP stats
RemotePacketsLost int64
RemoteJitterMs float64
RemoteRoundTripTimeMs float64
// Jitter buffer stats (from RTCInboundRtpStreamStats)
JitterBufferDelayMs float64 // Total time spent in jitter buffer / emitted count
JitterBufferTargetDelayMs float64 // Target delay for adaptive buffer
JitterBufferMinimumDelayMs float64 // User-configured minimum delay
JitterBufferEmittedCount int64 // Number of samples/frames emitted from buffer
}
RTCStats matches ShimRTCStats in shim.h
func PeerConnectionGetStats ¶
PeerConnectionGetStats gets connection statistics.
func RTPReceiverGetStats ¶
RTPReceiverGetStats gets statistics for a receiver.
func RTPSenderGetStats ¶
RTPSenderGetStats gets statistics for a sender. The current shim does not implement sender stats and returns ErrNotSupported.
type RTPEncodingParameters ¶
type RTPEncodingParameters struct {
RID [64]byte
MaxBitrateBps uint32
MinBitrateBps uint32
MaxFramerate float64
ScaleResolutionDownBy float64
Active int32
ScalabilityMode [32]byte
}
RTPEncodingParameters matches ShimRTPEncodingParameters in shim.h
type RTPHeaderExtensionParameter ¶
RTPHeaderExtensionParameter matches ShimRTPHeaderExtensionParameter in shim.h
type RTPSendParameters ¶
type RTPSendParameters struct {
Encodings uintptr
EncodingCount int32
HeaderExtensions uintptr
HeaderExtensionCount int32
TransactionID [64]byte
// contains filtered or unexported fields
}
RTPSendParameters matches ShimRTPSendParameters in shim.h
func RTPSenderGetParameters ¶
func RTPSenderGetParameters(sender uintptr, encodings []RTPEncodingParameters, headerExtensions []RTPHeaderExtensionParameter) (*RTPSendParameters, int, int, error)
RTPSenderGetParameters gets the current RTP send parameters.
type RuntimeDiagnosticsReport ¶
type RuntimeDiagnosticsReport struct {
Ready bool
Shim DependencyReport
OpenH264 DependencyReport
Warnings []string
}
RuntimeDiagnosticsReport summarizes libgowebrtc runtime dependency state.
func CheckRuntimeDependencies ¶
func CheckRuntimeDependencies() (*RuntimeDiagnosticsReport, error)
CheckRuntimeDependencies reports the currently configured runtime dependency state without downloading artifacts or mutating process-global loader state.
type ScreenCapture ¶
type ScreenCapture struct {
// contains filtered or unexported fields
}
ScreenCapture wraps a native screen/window capture.
func NewScreenCapture ¶
func NewScreenCapture(id int64, isWindow bool, fps int) (*ScreenCapture, error)
NewScreenCapture creates a new screen or window capture.
func (*ScreenCapture) IsRunning ¶
func (c *ScreenCapture) IsRunning() bool
IsRunning returns true if capture is active.
func (*ScreenCapture) Start ¶
func (c *ScreenCapture) Start(callback VideoCaptureCallback) error
Start begins screen capture with the given callback.
type ScreenInfo ¶
ScreenInfo represents information about a screen or window for capture.
func EnumerateScreens ¶
func EnumerateScreens() ([]ScreenInfo, error)
EnumerateScreens returns a list of available screens and windows for capture.
type ShimErrorBuffer ¶
type ShimErrorBuffer struct {
Message [MaxErrorMsgLen]byte
}
ShimErrorBuffer matches the C struct for error message passing. This struct is memory-compatible with the C ShimErrorBuffer type.
func (*ShimErrorBuffer) Ptr ¶
func (e *ShimErrorBuffer) Ptr() uintptr
Ptr returns a uintptr to this error buffer for FFI calls.
func (*ShimErrorBuffer) String ¶
func (e *ShimErrorBuffer) String() string
String returns the error message as a Go string.
func (*ShimErrorBuffer) ToError ¶
func (e *ShimErrorBuffer) ToError(code int32) error
ToError converts the error buffer and code to a Go error. Returns nil if code is ShimOK.
type ShimErrorWithMessage ¶
ShimErrorWithMessage wraps a shim error code with a detailed message. It implements error and supports errors.Is()/errors.As().
func (*ShimErrorWithMessage) Error ¶
func (e *ShimErrorWithMessage) Error() string
Error returns the error string including the message.
func (*ShimErrorWithMessage) Is ¶
func (e *ShimErrorWithMessage) Is(target error) bool
Is implements errors.Is for sentinel error comparison.
func (*ShimErrorWithMessage) Unwrap ¶
func (e *ShimErrorWithMessage) Unwrap() error
Unwrap returns the underlying sentinel error.
type SignalingStateCallback ¶
type SignalingStateCallback func(state int)
SignalingStateCallback is called when the signaling state changes.
type TransceiverDirection ¶
type TransceiverDirection int
TransceiverDirection represents the direction of a transceiver.
const ( TransceiverDirectionSendRecv TransceiverDirection = 0 TransceiverDirectionSendOnly TransceiverDirection = 1 TransceiverDirectionRecvOnly TransceiverDirection = 2 TransceiverDirectionInactive TransceiverDirection = 3 TransceiverDirectionStopped TransceiverDirection = 4 )
func TransceiverGetCurrentDirection ¶
func TransceiverGetCurrentDirection(transceiver uintptr) TransceiverDirection
TransceiverGetCurrentDirection gets the current direction as negotiated in SDP.
func TransceiverGetDirection ¶
func TransceiverGetDirection(transceiver uintptr) TransceiverDirection
TransceiverGetDirection gets the current direction of a transceiver.
type VideoCapture ¶
type VideoCapture struct {
// contains filtered or unexported fields
}
VideoCapture wraps a native video capture device.
func NewVideoCapture ¶
func NewVideoCapture(deviceID string, width, height, fps int) (*VideoCapture, error)
NewVideoCapture creates a new video capture device. deviceID can be empty to use the default device.
func (*VideoCapture) Close ¶
func (c *VideoCapture) Close()
Close releases the video capture device.
func (*VideoCapture) IsRunning ¶
func (c *VideoCapture) IsRunning() bool
IsRunning returns true if capture is active.
func (*VideoCapture) Start ¶
func (c *VideoCapture) Start(callback VideoCaptureCallback) error
Start begins video capture with the given callback.
type VideoCaptureCallback ¶
type VideoCaptureCallback func(frame *CapturedVideoFrame)
VideoCaptureCallback is called for each captured video frame.
type VideoEncoderConfig ¶
type VideoEncoderConfig struct {
Width int32
Height int32
BitrateBps uint32
Framerate float32
KeyframeInterval int32
H264Profile *byte // C string pointer
VP9Profile int32
PreferHW int32 // bool as int
ScalabilityMode *byte // C string pointer
}
VideoEncoderConfig matches ShimVideoEncoderConfig in shim.h
func (*VideoEncoderConfig) Ptr ¶
func (c *VideoEncoderConfig) Ptr() uintptr
Ptr returns a pointer to the config as uintptr for FFI calls.
Source Files
¶
- codec_params.go
- decoder.go
- device.go
- dl_helpers_linux_cgo.go
- encoder.go
- func_bind_purego.go
- func_vars.go
- generate.go
- lib.go
- openh264_download.go
- packetizer.go
- params_capture.go
- params_datachannel.go
- params_packetizer.go
- params_peerconnection.go
- params_rtp.go
- params_stats.go
- params_track.go
- peerconnection.go
- runtime_diagnostics.go
- shim_download.go
- shim_structs.go
- types.go