v4l2rtspserver/inc/ALSACapture.h

63 lines
1.9 KiB
C
Raw Normal View History

2016-06-19 17:15:51 +00:00
/* ---------------------------------------------------------------------------
** This software is in the public domain, furnished "as is", without technical
** support, and with no warranty, express or implied, as to its usefulness for
** any purpose.
**
2017-07-30 17:37:39 +00:00
** ALSACapture.h
2016-06-19 17:15:51 +00:00
**
** V4L2 RTSP streamer
**
** ALSA capture overide of V4l2Capture
**
** -------------------------------------------------------------------------*/
2016-09-18 19:57:53 +00:00
#ifndef ALSA_CAPTURE
#define ALSA_CAPTURE
2016-06-19 17:15:51 +00:00
#include <alsa/asoundlib.h>
#include "logger.h"
2016-06-19 17:15:51 +00:00
2016-09-18 19:57:53 +00:00
struct ALSACaptureParameters
{
ALSACaptureParameters(const char* devname, snd_pcm_format_t fmt, unsigned int sampleRate, unsigned int channels, int verbose) :
m_devName(devname), m_fmt(fmt), m_sampleRate(sampleRate), m_channels(channels), m_verbose(verbose) {};
2016-09-18 19:57:53 +00:00
std::string m_devName;
snd_pcm_format_t m_fmt;
unsigned int m_sampleRate;
unsigned int m_channels;
int m_verbose;
2016-09-18 19:57:53 +00:00
};
class ALSACapture
2016-06-19 17:15:51 +00:00
{
public:
2017-07-30 17:37:39 +00:00
static ALSACapture* createNew(const ALSACaptureParameters & params) ;
virtual ~ALSACapture();
void close();
2016-06-19 17:15:51 +00:00
protected:
2017-07-30 17:37:39 +00:00
ALSACapture(const ALSACaptureParameters & params);
2016-06-19 17:15:51 +00:00
public:
2017-07-30 17:37:39 +00:00
virtual size_t read(char* buffer, size_t bufferSize);
virtual int getFd();
2016-09-18 19:57:53 +00:00
2017-06-25 14:58:37 +00:00
virtual unsigned long getBufferSize() { return m_bufferSize; };
virtual int getWidth() {return -1;}
virtual int getHeight() {return -1;}
unsigned long getSampleRate() { return m_params.m_sampleRate; };
unsigned long getChannels () { return m_params.m_channels; };
2016-06-19 17:15:51 +00:00
private:
snd_pcm_t* m_pcm;
unsigned long m_bufferSize;
unsigned long m_periodSize;
ALSACaptureParameters m_params;
2016-06-19 17:15:51 +00:00
};
2016-09-18 19:57:53 +00:00
#endif