mediadevices

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2020 License: MIT Imports: 15 Imported by: 82

README

mediadevices

Go implementation of the MediaDevices API.

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 LocalTrack

type LocalTrack interface {
	WriteSample(s media.Sample) error
	Codec() *webrtc.RTPCodec
	ID() string
	Kind() webrtc.RTPCodecType
}

type MediaDeviceInfo

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

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

type MediaDeviceType

type MediaDeviceType int

MediaDeviceType enumerates type of media device.

const (
	VideoInput MediaDeviceType = iota
	AudioInput
	AudioOutput
)

MediaDeviceType definitions.

type MediaDevices

type MediaDevices interface {
	GetDisplayMedia(constraints MediaStreamConstraints) (MediaStream, error)
	GetUserMedia(constraints MediaStreamConstraints) (MediaStream, error)
	EnumerateDevices() []MediaDeviceInfo
}

MediaDevices is an interface that's defined on https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices

func NewMediaDevices

func NewMediaDevices(pc *webrtc.PeerConnection, opts ...MediaDevicesOption) MediaDevices

NewMediaDevices creates MediaDevices interface that provides access to connected media input devices like cameras and microphones, as well as screen sharing. In essence, it lets you obtain access to any hardware source of media data.

func NewMediaDevicesFromCodecs

func NewMediaDevicesFromCodecs(codecs map[webrtc.RTPCodecType][]*webrtc.RTPCodec, opts ...MediaDevicesOption) MediaDevices

NewMediaDevicesFromCodecs creates MediaDevices interface from lists of the available codecs that provides access to connected media input devices like cameras and microphones, as well as screen sharing. In essence, it lets you obtain access to any hardware source of media data.

type MediaDevicesOption

type MediaDevicesOption func(*MediaDevicesOptions)

MediaDevicesOption is a type of MediaDevices functional option.

func WithTrackGenerator

func WithTrackGenerator(gen TrackGenerator) MediaDevicesOption

WithTrackGenerator specifies a TrackGenerator to use customized track.

type MediaDevicesOptions

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

MediaDevicesOptions stores parameters used by MediaDevices.

type MediaOption

type MediaOption func(*MediaTrackConstraints)

type MediaStream

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

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

func NewMediaStream

func NewMediaStream(trackers ...Tracker) (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
}

type MediaTrackConstraints

type MediaTrackConstraints struct {
	prop.MediaConstraints
	Enabled bool
	// VideoEncoderBuilders are codec builders that are used for encoding the video
	// and later being used for sending the appropriate RTP payload type.
	//
	// If one encoder builder fails to build the codec, the next builder will be used,
	// repeating until a codec builds. If no builders build successfully, an error is returned.
	VideoEncoderBuilders []codec.VideoEncoderBuilder
	// AudioEncoderBuilders are codec builders that are used for encoding the audio
	// and later being used for sending the appropriate RTP payload type.
	//
	// If one encoder builder fails to build the codec, the next builder will be used,
	// repeating until a codec builds. If no builders build successfully, an error is returned.
	AudioEncoderBuilders []codec.AudioEncoderBuilder
	// VideoTransform will be used to transform the video that's coming from the driver.
	// So, basically it'll look like following: driver -> VideoTransform -> codec
	VideoTransform video.TransformFunc
	// AudioTransform will be used to transform the audio that's coming from the driver.
	// So, basically it'll look like following: driver -> AudioTransform -> code
	AudioTransform audio.TransformFunc
	// contains filtered or unexported fields
}

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

type TrackGenerator

type TrackGenerator func(payloadType uint8, ssrc uint32, id, label string, codec *webrtc.RTPCodec) (LocalTrack, error)

TrackGenerator is a function to create new track.

type Tracker

type Tracker interface {
	Track() *webrtc.Track
	LocalTrack() LocalTrack
	Stop()
	// 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))
}

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

Directories

Path Synopsis
examples module
internal
pkg
avfoundation
Package avfoundation provides AVFoundation binding for Go
Package avfoundation provides AVFoundation binding for Go
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