- formatting code using astyle

Conflicts:
	libarmbox/dmx.cpp
	libgeneric-pc/video_lib.h
	libspark/dmx.cpp

Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
svenhoefer
2021-05-17 23:47:39 +02:00
committed by Thilo Graf
parent 42264ba4af
commit 7e5b1fc5d2
161 changed files with 13043 additions and 11396 deletions

View File

@@ -27,7 +27,7 @@
#define hal_debug(args...) _hal_debug(HAL_DEBUG_AUDIO, this, args)
#define hal_info(args...) _hal_info(HAL_DEBUG_AUDIO, this, args)
cAudio * audioDecoder = NULL;
cAudio *audioDecoder = NULL;
cAudio::cAudio(void *, void *, void *)
{
@@ -114,12 +114,12 @@ int cAudio::StopClip()
void cAudio::getAudioInfo(int &type, int &layer, int &freq, int &bitrate, int &mode)
{
type = 0;
layer = 0; /* not used */
layer = 0; /* not used */
freq = 0;
bitrate = 0; /* not used, but easy to get :-) */
mode = 0; /* default: stereo */
bitrate = 0; /* not used, but easy to get :-) */
mode = 0; /* default: stereo */
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*/)

View File

@@ -13,7 +13,8 @@ typedef enum
AUDIO_SYNC_AUDIO_MASTER
} AUDIO_SYNC_MODE;
typedef enum {
typedef enum
{
HDMI_ENCODED_OFF,
HDMI_ENCODED_AUTO,
HDMI_ENCODED_FORCED
@@ -39,7 +40,7 @@ typedef enum
class cAudio
{
friend class cPlayback;
friend class cPlayback;
private:
int fd;
bool Muted;
@@ -48,7 +49,7 @@ class cAudio
int mixer_fd; /* if we are using the OSS mixer */
int mixer_num; /* oss mixer to use, if any */
AUDIO_FORMAT StreamType;
AUDIO_FORMAT StreamType;
AUDIO_SYNC_MODE SyncMode;
bool started;
bool thread_started;
@@ -66,17 +67,35 @@ class cAudio
/* construct & destruct */
cAudio(void *, void *, void *);
~cAudio(void);
int64_t getPts() { return curr_pts; }
int64_t getPts()
{
return curr_pts;
}
void *GetHandle() { return NULL; };
void *GetHandle()
{
return NULL;
};
/* shut up */
int mute(bool remember = true) { return do_mute(true, remember); };
int unmute(bool remember = true) { return do_mute(false, remember); };
int mute(bool remember = true)
{
return do_mute(true, remember);
};
int unmute(bool remember = true)
{
return do_mute(false, remember);
};
/* volume, min = 0, max = 255 */
int setVolume(unsigned int left, unsigned int right);
int getVolume(void) { return volume;}
bool getMuteStatus(void) { return Muted; };
int getVolume(void)
{
return volume;
}
bool getMuteStatus(void)
{
return Muted;
};
/* start and stop audio */
int Start(void);
@@ -88,9 +107,9 @@ class cAudio
/* select channels */
int setChannel(int channel);
int PrepareClipPlay(int uNoOfChannels, int uSampleRate, int uBitsPerSample, int bLittleEndian);
int WriteClip(unsigned char * buffer, int size);
int WriteClip(unsigned char *buffer, int size);
int StopClip();
void getAudioInfo(int &type, int &layer, int& freq, int &bitrate, int &mode);
void getAudioInfo(int &type, int &layer, int &freq, int &bitrate, int &mode);
void SetSRS(int iq_enable, int nmgr_enable, int iq_mode, int iq_level);
bool IsHdmiDDSupported();
void SetHdmiDD(bool enable);

View File

@@ -44,15 +44,16 @@ extern cVideo *videoDecoder;
#define hal_info_c(args...) _hal_info(HAL_DEBUG_DEMUX, NULL, args)
#define dmx_err(_errfmt, _errstr, _revents) do { \
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); \
} while(0);
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); \
} while(0);
cDemux *videoDemux = NULL;
cDemux *audioDemux = NULL;
//cDemux *pcrDemux = NULL;
static const char *DMX_T[] = {
static const char *DMX_T[] =
{
"DMX_INVALID",
"DMX_VIDEO",
"DMX_AUDIO",
@@ -64,7 +65,8 @@ static const char *DMX_T[] = {
};
/* map the device numbers. for now only demux0 is used */
static const char *devname[] = {
static const char *devname[] =
{
"/dev/dvb/adapter0/demux0",
"/dev/dvb/adapter0/demux0",
"/dev/dvb/adapter0/demux0"
@@ -95,7 +97,7 @@ cDemux::~cDemux()
bool cDemux::Open(DMX_CHANNEL_TYPE pes_type, void * /*hVideoBuffer*/, int uBufferSize)
{
int devnum = num;
int flags = O_RDWR|O_CLOEXEC;
int flags = O_RDWR | O_CLOEXEC;
if (fd > -1)
hal_info("%s FD ALREADY OPENED? fd = %d\n", __FUNCTION__, fd);
@@ -110,12 +112,12 @@ bool cDemux::Open(DMX_CHANNEL_TYPE pes_type, void * /*hVideoBuffer*/, int uBuffe
return false;
}
hal_debug("%s #%d pes_type: %s(%d), uBufferSize: %d fd: %d\n", __func__,
num, DMX_T[pes_type], pes_type, uBufferSize, fd);
num, DMX_T[pes_type], pes_type, uBufferSize, fd);
if (dmx_type == DMX_VIDEO_CHANNEL)
uBufferSize = 0x100000; /* 1MB */
uBufferSize = 0x100000; /* 1MB */
if (dmx_type == DMX_AUDIO_CHANNEL)
uBufferSize = 0x10000; /* 64k */
uBufferSize = 0x10000; /* 64k */
#if 0
if (!pesfds.empty())
{
@@ -190,17 +192,17 @@ int cDemux::Read(unsigned char *buff, int len, int timeout)
#if 0
if (len != 4095 && timeout != 100)
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
int rc;
struct pollfd ufds;
ufds.fd = fd;
ufds.events = POLLIN|POLLPRI|POLLERR;
ufds.events = POLLIN | POLLPRI | POLLERR;
ufds.revents = 0;
if (timeout > 0)
{
retry:
retry:
rc = ::poll(&ufds, 1, timeout);
if (!rc)
return 0; // timeout
@@ -241,9 +243,9 @@ int cDemux::Read(unsigned char *buff, int len, int timeout)
return rc;
}
bool cDemux::sectionFilter(unsigned short _pid, const unsigned char * const filter,
const unsigned char * const mask, int len, int timeout,
const unsigned char * const negmask)
bool cDemux::sectionFilter(unsigned short _pid, const unsigned char *const filter,
const unsigned char *const mask, int len, int timeout,
const unsigned char *const negmask)
{
struct dmx_sct_filter_params s_flt;
memset(&s_flt, 0, sizeof(s_flt));
@@ -262,79 +264,80 @@ bool cDemux::sectionFilter(unsigned short _pid, const unsigned char * const filt
if (negmask != NULL)
memcpy(s_flt.filter.mode, negmask, len);
s_flt.flags = DMX_IMMEDIATE_START|DMX_CHECK_CRC;
s_flt.flags = DMX_IMMEDIATE_START | DMX_CHECK_CRC;
int to = 0;
switch (filter[0]) {
case 0x00: /* program_association_section */
to = 2000;
break;
case 0x01: /* conditional_access_section */
to = 6000;
break;
case 0x02: /* program_map_section */
to = 1500;
break;
case 0x03: /* transport_stream_description_section */
to = 10000;
break;
/* 0x04 - 0x3F: reserved */
case 0x40: /* network_information_section - actual_network */
to = 10000;
break;
case 0x41: /* network_information_section - other_network */
to = 15000;
break;
case 0x42: /* service_description_section - actual_transport_stream */
to = 10000;
break;
/* 0x43 - 0x45: reserved for future use */
case 0x46: /* service_description_section - other_transport_stream */
to = 10000;
break;
/* 0x47 - 0x49: reserved for future use */
case 0x4A: /* bouquet_association_section */
to = 11000;
break;
/* 0x4B - 0x4D: reserved for future use */
case 0x4E: /* event_information_section - actual_transport_stream, present/following */
to = 2000;
break;
case 0x4F: /* event_information_section - other_transport_stream, present/following */
to = 10000;
break;
/* 0x50 - 0x5F: event_information_section - actual_transport_stream, schedule */
/* 0x60 - 0x6F: event_information_section - other_transport_stream, schedule */
case 0x70: /* time_date_section */
s_flt.flags &= ~DMX_CHECK_CRC; /* section has no CRC */
//s_flt.pid = 0x0014;
to = 30000;
break;
case 0x71: /* running_status_section */
s_flt.flags &= ~DMX_CHECK_CRC; /* section has no CRC */
to = 0;
break;
case 0x72: /* stuffing_section */
s_flt.flags &= ~DMX_CHECK_CRC; /* section has no CRC */
to = 0;
break;
case 0x73: /* time_offset_section */
//s_flt.pid = 0x0014;
to = 30000;
break;
/* 0x74 - 0x7D: reserved for future use */
case 0x7E: /* discontinuity_information_section */
s_flt.flags &= ~DMX_CHECK_CRC; /* section has no CRC */
to = 0;
break;
case 0x7F: /* selection_information_section */
to = 0;
break;
/* 0x80 - 0x8F: ca_message_section */
/* 0x90 - 0xFE: user defined */
/* 0xFF: reserved */
default:
break;
switch (filter[0])
{
case 0x00: /* program_association_section */
to = 2000;
break;
case 0x01: /* conditional_access_section */
to = 6000;
break;
case 0x02: /* program_map_section */
to = 1500;
break;
case 0x03: /* transport_stream_description_section */
to = 10000;
break;
/* 0x04 - 0x3F: reserved */
case 0x40: /* network_information_section - actual_network */
to = 10000;
break;
case 0x41: /* network_information_section - other_network */
to = 15000;
break;
case 0x42: /* service_description_section - actual_transport_stream */
to = 10000;
break;
/* 0x43 - 0x45: reserved for future use */
case 0x46: /* service_description_section - other_transport_stream */
to = 10000;
break;
/* 0x47 - 0x49: reserved for future use */
case 0x4A: /* bouquet_association_section */
to = 11000;
break;
/* 0x4B - 0x4D: reserved for future use */
case 0x4E: /* event_information_section - actual_transport_stream, present/following */
to = 2000;
break;
case 0x4F: /* event_information_section - other_transport_stream, present/following */
to = 10000;
break;
/* 0x50 - 0x5F: event_information_section - actual_transport_stream, schedule */
/* 0x60 - 0x6F: event_information_section - other_transport_stream, schedule */
case 0x70: /* time_date_section */
s_flt.flags &= ~DMX_CHECK_CRC; /* section has no CRC */
//s_flt.pid = 0x0014;
to = 30000;
break;
case 0x71: /* running_status_section */
s_flt.flags &= ~DMX_CHECK_CRC; /* section has no CRC */
to = 0;
break;
case 0x72: /* stuffing_section */
s_flt.flags &= ~DMX_CHECK_CRC; /* section has no CRC */
to = 0;
break;
case 0x73: /* time_offset_section */
//s_flt.pid = 0x0014;
to = 30000;
break;
/* 0x74 - 0x7D: reserved for future use */
case 0x7E: /* discontinuity_information_section */
s_flt.flags &= ~DMX_CHECK_CRC; /* section has no CRC */
to = 0;
break;
case 0x7F: /* selection_information_section */
to = 0;
break;
/* 0x80 - 0x8F: ca_message_section */
/* 0x90 - 0xFE: user defined */
/* 0xFF: reserved */
default:
break;
// return -1;
}
/* the negmask == NULL is a hack: the users of negmask are PMT-update
@@ -344,15 +347,22 @@ bool cDemux::sectionFilter(unsigned short _pid, const unsigned char * const filt
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,
pid, fd, DMX_T[dmx_type], len, s_flt.timeout,s_flt.flags, s_flt.filter.filter[0]);
pid, fd, DMX_T[dmx_type], len, s_flt.timeout, s_flt.flags, s_flt.filter.filter[0]);
if (debuglevel == 2) {
fprintf(stderr,"filt: ");for(int i=0;i<DMX_FILTER_SIZE;i++)fprintf(stderr,"%02hhx ",s_flt.filter.filter[i]);fprintf(stderr,"\n");
fprintf(stderr,"mask: ");for(int i=0;i<DMX_FILTER_SIZE;i++)fprintf(stderr,"%02hhx ",s_flt.filter.mask [i]);fprintf(stderr,"\n");
fprintf(stderr,"mode: ");for(int i=0;i<DMX_FILTER_SIZE;i++)fprintf(stderr,"%02hhx ",s_flt.filter.mode [i]);fprintf(stderr,"\n");
if (debuglevel == 2)
{
fprintf(stderr, "filt: ");
for (int i = 0; i < DMX_FILTER_SIZE; i++)fprintf(stderr, "%02hhx ", s_flt.filter.filter[i]);
fprintf(stderr, "\n");
fprintf(stderr, "mask: ");
for (int i = 0; i < DMX_FILTER_SIZE; i++)fprintf(stderr, "%02hhx ", s_flt.filter.mask [i]);
fprintf(stderr, "\n");
fprintf(stderr, "mode: ");
for (int i = 0; i < DMX_FILTER_SIZE; i++)fprintf(stderr, "%02hhx ", s_flt.filter.mode [i]);
fprintf(stderr, "\n");
}
ioctl (fd, DMX_STOP);
ioctl(fd, DMX_STOP);
if (ioctl(fd, DMX_SET_FILTER, &s_flt) < 0)
return false;
@@ -368,7 +378,7 @@ bool cDemux::pesFilter(const unsigned short _pid)
* this check originally is from tuxbox cvs but I'm not sure
* what it is good for...
if (pid <= 0x0001 && dmx_type != DMX_PCR_ONLY_CHANNEL)
return false;
return false;
*/
if ((pid >= 0x0002 && pid <= 0x000f) || pid >= 0x1fff)
return false;
@@ -380,31 +390,32 @@ bool cDemux::pesFilter(const unsigned short _pid)
p_flt.output = DMX_OUT_DECODER;
p_flt.input = DMX_IN_FRONTEND;
switch (dmx_type) {
case DMX_PCR_ONLY_CHANNEL:
p_flt.pes_type = DMX_PES_OTHER;
p_flt.output = DMX_OUT_TAP;
return true;
break;
case DMX_AUDIO_CHANNEL:
p_flt.pes_type = DMX_PES_OTHER;
p_flt.output = DMX_OUT_TSDEMUX_TAP;
break;
case DMX_VIDEO_CHANNEL:
p_flt.pes_type = DMX_PES_OTHER;
p_flt.output = DMX_OUT_TSDEMUX_TAP;
break;
case DMX_PES_CHANNEL:
p_flt.pes_type = DMX_PES_OTHER;
p_flt.output = DMX_OUT_TAP;
break;
case DMX_TP_CHANNEL:
p_flt.pes_type = DMX_PES_OTHER;
p_flt.output = DMX_OUT_TSDEMUX_TAP;
break;
default:
hal_info("%s #%d invalid dmx_type %d!\n", __func__, num, dmx_type);
return false;
switch (dmx_type)
{
case DMX_PCR_ONLY_CHANNEL:
p_flt.pes_type = DMX_PES_OTHER;
p_flt.output = DMX_OUT_TAP;
return true;
break;
case DMX_AUDIO_CHANNEL:
p_flt.pes_type = DMX_PES_OTHER;
p_flt.output = DMX_OUT_TSDEMUX_TAP;
break;
case DMX_VIDEO_CHANNEL:
p_flt.pes_type = DMX_PES_OTHER;
p_flt.output = DMX_OUT_TSDEMUX_TAP;
break;
case DMX_PES_CHANNEL:
p_flt.pes_type = DMX_PES_OTHER;
p_flt.output = DMX_OUT_TAP;
break;
case DMX_TP_CHANNEL:
p_flt.pes_type = DMX_PES_OTHER;
p_flt.output = DMX_OUT_TSDEMUX_TAP;
break;
default:
hal_info("%s #%d invalid dmx_type %d!\n", __func__, num, dmx_type);
return false;
}
return (ioctl(fd, DMX_SET_PES_FILTER, &p_flt) >= 0);
}
@@ -456,7 +467,8 @@ void cDemux::removePid(unsigned short Pid)
}
for (std::vector<pes_pids>::iterator i = pesfds.begin(); i != pesfds.end(); ++i)
{
if ((*i).pid == Pid) {
if ((*i).pid == Pid)
{
hal_debug("removePid: removing demux fd %d pid 0x%04x\n", fd, Pid);
if (ioctl(fd, DMX_REMOVE_PID, Pid) < 0)
hal_info("%s: (DMX_REMOVE_PID, 0x%04hx): %m\n", __func__, Pid);
@@ -467,7 +479,7 @@ void cDemux::removePid(unsigned short Pid)
hal_info("%s pid 0x%04x not found\n", __FUNCTION__, Pid);
}
void cDemux::getSTC(int64_t * STC)
void cDemux::getSTC(int64_t *STC)
{
int64_t pts = 0;
if (videoDecoder)

View File

@@ -31,31 +31,37 @@ class cRecord;
class cPlayback;
class cDemux
{
friend class cRecord;
friend class cPlayback;
friend class cRecord;
friend class cPlayback;
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);
bool Start(bool record = false);
bool Stop(void);
int Read(unsigned char *buff, int len, int Timeout = 0);
bool sectionFilter(unsigned short pid, const unsigned char * const filter, const unsigned char * const mask, int len, int Timeout = 0, const unsigned char * const negmask = NULL);
bool sectionFilter(unsigned short pid, const unsigned char *const filter, const unsigned char *const mask, int len, int Timeout = 0, const unsigned char *const negmask = NULL);
bool pesFilter(const unsigned short pid);
void SetSyncMode(AVSYNC_TYPE mode);
void * getBuffer();
void * getChannel();
DMX_CHANNEL_TYPE getChannelType(void) { return dmx_type; };
void *getBuffer();
void *getChannel();
DMX_CHANNEL_TYPE getChannelType(void)
{
return dmx_type;
};
bool addPid(unsigned short pid);
void getSTC(int64_t * STC);
void getSTC(int64_t *STC);
int getUnit(void);
static bool SetSource(int unit, int source);
static int GetSource(int unit);
int getFD(void) { return fd; }; /* needed by cPlayback class */
int getFD(void)
{
return fd;
}; /* needed by cPlayback class */
cDemux(int num = 0);
~cDemux();
private:
void removePid(unsigned short Pid); /* needed by cRecord class */
void removePid(unsigned short Pid); /* needed by cRecord class */
int num;
int fd;
int buffersize;

View File

@@ -1,21 +1,21 @@
/*
Copyright 2013 Stefan Seyfried <seife@tuxboxcvs.slipkontur.de>
Copyright 2013 Stefan Seyfried <seife@tuxboxcvs.slipkontur.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
The GLFB namespace is just because it's already established by the
generic-pc implementation.
The GLFB namespace is just because it's already established by the
generic-pc implementation.
*/
#include <vector>
@@ -50,10 +50,10 @@ static VC_IMAGE_TYPE_T type = VC_IMAGE_ARGB8888;
static OpenThreads::Mutex blit_mutex;
static OpenThreads::Condition blit_cond;
static bool goodbye = false; /* if set main loop is left */
static bool ready = false; /* condition predicate */
static bool goodbye = false; /* if set main loop is left */
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;
GLFramebuffer::GLFramebuffer(int x, int y)
@@ -126,11 +126,12 @@ void GLFramebuffer::setup()
/* 32bit FB depth, *2 because tuxtxt uses a shadow buffer */
osd_buf.resize(pitch * height * 2);
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];
/* initialize to half-transparent grey */
memset(image, 0x7f, osd_buf.size());
for (int i = 0; i < 2; i++) {
for (int i = 0; i < 2; i++)
{
res[i] = vc_dispmanx_resource_create(type, width, height, &vc_img_ptr[i]);
CHECK(res[i]);
}
@@ -142,15 +143,15 @@ void GLFramebuffer::setup()
vc_dispmanx_rect_set(&src_rect, 0, 0, width << 16, height << 16);
vc_dispmanx_rect_set(&dsp_rect, 0, 0, info.width, info.height);
element = vc_dispmanx_element_add(update,
display,
2000 /*layer*/,
&dsp_rect,
res[curr_res],
&src_rect,
DISPMANX_PROTECTION_NONE,
&alpha,
NULL,
DISPMANX_NO_ROTATE);
display,
2000 /*layer*/,
&dsp_rect,
res[curr_res],
&src_rect,
DISPMANX_PROTECTION_NONE,
&alpha,
NULL,
DISPMANX_NO_ROTATE);
ret = vc_dispmanx_update_submit_sync(update);
CHECK(ret == 0);
curr_res = !curr_res;

View File

@@ -1,18 +1,18 @@
/*
Copyright 2013 Stefan Seyfried <seife@tuxboxcvs.slipkontur.de>
Copyright 2013 Stefan Seyfried <seife@tuxboxcvs.slipkontur.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __glthread__
@@ -23,20 +23,26 @@
class GLFramebuffer : public OpenThreads::Thread
{
public:
GLFramebuffer(int x, int y);
~GLFramebuffer();
std::vector<unsigned char> *getOSDBuffer() { return &osd_buf; } /* pointer to OSD bounce buffer */
void blit();
fb_var_screeninfo getScreenInfo() { return si; }
public:
GLFramebuffer(int x, int y);
~GLFramebuffer();
std::vector<unsigned char> *getOSDBuffer()
{
return &osd_buf; /* pointer to OSD bounce buffer */
}
void blit();
fb_var_screeninfo getScreenInfo()
{
return si;
}
private:
void *pdata; /* not yet used */
fb_var_screeninfo si;
std::vector<unsigned char> osd_buf; /* silly bounce buffer */
void run(); /* for OpenThreads::Thread */
private:
void *pdata; /* not yet used */
fb_var_screeninfo si;
std::vector<unsigned char> osd_buf; /* silly bounce buffer */
void run(); /* for OpenThreads::Thread */
void setup();
void blit_osd();
void setup();
void blit_osd();
};
#endif

View File

@@ -27,7 +27,7 @@ hw_caps_t *get_hwcaps(void)
initialized = 1;
caps.can_cpufreq = 0;
caps.can_shutdown = 1; /* for testing */
caps.can_shutdown = 1; /* for testing */
caps.display_type = HW_DISPLAY_LINE_TEXT;
caps.has_HDMI = 1;
caps.display_xres = 8;

View File

@@ -49,24 +49,24 @@ static keymap_t kmap;
static void init_keymap(void)
{
/* same as generic-pc/glfb.cpp */
kmap[KEY_ENTER] = KEY_OK;
kmap[KEY_ESC] = KEY_EXIT;
kmap[KEY_E] = KEY_EPG;
kmap[KEY_I] = KEY_INFO;
kmap[KEY_M] = KEY_MENU;
kmap[KEY_F12] = KEY_VOLUMEUP; /* different than glfb, as we */
kmap[KEY_F11] = KEY_VOLUMEDOWN; /* don't consider the keyboard */
kmap[KEY_F10] = KEY_MUTE; /* layout... */
kmap[KEY_H] = KEY_HELP;
kmap[KEY_P] = KEY_POWER;
kmap[KEY_F1] = KEY_RED;
kmap[KEY_F2] = KEY_GREEN;
kmap[KEY_F3] = KEY_YELLOW;
kmap[KEY_F4] = KEY_BLUE;
kmap[KEY_F5] = KEY_WWW;
kmap[KEY_F6] = KEY_SUBTITLE;
kmap[KEY_F7] = KEY_MOVE;
kmap[KEY_F8] = KEY_SLEEP;
kmap[KEY_ENTER] = KEY_OK;
kmap[KEY_ESC] = KEY_EXIT;
kmap[KEY_E] = KEY_EPG;
kmap[KEY_I] = KEY_INFO;
kmap[KEY_M] = KEY_MENU;
kmap[KEY_F12] = KEY_VOLUMEUP; /* different than glfb, as we */
kmap[KEY_F11] = KEY_VOLUMEDOWN; /* don't consider the keyboard */
kmap[KEY_F10] = KEY_MUTE; /* layout... */
kmap[KEY_H] = KEY_HELP;
kmap[KEY_P] = KEY_POWER;
kmap[KEY_F1] = KEY_RED;
kmap[KEY_F2] = KEY_GREEN;
kmap[KEY_F3] = KEY_YELLOW;
kmap[KEY_F4] = KEY_BLUE;
kmap[KEY_F5] = KEY_WWW;
kmap[KEY_F6] = KEY_SUBTITLE;
kmap[KEY_F7] = KEY_MOVE;
kmap[KEY_F8] = KEY_SLEEP;
}
class Input: public OpenThreads::Thread
@@ -111,7 +111,7 @@ void Input::run()
init_keymap();
unlink("/tmp/neutrino.input");
mkfifo("/tmp/neutrino.input", 0600);
out_fd = open("/tmp/neutrino.input", O_RDWR|O_CLOEXEC|O_NONBLOCK);
out_fd = open("/tmp/neutrino.input", O_RDWR | O_CLOEXEC | O_NONBLOCK);
if (out_fd < 0)
hal_info("could not create /tmp/neutrino.input. good luck. error: %m\n");
@@ -120,16 +120,19 @@ void Input::run()
hal_info("no input devices /dev/input/eventX??\n");
else
{
while (n--) {
while (n--)
{
strcpy(inputstr + strlen("/dev/input/"), namelist[n]->d_name);
free(namelist[n]);
int fd = open(inputstr, O_RDWR|O_CLOEXEC|O_NONBLOCK);
if (fd < 0) {
int fd = open(inputstr, O_RDWR | O_CLOEXEC | O_NONBLOCK);
if (fd < 0)
{
hal_info("could not open %s:%m\n", inputstr);
continue;
}
ioctl(fd, EVIOCGBIT(0, EV_MAX), &bit);
if ((bit & (1 << EV_KEY)) == 0) {
if ((bit & (1 << EV_KEY)) == 0)
{
close(fd);
continue;
}
@@ -143,7 +146,8 @@ void Input::run()
fd_max++;
running = true;
while (running) {
while (running)
{
FD_ZERO(&rfds);
for (std::set<int>::iterator i = in_fds.begin(); i != in_fds.end(); ++i)
FD_SET((*i), &rfds);
@@ -154,18 +158,22 @@ void Input::run()
int ret = select(fd_max, &rfds, NULL, NULL, &timeout);
if (ret == 0) /* timed out */
continue;
if (ret < 0) {
if (ret < 0)
{
hal_info("input: select returned %d (%m)\n", ret);
continue;
}
for (std::set<int>::iterator i = in_fds.begin(); i != in_fds.end(); ++i) {
for (std::set<int>::iterator i = in_fds.begin(); i != in_fds.end(); ++i)
{
if (!FD_ISSET((*i), &rfds))
continue;
ret = read(*i, &in, sizeof(in));
if (ret != sizeof(in)) {
if (errno == ENODEV) {
if (ret != sizeof(in))
{
if (errno == ENODEV)
{
close(*i);
hal_info("input fd %d vanished?\n", *i);
in_fds.erase(i);
@@ -193,7 +201,8 @@ void hal_api_init()
if (!initialized)
hal_debug_init();
hal_info("%s begin, initialized=%d, debug=0x%02x\n", __func__, (int)initialized, debuglevel);
if (! glfb) {
if (! glfb)
{
int x = 1280, y = 720; /* default OSD FB resolution */
/*
* export GLFB_RESOLUTION=720,576
@@ -203,7 +212,8 @@ void hal_api_init()
const char *p = NULL;
if (tmp)
p = strchr(tmp, ',');
if (p) {
if (p)
{
x = atoi(tmp);
y = atoi(p + 1);
}

View File

@@ -81,7 +81,7 @@ int cVideo::setBlank(int)
int cVideo::SetVideoSystem(int system, bool)
{
int h;
switch(system)
switch (system)
{
case VIDEO_STD_NTSC:
case VIDEO_STD_480P:
@@ -101,7 +101,7 @@ int cVideo::SetVideoSystem(int system, bool)
break;
case VIDEO_STD_AUTO:
hal_info("%s: VIDEO_STD_AUTO not implemented\n", __func__);
// fallthrough
// fallthrough
case VIDEO_STD_SECAM:
case VIDEO_STD_PAL:
case VIDEO_STD_576P:
@@ -170,10 +170,10 @@ int cVideo::SetStreamType(VIDEO_FORMAT v)
return 0;
}
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",
__func__, data, xres, yres, get_video, get_osd, scale_to_video);
__func__, data, xres, yres, get_video, get_osd, scale_to_video);
return false;
}

View File

@@ -10,7 +10,8 @@ extern "C" {
#include <libavutil/rational.h>
}
typedef enum {
typedef enum
{
ANALOG_SD_RGB_CINCH = 0x00,
ANALOG_SD_YPRPB_CINCH,
ANALOG_HD_RGB_CINCH,
@@ -23,7 +24,8 @@ typedef enum {
} analog_mode_t;
typedef enum {
typedef enum
{
VIDEO_FORMAT_MPEG2 = 0,
VIDEO_FORMAT_MPEG4,
VIDEO_FORMAT_VC1,
@@ -32,7 +34,8 @@ typedef enum {
VIDEO_FORMAT_PNG
} VIDEO_FORMAT;
typedef enum {
typedef enum
{
VIDEO_SD = 0,
VIDEO_HD,
VIDEO_120x60i,
@@ -41,7 +44,8 @@ typedef enum {
VIDEO_360x288i
} VIDEO_DEFINITION;
typedef enum {
typedef enum
{
VIDEO_FRAME_RATE_23_976 = 0,
VIDEO_FRAME_RATE_24,
VIDEO_FRAME_RATE_25,
@@ -52,7 +56,8 @@ typedef enum {
VIDEO_FRAME_RATE_60
} VIDEO_FRAME_RATE;
typedef enum {
typedef enum
{
DISPLAY_AR_1_1,
DISPLAY_AR_4_3,
DISPLAY_AR_14_9,
@@ -61,20 +66,23 @@ typedef enum {
DISPLAY_AR_RAW
} DISPLAY_AR;
typedef enum {
typedef enum
{
DISPLAY_AR_MODE_PANSCAN = 0,
DISPLAY_AR_MODE_LETTERBOX,
DISPLAY_AR_MODE_NONE,
DISPLAY_AR_MODE_PANSCAN2
} DISPLAY_AR_MODE;
typedef enum {
typedef enum
{
VIDEO_DB_DR_NEITHER = 0,
VIDEO_DB_ON,
VIDEO_DB_DR_BOTH
} VIDEO_DB_DR;
typedef enum {
typedef enum
{
VIDEO_PLAY_STILL = 0,
VIDEO_PLAY_CLIP,
VIDEO_PLAY_TRICK,
@@ -82,7 +90,8 @@ typedef enum {
VIDEO_PLAY_MOTION_NO_SYNC
} VIDEO_PLAY_MODE;
typedef enum {
typedef enum
{
VIDEO_STD_NTSC,
VIDEO_STD_SECAM,
VIDEO_STD_PAL,
@@ -96,12 +105,13 @@ typedef enum {
VIDEO_STD_1080P24,
VIDEO_STD_1080P25,
VIDEO_STD_AUTO,
VIDEO_STD_1080P50, /* SPARK only */
VIDEO_STD_1080P50, /* SPARK only */
VIDEO_STD_MAX
} VIDEO_STD;
/* not used, for dummy functions */
typedef enum {
typedef enum
{
VIDEO_HDMI_CEC_MODE_OFF = 0,
VIDEO_HDMI_CEC_MODE_TUNER,
VIDEO_HDMI_CEC_MODE_RECORDER
@@ -121,27 +131,51 @@ typedef enum
#define VDEC_MAXBUFS 0x30
class cVideo
{
friend class GLFramebuffer;
friend class cDemux;
friend class GLFramebuffer;
friend class cDemux;
private:
/* called from GL thread */
class SWFramebuffer : public std::vector<unsigned char>
{
public:
SWFramebuffer() : mWidth(0), mHeight(0) {}
void width(int w) { mWidth = w; }
void height(int h) { mHeight = h; }
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:
int mWidth;
int mHeight;
int64_t mPts;
AVRational mAR;
public:
SWFramebuffer() : mWidth(0), mHeight(0) {}
void width(int w)
{
mWidth = w;
}
void height(int h)
{
mHeight = h;
}
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:
int mWidth;
int mHeight;
int64_t mPts;
AVRational mAR;
};
int buf_in, buf_out, buf_num;
int64_t GetPTS(void);
@@ -150,8 +184,14 @@ class cVideo
cVideo(int mode, void *, void *, unsigned int unit = 0);
~cVideo(void);
void * GetTVEnc() { return NULL; };
void * GetTVEncSD() { return NULL; };
void *GetTVEnc()
{
return NULL;
};
void *GetTVEncSD()
{
return NULL;
};
/* aspect ratio */
int getAspectRatio(void);
@@ -177,25 +217,58 @@ class cVideo
int SetVideoSystem(int video_system, bool remember = true);
int SetStreamType(VIDEO_FORMAT type);
void SetSyncMode(AVSYNC_TYPE mode);
bool SetCECMode(VIDEO_HDMI_CEC_MODE) { return true; };
void SetCECAutoView(bool) { return; };
void SetCECAutoStandby(bool) { return; };
bool ShowPicture(const char * fname);
bool SetCECMode(VIDEO_HDMI_CEC_MODE)
{
return true;
};
void SetCECAutoView(bool)
{
return;
};
void SetCECAutoStandby(bool)
{
return;
};
bool ShowPicture(const char *fname);
void StopPicture();
void Standby(unsigned int bOn);
void Pig(int x, int y, int w, int h, int osd_w = 1064, int osd_h = 600);
void SetControl(int, int) { return; };
void SetControl(int, int)
{
return;
};
void setContrast(int val);
void SetVideoMode(analog_mode_t mode);
void SetDBDR(int) { return; };
void SetAudioHandle(void *) { return; };
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 SetDBDR(int)
{
return;
};
void SetAudioHandle(void *)
{
return;
};
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);
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:
SWFramebuffer buffers[VDEC_MAXBUFS];
int dec_w, dec_h;