sync with seife

This commit is contained in:
martii
2013-10-06 10:16:33 +02:00
11 changed files with 115 additions and 89 deletions

View File

@@ -39,9 +39,8 @@ void cAudio::openDevice(void)
lt_debug("%s\n", __func__); lt_debug("%s\n", __func__);
if (fd < 0) if (fd < 0)
{ {
if ((fd = open(AUDIO_DEVICE, O_RDWR)) < 0) if ((fd = open(AUDIO_DEVICE, O_RDONLY|O_CLOEXEC)) < 0)
lt_info("openDevice: open failed (%m)\n"); lt_info("openDevice: open failed (%m)\n");
fcntl(fd, F_SETFD, FD_CLOEXEC);
do_mute(true, false); do_mute(true, false);
} }
else else
@@ -51,6 +50,7 @@ void cAudio::openDevice(void)
void cAudio::closeDevice(void) void cAudio::closeDevice(void)
{ {
lt_debug("%s\n", __func__); lt_debug("%s\n", __func__);
ioctl(fd, AUDIO_CONTINUE); /* enigma2 also does CONTINUE before close... */
if (fd >= 0) if (fd >= 0)
close(fd); close(fd);
fd = -1; fd = -1;
@@ -129,7 +129,9 @@ int cAudio::Start(void)
int cAudio::Stop(void) int cAudio::Stop(void)
{ {
lt_debug("%s\n", __func__); lt_debug("%s\n", __func__);
return ioctl(fd, AUDIO_STOP); ioctl(fd, AUDIO_STOP);
ioctl(fd, AUDIO_CONTINUE); /* no idea why we have to stop and then continue => enigma2 does it, too */
return 0;
} }
bool cAudio::Pause(bool /*Pcm*/) bool cAudio::Pause(bool /*Pcm*/)
@@ -211,12 +213,11 @@ int cAudio::PrepareClipPlay(int ch, int srate, int bits, int little_endian)
} }
lt_info("%s: dsp_dev %s mix_dev %s\n", __func__, dsp_dev, mix_dev); /* NULL mix_dev is ok */ lt_info("%s: dsp_dev %s mix_dev %s\n", __func__, dsp_dev, mix_dev); /* NULL mix_dev is ok */
/* the tdoss dsp driver seems to work only on the second open(). really. */ /* the tdoss dsp driver seems to work only on the second open(). really. */
clipfd = open(dsp_dev, O_WRONLY); clipfd = open(dsp_dev, O_WRONLY|O_CLOEXEC);
if (clipfd < 0) { if (clipfd < 0) {
lt_info("%s open %s: %m\n", dsp_dev, __FUNCTION__); lt_info("%s open %s: %m\n", dsp_dev, __FUNCTION__);
return -1; return -1;
} }
fcntl(clipfd, F_SETFD, FD_CLOEXEC);
/* no idea if we ever get little_endian == 0 */ /* no idea if we ever get little_endian == 0 */
if (little_endian) if (little_endian)
fmt = AFMT_S16_BE; fmt = AFMT_S16_BE;
@@ -234,7 +235,7 @@ int cAudio::PrepareClipPlay(int ch, int srate, int bits, int little_endian)
if (!mix_dev) if (!mix_dev)
return 0; return 0;
mixer_fd = open(mix_dev, O_RDWR); mixer_fd = open(mix_dev, O_RDWR|O_CLOEXEC);
if (mixer_fd < 0) { if (mixer_fd < 0) {
lt_info("%s: open mixer %s failed (%m)\n", __func__, mix_dev); lt_info("%s: open mixer %s failed (%m)\n", __func__, mix_dev);
/* not a real error */ /* not a real error */

View File

@@ -114,7 +114,7 @@ cDemux::~cDemux()
bool cDemux::Open(DMX_CHANNEL_TYPE pes_type, void * /*hVideoBuffer*/, int uBufferSize) bool cDemux::Open(DMX_CHANNEL_TYPE pes_type, void * /*hVideoBuffer*/, int uBufferSize)
{ {
int devnum = num; int devnum = num;
int flags = O_RDWR; int flags = O_RDWR|O_CLOEXEC;
if (fd > -1) if (fd > -1)
lt_info("%s FD ALREADY OPENED? fd = %d\n", __FUNCTION__, fd); lt_info("%s FD ALREADY OPENED? fd = %d\n", __FUNCTION__, fd);
@@ -127,7 +127,6 @@ bool cDemux::Open(DMX_CHANNEL_TYPE pes_type, void * /*hVideoBuffer*/, int uBuffe
lt_info("%s %s: %m\n", __FUNCTION__, devname[devnum]); lt_info("%s %s: %m\n", __FUNCTION__, devname[devnum]);
return false; return false;
} }
fcntl(fd, F_SETFD, FD_CLOEXEC);
lt_debug("%s #%d pes_type: %s(%d), uBufferSize: %d fd: %d\n", __func__, lt_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);
@@ -138,10 +137,10 @@ bool cDemux::Open(DMX_CHANNEL_TYPE pes_type, void * /*hVideoBuffer*/, int uBuffe
lt_info("%s ERROR! pesfds not empty!\n", __FUNCTION__); /* TODO: error handling */ lt_info("%s ERROR! pesfds not empty!\n", __FUNCTION__); /* TODO: error handling */
return false; return false;
} }
#endif
int n = DMX_SOURCE_FRONT0; int n = DMX_SOURCE_FRONT0;
if (ioctl(fd, DMX_SET_SOURCE, &n) < 0) if (ioctl(fd, DMX_SET_SOURCE, &n) < 0)
lt_info("%s DMX_SET_SOURCE failed!\n", __func__); lt_info("%s DMX_SET_SOURCE failed!\n", __func__);
#endif
if (uBufferSize > 0) if (uBufferSize > 0)
{ {
/* probably uBufferSize == 0 means "use default size". TODO: find a reasonable default */ /* probably uBufferSize == 0 means "use default size". TODO: find a reasonable default */
@@ -212,10 +211,11 @@ int cDemux::Read(unsigned char *buff, int len, int timeout)
#endif #endif
int rc; int rc;
int to = timeout; int to = timeout;
struct pollfd ufds; /* using a one-dimensional array seems to avoid strange segfaults / memory corruption?? */
ufds.fd = fd; struct pollfd ufds[1];
ufds.events = POLLIN|POLLPRI|POLLERR; ufds[0].fd = fd;
ufds.revents = 0; ufds[0].events = POLLIN|POLLPRI|POLLERR;
ufds[0].revents = 0;
/* hack: if the frontend loses and regains lock, the demuxer often will not /* hack: if the frontend loses and regains lock, the demuxer often will not
* return from read(), so as a "emergency exit" for e.g. NIT scan, set a (long) * return from read(), so as a "emergency exit" for e.g. NIT scan, set a (long)
@@ -226,7 +226,7 @@ int cDemux::Read(unsigned char *buff, int len, int timeout)
if (to > 0) if (to > 0)
{ {
retry: retry:
rc = ::poll(&ufds, 1, to); rc = ::poll(ufds, 1, to);
if (!rc) if (!rc)
{ {
if (timeout == 0) /* we took the emergency exit */ if (timeout == 0) /* we took the emergency exit */
@@ -253,14 +253,14 @@ int cDemux::Read(unsigned char *buff, int len, int timeout)
return 0; return 0;
} }
#endif #endif
if (ufds.revents & POLLHUP) /* we get POLLHUP if e.g. a too big DMX_BUFFER_SIZE was set */ if (ufds[0].revents & POLLHUP) /* we get POLLHUP if e.g. a too big DMX_BUFFER_SIZE was set */
{ {
dmx_err("received %s,", "POLLHUP", ufds.revents); dmx_err("received %s,", "POLLHUP", ufds[0].revents);
return -1; return -1;
} }
if (!(ufds.revents & POLLIN)) /* we requested POLLIN but did not get it? */ if (!(ufds[0].revents & POLLIN)) /* we requested POLLIN but did not get it? */
{ {
dmx_err("received %s, please report!", "POLLIN", ufds.revents); dmx_err("received %s, please report!", "POLLIN", ufds[0].revents);
return 0; return 0;
} }
} }
@@ -384,6 +384,7 @@ bool cDemux::sectionFilter(unsigned short pid, const unsigned char * const filte
ioctl (fd, DMX_STOP); ioctl (fd, DMX_STOP);
if (ioctl(fd, DMX_SET_FILTER, &s_flt) < 0) if (ioctl(fd, DMX_SET_FILTER, &s_flt) < 0)
return false; return false;
ioctl(fd, DMX_START);
return true; return true;
} }

