- Remove some globals from vcrcontrol

- Allow ttx/epg keys for timeshift
- Fix record+live streaming
- Live stream code changes for testing
- Changes to handle internal CA multi-decoding
- hack for -Werror compiling



git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@1040 e54a6e83-5905-42d5-8d5c-058d10e6a962
This commit is contained in:
focus
2011-01-25 17:22:38 +00:00
parent 80f321484a
commit ab0f7f731c
21 changed files with 306 additions and 214 deletions

View File

@@ -1,19 +1,21 @@
#include "pv_config.h"
#include <cstring>
#include <cstdlib>
#ifdef FBV_SUPPORT_CRW
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <setjmp.h>
#include "pictureviewer.h"
#undef HAVE_STDLIB_H // -Werror complain
extern "C" {
#include <jpeglib.h>
}
#include <setjmp.h>
#include "pictureviewer.h"
/*
Get a 2-byte integer, making no assumptions about CPU byte order.
Nor should we assume that the compiler evaluates left-to-right.

View File

@@ -17,10 +17,6 @@
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/socket.h>
extern "C" {
#include <jpeglib.h>
}
#include <setjmp.h>
@@ -28,6 +24,11 @@ extern "C" {
#include "pictureviewer.h"
#include "picv_client_server.h"
#undef HAVE_STDLIB_H // -Werror complain
extern "C" {
#include <jpeglib.h>
}
#define MIN(a,b) ((a)>(b)?(b):(a))
struct r_jpeg_error_mgr

View File

@@ -57,6 +57,7 @@
#if HAVE_COOL_HARDWARE
#include <record_cs.h>
#include <driver/vfd.h>
#include <ca_cs.h>
#endif
#if HAVE_TRIPLEDRAGON
#include <record_td.h>
@@ -137,9 +138,14 @@ stream2file_error_msg_t start_recording(const char * const filename,
record = NULL;
return STREAM2FILE_INVALID_DIRECTORY;
}
if(g_current_channel) {
cam0->setCaPmt(g_current_channel->getCaPmt(), DEMUX_SOURCE_0, cam0->getCaMask() | DEMUX_DECODE_2 /*5*/, true); // demux 0 + 2, update
if(g_current_channel)
cam0->setCaPmt(g_current_channel->getCaPmt(), 0, 5, true); // demux 0 + 2, update
int len;
unsigned char * pmt = g_current_channel->getRawPmt(len);
cCA * ca = cCA::GetInstance();
ca->SendPMT(DEMUX_SOURCE_2, pmt, len);
}
CVFD::getInstance()->ShowIcon(VFD_ICON_CAM1, true);

View File

