capture

package
v0.0.0-...-a783914 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: MIT Imports: 33 Imported by: 0

Documentation

Overview

Connecting to different camera sources and make it recording to disk.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base64Image

func Base64Image(captureDevice *Capture, communication *models.Communication) string

func CleanupRecordingDirectory

func CleanupRecordingDirectory(configDirectory string, configuration *models.Configuration)

func FindMPEG4Audio

func FindMPEG4Audio(desc *description.Session, isBackChannel bool) (*format.MPEG4Audio, *description.Media)

func FindOPUS

func FindOPUS(desc *description.Session, isBackChannel bool) (*format.Opus, *description.Media)

func FindPCMU

func FindPCMU(desc *description.Session, isBackChannel bool) (*format.G711, *description.Media)

func HandleRecordStream

func HandleRecordStream(queue *packets.Queue, configDirectory string, configuration *models.Configuration, communication *models.Communication, rtspClient RTSPClient)

func JpegImage

func JpegImage(captureDevice *Capture, communication *models.Communication) image.YCbCr

func VerifyCamera

func VerifyCamera(c *gin.Context)

VerifyCamera godoc @Router /api/camera/verify/{streamType} [post] @ID verify-camera @Tags camera @Param streamType path string true "Stream Type" Enums(primary, secondary) @Param cameraStreams body models.CameraStreams true "Camera Streams" @Summary Validate a specific RTSP profile camera connection. @Description This method will validate a specific profile connection from an RTSP camera, and try to get the codec. @Success 200 {object} models.APIResponse

func WriteMPEG4Audio

func WriteMPEG4Audio(forma *format.MPEG4Audio, aus [][]byte) ([]byte, error)

WriteMPEG4Audio writes MPEG-4 Audio access units.

Types

type Capture

type Capture struct {
	RTSPClient            *Golibrtsp
	RTSPSubClient         *Golibrtsp
	RTSPBackChannelClient *Golibrtsp
}

func (*Capture) SetBackChannelClient

func (c *Capture) SetBackChannelClient(rtspUrl string) *Golibrtsp

func (*Capture) SetMainClient

func (c *Capture) SetMainClient(rtspUrl string) *Golibrtsp

func (*Capture) SetSubClient

func (c *Capture) SetSubClient(rtspUrl string) *Golibrtsp

type Decoder

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

h264Decoder is a wrapper around FFmpeg's H264 decoder.

func (*Decoder) Close

func (d *Decoder) Close()

close closes the decoder.

type Golibrtsp

type Golibrtsp struct {
	RTSPClient
	Url string

	Client            gortsplib.Client
	VideoDecoderMutex *sync.Mutex

	VideoH264Index        int8
	VideoH264Media        *description.Media
	VideoH264Forma        *format.H264
	VideoH264Decoder      *rtph264.Decoder
	VideoH264FrameDecoder *Decoder

	VideoH265Index        int8
	VideoH265Media        *description.Media
	VideoH265Forma        *format.H265
	VideoH265Decoder      *rtph265.Decoder
	VideoH265FrameDecoder *Decoder

	AudioLPCMIndex   int8
	AudioLPCMMedia   *description.Media
	AudioLPCMForma   *format.LPCM
	AudioLPCMDecoder *rtplpcm.Decoder

	AudioG711Index   int8
	AudioG711Media   *description.Media
	AudioG711Forma   *format.G711
	AudioG711Decoder *rtplpcm.Decoder

	AudioOpusIndex   int8
	AudioOpusMedia   *description.Media
	AudioOpusForma   *format.Opus
	AudioOpusDecoder *rtpsimpleaudio.Decoder

	HasBackChannel            bool
	AudioG711IndexBackChannel int8
	AudioG711MediaBackChannel *description.Media
	AudioG711FormaBackChannel *format.G711

	AudioMPEG4Index   int8
	AudioMPEG4Media   *description.Media
	AudioMPEG4Forma   *format.MPEG4Audio
	AudioMPEG4Decoder *rtpmpeg4audio.Decoder

	Streams []packets.Stream
}

Implements the RTSPClient interface.

func (*Golibrtsp) Close

func (g *Golibrtsp) Close() error

Close the connection to the RTSP server.

func (*Golibrtsp) Connect

func (g *Golibrtsp) Connect(ctx context.Context) (err error)

Connect to the RTSP server.

func (*Golibrtsp) ConnectBackChannel

func (g *Golibrtsp) ConnectBackChannel(ctx context.Context) (err error)

func (*Golibrtsp) DecodePacket

func (g *Golibrtsp) DecodePacket(pkt packets.Packet) (image.YCbCr, error)

Decode a packet to an image.

func (*Golibrtsp) DecodePacketRaw

func (g *Golibrtsp) DecodePacketRaw(pkt packets.Packet) (image.Gray, error)

Decode a packet to a Gray image.

func (*Golibrtsp) GetAudioStreams

func (g *Golibrtsp) GetAudioStreams() ([]packets.Stream, error)

Get a list of audio streams from the RTSP server.

func (*Golibrtsp) GetStreams

func (j *Golibrtsp) GetStreams() ([]packets.Stream, error)

Get a list of streams from the RTSP server.

func (*Golibrtsp) GetVideoStreams

func (g *Golibrtsp) GetVideoStreams() ([]packets.Stream, error)

Get a list of video streams from the RTSP server.

func (*Golibrtsp) Start

func (g *Golibrtsp) Start(ctx context.Context, streamType string, queue *packets.Queue, configuration *models.Configuration, communication *models.Communication) (err error)

Start the RTSP client, and start reading packets.

func (*Golibrtsp) StartBackChannel

func (g *Golibrtsp) StartBackChannel(ctx context.Context) (err error)

Start the RTSP client, and start reading packets.

func (*Golibrtsp) WritePacket

func (g *Golibrtsp) WritePacket(pkt packets.Packet) error

type RTSPClient

type RTSPClient interface {
	// Connect to the RTSP server.
	Connect(ctx context.Context) error

	// Connect to a backchannel RTSP server.
	ConnectBackChannel(ctx context.Context) error

	// Start the RTSP client, and start reading packets.
	Start(ctx context.Context, streamType string, queue *packets.Queue, configuration *models.Configuration, communication *models.Communication) error

	// Start the RTSP client, and start reading packets.
	StartBackChannel(ctx context.Context) (err error)

	// Decode a packet into a image.
	DecodePacket(pkt packets.Packet) (image.YCbCr, error)

	// Decode a packet into a image.
	DecodePacketRaw(pkt packets.Packet) (image.Gray, error)

	// Write a packet to the RTSP server.
	WritePacket(pkt packets.Packet) error

	// Close the connection to the RTSP server.
	Close() error

	// Get a list of streams from the RTSP server.
	GetStreams() ([]packets.Stream, error)

	// Get a list of video streams from the RTSP server.
	GetVideoStreams() ([]packets.Stream, error)

	// Get a list of audio streams from the RTSP server.
	GetAudioStreams() ([]packets.Stream, error)
}

RTSPClient is a interface that abstracts the RTSP client implementation.

Jump to

Keyboard shortcuts

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