View File

@@ -74,7 +74,7 @@ static void show_iframe(int fd, unsigned char *iframe, size_t st_size);
#define VIDEO_STREAMTYPE_VC1_SM 5 #define VIDEO_STREAMTYPE_VC1_SM 5
#define VIDEO_STREAMTYPE_MPEG1 6 #define VIDEO_STREAMTYPE_MPEG1 6
cVideo::cVideo(int, void *, void *) cVideo::cVideo(int, void *, void *, unsigned int)
{ {
lt_debug("%s\n", __FUNCTION__); lt_debug("%s\n", __FUNCTION__);
@@ -90,7 +90,7 @@ cVideo::cVideo(int, void *, void *)
blank_data = NULL; /* initialize */ blank_data = NULL; /* initialize */
blank_size = 0; blank_size = 0;
blankfd = open(blankname, O_RDONLY); blankfd = open(blankname, O_RDONLY|O_CLOEXEC);
if (blankfd < 0) if (blankfd < 0)
lt_info("%s cannot open %s: %m", __func__, blankname); lt_info("%s cannot open %s: %m", __func__, blankname);
else else
@@ -129,7 +129,7 @@ void cVideo::openDevice(void)
if (fd != -1) /* already open */ if (fd != -1) /* already open */
return; return;
retry: retry:
if ((fd = open(VIDEO_DEVICE, O_RDWR)) < 0) if ((fd = open(VIDEO_DEVICE, O_RDWR|O_CLOEXEC)) < 0)
{ {
if (errno == EBUSY) if (errno == EBUSY)
{ {
@@ -140,16 +140,12 @@ retry:
} }
lt_info("%s cannot open %s: %m, retries %d\n", __func__, VIDEO_DEVICE, n); lt_info("%s cannot open %s: %m, retries %d\n", __func__, VIDEO_DEVICE, n);
} }
else
fcntl(fd, F_SETFD, FD_CLOEXEC);
playstate = VIDEO_STOPPED; playstate = VIDEO_STOPPED;
} }
void cVideo::closeDevice(void) void cVideo::closeDevice(void)
{ {
lt_debug("%s\n", __func__); lt_debug("%s\n", __func__);
/* looks like sometimes close is unhappy about non-empty buffers */
Start();
if (fd >= 0) if (fd >= 0)
close(fd); close(fd);
fd = -1; fd = -1;
@@ -288,16 +284,7 @@ int cVideo::SetVideoSystem(int video_system, bool remember)
return 0; return 0;
} }
lt_info("%s: old: '%s' new: '%s'\n", __func__, current, modes[video_system]); lt_info("%s: old: '%s' new: '%s'\n", __func__, current, modes[video_system]);
bool stopped = false;
if (playstate == VIDEO_PLAYING)
{
lt_info("%s: playstate == VIDEO_PLAYING, stopping video\n", __func__);
Stop();
stopped = true;
}
ret = proc_put("/proc/stb/video/videomode", modes[video_system],strlen(modes[video_system])); ret = proc_put("/proc/stb/video/videomode", modes[video_system],strlen(modes[video_system]));
if (stopped)
Start();
return ret; return ret;
} }
@@ -387,7 +374,7 @@ void cVideo::ShowPicture(const char * fname)
what we want. the mutex ensures proper ordering. */ what we want. the mutex ensures proper ordering. */
pthread_mutex_lock(&stillp_mutex); pthread_mutex_lock(&stillp_mutex);
mfd = open(destname, O_RDONLY); mfd = open(destname, O_RDONLY|O_CLOEXEC);
if (mfd < 0) if (mfd < 0)
{ {
lt_info("%s cannot open %s: %m", __func__, destname); lt_info("%s cannot open %s: %m", __func__, destname);
@@ -641,3 +628,8 @@ static void show_iframe(int fd, unsigned char *iframe, size_t st_size)
ioctl(fd, VIDEO_STOP, 0); ioctl(fd, VIDEO_STOP, 0);
ioctl(fd, VIDEO_SELECT_SOURCE, VIDEO_SOURCE_DEMUX); ioctl(fd, VIDEO_SELECT_SOURCE, VIDEO_SOURCE_DEMUX);
} }
void cVideo::SetDemux(cDemux *)
{
lt_debug("%s: not implemented yet\n", __func__);
}