@@ -29,14 +29,12 @@
#include <zapit/cam.h>
#include <zapit/channel.h>
extern CZapitChannel *g_current_channel;
extern CCam *cam0;
#define TS_SIZE 188
//#define IN_SIZE (2048 * TS_SIZE)
#define IN_SIZE (TS_SIZE * 362)
#define IN_SIZE (2048 * TS_SIZE)
//#define IN_SIZE (TS_SIZE * 362)
#define DMX_BUFFER_SIZE (3008 * 62)
#define DMX_BUFFER_SIZE (2 * 3008 * 62)
/* maximum number of pes pids */
#define MAXPIDS 64
@@ -47,14 +45,17 @@ extern CCam *cam0;
//unsigned char * buf;
int demuxfd[MAXPIDS];
extern CZapitChannel *g_current_channel;
extern CCam *cam0;
//int demuxfd[MAXPIDS];
static unsigned char exit_flag = 0;
static unsigned int writebuf_size = 0;
static unsigned char writebuf[PACKET_SIZE];
static int
sync_byte_offset (const unsigned char * buf, const unsigned int len)
#ifdef SYNC_TS
static int sync_byte_offset (const unsigned char * buf, const unsigned int len)
{
unsigned int i;
@@ -65,6 +66,7 @@ sync_byte_offset (const unsigned char * buf, const unsigned int len)
return -1;
}
#endif
void packet_stdout (int fd, unsigned char * buf, int count, void * /*p*/)
{
@@ -178,7 +180,7 @@ int open_incoming_port (int port)
void * streamts_live_thread(void *data);
int streamts_stop;
void streamts_main_thread(void */*data*/)
void streamts_main_thread(void * /*data*/)
{
struct sockaddr_in servaddr;
int clilen;
@@ -348,14 +350,22 @@ void * streamts_live_thread(void *data)
dmx->Start();
if(g_current_channel)
cam0->setCaPmt(g_current_channel->getCaPmt(), 0, 3, true); // demux 0 + 1, update
cam0->setCaPmt(g_current_channel->getCaPmt(), DEMUX_SOURCE_0, cam0->getCaMask() | DEMUX_DECODE_1 /*3*/, true); // demux 0 + 1, update
size_t pos;
ssize_t r;
#if 0
size_t pos;
ssize_t todo;
int offset;
#endif
#ifdef SYNC_TS
int offset = 0;
#endif
while (!exit_flag) {
r = dmx->Read(buf, IN_SIZE, 100);
if(r > 0)
packet_stdout(fd, buf, r, NULL);
#if 0
todo = IN_SIZE;
pos = 0;
@@ -369,7 +379,9 @@ void * streamts_live_thread(void *data)
usleep(1000);
}
if(!exit_flag) {
//packet_stdout(fd, buf, IN_SIZE, NULL);
#ifndef SYNC_TS
packet_stdout(fd, buf, IN_SIZE, NULL);
#else
/* make sure to start with a ts header */
offset = sync_byte_offset(buf, IN_SIZE);
@@ -377,12 +389,14 @@ void * streamts_live_thread(void *data)
continue;
packet_stdout(fd, buf + offset, IN_SIZE - offset, NULL);
#endif
}
#endif
}
printf("Exiting LIVE STREAM thread, fd %d\n", fd);
if(g_current_channel)
cam0->setCaPmt(g_current_channel->getCaPmt(), 0, 1, true); // demux 0, update
cam0->setCaPmt(g_current_channel->getCaPmt(), DEMUX_SOURCE_0, cam0->getCaMask() & ~DEMUX_DECODE_1 /* 1 */, true); // demux 0, update
delete dmx;
free(buf);

View File

@@ -28,32 +28,13 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <config.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <driver/vcrcontrol.h>
#include <gui/movieinfo.h>
#include <driver/encoding.h>
#include <driver/stream2file.h>
#include <gui/widget/messagebox.h>
#include <global.h>
#include <neutrino.h>
#include <gui/widget/hintbox.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
@@ -62,10 +43,22 @@
#include <sys/stat.h>
#include <sys/stat.h>
#include <sys/vfs.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h>
#include <math.h>
#include <global.h>
#include <neutrino.h>
#include <gui/widget/hintbox.h>
#include <gui/widget/messagebox.h>
#include <driver/vcrcontrol.h>
//#include <gui/movieinfo.h>
#include <driver/encoding.h>
#include <driver/stream2file.h>
#include <daemonc/remotecontrol.h>
#include <zapit/client/zapittools.h>
@@ -80,8 +73,6 @@ extern "C" {
#include <driver/genpsi.h>
}
static CMovieInfo * g_cMovieInfo;
static MI_MOVIE_INFO * g_movieInfo;
t_channel_id rec_channel_id;
static CVCRControl vcrControl;
@@ -131,6 +122,30 @@ bool CVCRControl::Record(const CTimerd::RecordingInfo * const eventinfo)
return Device->Record(eventinfo->channel_id, mode, eventinfo->epgID, eventinfo->epgTitle, eventinfo->apids, eventinfo->epg_starttime);
}
MI_MOVIE_INFO * CVCRControl::GetMovieInfo(void)
{
if(Device)
return Device->recMovieInfo;
return NULL;
}
bool CVCRControl::GetPids(unsigned short *vpid, unsigned short *vtype, unsigned short *apid, unsigned short *atype, unsigned short * apidnum, unsigned short * apids, unsigned short * atypes)
{
if(Device) {
*vpid = Device->rec_vpid;
*vtype = Device->rec_vtype;
*apid = Device->rec_currentapid;
*atype = Device->rec_currentac3;
*apidnum = Device->rec_numpida;
for(int i = 0; i < Device->rec_numpida; i++) {
apids[i] = Device->rec_apids[i];
atypes[i] = Device->rec_ac3flags[i];
}
return true;
}
return false;
}
//-------------------------------------------------------------------------
void CVCRControl::CDevice::getAPIDs(const unsigned char ap, APIDList & apid_list)
{
@@ -496,14 +511,14 @@ bool CVCRControl::CFileDevice::Stop()
{
std::string extMessage = " ";
time_t end_time = time(0);
//printf("[direct] Stop recording, g_movieInfo %lx\n", g_movieInfo); fflush(stdout);
//printf("[direct] Stop recording, recMovieInfo %lx\n", recMovieInfo); fflush(stdout);
//FIXME why not save info if shift ?
//if(!autoshift || autoshift_delete)
if(g_movieInfo && g_cMovieInfo) {
// g_movieInfo->length = (end_time - start_time) / 60;
g_movieInfo->length = (int) round((double) (end_time - start_time) / (double) 60);
if(recMovieInfo && cMovieInfo) {
// recMovieInfo->length = (end_time - start_time) / 60;
recMovieInfo->length = (int) round((double) (end_time - start_time) / (double) 60);
//printf("[direct] stop recording 1\n"); fflush(stdout);
g_cMovieInfo->encodeMovieInfoXml(&extMessage, g_movieInfo);
cMovieInfo->encodeMovieInfoXml(&extMessage, recMovieInfo);
//printf("[direct] stop recording 2\n"); fflush(stdout);
}
bool return_value = (::stop_recording(extMessage.c_str()) == STREAM2FILE_OK);
@@ -513,14 +528,14 @@ bool CVCRControl::CFileDevice::Stop()
deviceState = CMD_VCR_STOP;
if(g_movieInfo) {
g_movieInfo->audioPids.clear();
delete g_movieInfo;
g_movieInfo = NULL;
if(recMovieInfo) {
recMovieInfo->audioPids.clear();
delete recMovieInfo;
recMovieInfo = NULL;
}
if(g_cMovieInfo) {
delete g_cMovieInfo;
g_cMovieInfo = NULL;
if(cMovieInfo) {
delete cMovieInfo;
cMovieInfo = NULL;
}
return return_value;
@@ -811,25 +826,18 @@ bool CVCRControl::CServerDevice::serverConnect()
return true;
}
unsigned short rec_vpid;
unsigned short rec_vtype;
unsigned short rec_apids[10];
unsigned short rec_ac3flags[10];
unsigned short rec_numpida;
unsigned int rec_currentapid, rec_currentac3;
//-------------------------------------------------------------------------
std::string CVCRControl::CFileAndServerDevice::getMovieInfoString(const CVCRCommand /*command*/, const t_channel_id channel_id, const event_id_t epgid, const std::string& epgTitle, APIDList apid_list, const time_t epg_time)
{
std::string extMessage;
std::string apids10;
std::string info1, info2;
if(!g_cMovieInfo)
g_cMovieInfo = new CMovieInfo();
if(!g_movieInfo)
g_movieInfo = new MI_MOVIE_INFO();
if(!cMovieInfo)
cMovieInfo = new CMovieInfo();
if(!recMovieInfo)
recMovieInfo = new MI_MOVIE_INFO();
g_cMovieInfo->clearMovieInfo(g_movieInfo);
cMovieInfo->clearMovieInfo(recMovieInfo);
CZapitClient::responseGetPIDs pids;
g_Zapit->getPIDS (pids);
@@ -837,9 +845,9 @@ std::string CVCRControl::CFileAndServerDevice::getMovieInfoString(const CVCRComm
std::string tmpstring = g_Zapit->getChannelName(channel_id);
if (tmpstring.empty())
g_movieInfo->epgChannel = "unknown";
recMovieInfo->epgChannel = "unknown";
else
g_movieInfo->epgChannel = ZapitTools::UTF8_to_UTF8XML(tmpstring.c_str());
recMovieInfo->epgChannel = ZapitTools::UTF8_to_UTF8XML(tmpstring.c_str());
tmpstring = "not available";
if (epgid != 0) {
@@ -850,31 +858,31 @@ std::string CVCRControl::CFileAndServerDevice::getMovieInfoString(const CVCRComm
info1 = epgdata.info1;
info2 = epgdata.info2;
g_movieInfo->parentalLockAge = epgdata.fsk;
recMovieInfo->parentalLockAge = epgdata.fsk;
if(epgdata.contentClassification.size() > 0 )
g_movieInfo->genreMajor = epgdata.contentClassification[0];
recMovieInfo->genreMajor = epgdata.contentClassification[0];
g_movieInfo->length = epgdata.epg_times.dauer / 60;
recMovieInfo->length = epgdata.epg_times.dauer / 60;
printf("fsk:%d, Genre:%d, Dauer: %d\r\n",g_movieInfo->parentalLockAge,g_movieInfo->genreMajor,g_movieInfo->length);
printf("fsk:%d, Genre:%d, Dauer: %d\r\n",recMovieInfo->parentalLockAge,recMovieInfo->genreMajor,recMovieInfo->length);
}
} else if (!epgTitle.empty()) {
tmpstring = epgTitle;
}
g_movieInfo->epgTitle = ZapitTools::UTF8_to_UTF8XML(tmpstring.c_str());
g_movieInfo->epgId = channel_id;
g_movieInfo->epgInfo1 = ZapitTools::UTF8_to_UTF8XML(info1.c_str());
g_movieInfo->epgInfo2 = ZapitTools::UTF8_to_UTF8XML(info2.c_str());
g_movieInfo->epgEpgId = epgid ;
g_movieInfo->epgMode = g_Zapit->getMode();
g_movieInfo->epgVideoPid = si.vpid;
g_movieInfo->VideoType = si.vtype;
recMovieInfo->epgTitle = ZapitTools::UTF8_to_UTF8XML(tmpstring.c_str());
recMovieInfo->epgId = channel_id;
recMovieInfo->epgInfo1 = ZapitTools::UTF8_to_UTF8XML(info1.c_str());
recMovieInfo->epgInfo2 = ZapitTools::UTF8_to_UTF8XML(info2.c_str());
recMovieInfo->epgEpgId = epgid ;
recMovieInfo->epgMode = g_Zapit->getMode();
recMovieInfo->epgVideoPid = si.vpid;
recMovieInfo->VideoType = si.vtype;
rec_vpid = si.vpid;
rec_vtype = si.vtype;
rec_currentapid = si.apid;
memset(rec_apids, 0, sizeof(unsigned short)*10);
memset(rec_ac3flags, 0, sizeof(unsigned short)*10);
memset(rec_apids, 0, sizeof(unsigned short)*REC_MAX_APIDS);
memset(rec_ac3flags, 0, sizeof(unsigned short)*REC_MAX_APIDS);
rec_numpida = 0;
EPG_AUDIO_PIDS audio_pids;
@@ -890,7 +898,7 @@ std::string CVCRControl::CFileAndServerDevice::getMovieInfoString(const CVCRComm
audio_pids.epgAudioPidName = ZapitTools::UTF8_to_UTF8XML(g_RemoteControl->current_PIDs.APIDs[i].desc);
audio_pids.atype = pids.APIDs[i].is_ac3 ? 1 : pids.APIDs[i].is_aac ? 5 : 0;
audio_pids.selected = (audio_pids.epgAudioPid == (int) rec_currentapid) ? 1 : 0;
g_movieInfo->audioPids.push_back(audio_pids);
recMovieInfo->audioPids.push_back(audio_pids);
if(pids.APIDs[i].is_ac3)
rec_ac3flags[i] = 1;
@@ -905,19 +913,19 @@ std::string CVCRControl::CFileAndServerDevice::getMovieInfoString(const CVCRComm
}
}
//FIXME sometimes no apid in xml ??
if(g_movieInfo->audioPids.empty() && pids.APIDs.size()) {
if(recMovieInfo->audioPids.empty() && pids.APIDs.size()) {
int i = 0;
audio_pids.epgAudioPid = pids.APIDs[i].pid;
audio_pids.epgAudioPidName = ZapitTools::UTF8_to_UTF8XML(g_RemoteControl->current_PIDs.APIDs[i].desc);
audio_pids.atype = pids.APIDs[i].is_ac3 ? 1 : pids.APIDs[i].is_aac ? 5 : 0;
audio_pids.selected = 1;
g_movieInfo->audioPids.push_back(audio_pids);
recMovieInfo->audioPids.push_back(audio_pids);
}
g_movieInfo->epgVTXPID = si.vtxtpid;
recMovieInfo->epgVTXPID = si.vtxtpid;
g_cMovieInfo->encodeMovieInfoXml(&extMessage, g_movieInfo);
cMovieInfo->encodeMovieInfoXml(&extMessage, recMovieInfo);
//g_movieInfo->audioPids.clear();
//recMovieInfo->audioPids.clear();
return extMessage;
}

View File

@@ -39,7 +39,9 @@
#include <timerdclient/timerdclient.h>
#include <neutrinoMessages.h>
#include <gui/movieinfo.h>
#define REC_MAX_APIDS 10
class CVCRControl
{
@@ -74,7 +76,7 @@ class CVCRControl
virtual bool Pause() = 0;
virtual bool Resume() = 0;
virtual bool IsAvailable() = 0;
CDevice() { deviceState = CMD_VCR_STOP; };
CDevice() { deviceState = CMD_VCR_STOP; cMovieInfo = NULL; recMovieInfo = NULL; rec_numpida = 0; rec_vpid = 0;};
virtual ~CDevice(){};
typedef struct {
unsigned short apid;
@@ -83,6 +85,14 @@ class CVCRControl
} APIDDesc;
typedef std::list<APIDDesc> APIDList;
virtual void getAPIDs(const unsigned char apids, APIDList & apid_list);
CMovieInfo * cMovieInfo;
MI_MOVIE_INFO * recMovieInfo;
unsigned short rec_vpid;
unsigned short rec_vtype;
unsigned short rec_apids[REC_MAX_APIDS];
unsigned short rec_ac3flags[REC_MAX_APIDS];
unsigned short rec_numpida;
unsigned short rec_currentapid, rec_currentac3;
};
class CVCRDevice : public CDevice // VCR per IR
@@ -215,6 +225,8 @@ class CVCRControl
bool Pause(){return Device->Pause();};
bool Resume(){return Device->Resume();};
void Screenshot(const t_channel_id channel_id, char * fname = NULL);
MI_MOVIE_INFO * GetMovieInfo(void);
bool GetPids(unsigned short *vpid, unsigned short *vtype, unsigned short *apid, unsigned short *atype, unsigned short * apidnum, unsigned short * apids, unsigned short * atypes);
};

View File

@@ -40,6 +40,7 @@
#include <sys/stat.h>
#include <daemonc/remotecontrol.h>
#include <cs_api.h>
extern CRemoteControl * g_RemoteControl; /* neutrino.cpp */
CVFD::CVFD()
@@ -165,6 +166,7 @@ void CVFD::setlcdparameter(void)
setlcdparameter((mode == MODE_STANDBY) ? g_settings.lcd_setting[SNeutrinoSettings::LCD_STANDBY_BRIGHTNESS] : (mode == MODE_SHUTDOWN) ? g_settings.lcd_setting[SNeutrinoSettings::LCD_DEEPSTANDBY_BRIGHTNESS] : g_settings.lcd_setting[SNeutrinoSettings::LCD_BRIGHTNESS],
last_toggle_state_power);
}
void CVFD::setled(int led1, int led2){
int ret = ioctl(fd, IOC_VFD_LED_CTRL, led1);
if(ret < 0)
@@ -173,6 +175,7 @@ void CVFD::setled(int led1, int led2){
if(ret < 0)
perror("IOC_VFD_LED_CTRL");
}
void CVFD::setled(void)
{
if(!has_lcd) return;
@@ -219,13 +222,17 @@ printf("CVFD::showServicename: %s\n", name.c_str());
void CVFD::showTime(bool force)
{
//unsigned int system_rev = cs_get_revision();
static int recstatus = 0;
#if 0
if(!has_lcd)
return;
if(mode == MODE_SHUTDOWN) {
#endif
if(has_lcd && mode == MODE_SHUTDOWN) {
ShowIcon(VFD_ICON_CAM1, false);
return;
}
if (showclock) {
if (has_lcd && showclock) {
if (mode == MODE_STANDBY) {
char timestr[21];
struct timeb tm;
@@ -246,15 +253,22 @@ void CVFD::showTime(bool force)
if (CNeutrinoApp::getInstance ()->recordingstatus) {
if(clearClock) {
clearClock = 0;
ShowIcon(VFD_ICON_CAM1, false);
if(has_lcd)
ShowIcon(VFD_ICON_CAM1, false);
setled(VFD_LED_1_OFF, VFD_LED_2_OFF);
} else {
clearClock = 1;
ShowIcon(VFD_ICON_CAM1, true);
if(has_lcd)
ShowIcon(VFD_ICON_CAM1, true);
setled(VFD_LED_1_ON, VFD_LED_2_ON);
}
} else if(clearClock) { // in case icon ON after record stopped
} else if(recstatus != CNeutrinoApp::getInstance ()->recordingstatus) { // in case icon ON after record stopped
clearClock = 0;
ShowIcon(VFD_ICON_CAM1, false);
if(has_lcd)
ShowIcon(VFD_ICON_CAM1, false);
setled();
}
recstatus = CNeutrinoApp::getInstance ()->recordingstatus;
}
void CVFD::showRCLock(int /*duration*/)
@@ -601,6 +615,7 @@ void CVFD::Clear()
void CVFD::ShowIcon(vfd_icon icon, bool show)
{
if(!has_lcd) return;
//printf("CVFD::ShowIcon %s %x\n", show ? "show" : "hide", (int) icon);
int ret = ioctl(fd, show ? IOC_VFD_SET_ICON : IOC_VFD_CLEAR_ICON, icon);
if(ret < 0)