mirror of
https://github.com/tuxbox-neutrino/libstb-hal.git
synced 2025-08-27 07:23:11 +02:00
all: clean up cRecord header, hide private stuff
This commit is contained in:
@@ -1 +0,0 @@
|
|||||||
../libspark/record_lib.h
|
|
@@ -1 +0,0 @@
|
|||||||
../libspark/record_lib.h
|
|
41
include/record_hal.h
Normal file
41
include/record_hal.h
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* (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/>.
|
||||||
|
*/
|
||||||
|
#ifndef __record_hal__
|
||||||
|
#define __record_hal__
|
||||||
|
|
||||||
|
#define REC_STATUS_OK 0
|
||||||
|
#define REC_STATUS_SLOW 1
|
||||||
|
#define REC_STATUS_OVERFLOW 2
|
||||||
|
|
||||||
|
class RecData;
|
||||||
|
class cRecord
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
cRecord(int num = 0);
|
||||||
|
~cRecord();
|
||||||
|
|
||||||
|
bool Open();
|
||||||
|
bool Start(int fd, unsigned short vpid, unsigned short *apids, int numapids, uint64_t ch = 0);
|
||||||
|
bool Stop(void);
|
||||||
|
bool AddPid(unsigned short pid);
|
||||||
|
int GetStatus();
|
||||||
|
void ResetStatus();
|
||||||
|
bool ChangePids(unsigned short vpid, unsigned short *apids, int numapids);
|
||||||
|
private:
|
||||||
|
RecData *pd;
|
||||||
|
};
|
||||||
|
#endif
|
@@ -1,16 +1 @@
|
|||||||
#include <config.h>
|
#include "record_hal.h"
|
||||||
#if HAVE_TRIPLEDRAGON
|
|
||||||
#include "../libtriple/record_td.h"
|
|
||||||
#elif HAVE_SPARK_HARDWARE
|
|
||||||
#include "../libspark/record_lib.h"
|
|
||||||
#elif HAVE_AZBOX_HARDWARE
|
|
||||||
#include "../azbox/record_lib.h"
|
|
||||||
#elif HAVE_GENERIC_HARDWARE
|
|
||||||
#if BOXMODEL_RASPI
|
|
||||||
#include "../raspi/record_lib.h"
|
|
||||||
#else
|
|
||||||
#include "../generic-pc/record_lib.h"
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#error neither HAVE_TRIPLEDRAGON nor HAVE_SPARK_HARDWARE defined
|
|
||||||
#endif
|
|
||||||
|
@@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* (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/>.
|
||||||
|
*/
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
@@ -7,18 +23,50 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
|
#include <pthread.h>
|
||||||
#include <aio.h>
|
#include <aio.h>
|
||||||
|
|
||||||
#include "record_lib.h"
|
#include "record_hal.h"
|
||||||
#include "dmx_hal.h"
|
#include "dmx_hal.h"
|
||||||
#include "lt_debug.h"
|
#include "lt_debug.h"
|
||||||
#define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_RECORD, this, args)
|
#define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_RECORD, this, args)
|
||||||
#define lt_info(args...) _lt_info(TRIPLE_DEBUG_RECORD, this, args)
|
#define lt_info(args...) _lt_info(TRIPLE_DEBUG_RECORD, this, args)
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
RECORD_RUNNING,
|
||||||
|
RECORD_STOPPED,
|
||||||
|
RECORD_FAILED_READ, /* failed to read from DMX */
|
||||||
|
RECORD_FAILED_OVERFLOW, /* cannot write fast enough */
|
||||||
|
RECORD_FAILED_FILE, /* cannot write to file */
|
||||||
|
RECORD_FAILED_MEMORY /* out of memory */
|
||||||
|
} record_state_t;
|
||||||
|
|
||||||
|
class RecData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RecData(int num) {
|
||||||
|
dmx = NULL;
|
||||||
|
record_thread_running = false;
|
||||||
|
file_fd = -1;
|
||||||
|
exit_flag = RECORD_STOPPED;
|
||||||
|
dmx_num = num;
|
||||||
|
}
|
||||||
|
int file_fd;
|
||||||
|
int dmx_num;
|
||||||
|
cDemux *dmx;
|
||||||
|
pthread_t record_thread;
|
||||||
|
bool record_thread_running;
|
||||||
|
record_state_t exit_flag;
|
||||||
|
int state;
|
||||||
|
void RecordThread();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/* helper function to call the cpp thread loop */
|
/* helper function to call the cpp thread loop */
|
||||||
void *execute_record_thread(void *c)
|
void *execute_record_thread(void *c)
|
||||||
{
|
{
|
||||||
cRecord *obj = (cRecord *)c;
|
RecData *obj = (RecData *)c;
|
||||||
obj->RecordThread();
|
obj->RecordThread();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -26,24 +74,22 @@ void *execute_record_thread(void *c)
|
|||||||
cRecord::cRecord(int num)
|
cRecord::cRecord(int num)
|
||||||
{
|
{
|
||||||
lt_info("%s %d\n", __func__, num);
|
lt_info("%s %d\n", __func__, num);
|
||||||
dmx = NULL;
|
pd = new RecData(num);
|
||||||
record_thread_running = false;
|
|
||||||
file_fd = -1;
|
|
||||||
exit_flag = RECORD_STOPPED;
|
|
||||||
dmx_num = num;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cRecord::~cRecord()
|
cRecord::~cRecord()
|
||||||
{
|
{
|
||||||
lt_info("%s: calling ::Stop()\n", __func__);
|
lt_info("%s: calling ::Stop()\n", __func__);
|
||||||
Stop();
|
Stop();
|
||||||
|
delete pd;
|
||||||
|
pd = NULL;
|
||||||
lt_info("%s: end\n", __func__);
|
lt_info("%s: end\n", __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cRecord::Open(void)
|
bool cRecord::Open(void)
|
||||||
{
|
{
|
||||||
lt_info("%s\n", __func__);
|
lt_info("%s\n", __func__);
|
||||||
exit_flag = RECORD_STOPPED;
|
pd->exit_flag = RECORD_STOPPED;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,31 +106,31 @@ bool cRecord::Start(int fd, unsigned short vpid, unsigned short *apids, int nump
|
|||||||
lt_info("%s: fd %d, vpid 0x%03x\n", __func__, fd, vpid);
|
lt_info("%s: fd %d, vpid 0x%03x\n", __func__, fd, vpid);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!dmx)
|
if (!pd->dmx)
|
||||||
dmx = new cDemux(dmx_num);
|
pd->dmx = new cDemux(pd->dmx_num);
|
||||||
|
|
||||||
dmx->Open(DMX_TP_CHANNEL, NULL, 512*1024);
|
pd->dmx->Open(DMX_TP_CHANNEL, NULL, 512*1024);
|
||||||
dmx->pesFilter(vpid);
|
pd->dmx->pesFilter(vpid);
|
||||||
|
|
||||||
for (i = 0; i < numpids; i++)
|
for (i = 0; i < numpids; i++)
|
||||||
dmx->addPid(apids[i]);
|
pd->dmx->addPid(apids[i]);
|
||||||
|
|
||||||
file_fd = fd;
|
pd->file_fd = fd;
|
||||||
exit_flag = RECORD_RUNNING;
|
pd->exit_flag = RECORD_RUNNING;
|
||||||
if (posix_fadvise(file_fd, 0, 0, POSIX_FADV_DONTNEED))
|
if (posix_fadvise(pd->file_fd, 0, 0, POSIX_FADV_DONTNEED))
|
||||||
perror("posix_fadvise");
|
perror("posix_fadvise");
|
||||||
|
|
||||||
i = pthread_create(&record_thread, 0, execute_record_thread, this);
|
i = pthread_create(&pd->record_thread, 0, execute_record_thread, pd);
|
||||||
if (i != 0)
|
if (i != 0)
|
||||||
{
|
{
|
||||||
exit_flag = RECORD_FAILED_READ;
|
pd->exit_flag = RECORD_FAILED_READ;
|
||||||
errno = i;
|
errno = i;
|
||||||
lt_info("%s: error creating thread! (%m)\n", __func__);
|
lt_info("%s: error creating thread! (%m)\n", __func__);
|
||||||
delete dmx;
|
delete pd->dmx;
|
||||||
dmx = NULL;
|
pd->dmx = NULL;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
record_thread_running = true;
|
pd->record_thread_running = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,32 +138,33 @@ bool cRecord::Stop(void)
|
|||||||
{
|
{
|
||||||
lt_info("%s\n", __func__);
|
lt_info("%s\n", __func__);
|
||||||
|
|
||||||
if (exit_flag != RECORD_RUNNING)
|
if (pd->exit_flag != RECORD_RUNNING)
|
||||||
lt_info("%s: status not RUNNING? (%d)\n", __func__, exit_flag);
|
lt_info("%s: status not RUNNING? (%d)\n", __func__, pd->exit_flag);
|
||||||
|
|
||||||
exit_flag = RECORD_STOPPED;
|
pd->exit_flag = RECORD_STOPPED;
|
||||||
if (record_thread_running)
|
if (pd->record_thread_running)
|
||||||
pthread_join(record_thread, NULL);
|
pthread_join(pd->record_thread, NULL);
|
||||||
record_thread_running = false;
|
pd->record_thread_running = false;
|
||||||
|
|
||||||
/* We should probably do that from the destructor... */
|
/* We should probably do that from the destructor... */
|
||||||
if (!dmx)
|
if (!pd->dmx)
|
||||||
lt_info("%s: dmx == NULL?\n", __func__);
|
lt_info("%s: dmx == NULL?\n", __func__);
|
||||||
else
|
else
|
||||||
delete dmx;
|
delete pd->dmx;
|
||||||
dmx = NULL;
|
pd->dmx = NULL;
|
||||||
|
|
||||||
if (file_fd != -1)
|
if (pd->file_fd != -1)
|
||||||
close(file_fd);
|
close(pd->file_fd);
|
||||||
else
|
else
|
||||||
lt_info("%s: file_fd not open??\n", __func__);
|
lt_info("%s: file_fd not open??\n", __func__);
|
||||||
file_fd = -1;
|
pd->file_fd = -1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cRecord::ChangePids(unsigned short /*vpid*/, unsigned short *apids, int numapids)
|
bool cRecord::ChangePids(unsigned short /*vpid*/, unsigned short *apids, int numapids)
|
||||||
{
|
{
|
||||||
std::vector<pes_pids> pids;
|
std::vector<pes_pids> pids;
|
||||||
|
cDemux *dmx = pd->dmx;
|
||||||
int j;
|
int j;
|
||||||
bool found;
|
bool found;
|
||||||
unsigned short pid;
|
unsigned short pid;
|
||||||
@@ -157,6 +204,7 @@ bool cRecord::ChangePids(unsigned short /*vpid*/, unsigned short *apids, int num
|
|||||||
bool cRecord::AddPid(unsigned short pid)
|
bool cRecord::AddPid(unsigned short pid)
|
||||||
{
|
{
|
||||||
std::vector<pes_pids> pids;
|
std::vector<pes_pids> pids;
|
||||||
|
cDemux *dmx = pd->dmx;
|
||||||
lt_info("%s: \n", __func__);
|
lt_info("%s: \n", __func__);
|
||||||
if (!dmx) {
|
if (!dmx) {
|
||||||
lt_info("%s: DMX = NULL\n", __func__);
|
lt_info("%s: DMX = NULL\n", __func__);
|
||||||
@@ -170,7 +218,7 @@ bool cRecord::AddPid(unsigned short pid)
|
|||||||
return dmx->addPid(pid);
|
return dmx->addPid(pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cRecord::RecordThread()
|
void RecData::RecordThread()
|
||||||
{
|
{
|
||||||
lt_info("%s: begin\n", __func__);
|
lt_info("%s: begin\n", __func__);
|
||||||
#define BUFSIZE (1 << 20) /* 1MB */
|
#define BUFSIZE (1 << 20) /* 1MB */
|
||||||
|
@@ -1,44 +0,0 @@
|
|||||||
#ifndef __RECORD_TD_H
|
|
||||||
#define __RECORD_TD_H
|
|
||||||
|
|
||||||
#include <pthread.h>
|
|
||||||
|
|
||||||
#define REC_STATUS_OK 0
|
|
||||||
#define REC_STATUS_SLOW 1
|
|
||||||
#define REC_STATUS_OVERFLOW 2
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
RECORD_RUNNING,
|
|
||||||
RECORD_STOPPED,
|
|
||||||
RECORD_FAILED_READ, /* failed to read from DMX */
|
|
||||||
RECORD_FAILED_OVERFLOW, /* cannot write fast enough */
|
|
||||||
RECORD_FAILED_FILE, /* cannot write to file */
|
|
||||||
RECORD_FAILED_MEMORY /* out of memory */
|
|
||||||
} record_state_t;
|
|
||||||
|
|
||||||
class cDemux;
|
|
||||||
class cRecord
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
int file_fd;
|
|
||||||
int dmx_num;
|
|
||||||
cDemux *dmx;
|
|
||||||
pthread_t record_thread;
|
|
||||||
bool record_thread_running;
|
|
||||||
record_state_t exit_flag;
|
|
||||||
int state;
|
|
||||||
public:
|
|
||||||
cRecord(int num = 0);
|
|
||||||
~cRecord();
|
|
||||||
|
|
||||||
bool Open();
|
|
||||||
bool Start(int fd, unsigned short vpid, unsigned short *apids, int numapids, uint64_t ch = 0);
|
|
||||||
bool Stop(void);
|
|
||||||
bool AddPid(unsigned short pid);
|
|
||||||
int GetStatus();
|
|
||||||
void ResetStatus();
|
|
||||||
bool ChangePids(unsigned short vpid, unsigned short *apids, int numapids);
|
|
||||||
|
|
||||||
void RecordThread();
|
|
||||||
};
|
|
||||||
#endif
|
|
@@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* (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/>.
|
||||||
|
*/
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
@@ -6,16 +22,48 @@
|
|||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include "record_td.h"
|
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
|
#include "record_hal.h"
|
||||||
#include "dmx_hal.h"
|
#include "dmx_hal.h"
|
||||||
#include "lt_debug.h"
|
#include "lt_debug.h"
|
||||||
#define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_RECORD, this, args)
|
#define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_RECORD, this, args)
|
||||||
#define lt_info(args...) _lt_info(TRIPLE_DEBUG_RECORD, this, args)
|
#define lt_info(args...) _lt_info(TRIPLE_DEBUG_RECORD, this, args)
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
RECORD_RUNNING,
|
||||||
|
RECORD_STOPPED,
|
||||||
|
RECORD_FAILED_READ, /* failed to read from DMX */
|
||||||
|
RECORD_FAILED_OVERFLOW, /* cannot write fast enough */
|
||||||
|
RECORD_FAILED_FILE, /* cannot write to file */
|
||||||
|
RECORD_FAILED_MEMORY /* out of memory */
|
||||||
|
} record_state_t;
|
||||||
|
|
||||||
|
class RecData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RecData(void) {
|
||||||
|
dmx = NULL;
|
||||||
|
record_thread_running = false;
|
||||||
|
file_fd = -1;
|
||||||
|
exit_flag = RECORD_STOPPED;
|
||||||
|
}
|
||||||
|
int file_fd;
|
||||||
|
cDemux *dmx;
|
||||||
|
pthread_t record_thread;
|
||||||
|
bool record_thread_running;
|
||||||
|
record_state_t exit_flag;
|
||||||
|
int state;
|
||||||
|
void RecordThread();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/* helper function to call the cpp thread loop */
|
/* helper function to call the cpp thread loop */
|
||||||
void *execute_record_thread(void *c)
|
void *execute_record_thread(void *c)
|
||||||
{
|
{
|
||||||
cRecord *obj = (cRecord *)c;
|
RecData *obj = (RecData *)c;
|
||||||
obj->RecordThread();
|
obj->RecordThread();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -23,23 +71,22 @@ void *execute_record_thread(void *c)
|
|||||||
cRecord::cRecord(int /*num*/)
|
cRecord::cRecord(int /*num*/)
|
||||||
{
|
{
|
||||||
lt_info("%s\n", __func__);
|
lt_info("%s\n", __func__);
|
||||||
dmx = NULL;
|
pd = new RecData();
|
||||||
record_thread_running = false;
|
|
||||||
file_fd = -1;
|
|
||||||
exit_flag = RECORD_STOPPED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cRecord::~cRecord()
|
cRecord::~cRecord()
|
||||||
{
|
{
|
||||||
lt_info("%s: calling ::Stop()\n", __func__);
|
lt_info("%s: calling ::Stop()\n", __func__);
|
||||||
Stop();
|
Stop();
|
||||||
|
delete pd;
|
||||||
|
pd = NULL;
|
||||||
lt_info("%s: end\n", __func__);
|
lt_info("%s: end\n", __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cRecord::Open(void)
|
bool cRecord::Open(void)
|
||||||
{
|
{
|
||||||
lt_info("%s\n", __func__);
|
lt_info("%s\n", __func__);
|
||||||
exit_flag = RECORD_STOPPED;
|
pd->exit_flag = RECORD_STOPPED;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,31 +103,31 @@ bool cRecord::Start(int fd, unsigned short vpid, unsigned short *apids, int nump
|
|||||||
lt_info("%s: fd %d, vpid 0x%03x\n", __func__, fd, vpid);
|
lt_info("%s: fd %d, vpid 0x%03x\n", __func__, fd, vpid);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!dmx)
|
if (!pd->dmx)
|
||||||
dmx = new cDemux(1);
|
pd->dmx = new cDemux(1);
|
||||||
|
|
||||||
dmx->Open(DMX_TP_CHANNEL, NULL, 0);
|
pd->dmx->Open(DMX_TP_CHANNEL, NULL, 0);
|
||||||
dmx->pesFilter(vpid);
|
pd->dmx->pesFilter(vpid);
|
||||||
|
|
||||||
for (i = 0; i < numpids; i++)
|
for (i = 0; i < numpids; i++)
|
||||||
dmx->addPid(apids[i]);
|
pd->dmx->addPid(apids[i]);
|
||||||
|
|
||||||
file_fd = fd;
|
pd->file_fd = fd;
|
||||||
exit_flag = RECORD_RUNNING;
|
pd->exit_flag = RECORD_RUNNING;
|
||||||
if (posix_fadvise(file_fd, 0, 0, POSIX_FADV_DONTNEED))
|
if (posix_fadvise(pd->file_fd, 0, 0, POSIX_FADV_DONTNEED))
|
||||||
perror("posix_fadvise");
|
perror("posix_fadvise");
|
||||||
|
|
||||||
i = pthread_create(&record_thread, 0, execute_record_thread, this);
|
i = pthread_create(&pd->record_thread, 0, execute_record_thread, pd);
|
||||||
if (i != 0)
|
if (i != 0)
|
||||||
{
|
{
|
||||||
exit_flag = RECORD_FAILED_READ;
|
pd->exit_flag = RECORD_FAILED_READ;
|
||||||
errno = i;
|
errno = i;
|
||||||
lt_info("%s: error creating thread! (%m)\n", __func__);
|
lt_info("%s: error creating thread! (%m)\n", __func__);
|
||||||
delete dmx;
|
delete pd->dmx;
|
||||||
dmx = NULL;
|
pd->dmx = NULL;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
record_thread_running = true;
|
pd->record_thread_running = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,32 +135,33 @@ bool cRecord::Stop(void)
|
|||||||
{
|
{
|
||||||
lt_info("%s\n", __func__);
|
lt_info("%s\n", __func__);
|
||||||
|
|
||||||
if (exit_flag != RECORD_RUNNING)
|
if (pd->exit_flag != RECORD_RUNNING)
|
||||||
lt_info("%s: status not RUNNING? (%d)\n", __func__, exit_flag);
|
lt_info("%s: status not RUNNING? (%d)\n", __func__, pd->exit_flag);
|
||||||
|
|
||||||
exit_flag = RECORD_STOPPED;
|
pd->exit_flag = RECORD_STOPPED;
|
||||||
if (record_thread_running)
|
if (pd->record_thread_running)
|
||||||
pthread_join(record_thread, NULL);
|
pthread_join(pd->record_thread, NULL);
|
||||||
record_thread_running = false;
|
pd->record_thread_running = false;
|
||||||
|
|
||||||
/* We should probably do that from the destructor... */
|
/* We should probably do that from the destructor... */
|
||||||
if (!dmx)
|
if (!pd->dmx)
|
||||||
lt_info("%s: dmx == NULL?\n", __func__);
|
lt_info("%s: dmx == NULL?\n", __func__);
|
||||||
else
|
else
|
||||||
delete dmx;
|
delete pd->dmx;
|
||||||
dmx = NULL;
|
pd->dmx = NULL;
|
||||||
|
|
||||||
if (file_fd != -1)
|
if (pd->file_fd != -1)
|
||||||
close(file_fd);
|
close(pd->file_fd);
|
||||||
else
|
else
|
||||||
lt_info("%s: file_fd not open??\n", __func__);
|
lt_info("%s: file_fd not open??\n", __func__);
|
||||||
file_fd = -1;
|
pd->file_fd = -1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cRecord::ChangePids(unsigned short /*vpid*/, unsigned short *apids, int numapids)
|
bool cRecord::ChangePids(unsigned short /*vpid*/, unsigned short *apids, int numapids)
|
||||||
{
|
{
|
||||||
std::vector<pes_pids> pids;
|
std::vector<pes_pids> pids;
|
||||||
|
cDemux *dmx = pd->dmx;
|
||||||
int j;
|
int j;
|
||||||
bool found;
|
bool found;
|
||||||
unsigned short pid;
|
unsigned short pid;
|
||||||
@@ -153,6 +201,7 @@ bool cRecord::ChangePids(unsigned short /*vpid*/, unsigned short *apids, int num
|
|||||||
bool cRecord::AddPid(unsigned short pid)
|
bool cRecord::AddPid(unsigned short pid)
|
||||||
{
|
{
|
||||||
std::vector<pes_pids> pids;
|
std::vector<pes_pids> pids;
|
||||||
|
cDemux *dmx = pd->dmx;
|
||||||
lt_info("%s: \n", __func__);
|
lt_info("%s: \n", __func__);
|
||||||
if (!dmx) {
|
if (!dmx) {
|
||||||
lt_info("%s: DMX = NULL\n", __func__);
|
lt_info("%s: DMX = NULL\n", __func__);
|
||||||
@@ -166,7 +215,7 @@ bool cRecord::AddPid(unsigned short pid)
|
|||||||
return dmx->addPid(pid);
|
return dmx->addPid(pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cRecord::RecordThread()
|
void RecData::RecordThread()
|
||||||
{
|
{
|
||||||
lt_info("%s: begin\n", __func__);
|
lt_info("%s: begin\n", __func__);
|
||||||
#define BUFSIZE (1 << 19) /* 512 kB */
|
#define BUFSIZE (1 << 19) /* 512 kB */
|
||||||
|
@@ -1,43 +0,0 @@
|
|||||||
#ifndef __RECORD_TD_H
|
|
||||||
#define __RECORD_TD_H
|
|
||||||
|
|
||||||
#include <pthread.h>
|
|
||||||
|
|
||||||
#define REC_STATUS_OK 0
|
|
||||||
#define REC_STATUS_SLOW 1
|
|
||||||
#define REC_STATUS_OVERFLOW 2
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
RECORD_RUNNING,
|
|
||||||
RECORD_STOPPED,
|
|
||||||
RECORD_FAILED_READ, /* failed to read from DMX */
|
|
||||||
RECORD_FAILED_OVERFLOW, /* cannot write fast enough */
|
|
||||||
RECORD_FAILED_FILE, /* cannot write to file */
|
|
||||||
RECORD_FAILED_MEMORY /* out of memory */
|
|
||||||
} record_state_t;
|
|
||||||
|
|
||||||
class cDemux;
|
|
||||||
class cRecord
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
int file_fd;
|
|
||||||
cDemux *dmx;
|
|
||||||
pthread_t record_thread;
|
|
||||||
bool record_thread_running;
|
|
||||||
record_state_t exit_flag;
|
|
||||||
int state;
|
|
||||||
public:
|
|
||||||
cRecord(int num = 0);
|
|
||||||
~cRecord();
|
|
||||||
|
|
||||||
bool Open();
|
|
||||||
bool Start(int fd, unsigned short vpid, unsigned short *apids, int numapids, uint64_t ch = 0);
|
|
||||||
bool Stop(void);
|
|
||||||
bool AddPid(unsigned short pid);
|
|
||||||
int GetStatus();
|
|
||||||
void ResetStatus();
|
|
||||||
bool ChangePids(unsigned short vpid, unsigned short *apids, int numapids);
|
|
||||||
|
|
||||||
void RecordThread();
|
|
||||||
};
|
|
||||||
#endif
|
|
@@ -1 +0,0 @@
|
|||||||
../libspark/record_lib.h
|
|
Reference in New Issue
Block a user