View File

@@ -3,6 +3,7 @@
#include <linux/dvb/video.h> #include <linux/dvb/video.h>
#include "../common/cs_types.h" #include "../common/cs_types.h"
#include "dmx_lib.h"
typedef enum { typedef enum {
ANALOG_SD_RGB_CINCH = 0x00, ANALOG_SD_RGB_CINCH = 0x00,
@@ -141,7 +142,7 @@ class cVideo
void closeDevice(void); void closeDevice(void);
public: public:
/* constructor & destructor */ /* constructor & destructor */
cVideo(int mode, void *, void *); cVideo(int mode, void *, void *, unsigned int unit = 0);
~cVideo(void); ~cVideo(void);
void * GetTVEnc() { return NULL; }; void * GetTVEnc() { return NULL; };
@@ -189,6 +190,7 @@ class cVideo
int CloseVBI(void) { return 0; }; int CloseVBI(void) { return 0; };
int StartVBI(unsigned short) { return 0; }; int StartVBI(unsigned short) { return 0; };
int StopVBI(void) { return 0; }; int StopVBI(void) { return 0; };
void SetDemux(cDemux *dmx);
}; };
#endif #endif

View File

@@ -65,7 +65,7 @@ static const AVRational aspect_ratios[6] = {
{ -1,-1 } { -1,-1 }
}; };
cVideo::cVideo(int, void *, void *) cVideo::cVideo(int, void *, void *, unsigned int)
{ {
lt_debug("%s\n", __func__); lt_debug("%s\n", __func__);
av_register_all(); av_register_all();
@@ -660,3 +660,8 @@ int64_t cVideo::GetPTS(void)
buf_m.unlock(); buf_m.unlock();
return pts; return pts;
} }
void cVideo::SetDemux(cDemux *)
{
lt_debug("%s: not implemented yet\n", __func__);
}

