mirror of
https://github.com/tuxbox-neutrino/libstb-hal.git
synced 2025-08-26 15:02:58 +02:00
- libraspi: some manual code nicenings
Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
@@ -114,12 +114,11 @@ int cAudio::StopClip()
|
|||||||
void cAudio::getAudioInfo(int &type, int &layer, int &freq, int &bitrate, int &mode)
|
void cAudio::getAudioInfo(int &type, int &layer, int &freq, int &bitrate, int &mode)
|
||||||
{
|
{
|
||||||
type = 0;
|
type = 0;
|
||||||
layer = 0; /* not used */
|
layer = 0; /* not used */
|
||||||
freq = 0;
|
freq = 0;
|
||||||
bitrate = 0; /* not used, but easy to get :-) */
|
bitrate = 0; /* not used, but easy to get :-) */
|
||||||
mode = 0; /* default: stereo */
|
mode = 0; /* default: stereo */
|
||||||
hal_debug("%s t: %d l: %d f: %d b: %d m: %d\n",
|
hal_debug("%s t: %d l: %d f: %d b: %d m: %d\n", __func__, type, layer, freq, bitrate, mode);
|
||||||
__func__, type, layer, freq, bitrate, mode);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void cAudio::SetSRS(int /*iq_enable*/, int /*nmgr_enable*/, int /*iq_mode*/, int /*iq_level*/)
|
void cAudio::SetSRS(int /*iq_enable*/, int /*nmgr_enable*/, int /*iq_mode*/, int /*iq_level*/)
|
||||||
|
@@ -41,16 +41,17 @@ typedef enum
|
|||||||
class cAudio
|
class cAudio
|
||||||
{
|
{
|
||||||
friend class cPlayback;
|
friend class cPlayback;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int fd;
|
int fd;
|
||||||
bool Muted;
|
bool Muted;
|
||||||
|
|
||||||
int clipfd; /* for pcm playback */
|
int clipfd; /* for pcm playback */
|
||||||
int mixer_fd; /* if we are using the OSS mixer */
|
int mixer_fd; /* if we are using the OSS mixer */
|
||||||
int mixer_num; /* oss mixer to use, if any */
|
int mixer_num; /* oss mixer to use, if any */
|
||||||
|
|
||||||
AUDIO_FORMAT StreamType;
|
AUDIO_FORMAT StreamType;
|
||||||
AUDIO_SYNC_MODE SyncMode;
|
AUDIO_SYNC_MODE SyncMode;
|
||||||
bool started;
|
bool started;
|
||||||
bool thread_started;
|
bool thread_started;
|
||||||
|
|
||||||
@@ -67,35 +68,17 @@ class cAudio
|
|||||||
/* construct & destruct */
|
/* construct & destruct */
|
||||||
cAudio(void *, void *, void *);
|
cAudio(void *, void *, void *);
|
||||||
~cAudio(void);
|
~cAudio(void);
|
||||||
int64_t getPts()
|
int64_t getPts() { return curr_pts; }
|
||||||
{
|
|
||||||
return curr_pts;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *GetHandle()
|
void *GetHandle() { return NULL; };
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
};
|
|
||||||
/* shut up */
|
/* shut up */
|
||||||
int mute(bool remember = true)
|
int mute(bool remember = true) { return do_mute(true, remember); };
|
||||||
{
|
int unmute(bool remember = true) { return do_mute(false, remember); };
|
||||||
return do_mute(true, remember);
|
|
||||||
};
|
|
||||||
int unmute(bool remember = true)
|
|
||||||
{
|
|
||||||
return do_mute(false, remember);
|
|
||||||
};
|
|
||||||
|
|
||||||
/* volume, min = 0, max = 255 */
|
/* volume, min = 0, max = 255 */
|
||||||
int setVolume(unsigned int left, unsigned int right);
|
int setVolume(unsigned int left, unsigned int right);
|
||||||
int getVolume(void)
|
int getVolume(void) { return volume; }
|
||||||
{
|
bool getMuteStatus(void) { return Muted; };
|
||||||
return volume;
|
|
||||||
}
|
|
||||||
bool getMuteStatus(void)
|
|
||||||
{
|
|
||||||
return Muted;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* start and stop audio */
|
/* start and stop audio */
|
||||||
int Start(void);
|
int Start(void);
|
||||||
|
@@ -45,7 +45,7 @@ extern cVideo *videoDecoder;
|
|||||||
|
|
||||||
#define dmx_err(_errfmt, _errstr, _revents) do { \
|
#define dmx_err(_errfmt, _errstr, _revents) do { \
|
||||||
hal_info("%s " _errfmt " fd:%d, ev:0x%x %s pid:0x%04hx flt:0x%02hx\n", \
|
hal_info("%s " _errfmt " fd:%d, ev:0x%x %s pid:0x%04hx flt:0x%02hx\n", \
|
||||||
__func__, _errstr, fd, _revents, DMX_T[dmx_type], pid, flt); \
|
__func__, _errstr, fd, _revents, DMX_T[dmx_type], pid, flt); \
|
||||||
} while(0);
|
} while(0);
|
||||||
|
|
||||||
cDemux *videoDemux = NULL;
|
cDemux *videoDemux = NULL;
|
||||||
@@ -111,13 +111,13 @@ bool cDemux::Open(DMX_CHANNEL_TYPE pes_type, void * /*hVideoBuffer*/, int uBuffe
|
|||||||
hal_info("%s %s: %m\n", __FUNCTION__, devname[devnum]);
|
hal_info("%s %s: %m\n", __FUNCTION__, devname[devnum]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
hal_debug("%s #%d pes_type: %s(%d), uBufferSize: %d fd: %d\n", __func__,
|
hal_debug("%s #%d pes_type: %s(%d), uBufferSize: %d fd: %d\n",
|
||||||
num, DMX_T[pes_type], pes_type, uBufferSize, fd);
|
__func__, num, DMX_T[pes_type], pes_type, uBufferSize, fd);
|
||||||
|
|
||||||
if (dmx_type == DMX_VIDEO_CHANNEL)
|
if (dmx_type == DMX_VIDEO_CHANNEL)
|
||||||
uBufferSize = 0x100000; /* 1MB */
|
uBufferSize = 0x100000; /* 1MB */
|
||||||
if (dmx_type == DMX_AUDIO_CHANNEL)
|
if (dmx_type == DMX_AUDIO_CHANNEL)
|
||||||
uBufferSize = 0x10000; /* 64k */
|
uBufferSize = 0x10000; /* 64k */
|
||||||
#if 0
|
#if 0
|
||||||
if (!pesfds.empty())
|
if (!pesfds.empty())
|
||||||
{
|
{
|
||||||
@@ -192,7 +192,7 @@ int cDemux::Read(unsigned char *buff, int len, int timeout)
|
|||||||
#if 0
|
#if 0
|
||||||
if (len != 4095 && timeout != 100)
|
if (len != 4095 && timeout != 100)
|
||||||
fprintf(stderr, "cDemux::%s #%d fd: %d type: %s len: %d timeout: %d\n",
|
fprintf(stderr, "cDemux::%s #%d fd: %d type: %s len: %d timeout: %d\n",
|
||||||
__FUNCTION__, num, fd, DMX_T[dmx_type], len, timeout);
|
__FUNCTION__, num, fd, DMX_T[dmx_type], len, timeout);
|
||||||
#endif
|
#endif
|
||||||
int rc;
|
int rc;
|
||||||
struct pollfd ufds;
|
struct pollfd ufds;
|
||||||
@@ -244,8 +244,8 @@ retry:
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool cDemux::sectionFilter(unsigned short _pid, const unsigned char *const filter,
|
bool cDemux::sectionFilter(unsigned short _pid, const unsigned char *const filter,
|
||||||
const unsigned char *const mask, int len, int timeout,
|
const unsigned char *const mask, int len, int timeout,
|
||||||
const unsigned char *const negmask)
|
const unsigned char *const negmask)
|
||||||
{
|
{
|
||||||
struct dmx_sct_filter_params s_flt;
|
struct dmx_sct_filter_params s_flt;
|
||||||
memset(&s_flt, 0, sizeof(s_flt));
|
memset(&s_flt, 0, sizeof(s_flt));
|
||||||
@@ -260,7 +260,7 @@ bool cDemux::sectionFilter(unsigned short _pid, const unsigned char *const filte
|
|||||||
s_flt.pid = pid;
|
s_flt.pid = pid;
|
||||||
s_flt.timeout = timeout;
|
s_flt.timeout = timeout;
|
||||||
memcpy(s_flt.filter.filter, filter, len);
|
memcpy(s_flt.filter.filter, filter, len);
|
||||||
memcpy(s_flt.filter.mask, mask, len);
|
memcpy(s_flt.filter.mask, mask, len);
|
||||||
if (negmask != NULL)
|
if (negmask != NULL)
|
||||||
memcpy(s_flt.filter.mode, negmask, len);
|
memcpy(s_flt.filter.mode, negmask, len);
|
||||||
|
|
||||||
@@ -310,7 +310,7 @@ bool cDemux::sectionFilter(unsigned short _pid, const unsigned char *const filte
|
|||||||
/* 0x60 - 0x6F: event_information_section - other_transport_stream, schedule */
|
/* 0x60 - 0x6F: event_information_section - other_transport_stream, schedule */
|
||||||
case 0x70: /* time_date_section */
|
case 0x70: /* time_date_section */
|
||||||
s_flt.flags &= ~DMX_CHECK_CRC; /* section has no CRC */
|
s_flt.flags &= ~DMX_CHECK_CRC; /* section has no CRC */
|
||||||
//s_flt.pid = 0x0014;
|
//s_flt.pid = 0x0014;
|
||||||
to = 30000;
|
to = 30000;
|
||||||
break;
|
break;
|
||||||
case 0x71: /* running_status_section */
|
case 0x71: /* running_status_section */
|
||||||
@@ -322,7 +322,7 @@ bool cDemux::sectionFilter(unsigned short _pid, const unsigned char *const filte
|
|||||||
to = 0;
|
to = 0;
|
||||||
break;
|
break;
|
||||||
case 0x73: /* time_offset_section */
|
case 0x73: /* time_offset_section */
|
||||||
//s_flt.pid = 0x0014;
|
//s_flt.pid = 0x0014;
|
||||||
to = 30000;
|
to = 30000;
|
||||||
break;
|
break;
|
||||||
/* 0x74 - 0x7D: reserved for future use */
|
/* 0x74 - 0x7D: reserved for future use */
|
||||||
@@ -346,8 +346,8 @@ bool cDemux::sectionFilter(unsigned short _pid, const unsigned char *const filte
|
|||||||
if (timeout == 0 && negmask == NULL)
|
if (timeout == 0 && negmask == NULL)
|
||||||
s_flt.timeout = to;
|
s_flt.timeout = to;
|
||||||
|
|
||||||
hal_debug("%s #%d pid:0x%04hx fd:%d type:%s len:%d to:%d flags:%x flt[0]:%02x\n", __func__, num,
|
hal_debug("%s #%d pid:0x%04hx fd:%d type:%s len:%d to:%d flags:%x flt[0]:%02x\n",
|
||||||
pid, fd, DMX_T[dmx_type], len, s_flt.timeout, s_flt.flags, s_flt.filter.filter[0]);
|
__func__, num, pid, fd, DMX_T[dmx_type], len, s_flt.timeout, s_flt.flags, s_flt.filter.filter[0]);
|
||||||
|
|
||||||
if (debuglevel == 2)
|
if (debuglevel == 2)
|
||||||
{
|
{
|
||||||
@@ -355,10 +355,10 @@ bool cDemux::sectionFilter(unsigned short _pid, const unsigned char *const filte
|
|||||||
for (int i = 0; i < DMX_FILTER_SIZE; i++)fprintf(stderr, "%02hhx ", s_flt.filter.filter[i]);
|
for (int i = 0; i < DMX_FILTER_SIZE; i++)fprintf(stderr, "%02hhx ", s_flt.filter.filter[i]);
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
fprintf(stderr, "mask: ");
|
fprintf(stderr, "mask: ");
|
||||||
for (int i = 0; i < DMX_FILTER_SIZE; i++)fprintf(stderr, "%02hhx ", s_flt.filter.mask [i]);
|
for (int i = 0; i < DMX_FILTER_SIZE; i++)fprintf(stderr, "%02hhx ", s_flt.filter.mask[i]);
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
fprintf(stderr, "mode: ");
|
fprintf(stderr, "mode: ");
|
||||||
for (int i = 0; i < DMX_FILTER_SIZE; i++)fprintf(stderr, "%02hhx ", s_flt.filter.mode [i]);
|
for (int i = 0; i < DMX_FILTER_SIZE; i++)fprintf(stderr, "%02hhx ", s_flt.filter.mode[i]);
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -378,7 +378,7 @@ bool cDemux::pesFilter(const unsigned short _pid)
|
|||||||
* this check originally is from tuxbox cvs but I'm not sure
|
* this check originally is from tuxbox cvs but I'm not sure
|
||||||
* what it is good for...
|
* what it is good for...
|
||||||
if (pid <= 0x0001 && dmx_type != DMX_PCR_ONLY_CHANNEL)
|
if (pid <= 0x0001 && dmx_type != DMX_PCR_ONLY_CHANNEL)
|
||||||
return false;
|
return false;
|
||||||
*/
|
*/
|
||||||
if ((pid >= 0x0002 && pid <= 0x000f) || pid >= 0x1fff)
|
if ((pid >= 0x0002 && pid <= 0x000f) || pid >= 0x1fff)
|
||||||
return false;
|
return false;
|
||||||
@@ -388,30 +388,30 @@ bool cDemux::pesFilter(const unsigned short _pid)
|
|||||||
memset(&p_flt, 0, sizeof(p_flt));
|
memset(&p_flt, 0, sizeof(p_flt));
|
||||||
p_flt.pid = pid;
|
p_flt.pid = pid;
|
||||||
p_flt.output = DMX_OUT_DECODER;
|
p_flt.output = DMX_OUT_DECODER;
|
||||||
p_flt.input = DMX_IN_FRONTEND;
|
p_flt.input = DMX_IN_FRONTEND;
|
||||||
|
|
||||||
switch (dmx_type)
|
switch (dmx_type)
|
||||||
{
|
{
|
||||||
case DMX_PCR_ONLY_CHANNEL:
|
case DMX_PCR_ONLY_CHANNEL:
|
||||||
p_flt.pes_type = DMX_PES_OTHER;
|
p_flt.pes_type = DMX_PES_OTHER;
|
||||||
p_flt.output = DMX_OUT_TAP;
|
p_flt.output = DMX_OUT_TAP;
|
||||||
return true;
|
return true;
|
||||||
break;
|
break;
|
||||||
case DMX_AUDIO_CHANNEL:
|
case DMX_AUDIO_CHANNEL:
|
||||||
p_flt.pes_type = DMX_PES_OTHER;
|
p_flt.pes_type = DMX_PES_OTHER;
|
||||||
p_flt.output = DMX_OUT_TSDEMUX_TAP;
|
p_flt.output = DMX_OUT_TSDEMUX_TAP;
|
||||||
break;
|
break;
|
||||||
case DMX_VIDEO_CHANNEL:
|
case DMX_VIDEO_CHANNEL:
|
||||||
p_flt.pes_type = DMX_PES_OTHER;
|
p_flt.pes_type = DMX_PES_OTHER;
|
||||||
p_flt.output = DMX_OUT_TSDEMUX_TAP;
|
p_flt.output = DMX_OUT_TSDEMUX_TAP;
|
||||||
break;
|
break;
|
||||||
case DMX_PES_CHANNEL:
|
case DMX_PES_CHANNEL:
|
||||||
p_flt.pes_type = DMX_PES_OTHER;
|
p_flt.pes_type = DMX_PES_OTHER;
|
||||||
p_flt.output = DMX_OUT_TAP;
|
p_flt.output = DMX_OUT_TAP;
|
||||||
break;
|
break;
|
||||||
case DMX_TP_CHANNEL:
|
case DMX_TP_CHANNEL:
|
||||||
p_flt.pes_type = DMX_PES_OTHER;
|
p_flt.pes_type = DMX_PES_OTHER;
|
||||||
p_flt.output = DMX_OUT_TSDEMUX_TAP;
|
p_flt.output = DMX_OUT_TSDEMUX_TAP;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
hal_info("%s #%d invalid dmx_type %d!\n", __func__, num, dmx_type);
|
hal_info("%s #%d invalid dmx_type %d!\n", __func__, num, dmx_type);
|
||||||
|
@@ -32,6 +32,7 @@ class cDemux
|
|||||||
{
|
{
|
||||||
friend class cRecord;
|
friend class cRecord;
|
||||||
friend class cPlayback;
|
friend class cPlayback;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool Open(DMX_CHANNEL_TYPE pes_type, void *x = NULL, int y = 0);
|
bool Open(DMX_CHANNEL_TYPE pes_type, void *x = NULL, int y = 0);
|
||||||
void Close(void);
|
void Close(void);
|
||||||
@@ -43,19 +44,13 @@ class cDemux
|
|||||||
void SetSyncMode(AVSYNC_TYPE mode);
|
void SetSyncMode(AVSYNC_TYPE mode);
|
||||||
void *getBuffer();
|
void *getBuffer();
|
||||||
void *getChannel();
|
void *getChannel();
|
||||||
DMX_CHANNEL_TYPE getChannelType(void)
|
DMX_CHANNEL_TYPE getChannelType(void) { return dmx_type; };
|
||||||
{
|
|
||||||
return dmx_type;
|
|
||||||
};
|
|
||||||
bool addPid(unsigned short pid);
|
bool addPid(unsigned short pid);
|
||||||
void getSTC(int64_t *STC);
|
void getSTC(int64_t *STC);
|
||||||
int getUnit(void);
|
int getUnit(void);
|
||||||
static bool SetSource(int unit, int source);
|
static bool SetSource(int unit, int source);
|
||||||
static int GetSource(int unit);
|
static int GetSource(int unit);
|
||||||
int getFD(void)
|
int getFD(void) { return fd; }; /* needed by cPlayback class */
|
||||||
{
|
|
||||||
return fd;
|
|
||||||
}; /* needed by cPlayback class */
|
|
||||||
cDemux(int num = 0);
|
cDemux(int num = 0);
|
||||||
~cDemux();
|
~cDemux();
|
||||||
|
|
||||||
|
@@ -50,10 +50,10 @@ static VC_IMAGE_TYPE_T type = VC_IMAGE_ARGB8888;
|
|||||||
static OpenThreads::Mutex blit_mutex;
|
static OpenThreads::Mutex blit_mutex;
|
||||||
static OpenThreads::Condition blit_cond;
|
static OpenThreads::Condition blit_cond;
|
||||||
|
|
||||||
static bool goodbye = false; /* if set main loop is left */
|
static bool goodbye = false; /* if set main loop is left */
|
||||||
static bool ready = false; /* condition predicate */
|
static bool ready = false; /* condition predicate */
|
||||||
|
|
||||||
static int width; /* width and height, fixed for a framebuffer instance */
|
static int width; /* width and height, fixed for a framebuffer instance */
|
||||||
static int height;
|
static int height;
|
||||||
|
|
||||||
GLFramebuffer::GLFramebuffer(int x, int y)
|
GLFramebuffer::GLFramebuffer(int x, int y)
|
||||||
@@ -126,7 +126,7 @@ void GLFramebuffer::setup()
|
|||||||
/* 32bit FB depth, *2 because tuxtxt uses a shadow buffer */
|
/* 32bit FB depth, *2 because tuxtxt uses a shadow buffer */
|
||||||
osd_buf.resize(pitch * height * 2);
|
osd_buf.resize(pitch * height * 2);
|
||||||
hal_info("GLFB: Display is %d x %d, FB is %d x %d, memory size %d\n",
|
hal_info("GLFB: Display is %d x %d, FB is %d x %d, memory size %d\n",
|
||||||
info.width, info.height, width, height, osd_buf.size());
|
info.width, info.height, width, height, osd_buf.size());
|
||||||
image = &osd_buf[0];
|
image = &osd_buf[0];
|
||||||
/* initialize to half-transparent grey */
|
/* initialize to half-transparent grey */
|
||||||
memset(image, 0x7f, osd_buf.size());
|
memset(image, 0x7f, osd_buf.size());
|
||||||
@@ -143,15 +143,15 @@ void GLFramebuffer::setup()
|
|||||||
vc_dispmanx_rect_set(&src_rect, 0, 0, width << 16, height << 16);
|
vc_dispmanx_rect_set(&src_rect, 0, 0, width << 16, height << 16);
|
||||||
vc_dispmanx_rect_set(&dsp_rect, 0, 0, info.width, info.height);
|
vc_dispmanx_rect_set(&dsp_rect, 0, 0, info.width, info.height);
|
||||||
element = vc_dispmanx_element_add(update,
|
element = vc_dispmanx_element_add(update,
|
||||||
display,
|
display,
|
||||||
2000 /*layer*/,
|
2000 /*layer*/,
|
||||||
&dsp_rect,
|
&dsp_rect,
|
||||||
res[curr_res],
|
res[curr_res],
|
||||||
&src_rect,
|
&src_rect,
|
||||||
DISPMANX_PROTECTION_NONE,
|
DISPMANX_PROTECTION_NONE,
|
||||||
&alpha,
|
&alpha,
|
||||||
NULL,
|
NULL,
|
||||||
DISPMANX_NO_ROTATE);
|
DISPMANX_NO_ROTATE);
|
||||||
ret = vc_dispmanx_update_submit_sync(update);
|
ret = vc_dispmanx_update_submit_sync(update);
|
||||||
CHECK(ret == 0);
|
CHECK(ret == 0);
|
||||||
curr_res = !curr_res;
|
curr_res = !curr_res;
|
||||||
|
@@ -26,18 +26,12 @@ class GLFramebuffer : public OpenThreads::Thread
|
|||||||
public:
|
public:
|
||||||
GLFramebuffer(int x, int y);
|
GLFramebuffer(int x, int y);
|
||||||
~GLFramebuffer();
|
~GLFramebuffer();
|
||||||
std::vector<unsigned char> *getOSDBuffer()
|
std::vector<unsigned char> *getOSDBuffer() { return &osd_buf; } /* pointer to OSD bounce buffer */
|
||||||
{
|
|
||||||
return &osd_buf; /* pointer to OSD bounce buffer */
|
|
||||||
}
|
|
||||||
void blit();
|
void blit();
|
||||||
fb_var_screeninfo getScreenInfo()
|
fb_var_screeninfo getScreenInfo() { return si; }
|
||||||
{
|
|
||||||
return si;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void *pdata; /* not yet used */
|
void *pdata; /* not yet used */
|
||||||
fb_var_screeninfo si;
|
fb_var_screeninfo si;
|
||||||
std::vector<unsigned char> osd_buf; /* silly bounce buffer */
|
std::vector<unsigned char> osd_buf; /* silly bounce buffer */
|
||||||
void run(); /* for OpenThreads::Thread */
|
void run(); /* for OpenThreads::Thread */
|
||||||
|
@@ -29,7 +29,7 @@ hw_caps_t *get_hwcaps(void)
|
|||||||
caps.can_pip = 1;
|
caps.can_pip = 1;
|
||||||
|
|
||||||
caps.can_cpufreq = 0;
|
caps.can_cpufreq = 0;
|
||||||
caps.can_shutdown = 1; /* for testing */
|
caps.can_shutdown = 1; /* for testing */
|
||||||
caps.display_type = HW_DISPLAY_LINE_TEXT;
|
caps.display_type = HW_DISPLAY_LINE_TEXT;
|
||||||
caps.has_HDMI = 1;
|
caps.has_HDMI = 1;
|
||||||
caps.display_xres = 8;
|
caps.display_xres = 8;
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
* for the Raspberry Pi
|
* for the Raspberry Pi
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@@ -49,24 +50,24 @@ static keymap_t kmap;
|
|||||||
static void init_keymap(void)
|
static void init_keymap(void)
|
||||||
{
|
{
|
||||||
/* same as generic-pc/glfb.cpp */
|
/* same as generic-pc/glfb.cpp */
|
||||||
kmap[KEY_ENTER] = KEY_OK;
|
kmap[KEY_ENTER] = KEY_OK;
|
||||||
kmap[KEY_ESC] = KEY_EXIT;
|
kmap[KEY_ESC] = KEY_EXIT;
|
||||||
kmap[KEY_E] = KEY_EPG;
|
kmap[KEY_E] = KEY_EPG;
|
||||||
kmap[KEY_I] = KEY_INFO;
|
kmap[KEY_I] = KEY_INFO;
|
||||||
kmap[KEY_M] = KEY_MENU;
|
kmap[KEY_M] = KEY_MENU;
|
||||||
kmap[KEY_F12] = KEY_VOLUMEUP; /* different than glfb, as we */
|
kmap[KEY_F12] = KEY_VOLUMEUP; /* different than glfb, as we */
|
||||||
kmap[KEY_F11] = KEY_VOLUMEDOWN; /* don't consider the keyboard */
|
kmap[KEY_F11] = KEY_VOLUMEDOWN; /* don't consider the keyboard */
|
||||||
kmap[KEY_F10] = KEY_MUTE; /* layout... */
|
kmap[KEY_F10] = KEY_MUTE; /* layout... */
|
||||||
kmap[KEY_H] = KEY_HELP;
|
kmap[KEY_H] = KEY_HELP;
|
||||||
kmap[KEY_P] = KEY_POWER;
|
kmap[KEY_P] = KEY_POWER;
|
||||||
kmap[KEY_F1] = KEY_RED;
|
kmap[KEY_F1] = KEY_RED;
|
||||||
kmap[KEY_F2] = KEY_GREEN;
|
kmap[KEY_F2] = KEY_GREEN;
|
||||||
kmap[KEY_F3] = KEY_YELLOW;
|
kmap[KEY_F3] = KEY_YELLOW;
|
||||||
kmap[KEY_F4] = KEY_BLUE;
|
kmap[KEY_F4] = KEY_BLUE;
|
||||||
kmap[KEY_F5] = KEY_WWW;
|
kmap[KEY_F5] = KEY_WWW;
|
||||||
kmap[KEY_F6] = KEY_SUBTITLE;
|
kmap[KEY_F6] = KEY_SUBTITLE;
|
||||||
kmap[KEY_F7] = KEY_MOVE;
|
kmap[KEY_F7] = KEY_MOVE;
|
||||||
kmap[KEY_F8] = KEY_SLEEP;
|
kmap[KEY_F8] = KEY_SLEEP;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Input: public OpenThreads::Thread
|
class Input: public OpenThreads::Thread
|
||||||
|
@@ -173,7 +173,7 @@ int cVideo::SetStreamType(VIDEO_FORMAT v)
|
|||||||
bool cVideo::GetScreenImage(unsigned char *&data, int &xres, int &yres, bool get_video, bool get_osd, bool scale_to_video)
|
bool cVideo::GetScreenImage(unsigned char *&data, int &xres, int &yres, bool get_video, bool get_osd, bool scale_to_video)
|
||||||
{
|
{
|
||||||
hal_info("%s: data 0x%p xres %d yres %d vid %d osd %d scale %d\n",
|
hal_info("%s: data 0x%p xres %d yres %d vid %d osd %d scale %d\n",
|
||||||
__func__, data, xres, yres, get_video, get_osd, scale_to_video);
|
__func__, data, xres, yres, get_video, get_osd, scale_to_video);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -105,7 +105,7 @@ typedef enum
|
|||||||
VIDEO_STD_1080P24,
|
VIDEO_STD_1080P24,
|
||||||
VIDEO_STD_1080P25,
|
VIDEO_STD_1080P25,
|
||||||
VIDEO_STD_AUTO,
|
VIDEO_STD_AUTO,
|
||||||
VIDEO_STD_1080P50, /* SPARK only */
|
VIDEO_STD_1080P50, /* SPARK only */
|
||||||
VIDEO_STD_MAX
|
VIDEO_STD_MAX
|
||||||
} VIDEO_STD;
|
} VIDEO_STD;
|
||||||
|
|
||||||
@@ -133,44 +133,21 @@ class cVideo
|
|||||||
{
|
{
|
||||||
friend class GLFramebuffer;
|
friend class GLFramebuffer;
|
||||||
friend class cDemux;
|
friend class cDemux;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/* called from GL thread */
|
/* called from GL thread */
|
||||||
class SWFramebuffer : public std::vector<unsigned char>
|
class SWFramebuffer : public std::vector<unsigned char>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SWFramebuffer() : mWidth(0), mHeight(0) {}
|
SWFramebuffer() : mWidth(0), mHeight(0) {}
|
||||||
void width(int w)
|
void width(int w) { mWidth = w; }
|
||||||
{
|
void height(int h) { mHeight = h; }
|
||||||
mWidth = w;
|
void pts(uint64_t p) { mPts = p; }
|
||||||
}
|
void AR(AVRational a) { mAR = a; }
|
||||||
void height(int h)
|
int width() const { return mWidth; }
|
||||||
{
|
int height() const { return mHeight; }
|
||||||
mHeight = h;
|
int64_t pts() const { return mPts; }
|
||||||
}
|
AVRational AR() const { return mAR; }
|
||||||
void pts(uint64_t p)
|
|
||||||
{
|
|
||||||
mPts = p;
|
|
||||||
}
|
|
||||||
void AR(AVRational a)
|
|
||||||
{
|
|
||||||
mAR = a;
|
|
||||||
}
|
|
||||||
int width() const
|
|
||||||
{
|
|
||||||
return mWidth;
|
|
||||||
}
|
|
||||||
int height() const
|
|
||||||
{
|
|
||||||
return mHeight;
|
|
||||||
}
|
|
||||||
int64_t pts() const
|
|
||||||
{
|
|
||||||
return mPts;
|
|
||||||
}
|
|
||||||
AVRational AR() const
|
|
||||||
{
|
|
||||||
return mAR;
|
|
||||||
}
|
|
||||||
private:
|
private:
|
||||||
int mWidth;
|
int mWidth;
|
||||||
int mHeight;
|
int mHeight;
|
||||||
@@ -179,19 +156,14 @@ class cVideo
|
|||||||
};
|
};
|
||||||
int buf_in, buf_out, buf_num;
|
int buf_in, buf_out, buf_num;
|
||||||
int64_t GetPTS(void);
|
int64_t GetPTS(void);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/* constructor & destructor */
|
/* constructor & destructor */
|
||||||
cVideo(int mode, void *, void *, unsigned int unit = 0);
|
cVideo(int mode, void *, void *, unsigned int unit = 0);
|
||||||
~cVideo(void);
|
~cVideo(void);
|
||||||
|
|
||||||
void *GetTVEnc()
|
void *GetTVEnc() { return NULL; };
|
||||||
{
|
void *GetTVEncSD() { return NULL; };
|
||||||
return NULL;
|
|
||||||
};
|
|
||||||
void *GetTVEncSD()
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* aspect ratio */
|
/* aspect ratio */
|
||||||
int getAspectRatio(void);
|
int getAspectRatio(void);
|
||||||
@@ -217,58 +189,26 @@ class cVideo
|
|||||||
int SetVideoSystem(int video_system, bool remember = true);
|
int SetVideoSystem(int video_system, bool remember = true);
|
||||||
int SetStreamType(VIDEO_FORMAT type);
|
int SetStreamType(VIDEO_FORMAT type);
|
||||||
void SetSyncMode(AVSYNC_TYPE mode);
|
void SetSyncMode(AVSYNC_TYPE mode);
|
||||||
bool SetCECMode(VIDEO_HDMI_CEC_MODE)
|
bool SetCECMode(VIDEO_HDMI_CEC_MODE) { return true; };
|
||||||
{
|
void SetCECAutoView(bool) { return; };
|
||||||
return true;
|
void SetCECAutoStandby(bool) { return; };
|
||||||
};
|
|
||||||
void SetCECAutoView(bool)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
void SetCECAutoStandby(bool)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
bool ShowPicture(const char *fname);
|
bool ShowPicture(const char *fname);
|
||||||
void StopPicture();
|
void StopPicture();
|
||||||
void Standby(unsigned int bOn);
|
void Standby(unsigned int bOn);
|
||||||
void Pig(int x, int y, int w, int h, int osd_w = 1064, int osd_h = 600);
|
void Pig(int x, int y, int w, int h, int osd_w = 1064, int osd_h = 600);
|
||||||
void SetControl(int, int)
|
void SetControl(int, int) { return; };
|
||||||
{
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
void setContrast(int val);
|
void setContrast(int val);
|
||||||
void SetVideoMode(analog_mode_t mode);
|
void SetVideoMode(analog_mode_t mode);
|
||||||
void SetDBDR(int)
|
void SetDBDR(int) { return; };
|
||||||
{
|
void SetAudioHandle(void *) { return; };
|
||||||
return;
|
void SetAutoModes(int [VIDEO_STD_MAX]) { return; };
|
||||||
};
|
int OpenVBI(int) { return 0; };
|
||||||
void SetAudioHandle(void *)
|
int CloseVBI(void) { return 0; };
|
||||||
{
|
int StartVBI(unsigned short) { return 0; };
|
||||||
return;
|
int StopVBI(void) { return 0; };
|
||||||
};
|
|
||||||
void SetAutoModes(int [VIDEO_STD_MAX])
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
int OpenVBI(int)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
};
|
|
||||||
int CloseVBI(void)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
};
|
|
||||||
int StartVBI(unsigned short)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
};
|
|
||||||
int StopVBI(void)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
};
|
|
||||||
void SetDemux(cDemux *dmx);
|
void SetDemux(cDemux *dmx);
|
||||||
bool GetScreenImage(unsigned char *&data, int &xres, int &yres, bool get_video = true, bool get_osd = false, bool scale_to_video = false);
|
bool GetScreenImage(unsigned char *&data, int &xres, int &yres, bool get_video = true, bool get_osd = false, bool scale_to_video = false);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SWFramebuffer buffers[VDEC_MAXBUFS];
|
SWFramebuffer buffers[VDEC_MAXBUFS];
|
||||||
int dec_w, dec_h;
|
int dec_w, dec_h;
|
||||||
|
@@ -270,8 +270,7 @@ void cRecord::RecordThread()
|
|||||||
if (toread > readsize)
|
if (toread > readsize)
|
||||||
toread = readsize;
|
toread = readsize;
|
||||||
ssize_t s = dmx->Read(buf + buf_pos, toread, 50);
|
ssize_t s = dmx->Read(buf + buf_pos, toread, 50);
|
||||||
hal_debug("%s: buf_pos %6d s %6d / %6d\n", __func__,
|
hal_debug("%s: buf_pos %6d s %6d / %6d\n", __func__, buf_pos, (int)s, bufsize - buf_pos);
|
||||||
buf_pos, (int)s, bufsize - buf_pos);
|
|
||||||
if (s < 0)
|
if (s < 0)
|
||||||
{
|
{
|
||||||
if (errno != EAGAIN && (errno != EOVERFLOW || !overflow))
|
if (errno != EAGAIN && (errno != EOVERFLOW || !overflow))
|
||||||
@@ -312,7 +311,7 @@ void cRecord::RecordThread()
|
|||||||
hal_debug("%s: aio in progress, free: %d\n", __func__, bufsize - buf_pos);
|
hal_debug("%s: aio in progress, free: %d\n", __func__, bufsize - buf_pos);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// not calling aio_return causes a memory leak --martii
|
// not calling aio_return causes a memory leak --martii
|
||||||
r = aio_return(&a);
|
r = aio_return(&a);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
{
|
{
|
||||||
|
@@ -16,7 +16,7 @@ typedef enum
|
|||||||
RECORD_FAILED_READ, /* failed to read from DMX */
|
RECORD_FAILED_READ, /* failed to read from DMX */
|
||||||
RECORD_FAILED_OVERFLOW, /* cannot write fast enough */
|
RECORD_FAILED_OVERFLOW, /* cannot write fast enough */
|
||||||
RECORD_FAILED_FILE, /* cannot write to file */
|
RECORD_FAILED_FILE, /* cannot write to file */
|
||||||
RECORD_FAILED_MEMORY /* out of memory */
|
RECORD_FAILED_MEMORY /* out of memory */
|
||||||
} record_state_t;
|
} record_state_t;
|
||||||
|
|
||||||
class cRecord
|
class cRecord
|
||||||
@@ -38,20 +38,17 @@ class cRecord
|
|||||||
#define RECORD_WRITER_CHUNKS 16
|
#define RECORD_WRITER_CHUNKS 16
|
||||||
unsigned char *io_buf[RECORD_WRITER_CHUNKS];
|
unsigned char *io_buf[RECORD_WRITER_CHUNKS];
|
||||||
size_t io_len[RECORD_WRITER_CHUNKS];
|
size_t io_len[RECORD_WRITER_CHUNKS];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
cRecord(int num = 0, int bs_dmx = 2048 * 1024, int bs = 4096 * 1024);
|
cRecord(int num = 0, int bs_dmx = 2048 * 1024, int bs = 4096 * 1024);
|
||||||
void setFailureCallback(void (*f)(void *), void *d)
|
void setFailureCallback(void (*f)(void *), void *d) { failureCallback = f; failureData = d; }
|
||||||
{
|
|
||||||
failureCallback = f;
|
|
||||||
failureData = d;
|
|
||||||
}
|
|
||||||
~cRecord();
|
~cRecord();
|
||||||
|
|
||||||
bool Open();
|
bool Open();
|
||||||
bool Start(int fd, unsigned short vpid, unsigned short *apids, int numapids, uint64_t ch = 0);
|
bool Start(int fd, unsigned short vpid, unsigned short *apids, int numapids, uint64_t ch = 0);
|
||||||
bool Stop(void);
|
bool Stop(void);
|
||||||
bool AddPid(unsigned short pid);
|
bool AddPid(unsigned short pid);
|
||||||
int GetStatus();
|
int GetStatus();
|
||||||
void ResetStatus();
|
void ResetStatus();
|
||||||
bool ChangePids(unsigned short vpid, unsigned short *apids, int numapids);
|
bool ChangePids(unsigned short vpid, unsigned short *apids, int numapids);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user