demux device not gettting registered:(

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hello,

We have a problem in our demux device getting detected.. we have
writen a program code in c++ in linux. the error that it shows while
compiling is that the demux device does not get detected nor does the
streams. please do help us with this.. and reply immediately .
thank you ,
#include<stdio.h>
#include<string.h>
#include<poll.h>
#include<errno.h>
#include<stdlib.h>
#include<linux/version.h>
#include<linux/dvb/dmx.h>
#include<linux/dvb/ca.h>
#include<sys/msg.h>
#include<linux/types.h>
#include<pthread.h>
#include <unistd.h>
#include<sys/ioctl.h>
#include <fcntl.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<sys/mman.h>
#include<signal.h>
#include "bget.c"


//defining the macros//

static unsigned int mMemSpaceHandle = -1;
static pthread_mutex_t bget_mem_mutex = PTHREAD_MUTEX_INITIALIZER;
static const char *DVB_T_DMX_DEVICE = "/dev/dvb/adapter1/demux0";
static const char *DVB_C_DMX_DEVICE = "/dev/dvb/adapter2/demux1";


#define MEM_START_ADDR 0X3C00000
#define MEM_SIZE 0X1000000

#define THREAD_SLEEP_TIME   10*1000
#define MAX_SECTION_SIZE    (4*1024)
static int buffer [1024*1024];

static int *address;
typedef struct
{
        int pid;
        int BufferSize;
        int fd;
        int thread_status;
        pthread_t thread;
        int TimeOut;
}PcDmxDataType;
static int mMallocMem(size_t size);
static void mInitMem(void);
static void mFreeMem(void);
static int ConfigureDevice(int pid,int buffersize,int *error, int*subcrid);
static void *pcdmx_pes_thread(void *arg)
{
        PcDmxDataType *Filter = (PcDmxDataType*)arg;
        int *buf;
        int bytes;
        int length=0;
        void *handle = NULL;

        while(Filter->thread_status ==1)
        {
                usleep(THREAD_SLEEP_TIME);
                buf = (int*)mMallocMem(MAX_SECTION_SIZE);
                if(buf ==NULL) continue;
                bytes = read(Filter->fd, buf, MAX_SECTION_SIZE);
                length=length+bytes;
                if (bytes < 0)
                {
                        Filter->thread_status=0;
			 mFreeMem();
                }
        }

        handle=fopen("/home/lakshmi/1stapp.txt","wb");
        fwrite(buf,sizeof(buf),length,handle);
        fclose(handle);
}
int main()
{

        int error,subcrid;
        mInitMem();
        ConfigureDevice(600,MAX_SECTION_SIZE,&error,&subcrid);
}
void mInitMem(void)
{
        char *ptr=(char*)malloc(MEM_SIZE);

        pthread_mutex_lock(&bget_mem_mutex);

        if(!ptr)
        {
		 bpool(ptr, MEM_SIZE);
        }
        pthread_mutex_unlock(&bget_mem_mutex);
}
int mMallocMem(size_t size)
{

        pthread_mutex_lock(&bget_mem_mutex);
        address=bget(size);
        pthread_mutex_unlock(&bget_mem_mutex);
        return address;
}
void mFreeMem(void)

{
        pthread_mutex_lock(&bget_mem_mutex);
        brel(address);
        pthread_mutex_unlock(&bget_mem_mutex);
}
int ConfigureDevice(int pid,int buffersize,int *error, int*subcrid)
{
        PcDmxDataType* Filter;
        int fd;
	 fd = open(DVB_T_DMX_DEVICE,(O_RDWR|O_NONBLOCK));
        if (fd<0)
        {
                perror("Error in opening the Demux Device");
                return mMemSpaceHandle;
        }
        else
        {
                if (ioctl(fd,DMX_SET_BUFFER_SIZE,buffersize)== -1)
                {
                        printf("Error while setting the buffer size!!!\n");
                }
                else
                {
                        Filter = (PcDmxDataType*)mMallocMem(sizeof(PcDmxDataType));
                        printf("Prashanth: am here !!! first memory allocation passed\n");
                        if (Filter!=NULL)
                        {
                                struct dmx_pes_filter_params fp;
                                memset(Filter,0,DMX_SET_BUFFER_SIZE);
                                fp.input        = DMX_IN_FRONTEND;
				 fp.output       = DMX_OUT_TAP;
                                fp.pes_type     = DMX_PES_OTHER;
                                fp.flags        = DMX_IMMEDIATE_START;
                                fp.pid          = pid;
                                if (ioctl(fd,DMX_SET_FILTER,&fp)<0)
                                {
                                        mFreeMem();
                                        Filter=NULL;
                                        perror("error in setting the filter");
                                }
                                else
                                {
                                        pthread_t *p;
                                        Filter->thread_status =1;
                                        pthread_create (p,NULL, pcdmx_pes_thread,(void*)Filter);
                                        Filter->thread=*p;
                                }
                        }
                }
                close(fd);
        }
}


[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux