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

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