⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test_ttx.c

📁 IBM source for pallas/vulcan/vesta
💻 C
📖 第 1 页 / 共 2 页
字号:
/*----------------------------------------------------------------------------+|     This source code has been made available to you by IBM on an AS-IS|     basis.  Anyone receiving this source is licensed under IBM|     copyrights to use it in any way he or she deems fit, including|     copying it, modifying it, compiling it, and redistributing it either|     with or without modifications.  No license under IBM patents or|     patent applications is to be implied by the copyright license.||     Any user of this software should understand that IBM cannot provide|     technical support for this software and will not be responsible for|     any consequences resulting from the use of this software.||     Any person who transfers this source code or any derivative work|     must include the IBM copyright notice, this paragraph, and the|     preceding two paragraphs in the transferred software.||       IBM CONFIDENTIAL|       STB025XX VXWORKS EVALUATION KIT SOFTWARE|       (C) COPYRIGHT IBM CORPORATION 2003+----------------------------------------------------------------------------*//*----------------------------------------------------------------------------+| Author    :  Tony J. Cerreto| Component :  ttx| File      :  ttx_drv.c| Purpose   :  Teletext Driver| Changes   :|| Date:      By   Comment:| ---------  ---  --------| 30-Sep-03  TJC  Modified+----------------------------------------------------------------------------*/#include <sys/ioctl.h>#include <stdio.h>#include <stdint.h>#include <string.h>#include <pthread.h>#include <sched.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <time.h>#include <sys/poll.h>#include <ttx/ttx_osd_user.h>#include <vid/vid_inf.h>#include <xp/xp_osd_user.h>/*----------------------------------------------------------------------------+| Defines+----------------------------------------------------------------------------*//*----------------------------------------------------------------------------+| Static Declarations+----------------------------------------------------------------------------*/static int fd_pcr0     = 0;static int fd_xp0      = 0;static int fd_ttx0     = 0;static int ttx_inited  = 0;static int ttx_started = 0;static int ttx_loop    = 1;static int ttx_nullp   = 0;static unsigned char *mu_ttx_help[] = {         "t h[elp]            - TTX help menu      ",         "t init              - TTX initialize     ",         "t term              - TTX terminate      ",         "t start <ppid tpid> - TTX start          ",         "t stat  <get|clear> - TTX statistics     ",         "t stop              - TTX stop           ",         "t q[uit]            - Quit application   ",         0,};/*----------------------------------------------------------------------------+|  XXXXXX    XX     XXXXX   XX   XX   XXXXX|  X XX X   XXXX   XX   XX  XX  XX   XX   XX|    XX    XX  XX   XX      XX XX     XX|    XX    XX  XX     XX    XXXX        XX|    XX    XXXXXX      XX   XX XX        XX|    XX    XX  XX  XX   XX  XX  XX   XX   XX|   XXXX   XX  XX   XXXXX   XX   XX   XXXXX+----------------------------------------------------------------------------*//*----------------------------------------------------------------------------+| ttx_rw_task+----------------------------------------------------------------------------*/static int ttx_rw_task(void *dummy){  int           rc;  int           ttx_len;  unsigned char ttx_buffer[188*12];  ttx_len    = 0;  while(ttx_started) {    ttx_len = read(fd_xp0, ttx_buffer, 188*12);    if (ttx_len > 0) {       if ((rc = write(fd_ttx0, ttx_buffer, ttx_len)) != 0) {          printf("Error writing TTX packets to Teletext driver\n");       }    } else if (ttx_len < 0) {       ttx_nullp = ttx_nullp  + 1;    }  }}/*----------------------------------------------------------------------------+| XXXX   XX   XX   XXXXXX  XXXXXXX  XXXXXX   XX   XX     XX    XXXX|  XX    XXX  XX   X XX X   XX   X   XX  XX  XXX  XX    XXXX    XX|  XX    XXXX XX     XX     XX X     XX  XX  XXXX XX   XX  XX   XX|  XX    XX XXXX     XX     XXXX     XXXXX   XX XXXX   XX  XX   XX|  XX    XX  XXX     XX     XX X     XX XX   XX  XXX   XXXXXX   XX|  XX    XX   XX     XX     XX   X   XX  XX  XX   XX   XX  XX   XX  XX| XXXX   XX   XX    XXXX   XXXXXXX  XXX  XX  XX   XX   XX  XX  XXXXXXX+----------------------------------------------------------------------------*//*----------------------------------------------------------------------------+| ttx_get_stats+----------------------------------------------------------------------------*/static int ttx_get_stats(){  TTX_STATISTICS    tstats;  /*--------------------------------------------------------------------------+  | Verify TTX is in proper state  +--------------------------------------------------------------------------*/  if (!ttx_inited) {     printf("TTX Driver must be initialized to display statistics\n");     return(-1);  }  /*--------------------------------------------------------------------------+  | Display TTX Statistics  +--------------------------------------------------------------------------*/  ioctl(fd_ttx0, TTX_STATS_GET, &tstats);  printf("T T X  S T A T I S T I C S\n");  printf("-----  -------------------\n");  printf("Total incoming packets received:            %d\n", tstats.in_pkt);  printf("TTX Packets processed with PUSI:            %d\n", tstats.in_pusi);  printf("TTX Packets processed without PUSI:         %d\n", tstats.no_pusi);  printf("TTX Buffers queued for transmission:        %d\n", tstats.out_pusi);  printf("TTX Buffers transmitted:                    %d\n", tstats.inbound_pes);  printf("TTX Packet read attempts with no data:      %d\n", ttx_nullp);  printf("TTX Packets discarded due to STC mismatch:  %d\n", tstats.outbound_pes);  printf("TTX Packets discarded due to stream errors: %d\n", tstats.trash_pkt);  printf("\n");  return(0);}/*----------------------------------------------------------------------------+| ttx_clr_stats+----------------------------------------------------------------------------*/static int ttx_clr_stats(){  /*--------------------------------------------------------------------------+  | Verify TTX is in proper state  +--------------------------------------------------------------------------*/  if (!ttx_inited) {     printf("TTX Driver must be initialized to clear statistics\n");     return(-1);  }  /*--------------------------------------------------------------------------+  | Clear TTX Statistics  +--------------------------------------------------------------------------*/  ioctl(fd_ttx0, TTX_STATS_CLEAR);  ttx_nullp = 0;  return(0);}/*----------------------------------------------------------------------------+| ttx_stop+----------------------------------------------------------------------------*/static int ttx_stop(){  char          key;  int           ttx_file;  int           ttx_len, tot_len;  int           tflag;  unsigned char ttx_buffer[1024];  Pes_para      PesPara;  /*--------------------------------------------------------------------------+  | Verify TTX is in proper state  +--------------------------------------------------------------------------*/  if (!ttx_started) {     return(0);  }  /*--------------------------------------------------------------------------+  | Stop Demux 0 Filter to Acquire TTX Data  +--------------------------------------------------------------------------*/  if (ioctl(fd_xp0, DEMUX_STOP) < 0) {    printf("Error stopping Demux Teletext Filter\n");    return(-1);  }  /*--------------------------------------------------------------------------+  | Stop the PCR PID  +--------------------------------------------------------------------------*/    if (ioctl(fd_pcr0, DEMUX_STOP) < 0) {     printf("Error stopping Demux PCR Filter\n");     return(-1);  }  /*--------------------------------------------------------------------------+  | Stop TTX  +--------------------------------------------------------------------------*/  if (ioctl(fd_ttx0, TTX_STOP) < 0) {    printf("Error stopping Teletext Driver\n");    return(-1);  }  ttx_started = 0;  return(0);}/*----------------------------------------------------------------------------+| ttx_start+----------------------------------------------------------------------------*/static int ttx_start(int pcrpid, int txtpid){  int                rc;  Pes_para           PesPara;  pthread_attr_t     attr;  pthread_t          thread;  struct sched_param sched;  /*--------------------------------------------------------------------------+  | Verify TTX is in proper state  +--------------------------------------------------------------------------*/  if (!ttx_inited) {     printf("TTX Driver must be initialized before re-started\n");     return(-1);  }  if (ttx_started) {     printf("TTX Driver must be stopped before started\n");     return(-1);  }  /*--------------------------------------------------------------------------+  | Start TTX  +--------------------------------------------------------------------------*/  if (ioctl(fd_ttx0, TTX_START, txtpid) < 0) {    printf("Error starting Teletext Driver\n");    return(-1);  }  /*--------------------------------------------------------------------------+  | Set PCR PID  +--------------------------------------------------------------------------*/  PesPara.pid     = pcrpid;  PesPara.output  = OUT_DECODER;  PesPara.pesType = DMX_PES_PCR;  if (ioctl(fd_pcr0, DEMUX_FILTER_PES_SET, &PesPara) < 0) {     printf("Error setting Demux PCR Filter\n");     return(-1);  }  if (ioctl(fd_pcr0, DEMUX_START) < 0) {     printf("Error starting Demux PCR Filter\n");     return(-1);  }  /*--------------------------------------------------------------------------+  | Start Demux 0 Filter to Acquire TTX Data  +--------------------------------------------------------------------------*/  PesPara.pid                    = txtpid;  PesPara.output                 = OUT_MEMORY;  PesPara.pesType                = DMX_PES_TELETEXT;  PesPara.unloader.threshold     = 2;  PesPara.unloader.unloader_type = UNLOADER_TYPE_TRANSPORT;  if (ioctl(fd_xp0, DEMUX_FILTER_PES_SET, &PesPara) < 0) {    printf("Error setting Demux Teletext Filter\n");    return(-1);  }  if (ioctl(fd_xp0, DEMUX_START) < 0) {    printf("Error starting Demux Teletext Filter\n");    return(-1);  }  /*--------------------------------------------------------------------------+  | Start TTX Receive and Transmit Task  +--------------------------------------------------------------------------*/  ttx_started = 1;  if ((rc = pthread_attr_init(&attr)) != 0) {    printf("Error initializing Teletext Receive Task\n");    return(rc);  }  if ((rc = pthread_attr_setschedpolicy(&attr, SCHED_RR)) != 0) {    printf("Error setting scheduler policy for Teletext Receive Task\n");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -