mediadevices

package module
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2020 License: MIT Imports: 16 Imported by: 82

README


Pion MediaDevices

Go implementation of the MediaDevices API

Slack Widget Build status GoDoc Coverage Status


Interfaces

Interface Linux Mac Windows
Camera ✔️ ✔️ ✔️
Microphone ✔️ ✖️ ✔️
Screen ✔️ ✖️ ✖️

Camera

OS Library/Interface
Linux Video4Linux
Mac AVFoundation
Windows DirectShow
Pixel Format Linux Mac Windows
YUY2 ✔️ ✖️ ✔️
UYVY ✔️ ✔️ ✖️
I420 ✔️ ✖️ ✖️
NV21 ✔️ ✔️ ✖️
MJPEG ✔️ ✖️ ✖️

Microphone

OS Library/Interface
Linux PulseAudio
Mac N/A
Windows waveIn

Screen casting

OS Library/Interface
Linux X11
Mac N/A
Windows N/A

Codecs

Audio Codec Library/Interface
OPUS libopus
Video Codec Library/Interface
H.264 OpenH264
VP8 libvpx
VP9 libvpx

Usage

Wiki

Contributing

Project Status

Stargazers over time

References

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterDriverAdapter

func RegisterDriverAdapter(a driver.Adapter, info driver.Info) error

RegisterDriverAdapter allows user space level of driver registration

Types

type AudioSource added in v0.1.2

type AudioSource interface {
	audio.Reader
	Source
}

AudioSource is a specific type of media source that emits a series of audio chunks

type AudioTrack added in v0.1.2

type AudioTrack struct {
	*audio.Broadcaster
	// contains filtered or unexported fields
}

AudioTrack is a specific track type that contains audio source which allows multiple readers to access, and manipulate.

func (*AudioTrack) Bind added in v0.1.2

func (track *AudioTrack) Bind(pc *webrtc.PeerConnection) (*webrtc.Track, error)

func (AudioTrack) Kind added in v0.1.2

func (track AudioTrack) Kind() MediaDeviceType

Kind returns track's kind

func (AudioTrack) OnEnded added in v0.1.2

func (track AudioTrack) OnEnded(handler func(error))

OnEnded sets an error handler. When a track has been created and started, if an error occurs, handler will get called with the error given to the parameter.

func (*AudioTrack) Transform added in v0.1.2

func (track *AudioTrack) Transform(fns ...audio.TransformFunc)

Transform transforms the underlying source by applying the given fns in serial order

func (*AudioTrack) Unbind added in v0.1.2

func (track *AudioTrack) Unbind(pc *webrtc.PeerConnection) error

type CodecSelector added in v0.1.2

type CodecSelector struct {
	// contains filtered or unexported fields
}

CodecSelector is a container of video and audio encoder builders, which later will be used for codec matching.

func NewCodecSelector added in v0.1.2

func NewCodecSelector(opts ...CodecSelectorOption) *CodecSelector

NewCodecSelector constructs CodecSelector with given variadic options

func (*CodecSelector) Populate added in v0.1.2

func (selector *CodecSelector) Populate(setting *webrtc.MediaEngine)

Populate lets the webrtc engine be aware of supported codecs that are contained in CodecSelector

type CodecSelectorOption added in v0.1.2

type CodecSelectorOption func(*CodecSelector)

CodecSelectorOption is a type for specifying CodecSelector options

func WithAudioEncoders added in v0.1.2

func WithAudioEncoders(encoders ...codec.AudioEncoderBuilder) CodecSelectorOption

WithVideoEncoders replace current audio codecs with listed encoders

func WithVideoEncoders added in v0.1.2

func WithVideoEncoders(encoders ...codec.VideoEncoderBuilder) CodecSelectorOption

WithVideoEncoders replace current video codecs with listed encoders

type MediaDeviceInfo

type MediaDeviceInfo struct {
	DeviceID   string
	Kind       MediaDeviceType
	Label      string
	DeviceType driver.DeviceType
}

MediaDeviceInfo represents https://w3c.github.io/mediacapture-main/#dom-mediadeviceinfo

func EnumerateDevices added in v0.1.2

func EnumerateDevices() []MediaDeviceInfo

type MediaDeviceType

type MediaDeviceType int

MediaDeviceType enumerates type of media device.

const (
	VideoInput MediaDeviceType = iota + 1
	AudioInput
	AudioOutput
)

MediaDeviceType definitions.

type MediaOption

type MediaOption func(*MediaTrackConstraints)

type MediaStream

type MediaStream interface {
	// GetAudioTracks implements https://w3c.github.io/mediacapture-main/#dom-mediastream-getaudiotracks
	GetAudioTracks() []Track
	// GetVideoTracks implements https://w3c.github.io/mediacapture-main/#dom-mediastream-getvideotracks
	GetVideoTracks() []Track
	// GetTracks implements https://w3c.github.io/mediacapture-main/#dom-mediastream-gettracks
	GetTracks() []Track
	// AddTrack implements https://w3c.github.io/mediacapture-main/#dom-mediastream-addtrack
	AddTrack(t Track)
	// RemoveTrack implements https://w3c.github.io/mediacapture-main/#dom-mediastream-removetrack
	RemoveTrack(t Track)
}

MediaStream is an interface that represents a collection of existing tracks.

func GetDisplayMedia added in v0.1.2

func GetDisplayMedia(constraints MediaStreamConstraints) (MediaStream, error)

GetDisplayMedia prompts the user to select and grant permission to capture the contents of a display or portion thereof (such as a window) as a MediaStream. Reference: https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getDisplayMedia

func GetUserMedia added in v0.1.2

func GetUserMedia(constraints MediaStreamConstraints) (MediaStream, error)

GetUserMedia prompts the user for permission to use a media input which produces a MediaStream with tracks containing the requested types of media. Reference: https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia

func NewMediaStream

func NewMediaStream(tracks ...Track) (MediaStream, error)

NewMediaStream creates a MediaStream interface that's defined in https://w3c.github.io/mediacapture-main/#dom-mediastream

type MediaStreamConstraints

type MediaStreamConstraints struct {
	Audio MediaOption
	Video MediaOption
	Codec *CodecSelector
}

type MediaTrackConstraints

type MediaTrackConstraints struct {
	prop.MediaConstraints
	// contains filtered or unexported fields
}

MediaTrackConstraints represents https://w3c.github.io/mediacapture-main/#dom-mediatrackconstraints

type Source added in v0.1.2

type Source interface {
	ID() string
	Close() error
}

Source is a generic representation of a media source

type Track added in v0.1.2

type Track interface {
	Source
	// OnEnded registers a handler to receive an error from the media stream track.
	// If the error is already occured before registering, the handler will be
	// immediately called.
	OnEnded(func(error))
	Kind() MediaDeviceType
	// Bind binds the current track source to the given peer connection. In Pion/webrtc v3, the bind
	// call will happen automatically after the SDP negotiation. Users won't need to call this manually.
	Bind(*webrtc.PeerConnection) (*webrtc.Track, error)
	// Unbind is the clean up operation that should be called after Bind. Similar to Bind, unbind will
	// be called automatically in the future.
	Unbind(*webrtc.PeerConnection) error
}

Track is an interface that represent MediaStreamTrack Reference: https://w3c.github.io/mediacapture-main/#mediastreamtrack

func NewAudioTrack added in v0.1.2

func NewAudioTrack(source AudioSource, selector *CodecSelector) Track

NewAudioTrack constructs a new VideoTrack

func NewVideoTrack added in v0.1.2

func NewVideoTrack(source VideoSource, selector *CodecSelector) Track

NewVideoTrack constructs a new VideoTrack

type VideoSource added in v0.1.2

type VideoSource interface {
	video.Reader
	Source
}

VideoSource is a specific type of media source that emits a series of video frames

type VideoTrack added in v0.1.2

type VideoTrack struct {
	*video.Broadcaster
	// contains filtered or unexported fields
}

VideoTrack is a specific track type that contains video source which allows multiple readers to access, and manipulate.

func (*VideoTrack) Bind added in v0.1.2

func (track *VideoTrack) Bind(pc *webrtc.PeerConnection) (*webrtc.Track, error)

func (VideoTrack) Kind added in v0.1.2

func (track VideoTrack) Kind() MediaDeviceType

Kind returns track's kind

func (VideoTrack) OnEnded added in v0.1.2

func (track VideoTrack) OnEnded(handler func(error))

OnEnded sets an error handler. When a track has been created and started, if an error occurs, handler will get called with the error given to the parameter.

func (*VideoTrack) Transform added in v0.1.2

func (track *VideoTrack) Transform(fns ...video.TransformFunc)

Transform transforms the underlying source by applying the given fns in serial order

func (*VideoTrack) Unbind added in v0.1.2

func (track *VideoTrack) Unbind(pc *webrtc.PeerConnection) error

Directories

Path Synopsis
examples module
internal
pkg
avfoundation
Package avfoundation provides AVFoundation binding for Go
Package avfoundation provides AVFoundation binding for Go
codec/mmal
Package mmal implements a hardware accelerated H264 encoder for raspberry pi.
Package mmal implements a hardware accelerated H264 encoder for raspberry pi.
codec/vaapi
Package vaapi implements hardware accelerated codecs.
Package vaapi implements hardware accelerated codecs.
codec/vpx
Package vpx implements VP8 and VP9 encoder.
Package vpx implements VP8 and VP9 encoder.
codec/x264
Package x264 implements H264 encoder.
Package x264 implements H264 encoder.
driver/audiotest
Package audiotest provides dummy audio driver for testing.
Package audiotest provides dummy audio driver for testing.
driver/videotest
Package videotest provides dummy video driver for testing.
Package videotest provides dummy video driver for testing.
io
wave
Package wave implements a basic audio data library.
Package wave implements a basic audio data library.
codec/ffmpeg module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL