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

📄 directory.cpp

📁 用于解析ts流中的各种业务信息表可以用于dvb中嘛流分析
💻 CPP
字号:
/* Copyright (C) 1995, Tektronix Inc. All Rights Reserved. * *   Usage Restrictions * * License is granted to copy, to use, and to make and to use derivative * works for research and evaluation purposes only. * *   Disclaimer of Warranty * * These software programs are available to the user without any license * fee or royalty on an "as is" basis.  Tektronix Inc. disclaims any and * all warranties, whether express, implied, or statuary, including any * implied warranties or merchantability or of fitness for a particular * purpose.  In no event shall the copyright-holder be liable for any  * incidental, punitive, or consequential damages of any kind whatsoever * arising from the use of these programs. * * This disclaimer of warranty extends to the user of these programs and * user's customers, employees, agents, transferees, successors, and * assigns. * * The Tektronix Inc. does not represent or warrant that the programs * furnished hereunder are free of infringement of any third-party * patents.*//* Directory, Program and EStream implementations *///#include "stdafx.h"#include "Utilities.H"#include "Directory.H"extern "C"{#include <stdio.h>}/* Directory functions */Directory::Directory (){  head_prec = NULL;}void Directory::add_program (Program* p){  ProgramRecord* new_prec = new ProgramRecord(p);  new_prec->next_prec = head_prec;  head_prec = new_prec;}void Directory::remove_program (Program* p){  ProgramRecord* cur_prec = head_prec;  ProgramRecord* prev_prec;  while (cur_prec)    {      if (cur_prec->program == p)	{	  if (cur_prec == head_prec)	    {	      head_prec = head_prec->next_prec;	    }	  else	    {	      prev_prec->next_prec = cur_prec->next_prec;	    }	  delete cur_prec;	  return;	}      prev_prec = cur_prec;      cur_prec = cur_prec->next_prec;    }}void Directory::remove_program (int pn){  ProgramRecord* cur_prec = head_prec;  ProgramRecord* prev_prec;  while (cur_prec)    {      if (cur_prec->program->program_number == pn)	{	  if (cur_prec == head_prec)	    {	      head_prec = head_prec->next_prec;	    }	  else	    {	      prev_prec->next_prec = cur_prec->next_prec;	    }	  delete cur_prec;	  return;	}      prev_prec = cur_prec;      cur_prec = cur_prec->next_prec;    }}Program* Directory::get_program (int pn){  ProgramRecord* prec = head_prec;  while (prec)    {      if (prec->program->program_number == pn)	{	  return prec->program;	}      prec = prec->next_prec;    }  return NULL;}int Directory::get_num_programs (){  ProgramRecord* prec = head_prec;  int n = 0;  while (prec)    {      n++;      prec = prec->next_prec;    }  return n;}void Directory::print (){  ProgramRecord* prec = head_prec;  while (prec)    {      prec->program->print();      prec = prec->next_prec;    }}/* Program functions */Program::Program (){  program_number = UNASSIGNED;  pid = UNASSIGNED;  active = ACTIVE;  head_erec = NULL;
  pcr_estream = NULL;}Program::Program (int pn){  program_number = pn;  pid = UNASSIGNED;  active = ACTIVE;  head_erec = NULL;  pcr_estream = NULL;
}Program::Program (int pn, int id){  program_number = pn;  pid = id;  active = ACTIVE;  head_erec = NULL;  pcr_estream = NULL;
}void Program::activate (){  active = ACTIVE;}void Program::deactivate (){  active = NOTACTIVE;}void Program::add_estream (EStream* es){  EStreamRecord* new_erec = new EStreamRecord(es);  new_erec->next_erec = head_erec;  head_erec = new_erec;}void Program::set_pcr_estream (EStream* es){  pcr_estream = es;}void Program::remove_estream (EStream* es){  EStreamRecord* cur_erec = head_erec;  EStreamRecord* prev_erec;  while (cur_erec)    {      if (cur_erec->estream == es)	{	  if (cur_erec == head_erec)	    {	      head_erec = head_erec->next_erec;	    }	  else	    {	      prev_erec->next_erec = cur_erec->next_erec;	    }	  delete cur_erec;	  return;	}      prev_erec = cur_erec;      cur_erec = cur_erec->next_erec;    }}EStream* Program::get_estream (int id){  EStreamRecord* erec = head_erec;  while (erec)    {      if (erec->estream->pid == id) return erec->estream;      erec = erec->next_erec;    }   return NULL;}int Program::get_num_streams (){  EStreamRecord* erec = head_erec;  int n = 0;  while (erec)    {      n++;      erec = erec->next_erec;    }  return n;}void Program::print (){  printf(" Program %d:\n", program_number);  printf("  pid: %d\n", pid);  EStreamRecord* erec = head_erec;  while (erec)    {      erec->estream->print();      erec = erec->next_erec;    }}ProgramRecord::ProgramRecord (Program* prog){  program = prog;  next_prec = NULL;}/* EStream functions */EStream::EStream (StreamType type, int id, int b){  stream_type = type;  pid = id;  bandwidth = b;}void EStream::print (){  printf("  EStream of type: %d pid: %d\n", stream_type, pid);}EStreamRecord::EStreamRecord (EStream* es){  estream = es;  next_erec = NULL;}

⌨️ 快捷键说明

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