ndi

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2021 License: MPL-2.0 Imports: 7 Imported by: 0

README

ndi-go

Documentation

Index

Constants

View Source
const (
	SendTimecodeSynthesize int64 = math.MaxInt64
	SendTimecodeEmpty      int64 = 0
)

Variables

View Source
var (
	FourCCTypeUYVY = [4]byte{'U', 'Y', 'V', 'Y'}

	//BGRA
	FourCCTypeBGRA = [4]byte{'B', 'G', 'R', 'A'}
	FourCCTypeBGRX = [4]byte{'B', 'G', 'R', 'X'}

	//This is a UYVY buffer followed immediately by an alpha channel buffer.
	//If the stride of the YCbCr component is "stride", then the alpha channel
	//starts at image_ptr + yres*stride. The alpha channel stride is stride/2.
	FourCCTypeUYVA = [4]byte{'U', 'Y', 'V', 'A'}
)

Functions

func DestroyAndUnload

func DestroyAndUnload()

func IsSupportedCPU

func IsSupportedCPU() bool

func LoadAndInitialize

func LoadAndInitialize(path string) error

func Version

func Version() string

Types

type AudioFrameV2

type AudioFrameV2 struct {
	SampleRate,
	NumChannels,
	NumSamples int32 //The number of audio samples per channel.
	Timecode      int64    //The timecode of this frame in 100ns intervals.
	Data          *float32 //The audio data
	ChannelStride int32    //The inter channel stride of the audio channels, in bytes.

	//Per frame metadata for this frame. This is a NULL terminated UTF8 string that should be
	//in XML format. If you do not want any metadata then you may specify NULL here.
	Metadata *byte

	// This is only valid when receiving a frame and is specified as a 100ns time that was the exact
	// moment that the frame was submitted by the sending side and is generated by the SDK. If this
	// value is NDIlib_recv_timestamp_undefined then this value is not available and is NDIlib_recv_timestamp_undefined.
	Timestamp int64
}

func NewAudioFrameV2

func NewAudioFrameV2() *AudioFrameV2

func (*AudioFrameV2) SetDefault

func (af *AudioFrameV2) SetDefault()

type Error

type Error struct {
	syscall.Errno
}

func (*Error) Timeout

func (e *Error) Timeout() bool

type FindCreateSettings

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

type FindInstance

type FindInstance struct{}

func NewFindInstanceV2

func NewFindInstanceV2(settings *FindCreateSettings) *FindInstance

func (*FindInstance) Destroy

func (inst *FindInstance) Destroy()

func (*FindInstance) GetCurrentSources

func (inst *FindInstance) GetCurrentSources() []*Source

This function will recover the current set of sources (i.e. the ones that exist right this second).

func (*FindInstance) WaitForSources

func (inst *FindInstance) WaitForSources(timeoutInMs uint32) (int, error)

This will allow you to wait until the number of online sources have changed.

type FrameFormat

type FrameFormat int32
const (
	FrameFormatInterleaved FrameFormat = iota //A fielded frame with the field 0 being on the even lines and field 1 being on the odd lines.
	FrameFormatProgressive                    //A progressive frame.

	//Individual fields.
	FrameFormatField0
	FrameFormatField1
)

type FrameType

type FrameType int32
const (
	FrameTypeNone FrameType = iota
	FrameTypeVideo
	FrameTypeAudio
	FrameTypeMetadata
	FrameTypeError

	//This indicates that the settings on this input have changed.
	//For instamce, this value will be returned from NDIlib_recv_capture_v2 and NDIlib_recv_capture
	//when the device is known to have new settings, for instance the web-url has changed ot the device
	//is now known to be a PTZ camera.
	FrameTypeStatusChange FrameType = 100
)

An enumeration to specify the type of a packet returned by the functions

type MetadataFrame

type MetadataFrame struct {
	//The length of the string in UTF8 characters. This includes the NULL terminating character.
	//If this is 0, then the length is assume to be the length of a null terminated string.
	Length int32

	Timecode int64 //The timecode of this frame in 100ns intervals.
	Data     *byte //The metadata as a UTF8 XML string. This is a NULL terminated string.
}

The data description for metadata

func NewMetadataFrame

func NewMetadataFrame() *MetadataFrame

func (*MetadataFrame) SetDefault

func (mf *MetadataFrame) SetDefault()

type ObjectPool

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

func NewObjectPool

func NewObjectPool() *ObjectPool

func (*ObjectPool) NewFindCreateSettings

func (p *ObjectPool) NewFindCreateSettings(showLocalSources bool, groups, ips string) *FindCreateSettings

func (*ObjectPool) NewSendCreateSettings

func (p *ObjectPool) NewSendCreateSettings(name, groups string, clockVideo, clockAudio bool) *SendCreateSettings

func (*ObjectPool) Register

func (p *ObjectPool) Register(o interface{})

func (*ObjectPool) Release

func (p *ObjectPool) Release(o interface{})

type RecvBandwidth

type RecvBandwidth int32
const (
	RecvBandwidthMetadataOnly RecvBandwidth = -10 //Receive metadata.
	RecvBandwidthAudioOnly    RecvBandwidth = 10  //Receive metadata, audio.
	RecvBandwidthLowest       RecvBandwidth = 0   //Receive metadata, audio, video at a lower bandwidth and resolution.
	RecvBandwidthHighest      RecvBandwidth = 100 //Receive metadata, audio, video at full resolution.
)

type RecvColorFormat

