all: clean up cVideo header, separate private stuff

This commit is contained in:
Stefan Seyfried
2013-11-02 18:44:34 +01:00
parent 5a56339925
commit 69527185a9
23 changed files with 494 additions and 957 deletions

View File

@@ -31,11 +31,12 @@
#include <cstdio>
#include <string>
#include <sys/ioctl.h>
#include "dmx_lib.h"
#include "dmx_hal.h"
#include "lt_debug.h"
/* Ugh... see comment in destructor for details... */
#include "video_lib.h"
#include "video_hal.h"
#include "video_priv.h"
extern cVideo *videoDecoder;
#define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_DEMUX, this, args)
@@ -493,7 +494,7 @@ void cDemux::getSTC(int64_t * STC)
lt_debug("%s #%d\n", __func__, num);
int64_t pts = 0;
if (videoDecoder)
pts = videoDecoder->GetPTS();
pts = videoDecoder->vdec->GetPTS();
*STC = pts;
}

View File

@@ -37,7 +37,9 @@
#include <proc_tools.h>
#include "video_lib.h"
#include "video_hal.h"
#include "video_priv.h"
#define VIDEO_DEVICE "/dev/dvb/adapter0/video0"
#include "lt_debug.h"
#define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_VIDEO, this, args)
@@ -75,12 +77,22 @@ static void show_iframe(int fd, unsigned char *iframe, size_t st_size);
#define VIDEO_STREAMTYPE_MPEG1 6
cVideo::cVideo(int, void *, void *, unsigned int)
{
vdec = new VDec();
}
cVideo::~cVideo(void)
{
delete vdec;
vdec = NULL;
}
VDec::VDec(void)
{
lt_debug("%s\n", __FUNCTION__);
//croppingMode = VID_DISPMODE_NORM;
//outputformat = VID_OUTFMT_RGBC_SVIDEO;
scartvoltage = -1;
video_standby = 0;
fd = -1;
@@ -111,17 +123,17 @@ cVideo::cVideo(int, void *, void *, unsigned int)
close(blankfd);
}
openDevice();
Pig(-1, -1, -1, -1);
Pig(-1, -1, -1, -1, 1, 1);
}
cVideo::~cVideo(void)
VDec::~VDec(void)
{
closeDevice();
if (blank_data)
free(blank_data);
}
void cVideo::openDevice(void)
void VDec::openDevice(void)
{
int n = 0;
lt_debug("%s\n", __func__);
@@ -143,7 +155,7 @@ retry:
playstate = VIDEO_STOPPED;
}
void cVideo::closeDevice(void)
void VDec::closeDevice(void)
{
lt_debug("%s\n", __func__);
if (fd >= 0)
@@ -181,6 +193,11 @@ int cVideo::setAspectRatio(int aspect, int mode)
}
int cVideo::getAspectRatio(void)
{
return vdec->getAspectRatio();
}
int VDec::getAspectRatio(void)
{
video_size_t s;
if (fd == -1)
@@ -198,7 +215,7 @@ int cVideo::getAspectRatio(void)
return s.aspect_ratio * 2 + 1;
}
int cVideo::setCroppingMode(int /*vidDispMode_t format*/)
int cVideo::setCroppingMode(void)
{
return 0;
#if 0
@@ -215,6 +232,16 @@ int cVideo::setCroppingMode(int /*vidDispMode_t format*/)
}
int cVideo::Start(void * /*PcrChannel*/, unsigned short /*PcrPid*/, unsigned short /*VideoPid*/, void * /*hChannel*/)
{
return vdec->Start();
}
int cVideo::Stop(bool blank)
{
return vdec->Stop(blank);
}
int VDec::Start(void)
{
lt_debug("%s playstate=%d\n", __FUNCTION__, playstate);
#if 0
@@ -227,7 +254,7 @@ int cVideo::Start(void * /*PcrChannel*/, unsigned short /*PcrPid*/, unsigned sho
return fop(ioctl, VIDEO_PLAY);
}
int cVideo::Stop(bool blank)
int VDec::Stop(bool blank)
{
lt_debug("%s(%d)\n", __FUNCTION__, blank);
if (stillpicture)
@@ -242,7 +269,12 @@ int cVideo::Stop(bool blank)
return fop(ioctl, VIDEO_STOP, blank ? 1 : 0);
}
int cVideo::setBlank(int)
int cVideo::setBlank(int b)
{
return vdec->setBlank(b);
}
int VDec::setBlank(int)
{
pthread_mutex_lock(&stillp_mutex);
if (blank_data)
@@ -291,7 +323,7 @@ int cVideo::SetVideoSystem(int video_system, bool remember)
int cVideo::getPlayState(void)
{
return playstate;
return vdec->playstate;
}
void cVideo::SetVideoMode(analog_mode_t mode)
@@ -320,6 +352,11 @@ void cVideo::SetVideoMode(analog_mode_t mode)
}
void cVideo::ShowPicture(const char * fname)
{
vdec->ShowPicture(fname);
}
void VDec::ShowPicture(const char * fname)
{
lt_debug("%s(%s)\n", __func__, fname);
char destname[512];
@@ -402,10 +439,15 @@ void cVideo::ShowPicture(const char * fname)
void cVideo::StopPicture()
{
lt_debug("%s\n", __func__);
stillpicture = false;
vdec->stillpicture = false;
}
void cVideo::Standby(unsigned int bOn)
{
vdec->Standby(bOn);
}
void VDec::Standby(unsigned int bOn)
{
lt_debug("%s(%d)\n", __func__, bOn);
if (bOn)
@@ -428,26 +470,12 @@ int cVideo::getBlank(void)
return !ret;
}
/* this function is regularly called, checks if video parameters
changed and triggers appropriate actions */
void cVideo::VideoParamWatchdog(void)
void cVideo::Pig(int x, int y, int w, int h, int osd_w, int osd_h)
{
#if 0
static unsigned int _v_info = (unsigned int) -1;
unsigned int v_info;
if (fd == -1)
return;
ioctl(fd, MPEG_VID_GET_V_INFO_RAW, &v_info);
if (_v_info != v_info)
{
lt_debug("%s params changed. old: %08x new: %08x\n", __FUNCTION__, _v_info, v_info);
setAspectRatio(-1, -1);
}
_v_info = v_info;
#endif
vdec->Pig(x, y, w, h, osd_w, osd_h);
}
void cVideo::Pig(int x, int y, int w, int h, int osd_w, int osd_h)
void VDec::Pig(int x, int y, int w, int h, int osd_w, int osd_h)
{
char buffer[64];
int _x, _y, _w, _h;
@@ -509,6 +537,11 @@ static inline int rate2csapi(int rate)
}
void cVideo::getPictureInfo(int &width, int &height, int &rate)
{
vdec->getPictureInfo(width, height, rate);
}
void VDec::getPictureInfo(int &width, int &height, int &rate)
{
video_size_t s;
int r;
@@ -554,6 +587,11 @@ void cVideo::SetSyncMode(AVSYNC_TYPE mode)
};
int cVideo::SetStreamType(VIDEO_FORMAT type)
{
return vdec->SetStreamType(type);
}
int VDec::SetStreamType(VIDEO_FORMAT type)
{
static const char *VF[] = {
"VIDEO_FORMAT_MPEG2",
@@ -585,7 +623,7 @@ int cVideo::SetStreamType(VIDEO_FORMAT type)
return 0;
}
int64_t cVideo::GetPTS(void)
int64_t VDec::GetPTS(void)
{
int64_t pts = 0;
if (ioctl(fd, VIDEO_GET_PTS, &pts) < 0)

View File

@@ -1,196 +0,0 @@
#ifndef _VIDEO_TD_H
#define _VIDEO_TD_H
#include <linux/dvb/video.h>
#include <cs_types.h>
typedef enum {
ANALOG_SD_RGB_CINCH = 0x00,
ANALOG_SD_YPRPB_CINCH,
ANALOG_HD_RGB_CINCH,
ANALOG_HD_YPRPB_CINCH,
ANALOG_SD_RGB_SCART = 0x10,
ANALOG_SD_YPRPB_SCART,
ANALOG_HD_RGB_SCART,
ANALOG_HD_YPRPB_SCART,
ANALOG_SCART_MASK = 0x10
} analog_mode_t;
typedef enum {
VIDEO_FORMAT_MPEG2 = 0,
VIDEO_FORMAT_MPEG4,
VIDEO_FORMAT_VC1,
VIDEO_FORMAT_JPEG,
VIDEO_FORMAT_GIF,
VIDEO_FORMAT_PNG
} VIDEO_FORMAT;
typedef enum {
VIDEO_SD = 0,
VIDEO_HD,
VIDEO_120x60i,
VIDEO_320x240i,
VIDEO_1440x800i,
VIDEO_360x288i
} VIDEO_DEFINITION;
typedef enum {
VIDEO_FRAME_RATE_23_976 = 0,
VIDEO_FRAME_RATE_24,
VIDEO_FRAME_RATE_25,
VIDEO_FRAME_RATE_29_97,
VIDEO_FRAME_RATE_30,
VIDEO_FRAME_RATE_50,
VIDEO_FRAME_RATE_59_94,
VIDEO_FRAME_RATE_60
} VIDEO_FRAME_RATE;
typedef enum {
DISPLAY_AR_1_1,
DISPLAY_AR_4_3,
DISPLAY_AR_14_9,
DISPLAY_AR_16_9,
DISPLAY_AR_20_9,
DISPLAY_AR_RAW,
} DISPLAY_AR;
typedef enum {
DISPLAY_AR_MODE_PANSCAN = 0,
DISPLAY_AR_MODE_LETTERBOX,
DISPLAY_AR_MODE_NONE,
DISPLAY_AR_MODE_PANSCAN2
} DISPLAY_AR_MODE;
typedef enum {
VIDEO_DB_DR_NEITHER = 0,
VIDEO_DB_ON,
VIDEO_DB_DR_BOTH
} VIDEO_DB_DR;
typedef enum {
VIDEO_PLAY_STILL = 0,
VIDEO_PLAY_CLIP,
VIDEO_PLAY_TRICK,
VIDEO_PLAY_MOTION,
VIDEO_PLAY_MOTION_NO_SYNC
} VIDEO_PLAY_MODE;
typedef enum {
VIDEO_STD_NTSC,
VIDEO_STD_SECAM,
VIDEO_STD_PAL,
VIDEO_STD_480P,
VIDEO_STD_576P,
VIDEO_STD_720P60,
VIDEO_STD_1080I60,
VIDEO_STD_720P50,
VIDEO_STD_1080I50,
VIDEO_STD_1080P30,
VIDEO_STD_1080P24,
VIDEO_STD_1080P25,
VIDEO_STD_AUTO,
VIDEO_STD_1080P50, /* SPARK only */
VIDEO_STD_MAX
} VIDEO_STD;
/* not used, for dummy functions */
typedef enum {
VIDEO_HDMI_CEC_MODE_OFF = 0,
VIDEO_HDMI_CEC_MODE_TUNER,
VIDEO_HDMI_CEC_MODE_RECORDER
} VIDEO_HDMI_CEC_MODE;
typedef enum
{
VIDEO_CONTROL_BRIGHTNESS = 0,
VIDEO_CONTROL_CONTRAST,
VIDEO_CONTROL_SATURATION,
VIDEO_CONTROL_HUE,
VIDEO_CONTROL_SHARPNESS,
VIDEO_CONTROL_MAX = VIDEO_CONTROL_SHARPNESS
} VIDEO_CONTROL;
class cDemux;
class cVideo
{
friend class cDemux;
friend class cPlayback;
private:
/* video device */
int fd;
/* apparently we cannot query the driver's state
=> remember it */
video_play_state_t playstate;
int /*vidDispMode_t*/ croppingMode;
int /*vidOutFmt_t*/ outputformat;
int scartvoltage;
VIDEO_FORMAT StreamType;
VIDEO_DEFINITION VideoDefinition;
DISPLAY_AR DisplayAR;
VIDEO_PLAY_MODE SyncMode;
DISPLAY_AR_MODE ARMode;
VIDEO_DB_DR eDbDr;
DISPLAY_AR PictureAR;
VIDEO_FRAME_RATE FrameRate;
int video_standby;
int64_t GetPTS(void);
void openDevice(void);
void closeDevice(void);
public:
/* constructor & destructor */
cVideo(int mode, void *, void *, unsigned int unit = 0);
~cVideo(void);
void * GetTVEnc() { return NULL; };
void * GetTVEncSD() { return NULL; };
/* aspect ratio */
int getAspectRatio(void);
void getPictureInfo(int &width, int &height, int &rate);
int setAspectRatio(int aspect, int mode);
/* cropping mode */
int setCroppingMode(int x = 0 /*vidDispMode_t x = VID_DISPMODE_NORM*/);
/* get play state */
int getPlayState(void);
/* blank on freeze */
int getBlank(void);
int setBlank(int enable);
/* change video play state. Parameters are all unused. */
int Start(void *PcrChannel = NULL, unsigned short PcrPid = 0, unsigned short VideoPid = 0, void *x = NULL);
int Stop(bool blank = true);
bool Pause(void);
/* set video_system */
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; };
void 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 VideoParamWatchdog(void);
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 SetDemux(cDemux *dmx);
};
#endif

60
azbox/video_priv.h Normal file
View File

@@ -0,0 +1,60 @@
/*
* (C) 2010-2013 Stefan Seyfried
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* private video functions, to be used only inside libstb-hal
*/
#ifndef __video_priv__
#define __video_priv__
#include <video_hal.h>
#include <linux/dvb/video.h>
class VDec
{
public:
/* all public, used inside libstb-hal only anyways... */
int fd; /* video device fd */
/* apparently we cannot query the driver's state
=> remember it */
video_play_state_t playstate;
int video_standby;
bool stillpicture;
/* constructor & destructor */
VDec(void);
~VDec(void);
/* used directly by cVideo */
int getAspectRatio(void);
void getPictureInfo(int &width, int &height, int &rate);
int Start(void);
int Stop(bool blank = true);
int setBlank(int blank);
int SetStreamType(VIDEO_FORMAT type);
void SetSyncMode(AVSYNC_TYPE mode);
void ShowPicture(const char * fname);
void Standby(unsigned int bOn);
void Pig(int x, int y, int w, int h, int osd_w, int osd_h);
/* used internally by dmx */
int64_t GetPTS(void);
/* used internally by playback */
void openDevice(void);
void closeDevice(void);
};
#endif

View File

@@ -38,7 +38,7 @@ extern "C" {
/* my own buf 256k */
#define DMX_BUF_SZ 0x20000
#include "video_lib.h"
#include "video_hal.h"
#include "dmx_hal.h"
#include "glfb_priv.h"
#include "video_priv.h"

View File

@@ -20,7 +20,7 @@
#include <OpenThreads/Thread>
#include <OpenThreads/Mutex>
#include "video_lib.h"
#include "video_hal.h"
extern "C" {
#include <libavutil/rational.h>
}

View File

@@ -145,9 +145,13 @@ typedef enum
} VIDEO_CONTROL;
class cDemux;
class cPlayback;
class VDec;
class cVideo
{
friend class cPlayback;
friend class cDemux;
public:
/* constructor & destructor */
cVideo(int mode, void *, void *, unsigned int unit = 0);
@@ -200,7 +204,8 @@ class cVideo
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);
private:
void *pdata; /* not yet used */
VDec *vdec;
void *pdata;
};
#endif

View File

@@ -1,20 +1 @@
#include <config.h>
#if HAVE_TRIPLEDRAGON
#include "../libtriple/video_td.h"
#elif HAVE_SPARK_HARDWARE
#include "../libspark/video_lib.h"
#elif HAVE_AZBOX_HARDWARE
#include "../azbox/video_lib.h"
#elif HAVE_GENERIC_HARDWARE
#if BOXMODEL_RASPI
#include "../raspi/video_lib.h"
#else
#include "../generic-pc/video_lib.h"
#endif
#else
#error neither HAVE_TRIPLEDRAGON nor HAVE_SPARK_HARDWARE defined
#endif
#if STB_HAL_VIDEO_HAS_GETSCREENIMAGE
#define SCREENSHOT 1
#endif
#include "video_hal.h"

View File

@@ -69,8 +69,8 @@
#include "dmx_hal.h"
#include "lt_debug.h"
#include "video_priv.h"
/* Ugh... see comment in destructor for details... */
#include "video_lib.h"
extern cVideo *videoDecoder;
#define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_DEMUX, this, args)
@@ -579,7 +579,7 @@ void cDemux::getSTC(int64_t * STC)
lt_debug("%s #%d\n", __func__, num);
int64_t pts = 0;
if (videoDecoder)
pts = videoDecoder->GetPTS();
pts = videoDecoder->vdec->GetPTS();
*STC = pts;
}

View File

@@ -9,7 +9,7 @@
#include <cstring>
#include "playback_lib.h"
#include "dmx_lib.h"
#include "dmx_hal.h"
#include "audio_lib.h"
#include "video_lib.h"
#include "lt_debug.h"

View File

@@ -4,7 +4,7 @@
#include <sys/stat.h>
#include <audio_lib.h>
#include <video_lib.h>
#include <video_priv.h>
#include <common.h>
extern OutputHandler_t OutputHandler;
@@ -38,7 +38,7 @@ bool cPlayback::Open(playmode_t PlayMode)
if (PlayMode != PLAYMODE_TS)
{
audioDecoder->closeDevice();
videoDecoder->closeDevice();
videoDecoder->vdec->closeDevice();
decoders_closed = true;
}
@@ -81,7 +81,7 @@ void cPlayback::Close(void)
if (decoders_closed)
{
audioDecoder->openDevice();
videoDecoder->openDevice();
videoDecoder->vdec->openDevice();
decoders_closed = false;
}
}
@@ -200,7 +200,7 @@ bool cPlayback::Start(char *filename, unsigned short vpid, int vtype, unsigned s
if (player && player->output && player->playback)
{
ret = true;
videoDecoder->Stop(false);
videoDecoder->vdec->Stop(false);
audioDecoder->Stop();
}
}
@@ -235,7 +235,7 @@ bool cPlayback::Stop(void)
return true;
}
bool cPlayback::SetAPid(unsigned short pid, bool ac3)
bool cPlayback::SetAPid(unsigned short pid, bool /*ac3*/)
{
printf("%s:%s\n", FILENAME, __FUNCTION__);
int i=pid;
@@ -254,7 +254,7 @@ bool cPlayback::SetSpeed(int speed)
if (! decoders_closed)
{
audioDecoder->closeDevice();
videoDecoder->closeDevice();
videoDecoder->vdec->closeDevice();
decoders_closed = true;
usleep(500000);
if (player && player->output && player->playback) {
@@ -400,7 +400,7 @@ bool cPlayback::GetPosition(int &position, int &duration)
return true;
}
bool cPlayback::SetPosition(int position, bool absolute)
bool cPlayback::SetPosition(int position, bool /*absolute*/)
{
printf("%s:%s %d\n", FILENAME, __FUNCTION__,position);
if (playing == false)
@@ -483,7 +483,7 @@ void cPlayback::RequestAbort(void)
}
//
cPlayback::cPlayback(int num)
cPlayback::cPlayback(int /*num*/)
{
printf("%s:%s\n", FILENAME, __FUNCTION__);
playing=false;

View File

@@ -33,7 +33,8 @@
#include <linux/dvb/video.h>
#include <linux/stmfb.h>
#include "video_lib.h"
#include "video_hal.h"
#include "video_priv.h"
#include "lt_debug.h"
#define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_VIDEO, this, args)
#define lt_info(args...) _lt_info(TRIPLE_DEBUG_VIDEO, this, args)
@@ -54,10 +55,10 @@
cVideo * videoDecoder = NULL;
cVideo * pipDecoder = NULL;
int system_rev = 0;
static bool hdmi_enabled = true;
static bool stillpicture = false;
static const char *VDEV[] = {
"/dev/dvb/adapter0/video0",
@@ -172,13 +173,22 @@ out:
cVideo::cVideo(int, void *, void *, unsigned int unit)
{
vdec = new VDec(unit);
}
cVideo::~cVideo(void)
{
delete vdec;
vdec = NULL;
}
VDec::VDec(unsigned int unit)
{
lt_debug("%s unit %u\n", __func__, unit);
//croppingMode = VID_DISPMODE_NORM;
//outputformat = VID_OUTFMT_RGBC_SVIDEO;
scartvoltage = -1;
video_standby = 0;
stillpicture = false;
if (unit > 1) {
lt_info("%s: unit %d out of range, setting to 0\n", __func__, unit);
devnum = 0;
@@ -188,12 +198,12 @@ cVideo::cVideo(int, void *, void *, unsigned int unit)
openDevice();
}
cVideo::~cVideo(void)
VDec::~VDec(void)
{
closeDevice();
}
void cVideo::openDevice(void)
void VDec::openDevice(void)
{
int n = 0;
lt_debug("#%d: %s\n", devnum, __func__);
@@ -215,7 +225,7 @@ retry:
playstate = VIDEO_STOPPED;
}
void cVideo::closeDevice(void)
void VDec::closeDevice(void)
{
lt_debug("%s\n", __func__);
/* looks like sometimes close is unhappy about non-empty buffers */
@@ -254,6 +264,11 @@ int cVideo::setAspectRatio(int aspect, int mode)
}
int cVideo::getAspectRatio(void)
{
return vdec->getAspectRatio();
}
int VDec::getAspectRatio(void)
{
video_size_t s;
if (fd == -1)
@@ -271,7 +286,7 @@ int cVideo::getAspectRatio(void)
return s.aspect_ratio * 2 + 1;
}
int cVideo::setCroppingMode(int /*vidDispMode_t format*/)
int cVideo::setCroppingMode(void)
{
return 0;
#if 0
@@ -288,6 +303,16 @@ int cVideo::setCroppingMode(int /*vidDispMode_t format*/)
}
int cVideo::Start(void * /*PcrChannel*/, unsigned short /*PcrPid*/, unsigned short /*VideoPid*/, void * /*hChannel*/)
{
return vdec->Start();
}
int cVideo::Stop(bool blank)
{
return vdec->Stop(blank);
}
int VDec::Start(void)
{
lt_debug("#%d: %s playstate=%d\n", devnum, __func__, playstate);
#if 0
@@ -301,7 +326,7 @@ int cVideo::Start(void * /*PcrChannel*/, unsigned short /*PcrPid*/, unsigned sho
return fop(ioctl, VIDEO_PLAY);
}
int cVideo::Stop(bool blank)
int VDec::Stop(bool blank)
{
lt_debug("#%d: %s(%d)\n", devnum, __func__, blank);
if (stillpicture)
@@ -352,7 +377,7 @@ int cVideo::SetVideoSystem(int video_system, bool remember)
}
lt_info("%s: old: '%s' new: '%s'\n", __func__, current, modes[video_system]);
bool stopped = false;
if (playstate == VIDEO_PLAYING)
if (vdec->playstate == VIDEO_PLAYING)
{
lt_info("%s: playstate == VIDEO_PLAYING, stopping video\n", __func__);
Stop();
@@ -369,12 +394,12 @@ int cVideo::SetVideoSystem(int video_system, bool remember)
int cVideo::getPlayState(void)
{
return playstate;
return vdec->playstate;
}
void cVideo::SetVideoMode(analog_mode_t mode)
{
lt_debug("#%d: %s(%d)\n", devnum, __func__, mode);
lt_debug("#%d: %s(%d)\n", vdec->devnum, __func__, mode);
if (!(mode & ANALOG_SCART_MASK))
{
lt_debug("%s: non-SCART mode ignored\n", __func__);
@@ -398,6 +423,11 @@ void cVideo::SetVideoMode(analog_mode_t mode)
}
void cVideo::ShowPicture(const char * fname)
{
vdec->ShowPicture(fname);
}
void VDec::ShowPicture(const char * fname)
{
lt_debug("%s(%s)\n", __func__, fname);
static const unsigned char pes_header[] = { 0x00, 0x00, 0x01, 0xE0, 0x00, 0x00, 0x80, 0x00, 0x00 };
@@ -492,10 +522,15 @@ void cVideo::ShowPicture(const char * fname)
void cVideo::StopPicture()
{
lt_debug("%s\n", __func__);
stillpicture = false;
vdec->stillpicture = false;
}
void cVideo::Standby(unsigned int bOn)
{
vdec->Standby(bOn);
}
void VDec::Standby(unsigned int bOn)
{
lt_debug("%s(%d)\n", __func__, bOn);
if (bOn)
@@ -546,30 +581,11 @@ int cVideo::getBlank(void)
free(line);
fclose(f);
int ret = (count == lastcount); /* no new decode -> return 1 */
lt_debug("#%d: %s: %d (irq++: %d)\n", devnum, __func__, ret, count - lastcount);
lt_debug("#%d: %s: %d (irq++: %d)\n", vdec->devnum, __func__, ret, count - lastcount);
lastcount = count;
return ret;
}
/* this function is regularly called, checks if video parameters
changed and triggers appropriate actions */
void cVideo::VideoParamWatchdog(void)
{
#if 0
static unsigned int _v_info = (unsigned int) -1;
unsigned int v_info;
if (fd == -1)
return;
ioctl(fd, MPEG_VID_GET_V_INFO_RAW, &v_info);
if (_v_info != v_info)
{
lt_debug("%s params changed. old: %08x new: %08x\n", __FUNCTION__, _v_info, v_info);
setAspectRatio(-1, -1);
}
_v_info = v_info;
#endif
}
void cVideo::Pig(int x, int y, int w, int h, int osd_w, int osd_h)
{
char buffer[64];
@@ -578,7 +594,7 @@ void cVideo::Pig(int x, int y, int w, int h, int osd_w, int osd_h)
* TODO: check this in the driver sources */
int xres = 720; /* proc_get_hex("/proc/stb/vmpeg/0/xres") */
int yres = 576; /* proc_get_hex("/proc/stb/vmpeg/0/yres") */
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);
lt_debug("#%d %s: x:%d y:%d w:%d h:%d ow:%d oh:%d\n", vdec->devnum, __func__, x, y, w, h, osd_w, osd_h);
if (x == -1 && y == -1 && w == -1 && h == -1)
{
_w = xres;
@@ -593,9 +609,9 @@ void cVideo::Pig(int x, int y, int w, int h, int osd_w, int osd_h)
_y = y * yres / osd_h;
_h = h * yres / osd_h;
}
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);
lt_debug("#%d %s: x:%d y:%d w:%d h:%d xr:%d yr:%d\n", vdec->devnum, __func__, _x, _y, _w, _h, xres, yres);
sprintf(buffer, "%x %x %x %x", _x, _y, _w, _h);
proc_put(VMPEG_dst_all[devnum], buffer, strlen(buffer));
proc_put(VMPEG_dst_all[vdec->devnum], buffer, strlen(buffer));
}
static inline int rate2csapi(int rate)
@@ -625,6 +641,11 @@ static inline int rate2csapi(int rate)
}
void cVideo::getPictureInfo(int &width, int &height, int &rate)
{
vdec->getPictureInfo(width, height, rate);
}
void VDec::getPictureInfo(int &width, int &height, int &rate)
{
video_size_t s;
int r;
@@ -662,6 +683,11 @@ void cVideo::SetSyncMode(AVSYNC_TYPE mode)
};
int cVideo::SetStreamType(VIDEO_FORMAT type)
{
return vdec->SetStreamType(type);
}
int VDec::SetStreamType(VIDEO_FORMAT type)
{
static const char *VF[] = {
"VIDEO_FORMAT_MPEG2",
@@ -693,7 +719,7 @@ int cVideo::SetStreamType(VIDEO_FORMAT type)
return 0;
}
int64_t cVideo::GetPTS(void)
int64_t VDec::GetPTS(void)
{
int64_t pts = 0;
if (ioctl(fd, VIDEO_GET_PTS, &pts) < 0)
@@ -703,5 +729,5 @@ int64_t cVideo::GetPTS(void)
void cVideo::SetDemux(cDemux *)
{
lt_debug("#%d %s not implemented yet\n", devnum, __func__);
lt_debug("#%d %s not implemented yet\n", vdec->devnum, __func__);
}

View File

@@ -1,197 +0,0 @@
#ifndef _VIDEO_TD_H
#define _VIDEO_TD_H
#include <linux/dvb/video.h>
#include <cs_types.h>
typedef enum {
ANALOG_SD_RGB_CINCH = 0x00,
ANALOG_SD_YPRPB_CINCH,
ANALOG_HD_RGB_CINCH,
ANALOG_HD_YPRPB_CINCH,
ANALOG_SD_RGB_SCART = 0x10,
ANALOG_SD_YPRPB_SCART,
ANALOG_HD_RGB_SCART,
ANALOG_HD_YPRPB_SCART,
ANALOG_SCART_MASK = 0x10
} analog_mode_t;
typedef enum {
VIDEO_FORMAT_MPEG2 = 0,
VIDEO_FORMAT_MPEG4,
VIDEO_FORMAT_VC1,
VIDEO_FORMAT_JPEG,
VIDEO_FORMAT_GIF,
VIDEO_FORMAT_PNG
} VIDEO_FORMAT;
typedef enum {
VIDEO_SD = 0,
VIDEO_HD,
VIDEO_120x60i,
VIDEO_320x240i,
VIDEO_1440x800i,
VIDEO_360x288i
} VIDEO_DEFINITION;
typedef enum {
VIDEO_FRAME_RATE_23_976 = 0,
VIDEO_FRAME_RATE_24,
VIDEO_FRAME_RATE_25,
VIDEO_FRAME_RATE_29_97,
VIDEO_FRAME_RATE_30,
VIDEO_FRAME_RATE_50,
VIDEO_FRAME_RATE_59_94,
VIDEO_FRAME_RATE_60
} VIDEO_FRAME_RATE;
typedef enum {
DISPLAY_AR_1_1,
DISPLAY_AR_4_3,
DISPLAY_AR_14_9,
DISPLAY_AR_16_9,
DISPLAY_AR_20_9,
DISPLAY_AR_RAW,
} DISPLAY_AR;
typedef enum {
DISPLAY_AR_MODE_PANSCAN = 0,
DISPLAY_AR_MODE_LETTERBOX,
DISPLAY_AR_MODE_NONE,
DISPLAY_AR_MODE_PANSCAN2
} DISPLAY_AR_MODE;
typedef enum {
VIDEO_DB_DR_NEITHER = 0,
VIDEO_DB_ON,
VIDEO_DB_DR_BOTH
} VIDEO_DB_DR;
typedef enum {
VIDEO_PLAY_STILL = 0,
VIDEO_PLAY_CLIP,
VIDEO_PLAY_TRICK,
VIDEO_PLAY_MOTION,
VIDEO_PLAY_MOTION_NO_SYNC
} VIDEO_PLAY_MODE;
typedef enum {
VIDEO_STD_NTSC,
VIDEO_STD_SECAM,
VIDEO_STD_PAL,
VIDEO_STD_480P,
VIDEO_STD_576P,
VIDEO_STD_720P60,
VIDEO_STD_1080I60,
VIDEO_STD_720P50,
VIDEO_STD_1080I50,
VIDEO_STD_1080P30,
VIDEO_STD_1080P24,
VIDEO_STD_1080P25,
VIDEO_STD_AUTO,
VIDEO_STD_1080P50, /* SPARK only */
VIDEO_STD_MAX
} VIDEO_STD;
/* not used, for dummy functions */
typedef enum {
VIDEO_HDMI_CEC_MODE_OFF = 0,
VIDEO_HDMI_CEC_MODE_TUNER,
VIDEO_HDMI_CEC_MODE_RECORDER
} VIDEO_HDMI_CEC_MODE;
typedef enum
{
VIDEO_CONTROL_BRIGHTNESS = 0,
VIDEO_CONTROL_CONTRAST,
VIDEO_CONTROL_SATURATION,
VIDEO_CONTROL_HUE,
VIDEO_CONTROL_SHARPNESS,
VIDEO_CONTROL_MAX = VIDEO_CONTROL_SHARPNESS
} VIDEO_CONTROL;
class cDemux;
class cVideo
{
friend class cDemux;
friend class cPlayback;
private:
/* video device */
int fd;
unsigned int devnum;
/* apparently we cannot query the driver's state
=> remember it */
video_play_state_t playstate;
int /*vidDispMode_t*/ croppingMode;
int /*vidOutFmt_t*/ outputformat;
int scartvoltage;
VIDEO_FORMAT StreamType;
VIDEO_DEFINITION VideoDefinition;
DISPLAY_AR DisplayAR;
VIDEO_PLAY_MODE SyncMode;
DISPLAY_AR_MODE ARMode;
VIDEO_DB_DR eDbDr;
DISPLAY_AR PictureAR;
VIDEO_FRAME_RATE FrameRate;
int video_standby;
int64_t GetPTS(void);
void openDevice(void);
void closeDevice(void);
public:
/* constructor & destructor */
cVideo(int mode, void *, void *, unsigned int unit = 0);
~cVideo(void);
void * GetTVEnc() { return NULL; };
void * GetTVEncSD() { return NULL; };
/* aspect ratio */
int getAspectRatio(void);
void getPictureInfo(int &width, int &height, int &rate);
int setAspectRatio(int aspect, int mode);
/* cropping mode */
int setCroppingMode(int x = 0 /*vidDispMode_t x = VID_DISPMODE_NORM*/);
/* get play state */
int getPlayState(void);
/* blank on freeze */
int getBlank(void);
int setBlank(int enable);
/* change video play state. Parameters are all unused. */
int Start(void *PcrChannel = NULL, unsigned short PcrPid = 0, unsigned short VideoPid = 0, void *x = NULL);
int Stop(bool blank = true);
bool Pause(void);
/* set video_system */
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; };
void 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 VideoParamWatchdog(void);
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 SetDemux(cDemux *dmx);
};
#endif

59
libspark/video_priv.h Normal file
View File

@@ -0,0 +1,59 @@
/*
* (C) 2010-2013 Stefan Seyfried
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* private video functions, to be used only inside libstb-hal
*/
#ifndef __video_priv__
#define __video_priv__
#include <video_hal.h>
#include <linux/dvb/video.h>
class VDec
{
public:
/* all public, used inside libstb-hal only anyways... */
int fd; /* video device fd */
unsigned int devnum; /* unit number */
/* apparently we cannot query the driver's state
=> remember it */
video_play_state_t playstate;
int video_standby;
bool stillpicture;
/* constructor & destructor */
VDec(unsigned int unit);
~VDec(void);
/* used directly by cVideo */
int getAspectRatio(void);
void getPictureInfo(int &width, int &height, int &rate);
int Start(void);
int Stop(bool blank = true);
int SetStreamType(VIDEO_FORMAT type);
void SetSyncMode(AVSYNC_TYPE mode);
void ShowPicture(const char * fname);
void Standby(unsigned int bOn);
/* used internally by dmx */
int64_t GetPTS(void);
/* used internally by playback */
void openDevice(void);
void closeDevice(void);
};
#endif

View File

@@ -34,7 +34,7 @@
#include "lt_debug.h"
/* Ugh... see comment in destructor for details... */
#include "video_td.h"
#include "video_hal.h"
extern cVideo *videoDecoder;
#define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_DEMUX, this, args)

View File

@@ -40,8 +40,8 @@
#include "lt_dfbinput.h"
/* needed for videodecoder watchdog */
#include "video_td.h"
extern cVideo *videoDecoder;
#include "video_priv.h"
extern VDec *_vdec;
/* same defines as in neutrino's rcinput.h */
#define KEY_TTTV KEY_FN_1
@@ -249,8 +249,8 @@ static void *input_thread(void *data)
{
/* check every 250ms (if a key is pressed on remote, we might
* even check earlier, but it does not really hurt... */
if (videoDecoder)
videoDecoder->VideoParamWatchdog();
if (_vdec)
_vdec->VideoParamWatchdog();
if (events->WaitForEventWithTimeout(events, 0, 250) == DFB_TIMEOUT)
continue;

View File

@@ -12,7 +12,8 @@
#include "playback_td.h"
#include "dmx_hal.h"
#include "audio_td.h"
#include "video_td.h"
#include "video_hal.h"
#include "video_priv.h"
#include "lt_debug.h"
#define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_PLAYBACK, this, args)
#define lt_info(args...) _lt_info(TRIPLE_DEBUG_PLAYBACK, this, args)
@@ -432,7 +433,7 @@ bool cPlayback::SetSpeed(int speed)
if (playback_speed == 1 && speed > 1)
{
audioDecoder->mute(false);
videoDecoder->FastForwardMode();
videoDecoder->vdec->FastForwardMode();
}
playback_speed = speed;
if (playback_speed == 0)
@@ -1212,7 +1213,7 @@ ssize_t cPlayback::read_mpeg()
int pesPacketLen = ((ppes[4] << 8) | ppes[5]) + 6;
if (count + pesPacketLen >= pesbuf_pos)
{
lt_debug("buffer len: %ld, pesPacketLen: %d :-(\n", pesbuf_pos - count, pesPacketLen);
lt_debug("buffer len: %ld, pesPacketLen: %d :-(\n", (long)(pesbuf_pos - count), pesPacketLen);
break;
}

88
libtriple/video_priv.h Normal file
View File

@@ -0,0 +1,88 @@
/*
* (C) 2010-2013 Stefan Seyfried
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* private video functions, only to be used in libstb-hal
*/
#ifndef __video_priv__
#define __video_priv__
#include "video_hal.h"
#include <hardware/vid/vid_inf.h>
#define video_format_t vidDispSize_t
#include <cs_types.h>
#include "dmx_td.h"
#define STB_HAL_VIDEO_HAS_GETSCREENIMAGE 1
typedef enum {
VIDEO_STOPPED, /* Video is stopped */
VIDEO_PLAYING, /* Video is currently playing */
VIDEO_FREEZED /* Video is freezed */
} video_play_state_t;
class VDec
{
public:
/* video device */
int fd;
/* apparently we cannot query the driver's state
=> remember it */
video_play_state_t playstate;
vidDispMode_t croppingMode;
vidOutFmt_t outputformat;
int scartvoltage;
int z[2]; /* zoomvalue for 4:3 (0) and 16:9 (1) in percent */
int *zoomvalue;
void *blank_data[2]; /* we store two blank MPEGs (PAL/NTSC) in there */
int blank_size[2];
void routeVideo(int standby);
int video_standby;
/* constructor & destructor */
VDec(void);
~VDec(void);
/* aspect ratio */
int getAspectRatio(void);
int setAspectRatio(int aspect, int mode);
/* cropping mode */
int setCroppingMode(vidDispMode_t x = VID_DISPMODE_NORM);
/* blank on freeze */
int getBlank(void);
int setBlank(void);
/* change video play state. Parameters are all unused. */
int Start(void);
int Stop(bool blank = true);
/* set video_system */
int SetVideoSystem(int video_system, bool remember = true);
void ShowPicture(const char * fname);
void StopPicture();
void Standby(unsigned int bOn);
void Pig(int x, int y, int w, int h);
int setZoom(int);
void VideoParamWatchdog(void);
void SetVideoMode(analog_mode_t mode);
void FastForwardMode(int mode = 0);
bool GetScreenImage(unsigned char * &data, int &xres, int &yres, bool get_video = true, bool get_osd = false, bool scale_to_video = false);
};
#endif

View File

@@ -34,7 +34,9 @@
#include <avs/avs_inf.h>
#include <clip/clipinfo.h>
#include <hw/hardware.h>
#include "video_td.h"
#include "video_hal.h"
#include "video_priv.h"
#include <hardware/tddevices.h>
#define VIDEO_DEVICE "/dev/" DEVICE_NAME_VIDEO
#include "lt_debug.h"
@@ -53,7 +55,11 @@
_r; \
})
/* catch errors due to usage of class member vdec */
#define vdec __this_is_the_wrong_vdec__
cVideo * videoDecoder = NULL;
VDec * _vdec = NULL;
int system_rev = 0;
#if 0
@@ -64,13 +70,23 @@ extern IDirectFB *dfb;
extern IDirectFBSurface *dfbdest;
#endif
extern struct Ssettings settings;
static pthread_mutex_t stillp_mutex = PTHREAD_MUTEX_INITIALIZER;
/* debugging hacks */
static bool noscart = false;
cVideo::cVideo(int, void *, void *, unsigned int)
{
_vdec = new VDec();
}
cVideo::~cVideo(void)
{
delete _vdec;
_vdec = NULL;
}
VDec::VDec(void)
{
lt_debug("%s\n", __FUNCTION__);
if ((fd = open(VIDEO_DEVICE, O_RDWR)) < 0)
@@ -124,7 +140,7 @@ cVideo::cVideo(int, void *, void *, unsigned int)
lt_info("%s TRIPLE_NOSCART variable prevents SCART switching\n", __FUNCTION__);
}
cVideo::~cVideo(void)
VDec::~VDec(void)
{
playstate = VIDEO_STOPPED;
for (int i = 0; i < 2; i++)
@@ -140,6 +156,11 @@ cVideo::~cVideo(void)
}
int cVideo::setAspectRatio(int aspect, int mode)
{
return _vdec->setAspectRatio(aspect, mode);
}
int VDec::setAspectRatio(int aspect, int mode)
{
static int _mode = -1;
static int _aspect = -1;
@@ -247,6 +268,11 @@ int cVideo::setAspectRatio(int aspect, int mode)
}
int cVideo::getAspectRatio(void)
{
return _vdec->getAspectRatio();
}
int VDec::getAspectRatio(void)
{
VIDEOINFO v;
/* this memset silences *TONS* of valgrind warnings */
@@ -271,7 +297,12 @@ int cVideo::getAspectRatio(void)
}
}
int cVideo::setCroppingMode(vidDispMode_t format)
int cVideo::setCroppingMode(void)
{
return _vdec->setCroppingMode();
}
int VDec::setCroppingMode(vidDispMode_t format)
{
croppingMode = format;
const char *format_string[] = { "norm", "letterbox", "unknown", "mode_1_2", "mode_1_4", "mode_2x", "scale", "disexp" };
@@ -285,6 +316,11 @@ int cVideo::setCroppingMode(vidDispMode_t format)
}
int cVideo::Start(void * /*PcrChannel*/, unsigned short /*PcrPid*/, unsigned short /*VideoPid*/, void * /*hChannel*/)
{
return _vdec->Start();
}
int VDec::Start(void)
{
lt_debug("%s playstate=%d\n", __FUNCTION__, playstate);
if (playstate == VIDEO_PLAYING)
@@ -297,19 +333,29 @@ int cVideo::Start(void * /*PcrChannel*/, unsigned short /*PcrPid*/, unsigned sho
}
int cVideo::Stop(bool blank)
{
return _vdec->Stop(blank);
}
int VDec::Stop(bool blank)
{
lt_debug("%s(%d)\n", __FUNCTION__, blank);
if (blank)
{
playstate = VIDEO_STOPPED;
fop(ioctl, MPEG_VID_STOP);
return setBlank(1);
return setBlank();
}
playstate = VIDEO_FREEZED;
return fop(ioctl, MPEG_VID_FREEZE);
}
int cVideo::setBlank(int)
{
return _vdec->setBlank();
}
int VDec::setBlank(void)
{
lt_debug("%s\n", __FUNCTION__);
/* The TripleDragon has no VIDEO_SET_BLANK ioctl.
@@ -359,19 +405,40 @@ int cVideo::setBlank(int)
}
int cVideo::SetVideoSystem(int video_system, bool remember)
{
return _vdec->SetVideoSystem(video_system, remember);
}
int VDec::SetVideoSystem(int video_system, bool remember)
{
lt_info("%s(%d, %d)\n", __FUNCTION__, video_system, remember);
if (video_system > VID_DISPFMT_SECAM || video_system < 0)
video_system = VID_DISPFMT_PAL;
return fop(ioctl, MPEG_VID_SET_DISPFMT, video_system);
vidDispFmt_t tmp;
switch (video_system) {
case VIDEO_STD_SECAM:
tmp = VID_DISPFMT_SECAM;
break;
case VIDEO_STD_NTSC:
tmp = VID_DISPFMT_NTSC;
break;
case VIDEO_STD_PAL:
default:
tmp = VID_DISPFMT_PAL;
break;
}
return fop(ioctl, MPEG_VID_SET_DISPFMT, tmp);
}
int cVideo::getPlayState(void)
{
return playstate;
return _vdec->playstate;
}
void cVideo::SetVideoMode(analog_mode_t mode)
{
_vdec->SetVideoMode(mode);
}
void VDec::SetVideoMode(analog_mode_t mode)
{
lt_debug("%s(%d)\n", __FUNCTION__, mode);
switch(mode)
@@ -390,6 +457,11 @@ void cVideo::SetVideoMode(analog_mode_t mode)
}
void cVideo::ShowPicture(const char * fname)
{
_vdec->ShowPicture(fname);
}
void VDec::ShowPicture(const char * fname)
{
lt_debug("%s(%s)\n", __FUNCTION__, fname);
char destname[512];
@@ -484,17 +556,27 @@ void cVideo::ShowPicture(const char * fname)
}
void cVideo::StopPicture()
{
_vdec->StopPicture();
}
void VDec::StopPicture()
{
lt_debug("%s\n", __FUNCTION__);
fop(ioctl, MPEG_VID_SELECT_SOURCE, VID_SOURCE_DEMUX);
}
void cVideo::Standby(unsigned int bOn)
{
_vdec->Standby(bOn);
}
void VDec::Standby(unsigned int bOn)
{
lt_debug("%s(%d)\n", __FUNCTION__, bOn);
if (bOn)
{
setBlank(1);
setBlank();
fop(ioctl, MPEG_VID_SET_OUTFMT, VID_OUTFMT_DISABLE_DACS);
} else
fop(ioctl, MPEG_VID_SET_OUTFMT, outputformat);
@@ -503,6 +585,11 @@ void cVideo::Standby(unsigned int bOn)
}
int cVideo::getBlank(void)
{
return _vdec->getBlank();
}
int VDec::getBlank(void)
{
VIDEOINFO v;
memset(&v, 0, sizeof(v));
@@ -516,7 +603,7 @@ int cVideo::getBlank(void)
}
/* set zoom in percent (100% == 1:1) */
int cVideo::setZoom(int zoom)
int VDec::setZoom(int zoom)
{
if (zoom == -1) // "auto" reset
zoom = *zoomvalue;
@@ -604,7 +691,7 @@ void cVideo::setZoomAspect(int index)
/* this function is regularly called, checks if video parameters
changed and triggers appropriate actions */
void cVideo::VideoParamWatchdog(void)
void VDec::VideoParamWatchdog(void)
{
static unsigned int _v_info = (unsigned int) -1;
unsigned int v_info;
@@ -620,6 +707,11 @@ void cVideo::VideoParamWatchdog(void)
}
void cVideo::Pig(int x, int y, int w, int h, int /*osd_w*/, int /*osd_h*/)
{
_vdec->Pig(x, y, w, h);
}
void VDec::Pig(int x, int y, int w, int h)
{
/* x = y = w = h = -1 -> reset / "hide" PIG */
if (x == -1 && y == -1 && w == -1 && h == -1)
@@ -649,7 +741,7 @@ void cVideo::getPictureInfo(int &width, int &height, int &rate)
VIDEOINFO v;
/* this memset silences *TONS* of valgrind warnings */
memset(&v, 0, sizeof(v));
ioctl(fd, MPEG_VID_GET_V_INFO, &v);
ioctl(_vdec->fd, MPEG_VID_GET_V_INFO, &v);
/* convert to Coolstream API */
rate = (int)v.frame_rate - 1;
width = (int)v.h_size;
@@ -664,6 +756,7 @@ void cVideo::SetSyncMode(AVSYNC_TYPE Mode)
* { 1, LOCALE_OPTIONS_ON },
* { 2, LOCALE_AUDIOMENU_AVSYNC_AM }
*/
int fd = _vdec->fd;
switch(Mode)
{
case 0:
@@ -693,7 +786,7 @@ int cVideo::SetStreamType(VIDEO_FORMAT type)
return 0;
}
void cVideo::routeVideo(int standby)
void VDec::routeVideo(int standby)
{
lt_debug("%s(%d)\n", __FUNCTION__, standby);
@@ -729,7 +822,7 @@ void cVideo::routeVideo(int standby)
close(avsfd);
}
void cVideo::FastForwardMode(int mode)
void VDec::FastForwardMode(int mode)
{
lt_debug("%s\n", __FUNCTION__);
fop(ioctl, MPEG_VID_FASTFORWARD, mode);

View File

@@ -1,196 +0,0 @@
#ifndef _VIDEO_TD_H
#define _VIDEO_TD_H
#include <hardware/vid/vid_inf.h>
#define video_format_t vidDispSize_t
//#define video_displayformat_t vidDispMode_t
#include <cs_types.h>
#define STB_HAL_VIDEO_HAS_GETSCREENIMAGE 1
typedef enum {
ANALOG_SD_RGB_SCART = 0x00,
ANALOG_SD_YPRPB_SCART,
ANALOG_HD_RGB_SCART,
ANALOG_HD_YPRPB_SCART,
ANALOG_SD_RGB_CINCH = 0x80,
ANALOG_SD_YPRPB_CINCH,
ANALOG_HD_RGB_CINCH,
ANALOG_HD_YPRPB_CINCH,
} analog_mode_t;
typedef enum {
VIDEO_FORMAT_MPEG2 = 0,
VIDEO_FORMAT_MPEG4,
VIDEO_FORMAT_VC1,
VIDEO_FORMAT_JPEG,
VIDEO_FORMAT_GIF,
VIDEO_FORMAT_PNG
} VIDEO_FORMAT;
typedef enum {
VIDEO_SD = 0,
VIDEO_HD,
VIDEO_120x60i,
VIDEO_320x240i,
VIDEO_1440x800i,
VIDEO_360x288i
} VIDEO_DEFINITION;
typedef enum {
VIDEO_FRAME_RATE_23_976 = 0,
VIDEO_FRAME_RATE_24,
VIDEO_FRAME_RATE_25,
VIDEO_FRAME_RATE_29_97,
VIDEO_FRAME_RATE_30,
VIDEO_FRAME_RATE_50,
VIDEO_FRAME_RATE_59_94,
VIDEO_FRAME_RATE_60
} VIDEO_FRAME_RATE;
typedef enum {
DISPLAY_AR_1_1,
DISPLAY_AR_4_3,
DISPLAY_AR_14_9,
DISPLAY_AR_16_9,
DISPLAY_AR_20_9,
DISPLAY_AR_RAW,
} DISPLAY_AR;
typedef enum {
DISPLAY_AR_MODE_PANSCAN = 0,
DISPLAY_AR_MODE_LETTERBOX,
DISPLAY_AR_MODE_NONE,
DISPLAY_AR_MODE_PANSCAN2
} DISPLAY_AR_MODE;
typedef enum {
VIDEO_DB_DR_NEITHER = 0,
VIDEO_DB_ON,
VIDEO_DB_DR_BOTH
} VIDEO_DB_DR;
typedef enum {
VIDEO_PLAY_STILL = 0,
VIDEO_PLAY_CLIP,
VIDEO_PLAY_TRICK,
VIDEO_PLAY_MOTION,
VIDEO_PLAY_MOTION_NO_SYNC
} VIDEO_PLAY_MODE;
typedef enum {
VIDEO_STD_NTSC = VID_DISPFMT_NTSC, /* 0 */
VIDEO_STD_PAL = VID_DISPFMT_PAL, /* 1 */
VIDEO_STD_SECAM = VID_DISPFMT_SECAM, /* 4 */
VIDEO_STD_1080I50 = VIDEO_STD_PAL, /* hack, this is used in neutrino settings default */
VIDEO_STD_MAX = VIDEO_STD_SECAM + 1
} VIDEO_STD;
typedef enum {
VIDEO_STOPPED, /* Video is stopped */
VIDEO_PLAYING, /* Video is currently playing */
VIDEO_FREEZED /* Video is freezed */
} video_play_state_t;
/* not used, for dummy functions */
typedef enum {
VIDEO_HDMI_CEC_MODE_OFF = 0,
VIDEO_HDMI_CEC_MODE_TUNER,
VIDEO_HDMI_CEC_MODE_RECORDER
} VIDEO_HDMI_CEC_MODE;
typedef enum
{
VIDEO_CONTROL_BRIGHTNESS = 0,
VIDEO_CONTROL_CONTRAST,
VIDEO_CONTROL_SATURATION,
VIDEO_CONTROL_HUE,
VIDEO_CONTROL_SHARPNESS,
VIDEO_CONTROL_MAX = VIDEO_CONTROL_SHARPNESS
} VIDEO_CONTROL;
class cDemux;
class cVideo
{
private:
/* video device */
int fd;
/* apparently we cannot query the driver's state
=> remember it */
video_play_state_t playstate;
vidDispMode_t croppingMode;
vidOutFmt_t outputformat;
int scartvoltage;
int z[2]; /* zoomvalue for 4:3 (0) and 16:9 (1) in percent */
int *zoomvalue;
void *blank_data[2]; /* we store two blank MPEGs (PAL/NTSC) in there */
int blank_size[2];
VIDEO_FORMAT StreamType;
VIDEO_DEFINITION VideoDefinition;
DISPLAY_AR DisplayAR;
VIDEO_PLAY_MODE SyncMode;
DISPLAY_AR_MODE ARMode;
VIDEO_DB_DR eDbDr;
DISPLAY_AR PictureAR;
VIDEO_FRAME_RATE FrameRate;
void routeVideo(int standby);
int video_standby;
public:
/* constructor & destructor */
cVideo(int mode, void *, void *, unsigned int unit = 0);
~cVideo(void);
void * GetTVEnc() { return NULL; };
void * GetTVEncSD() { return NULL; };
/* aspect ratio */
int getAspectRatio(void);
void getPictureInfo(int &width, int &height, int &rate);
int setAspectRatio(int aspect, int mode);
/* cropping mode */
int setCroppingMode(vidDispMode_t x = VID_DISPMODE_NORM);
/* get play state */
int getPlayState(void);
/* blank on freeze */
int getBlank(void);
int setBlank(int enable);
/* change video play state. Parameters are all unused. */
int Start(void *PcrChannel = NULL, unsigned short PcrPid = 0, unsigned short VideoPid = 0, void *x = NULL);
int Stop(bool blank = true);
bool Pause(void);
/* set video_system */
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; };
void 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; };
int setZoom(int);
void VideoParamWatchdog(void);
void setContrast(int val);
void SetVideoMode(analog_mode_t mode);
void SetDBDR(int) { return; };
void SetAudioHandle(void *) { return; };
void FastForwardMode(int mode = 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);
bool GetScreenImage(unsigned char * &data, int &xres, int &yres, bool get_video = true, bool get_osd = false, bool scale_to_video = false);
};
#endif

View File

@@ -37,7 +37,7 @@
#include "lt_debug.h"
/* needed for getSTC :-( */
#include "video_lib.h"
#include "video_hal.h"
extern cVideo *videoDecoder;
#define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_DEMUX, this, args)
@@ -468,8 +468,11 @@ void cDemux::removePid(unsigned short Pid)
void cDemux::getSTC(int64_t * STC)
{
int64_t pts = 0;
#if 0
/* is not yet implemented in vdec anyway */
if (videoDecoder)
pts = videoDecoder->GetPTS();
#endif
*STC = pts;
}

View File

@@ -23,7 +23,7 @@
#include <cstdio>
#include <cstdlib>
#include "video_lib.h"
#include "video_hal.h"
#include "dmx_hal.h"
#include "avdec.h"
#include "lt_debug.h"
@@ -40,9 +40,6 @@ extern AVDec *avdec;
cVideo::cVideo(int, void *, void *, unsigned int)
{
lt_debug("%s\n", __func__);
display_aspect = DISPLAY_AR_16_9;
display_crop = DISPLAY_AR_MODE_LETTERBOX;
v_format = VIDEO_FORMAT_MPEG2;
}
cVideo::~cVideo(void)
@@ -61,21 +58,21 @@ int cVideo::getAspectRatio(void)
return ret;
}
int cVideo::setCroppingMode(int)
int cVideo::setCroppingMode(void)
{
return 0;
}
int cVideo::Start(void *, unsigned short, unsigned short, void *)
{
lt_debug("%s running %d >\n", __func__, thread_running);
lt_debug("%s >\n", __func__);
avdec->start_video();
return 0;
}
int cVideo::Stop(bool)
{
lt_debug("%s running %d >\n", __func__, thread_running);
lt_debug("%s >\n", __func__);
avdec->stop_video();
return 0;
}
@@ -85,6 +82,7 @@ int cVideo::setBlank(int)
return 1;
}
/* this is a dummy */
int cVideo::SetVideoSystem(int system, bool)
{
int h;
@@ -118,14 +116,13 @@ int cVideo::SetVideoSystem(int system, bool)
lt_info("%s: unhandled value %d\n", __func__, system);
return 0;
}
v_std = (VIDEO_STD) system;
output_h = h;
lt_debug("%s: pic height is %d\n", __func__, h);
return 0;
}
int cVideo::getPlayState(void)
{
return VIDEO_PLAYING;
return 1; //VIDEO_PLAYING;
}
void cVideo::SetVideoMode(analog_mode_t)
@@ -154,18 +151,14 @@ int cVideo::getBlank(void)
void cVideo::Pig(int x, int y, int w, int h, int, int)
{
pig_x = x;
pig_y = y;
pig_w = w;
pig_h = h;
avdec->pig(x, y, w, h);
}
void cVideo::getPictureInfo(int &width, int &height, int &rate)
{
width = dec_w;
height = dec_h;
rate = dec_r;
width = 1; //dec_w;
height = 1; //dec_h;
rate = 1; //dec_r;
}
void cVideo::SetSyncMode(AVSYNC_TYPE)
@@ -174,7 +167,6 @@ void cVideo::SetSyncMode(AVSYNC_TYPE)
int cVideo::SetStreamType(VIDEO_FORMAT v)
{
v_format = v;
return avdec->set_videoformat(v);
}
@@ -185,12 +177,6 @@ bool cVideo::GetScreenImage(unsigned char * &data, int &xres, int &yres, bool ge
return false;
}
int64_t cVideo::GetPTS(void)
{
int64_t pts = 0;
return pts;
}
void cVideo::SetDemux(cDemux *)
{
lt_debug("%s: not implemented yet\n", __func__);

View File

@@ -1,215 +0,0 @@
#ifndef _VIDEO_TD_H
#define _VIDEO_TD_H
#include <vector>
#include <linux/dvb/video.h>
#include <cs_types.h>
extern "C" {
#include <libavutil/rational.h>
}
typedef enum {
ANALOG_SD_RGB_CINCH = 0x00,
ANALOG_SD_YPRPB_CINCH,
ANALOG_HD_RGB_CINCH,
ANALOG_HD_YPRPB_CINCH,
ANALOG_SD_RGB_SCART = 0x10,
ANALOG_SD_YPRPB_SCART,
ANALOG_HD_RGB_SCART,
ANALOG_HD_YPRPB_SCART,
ANALOG_SCART_MASK = 0x10
} analog_mode_t;
typedef enum {
VIDEO_FORMAT_MPEG2 = 0,
VIDEO_FORMAT_MPEG4,
VIDEO_FORMAT_VC1,
VIDEO_FORMAT_JPEG,
VIDEO_FORMAT_GIF,
VIDEO_FORMAT_PNG
} VIDEO_FORMAT;
typedef enum {
VIDEO_SD = 0,
VIDEO_HD,
VIDEO_120x60i,
VIDEO_320x240i,
VIDEO_1440x800i,
VIDEO_360x288i
} VIDEO_DEFINITION;
typedef enum {
VIDEO_FRAME_RATE_23_976 = 0,
VIDEO_FRAME_RATE_24,
VIDEO_FRAME_RATE_25,
VIDEO_FRAME_RATE_29_97,
VIDEO_FRAME_RATE_30,
VIDEO_FRAME_RATE_50,
VIDEO_FRAME_RATE_59_94,
VIDEO_FRAME_RATE_60
} VIDEO_FRAME_RATE;
typedef enum {
DISPLAY_AR_1_1,
DISPLAY_AR_4_3,
DISPLAY_AR_14_9,
DISPLAY_AR_16_9,
DISPLAY_AR_20_9,
DISPLAY_AR_RAW,
} DISPLAY_AR;
typedef enum {
DISPLAY_AR_MODE_PANSCAN = 0,
DISPLAY_AR_MODE_LETTERBOX,
DISPLAY_AR_MODE_NONE,
DISPLAY_AR_MODE_PANSCAN2
} DISPLAY_AR_MODE;
typedef enum {
VIDEO_DB_DR_NEITHER = 0,
VIDEO_DB_ON,
VIDEO_DB_DR_BOTH
} VIDEO_DB_DR;
typedef enum {
VIDEO_PLAY_STILL = 0,
VIDEO_PLAY_CLIP,
VIDEO_PLAY_TRICK,
VIDEO_PLAY_MOTION,
VIDEO_PLAY_MOTION_NO_SYNC
} VIDEO_PLAY_MODE;
typedef enum {
VIDEO_STD_NTSC,
VIDEO_STD_SECAM,
VIDEO_STD_PAL,
VIDEO_STD_480P,
VIDEO_STD_576P,
VIDEO_STD_720P60,
VIDEO_STD_1080I60,
VIDEO_STD_720P50,
VIDEO_STD_1080I50,
VIDEO_STD_1080P30,
VIDEO_STD_1080P24,
VIDEO_STD_1080P25,
VIDEO_STD_AUTO,
VIDEO_STD_1080P50, /* SPARK only */
VIDEO_STD_MAX
} VIDEO_STD;
/* not used, for dummy functions */
typedef enum {
VIDEO_HDMI_CEC_MODE_OFF = 0,
VIDEO_HDMI_CEC_MODE_TUNER,
VIDEO_HDMI_CEC_MODE_RECORDER
} VIDEO_HDMI_CEC_MODE;
typedef enum
{
VIDEO_CONTROL_BRIGHTNESS = 0,
VIDEO_CONTROL_CONTRAST,
VIDEO_CONTROL_SATURATION,
VIDEO_CONTROL_HUE,
VIDEO_CONTROL_SHARPNESS,
VIDEO_CONTROL_MAX = VIDEO_CONTROL_SHARPNESS
} VIDEO_CONTROL;
class cDemux;
#define VDEC_MAXBUFS 0x30
class cVideo
{
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;
};
int buf_in, buf_out, buf_num;
int64_t GetPTS(void);
public:
/* constructor & destructor */
cVideo(int mode, void *, void *, unsigned int unit = 0);
~cVideo(void);
void * GetTVEnc() { return NULL; };
void * GetTVEncSD() { return NULL; };
/* aspect ratio */
int getAspectRatio(void);
void getPictureInfo(int &width, int &height, int &rate);
int setAspectRatio(int aspect, int mode);
/* cropping mode */
int setCroppingMode(int x = 0 /*vidDispMode_t x = VID_DISPMODE_NORM*/);
/* get play state */
int getPlayState(void);
/* blank on freeze */
int getBlank(void);
int setBlank(int enable);
/* change video play state. Parameters are all unused. */
int Start(void *PcrChannel = NULL, unsigned short PcrPid = 0, unsigned short VideoPid = 0, void *x = NULL);
int Stop(bool blank = true);
bool Pause(void);
/* set video_system */
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; };
void 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 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 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);
private:
SWFramebuffer buffers[VDEC_MAXBUFS];
int dec_w, dec_h;
int dec_r;
bool w_h_changed;
bool thread_running;
VIDEO_FORMAT v_format;
VIDEO_STD v_std;
DISPLAY_AR display_aspect;
DISPLAY_AR_MODE display_crop;
int output_h;
int pig_x;
int pig_y;
int pig_w;
int pig_h;
};
#endif