View File

@@ -6,6 +6,7 @@
#include <vector> #include <vector>
#include <linux/dvb/video.h> #include <linux/dvb/video.h>
#include "../common/cs_types.h" #include "../common/cs_types.h"
#include "dmx_lib.h"
extern "C" { extern "C" {
#include <libavutil/rational.h> #include <libavutil/rational.h>
} }
@@ -147,7 +148,7 @@ class cVideo : public OpenThreads::Thread
int64_t GetPTS(void); int64_t GetPTS(void);
public: public:
/* constructor & destructor */ /* constructor & destructor */
cVideo(int mode, void *, void *); cVideo(int mode, void *, void *, unsigned int unit = 0);
~cVideo(void); ~cVideo(void);
void * GetTVEnc() { return NULL; }; void * GetTVEnc() { return NULL; };
@@ -194,6 +195,7 @@ class cVideo : public OpenThreads::Thread
int CloseVBI(void) { return 0; }; int CloseVBI(void) { return 0; };
int StartVBI(unsigned short) { return 0; }; int StartVBI(unsigned short) { return 0; };
int StopVBI(void) { 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);
SWFramebuffer *getDecBuf(void); SWFramebuffer *getDecBuf(void);
private: private:

View File

@@ -71,7 +71,6 @@
/* Ugh... see comment in destructor for details... */ /* Ugh... see comment in destructor for details... */
#include "video_lib.h" #include "video_lib.h"
extern cVideo *videoDecoder; extern cVideo *videoDecoder;
extern cVideo *pipDecoder;
#define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_DEMUX, this, args) #define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_DEMUX, this, args)
#define lt_info(args...) _lt_info(TRIPLE_DEBUG_DEMUX, this, args) #define lt_info(args...) _lt_info(TRIPLE_DEBUG_DEMUX, this, args)
@@ -91,7 +90,6 @@ extern cVideo *pipDecoder;
cDemux *videoDemux = NULL; cDemux *videoDemux = NULL;
cDemux *audioDemux = NULL; cDemux *audioDemux = NULL;
//cDemux *pcrDemux = NULL; //cDemux *pcrDemux = NULL;
cDemux *pipDemux = NULL;
static const char *DMX_T[] = { static const char *DMX_T[] = {
"DMX_INVALID", "DMX_INVALID",
@@ -156,8 +154,6 @@ cDemux::~cDemux()
*/ */
if (dmx_type == DMX_VIDEO_CHANNEL) if (dmx_type == DMX_VIDEO_CHANNEL)
videoDecoder = NULL; videoDecoder = NULL;
if (dmx_type == DMX_PIP_CHANNEL)
pipDecoder = NULL;
} }
bool cDemux::Open(DMX_CHANNEL_TYPE pes_type, void * /*hVideoBuffer*/, int uBufferSize) bool cDemux::Open(DMX_CHANNEL_TYPE pes_type, void * /*hVideoBuffer*/, int uBufferSize)
@@ -496,6 +492,9 @@ bool cDemux::pesFilter(const unsigned short pid)
case DMX_VIDEO_CHANNEL: case DMX_VIDEO_CHANNEL:
p_flt.pes_type = DMX_PES_VIDEO; p_flt.pes_type = DMX_PES_VIDEO;
break; break;
case DMX_PIP_CHANNEL: /* PIP is a special version of DMX_VIDEO_CHANNEL */
p_flt.pes_type = DMX_PES_VIDEO1;
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;
@@ -504,9 +503,6 @@ bool cDemux::pesFilter(const unsigned short pid)
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_PIP_CHANNEL:
p_flt.pes_type = DMX_PES_VIDEO1;
break;
default: default:
lt_info("%s #%d invalid dmx_type %d!\n", __func__, num, dmx_type); lt_info("%s #%d invalid dmx_type %d!\n", __func__, num, dmx_type);
return false; return false;

