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

@@ -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