type RecvColorFormat int32
const (
	RecvColorFormatBGRXBGRA RecvColorFormat = 0 //No alpha channel: BGRX, Alpha channel: BGRA
	RecvColorFormatUYVYBGRA RecvColorFormat = 1 //No alpha channel: UYVY, Alpha channel: BGRA
	RecvColorFormatRGBXRGBA RecvColorFormat = 2 //No alpha channel: RGBX, Alpha channel: RGBA
	RecvColorFormatUYVYRGBA RecvColorFormat = 3 //No alpha channel: UYVY, Alpha channel: RGBA

	//Read the SDK documentation to understand the pros and cons of this format.
	RecvColorFormatFastest RecvColorFormat = 100
)

type RecvCreateSettings

type RecvCreateSettings struct {
	SourceToConnectTo Source

	//Your preference of color space.
	ColorFormat RecvColorFormat

	//The bandwidth setting that you wish to use for this video source. Bandwidth
	//controlled by changing both the compression level and the resolution of the source.
	//A good use for low bandwidth is working on WIFI connections.
	Bandwidth RecvBandwidth

	//When this flag is FALSE, all video that you receive will be progressive. For sources
	//that provide fields, this is de-interlaced on the receiving side (because we cannot change
	//what the up-stream source was actually rendering. This is provided as a convenience to
	//down-stream sources that do not wish to understand fielded video. There is almost no
	//performance impact of using this function.
	AllowVideoFields bool
}

func NewRecvCreateSettings

func NewRecvCreateSettings() *RecvCreateSettings

func (*RecvCreateSettings) SetDefault

func (s *RecvCreateSettings) SetDefault()

type RecvInstance

type RecvInstance struct{}

func NewRecvInstanceV2

func NewRecvInstanceV2(settings *RecvCreateSettings) *RecvInstance

func (*RecvInstance) CaptureV2

func (inst *RecvInstance) CaptureV2(vf *VideoFrameV2, af *AudioFrameV2, mf *MetadataFrame, timeoutInMs uint32) FrameType

func (*RecvInstance) Destroy

func (inst *RecvInstance) Destroy()

func (*RecvInstance) FreeAudioV2

func (inst *RecvInstance) FreeAudioV2(af *AudioFrameV2)

func (*RecvInstance) FreeMetadataV2

func (inst *RecvInstance) FreeMetadataV2(mf *MetadataFrame)

func (*RecvInstance) FreeVideoV2

func (inst *RecvInstance) FreeVideoV2(vf *VideoFrameV2)

func (*RecvInstance) GetNumConnections

func (inst *RecvInstance) GetNumConnections(timeoutInMs uint32) (int, error)

Is this receiver currently connected to a source on the other end, or has the source not yet been found or is no longe ronline. This will normally return 0 or 1.

func (*RecvInstance) SendMetadata

func (inst *RecvInstance) SendMetadata(mf *MetadataFrame) bool

This function will send a meta message to the source that we are connected too. This returns FALSE if we are not currently connected to anything.

func (*RecvInstance) SetTally

func (inst *RecvInstance) SetTally(tally *Tally) bool

Set the up-stream tally notifications. This returns FALSE if we are not currently connected to anything. That said, the moment that we do connect to something it will automatically be sent the tally state.

type SendCreateSettings

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

type SendInstance

type SendInstance struct{}

func NewSendInstance

func NewSendInstance(settings *SendCreateSettings) *SendInstance

func (*SendInstance) Destroy

func (inst *SendInstance) Destroy()

func (*SendInstance) GetNumConnections

func (inst *SendInstance) GetNumConnections(timeoutInMs uint32) (int, error)

Get the current number of receivers connected to this source. This can be used to avoid even rendering when nothing is connected to the video source. which can significantly improve the efficiency if you want to make a lot of sources available on the network. If you specify a timeout that is not 0 then it will wait until there are connections for this amount of time.

func (*SendInstance) SendVideoV2

func (inst *SendInstance) SendVideoV2(frame *VideoFrameV2)

This will add a video frame.

type Source

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

func (*Source) Address

func (s *Source) Address() string

func (*Source) Name

func (s *Source) Name() string

type Tally

type Tally struct {
	OnProgram, OnPreview bool
}

type VideoFrameV2

type VideoFrameV2 struct {
	Xres, Yres int32   //The resolution of this frame.
	FourCC     [4]byte //What FourCC this is with. This can be two values.

	//What is the frame-rate of this frame.
	//For instance NTSC is 30000,1001 = 30000/1001 = 29.97fps.
	FrameRateN, FrameRateD int32

	//What is the picture aspect ratio of this frame.
	//For instance 16.0/9.0 = 1.778 is 16:9 video
	//0 means square pixels.
	PictureAspectRatio float32

	//Is this a fielded frame, or is it progressive.
	FrameFormatType FrameFormat

	//The timecode of this frame in 100ns intervals.
	Timecode int64

	//The video data itself.
	Data *byte

	//The inter line stride of the video data, in bytes.
	LineStride int32

	//Per frame metadata for this frame. This is a NULL terminated UTF8 string that should be
	//in XML format. If you do not want any metadata then you may specify NULL here.
	Metadata *byte

	//This is only valid when receiving a frame and is specified as a 100ns time that was the exact
	//moment that the frame was submitted by the sending side and is generated by the SDK. If this
	//value is NDIlib_recv_timestamp_undefined then this value is not available and is NDIlib_recv_timestamp_undefined.
	Timestamp int64
}

This describes a video frame.

func NewVideoFrameV2

func NewVideoFrameV2() *VideoFrameV2

func (*VideoFrameV2) ReadData

func (vf *VideoFrameV2) ReadData() []byte

func (*VideoFrameV2) SetDefault

func (vf *VideoFrameV2) SetDefault()

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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