View File

@@ -34,7 +34,6 @@
#include <linux/dvb/video.h> #include <linux/dvb/video.h>
#include <linux/stmfb.h> #include <linux/stmfb.h>
#include "video_lib.h" #include "video_lib.h"
#define VIDEO_DEVICE_FMT "/dev/dvb/adapter0/video%d"
#include "lt_debug.h" #include "lt_debug.h"
#define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_VIDEO, this, args) #define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_VIDEO, this, args)
#define lt_info(args...) _lt_info(TRIPLE_DEBUG_VIDEO, this, args) #define lt_info(args...) _lt_info(TRIPLE_DEBUG_VIDEO, this, args)
@@ -53,13 +52,43 @@
_r; \ _r; \
}) })
cVideo * pipDecoder = NULL;
cVideo * videoDecoder = NULL; cVideo * videoDecoder = NULL;
cVideo * pipDecoder = NULL;
int system_rev = 0; int system_rev = 0;
static bool hdmi_enabled = true; static bool hdmi_enabled = true;
static bool stillpicture = false; static bool stillpicture = false;
static const char *VDEV[] = {
"/dev/dvb/adapter0/video0",
"/dev/dvb/adapter0/video1"
};
static const char *VMPEG_aspect[] = {
"/proc/stb/vmpeg/0/aspect",
"/proc/stb/vmpeg/1/aspect"
};
static const char *VMPEG_xres[] = {
"/proc/stb/vmpeg/0/xres",
"/proc/stb/vmpeg/1/xres"
};
static const char *VMPEG_yres[] = {
"/proc/stb/vmpeg/0/yres",
"/proc/stb/vmpeg/1/yres"
};
static const char *VMPEG_dst_all[] = {
"/proc/stb/vmpeg/0/dst_all",
"/proc/stb/vmpeg/1/dst_all"
};
static const char *VMPEG_framerate[] = {
"/proc/stb/vmpeg/0/framerate",
"/proc/stb/vmpeg/1/framerate"
};
#define VIDEO_STREAMTYPE_MPEG2 0 #define VIDEO_STREAMTYPE_MPEG2 0
#define VIDEO_STREAMTYPE_MPEG4_H264 1 #define VIDEO_STREAMTYPE_MPEG4_H264 1
#define VIDEO_STREAMTYPE_VC1 3 #define VIDEO_STREAMTYPE_VC1 3
@@ -142,16 +171,20 @@ out:
} }
cVideo::cVideo(int, void *, void *, int _dev) cVideo::cVideo(int, void *, void *, unsigned int unit)
{ {
lt_debug("%s\n", __FUNCTION__); lt_debug("%s unit %u\n", __func__, unit);
//croppingMode = VID_DISPMODE_NORM; //croppingMode = VID_DISPMODE_NORM;
//outputformat = VID_OUTFMT_RGBC_SVIDEO; //outputformat = VID_OUTFMT_RGBC_SVIDEO;
scartvoltage = -1; scartvoltage = -1;
video_standby = 0; video_standby = 0;
if (unit > 1) {
lt_info("%s: unit %d out of range, setting to 0\n", __func__, unit);
devnum = 0;
} else
devnum = unit;
fd = -1; fd = -1;
dev = _dev;
openDevice(); openDevice();
} }
@@ -163,14 +196,12 @@ cVideo::~cVideo(void)
void cVideo::openDevice(void) void cVideo::openDevice(void)
{ {
int n = 0; int n = 0;
lt_debug("%s\n", __func__); lt_debug("#%d: %s\n", devnum, __func__);
/* todo: this fd checking is racy, should be protected by a lock */ /* todo: this fd checking is racy, should be protected by a lock */
if (fd != -1) /* already open */ if (fd != -1) /* already open */
return; return;
char vd[sizeof(VIDEO_DEVICE_FMT) + 10];
snprintf(vd, sizeof(vd), VIDEO_DEVICE_FMT, dev);
retry: retry:
if ((fd = open(vd, O_RDWR)) < 0) if ((fd = open(VDEV[devnum], O_RDWR|O_CLOEXEC)) < 0)
{ {
if (errno == EBUSY) if (errno == EBUSY)
{ {
@@ -179,10 +210,8 @@ retry:
if (++n < 10) if (++n < 10)
goto retry; goto retry;
} }
lt_info("%s cannot open %s: %m, retries %d\n", __func__, vd, n); lt_info("#%d: %s cannot open %s: %m, retries %d\n", devnum, __func__, VDEV[devnum], n);
} }
else
fcntl(fd, F_SETFD, FD_CLOEXEC);
playstate = VIDEO_STOPPED; playstate = VIDEO_STOPPED;
} }
@@ -197,12 +226,6 @@ void cVideo::closeDevice(void)
playstate = VIDEO_STOPPED; playstate = VIDEO_STOPPED;
} }
void cVideo::SetDemux(cDemux * /*dmx*/)
{
lt_debug("%s\n", __func__);
// FIXME, stub only
}
int cVideo::setAspectRatio(int aspect, int mode) int cVideo::setAspectRatio(int aspect, int mode)
{ {
static const char *a[] = { "n/a", "4:3", "14:9", "16:9" }; static const char *a[] = { "n/a", "4:3", "14:9", "16:9" };
@@ -236,9 +259,7 @@ int cVideo::getAspectRatio(void)
if (fd == -1) if (fd == -1)
{ {
/* in movieplayer mode, fd is not opened -> fall back to procfs */ /* in movieplayer mode, fd is not opened -> fall back to procfs */
char tmp[100]; int n = proc_get_hex(VMPEG_aspect[devnum]);
snprintf(tmp, sizeof(tmp), "/proc/stb/vmpeg/%d/aspect", dev);
int n = proc_get_hex(tmp);
return n * 2 + 1; return n * 2 + 1;
} }
if (fop(ioctl, VIDEO_GET_SIZE, &s) < 0) if (fop(ioctl, VIDEO_GET_SIZE, &s) < 0)
@@ -246,7 +267,7 @@ int cVideo::getAspectRatio(void)
lt_info("%s: VIDEO_GET_SIZE %m\n", __func__); lt_info("%s: VIDEO_GET_SIZE %m\n", __func__);
return -1; return -1;
} }
lt_debug("%s: %d\n", __func__, s.aspect_ratio); lt_debug("#%d: %s: %d\n", devnum, __func__, s.aspect_ratio);
return s.aspect_ratio * 2 + 1; return s.aspect_ratio * 2 + 1;
} }
@@ -268,7 +289,7 @@ int cVideo::setCroppingMode(int /*vidDispMode_t format*/)
int cVideo::Start(void * /*PcrChannel*/, unsigned short /*PcrPid*/, unsigned short /*VideoPid*/, void * /*hChannel*/) int cVideo::Start(void * /*PcrChannel*/, unsigned short /*PcrPid*/, unsigned short /*VideoPid*/, void * /*hChannel*/)
{ {
lt_debug("%s playstate=%d\n", __FUNCTION__, playstate); lt_debug("#%d: %s playstate=%d\n", devnum, __func__, playstate);
#if 0 #if 0
if (playstate == VIDEO_PLAYING) if (playstate == VIDEO_PLAYING)
return 0; return 0;
@@ -282,7 +303,7 @@ int cVideo::Start(void * /*PcrChannel*/, unsigned short /*PcrPid*/, unsigned sho
int cVideo::Stop(bool blank) int cVideo::Stop(bool blank)
{ {
lt_debug("%s(%d)\n", __FUNCTION__, blank); lt_debug("#%d: %s(%d)\n", devnum, __func__, blank);
if (stillpicture) if (stillpicture)
{ {
lt_debug("%s: stillpicture == true\n", __func__); lt_debug("%s: stillpicture == true\n", __func__);
@@ -357,7 +378,7 @@ int cVideo::getPlayState(void)
void cVideo::SetVideoMode(analog_mode_t mode) void cVideo::SetVideoMode(analog_mode_t mode)
{ {
lt_debug("%s(%d)\n", __func__, mode); lt_debug("#%d: %s(%d)\n", devnum, __func__, mode);
if (!(mode & ANALOG_SCART_MASK)) if (!(mode & ANALOG_SCART_MASK))
{ {
lt_debug("%s: non-SCART mode ignored\n", __func__); lt_debug("%s: non-SCART mode ignored\n", __func__);
@@ -523,7 +544,7 @@ int cVideo::getBlank(void)
free(line); free(line);
fclose(f); fclose(f);
int ret = (count == lastcount); /* no new decode -> return 1 */ int ret = (count == lastcount); /* no new decode -> return 1 */
lt_debug("%s: %d (irq++: %d)\n", __func__, ret, count - lastcount); lt_debug("#%d: %s: %d (irq++: %d)\n", devnum, __func__, ret, count - lastcount);
lastcount = count; lastcount = count;
return ret; return ret;
} }
@@ -555,7 +576,7 @@ void cVideo::Pig(int x, int y, int w, int h, int osd_w, int osd_h, int startx, i
* TODO: check this in the driver sources */ * TODO: check this in the driver sources */
int xres = 720; /* proc_get_hex("/proc/stb/vmpeg/0/xres") */ int xres = 720; /* proc_get_hex("/proc/stb/vmpeg/0/xres") */
int yres = 576; /* proc_get_hex("/proc/stb/vmpeg/0/yres") */ int yres = 576; /* proc_get_hex("/proc/stb/vmpeg/0/yres") */
lt_debug("%s: x:%d y:%d w:%d h:%d ow:%d oh:%d\n", __func__, x, y, w, h, osd_w, osd_h); lt_debug("#%d %s: x:%d y:%d w:%d h:%d ow:%d oh:%d\n", devnum, __func__, x, y, w, h, osd_w, osd_h);
if (x == -1 && y == -1 && w == -1 && h == -1) if (x == -1 && y == -1 && w == -1 && h == -1)
{ {
_w = xres; _w = xres;
@@ -581,11 +602,9 @@ void cVideo::Pig(int x, int y, int w, int h, int osd_w, int osd_h, int startx, i
_w /= 1280; _w /= 1280;
_h /= 720; _h /= 720;
} }
lt_debug("%s: x:%d y:%d w:%d h:%d xr:%d yr:%d\n", __func__, _x, _y, _w, _h, xres, yres); lt_debug("#%d %s: x:%d y:%d w:%d h:%d xr:%d yr:%d\n", devnum, __func__, _x, _y, _w, _h, xres, yres);
sprintf(buffer, "%x %x %x %x", _x, _y, _w, _h); sprintf(buffer, "%x %x %x %x", _x, _y, _w, _h);
char tmp[100]; proc_put(VMPEG_dst_all[devnum], buffer, strlen(buffer));
snprintf(tmp, sizeof(tmp), "/proc/stb/vmpeg/%d/dst_all", dev);
proc_put(tmp, buffer, strlen(buffer));
} }
static inline int rate2csapi(int rate) static inline int rate2csapi(int rate)
@@ -621,13 +640,9 @@ void cVideo::getPictureInfo(int &width, int &height, int &rate)
if (fd == -1) if (fd == -1)
{ {
/* in movieplayer mode, fd is not opened -> fall back to procfs */ /* in movieplayer mode, fd is not opened -> fall back to procfs */
char tmp[100]; r = proc_get_hex(VMPEG_framerate[devnum]);
snprintf(tmp, sizeof(tmp), "/proc/stb/vmpeg/%d/framerate", dev); width = proc_get_hex(VMPEG_xres[devnum]);
r = proc_get_hex(tmp); height = proc_get_hex(VMPEG_yres[devnum]);
snprintf(tmp, sizeof(tmp), "/proc/stb/vmpeg/%d/xres", dev);
width = proc_get_hex(tmp);
snprintf(tmp, sizeof(tmp), "/proc/stb/vmpeg/%d/yres", dev);
height = proc_get_hex(tmp);
rate = rate2csapi(r); rate = rate2csapi(r);
return; return;
} }
@@ -636,7 +651,7 @@ void cVideo::getPictureInfo(int &width, int &height, int &rate)
rate = rate2csapi(r); rate = rate2csapi(r);
height = s.h; height = s.h;
width = s.w; width = s.w;
lt_debug("%s: rate: %d, width: %d height: %d\n", __func__, rate, width, height); lt_debug("#%d: %s: rate: %d, width: %d height: %d\n", devnum, __func__, rate, width, height);
} }
void cVideo::SetSyncMode(AVSYNC_TYPE mode) void cVideo::SetSyncMode(AVSYNC_TYPE mode)
@@ -666,7 +681,7 @@ int cVideo::SetStreamType(VIDEO_FORMAT type)
"VIDEO_FORMAT_PNG" "VIDEO_FORMAT_PNG"
}; };
int t; int t;
lt_debug("%s type=%s\n", __FUNCTION__, VF[type]); lt_debug("#%d: %s type=%s\n", devnum, __func__, VF[type]);
switch (type) switch (type)
{ {
@@ -695,6 +710,11 @@ int64_t cVideo::GetPTS(void)
return pts; return pts;
} }
void cVideo::SetDemux(cDemux *)
{
lt_debug("#%d %s not implemented yet\n", devnum, __func__);
}
void cVideo::SetControl(int control, int value) { void cVideo::SetControl(int control, int value) {
const char *p = NULL; const char *p = NULL;
switch (control) { switch (control) {

View File

@@ -130,7 +130,7 @@ class cVideo
private: private:
/* video device */ /* video device */
int fd; int fd;
int dev; unsigned int devnum;
/* apparently we cannot query the driver's state /* apparently we cannot query the driver's state
=> remember it */ => remember it */
video_play_state_t playstate; video_play_state_t playstate;
@@ -153,7 +153,7 @@ class cVideo
void closeDevice(void); void closeDevice(void);
public: public:
/* constructor & destructor */ /* constructor & destructor */
cVideo(int mode, void *, void *, int dev = 0); cVideo(int mode, void *, void *, unsigned int unit = 0);
~cVideo(void); ~cVideo(void);
void * GetTVEnc() { return NULL; }; void * GetTVEnc() { return NULL; };

View File

@@ -70,7 +70,7 @@ static pthread_mutex_t stillp_mutex = PTHREAD_MUTEX_INITIALIZER;
/* debugging hacks */ /* debugging hacks */
static bool noscart = false; static bool noscart = false;
cVideo::cVideo(int, void *, void *) cVideo::cVideo(int, void *, void *, unsigned int)
{ {
lt_debug("%s\n", __FUNCTION__); lt_debug("%s\n", __FUNCTION__);
if ((fd = open(VIDEO_DEVICE, O_RDWR)) < 0) if ((fd = open(VIDEO_DEVICE, O_RDWR)) < 0)
@@ -1098,3 +1098,8 @@ bool cVideo::GetScreenImage(unsigned char * &video, int &xres, int &yres, bool g
close(mfd); close(mfd);
return true; return true;
} }
void cVideo::SetDemux(cDemux *)
{
lt_debug("%s: not implemented yet\n", __func__);
}

View File

@@ -5,6 +5,7 @@
#define video_format_t vidDispSize_t #define video_format_t vidDispSize_t
//#define video_displayformat_t vidDispMode_t //#define video_displayformat_t vidDispMode_t
#include "../common/cs_types.h" #include "../common/cs_types.h"
#include "dmx_td.h"
#define STB_HAL_VIDEO_HAS_GETSCREENIMAGE 1 #define STB_HAL_VIDEO_HAS_GETSCREENIMAGE 1
@@ -138,7 +139,7 @@ class cVideo
int video_standby; int video_standby;
public: public:
/* constructor & destructor */ /* constructor & destructor */
cVideo(int mode, void *, void *); cVideo(int mode, void *, void *, unsigned int unit = 0);
~cVideo(void); ~cVideo(void);
void * GetTVEnc() { return NULL; }; void * GetTVEnc() { return NULL; };
@@ -188,6 +189,7 @@ class cVideo
int CloseVBI(void) { return 0; }; int CloseVBI(void) { return 0; };
int StartVBI(unsigned short) { return 0; }; int StartVBI(unsigned short) { return 0; };
int StopVBI(void) { 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);
}; };