亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? packet_data_agent.cpp

?? 各種視頻壓縮格式的網(wǎng)絡傳輸?shù)哪M信道分析
?? CPP
字號:
/*
 ==========================================================================================
 ITU-T Telecommunications Standardization Sector      Document:   VCEG-M77
 Study Group 16 Question 6                            Filename:   packet_data_agent.cc
 Video Coding Experts Group (VCEG)                    Generated:  29 June, 2001
 ----------------------------------------
 Thirteenth meeting: Austin, Texas, 2-4 April, 2001


 Intention: 
 ~~~~~~~~~~~~
 Simple offline software simulator for RTP/IP over 3GPP/3GPP2 bearers


 Source:
 ~~~~~~~
 Thomas Stockhammer, Guenther Liebl                  Tel:   +49 89 28923473
 Institute for Communications Engineering            Fax:   +49 89 28923490
 Munich University of Technology                     Email: {stockhammer,liebl}@ei.tum.de
 80290 Munich, Germany
 ==========================================================================================
*/

#include "packet_data_agent.h"



// constructor
PACKET_DATA_AGENT::PACKET_DATA_AGENT()
{
  int32 i;

  // basic initialization
  ModuleName = "PACKET-DATA-AGENT";

  agent_header_size = 0;
  compressed_Internet_header_size = 0;

  for (i=0;i<PACKET_BUFFER_SIZE;i++)
    {
      RTP_Buffer[i].size = 0;
      RTP_Buffer[i].timestamp = 0;
    }

  RTP_buffer_read_position = 0;
  RTP_buffer_write_position = 0;
  RTP_buffer_length = 0;

  total_packets_counter = 0;
  total_lost_packets_counter = 0;
  packet_loss_rate = 0;
  total_correct_bits_counter = 0;
  total_correct_payload_bits_counter = 0;
  effective_bitrate = 0.;
  effective_net_bitrate = 0.;

  simulation_time = 0;
}



// destructor
PACKET_DATA_AGENT::~PACKET_DATA_AGENT()
{
  fclose(InputFile_ptr);
  fclose(OutputFile_ptr);
}



// initialize the packet data agent from the given parameter file
void PACKET_DATA_AGENT::initialize(FILE *ParameterFile_ptr, FILE *CommonLogFile_ptr)
{
  int32 file_size;

  LogFile_ptr = CommonLogFile_ptr;  
  fprintf(LogFile_ptr,"%s: start initialization process\n",ModuleName);

  // get the location of the input RTP stream from the parameter file
  fscanf(ParameterFile_ptr,"- file containing the input RTP stream: %s\n",InputFile);
  if ( (InputFile_ptr=fopen(InputFile,"rb")) == NULL )
    {
      fprintf(stderr,"!!error in module %s: couldn't open file %s \n",ModuleName,InputFile);
      exit(-1);
    }
  else 
    {
      fprintf(LogFile_ptr,"%s: reading RTP input stream from binary file %s\n",ModuleName,InputFile);
    } 

  // determine length of the input file
  if ( fseek(InputFile_ptr,0L,SEEK_END) )
    {
      fprintf(stderr,"!!error in module %s: can't fseek to end of file %s\n",ModuleName,InputFile);
      exit(-1);
    }
  if ( (file_size = ftell(InputFile_ptr)) == -1 )
    {
      fprintf(stderr,"!!error in module %s: can't get size of file %s\n",ModuleName,InputFile);
      exit(-1);
    }
  else if ( file_size == 0 )
    {
      fprintf(stderr,"!!error in module %s: input file %s is empty\n",ModuleName,InputFile);
      exit(-1);
    }
  else
    {
      fprintf(LogFile_ptr,"%s: input file is of size %d bytes\n",ModuleName,file_size);
    }
  fseek(InputFile_ptr,0L,SEEK_SET);


  // get the location of the output RTP stream from the parameter file
  fscanf(ParameterFile_ptr,"- file containing the output RTP stream: %s\n",OutputFile);
  if ( (OutputFile_ptr=fopen(OutputFile,"wb")) == NULL )
    {
      fprintf(stderr,"!!error in module %s: couldn't open file %s for writing\n",ModuleName,OutputFile);
      exit(-1);
    }
  else 
    {
      fprintf(LogFile_ptr,"%s: writing RTP output stream to binary file %s\n",ModuleName,OutputFile);
    } 


  // get the size of the compressed Internet header from the parameter file
  fscanf(ParameterFile_ptr,"- compressed RTP/UDP/IP header size (in bytes): %d\n",&compressed_Internet_header_size);
  if ( compressed_Internet_header_size <= 0 )
    {
      fprintf(stderr,"!!error in module %s: illegal value %d for the compressed RTP/UDP/IP header size\n",ModuleName,compressed_Internet_header_size);
      exit(-1);
    }
   else 
     {
       fprintf(LogFile_ptr,"%s: compressing each RTP/UDP/IP header to %d bytes\n",ModuleName,compressed_Internet_header_size);
     }


  // get the header size of the packet data agent from the parameter file
  fscanf(ParameterFile_ptr,"- packet agent header size (in bytes): %d\n",&agent_header_size);
  if ( agent_header_size <= 0 )
    {
      fprintf(stderr,"!!error in module %s: illegal value %d for the packet agent header size\n",ModuleName,agent_header_size);
      exit(-1);
    }
   else 
     {
       fprintf(LogFile_ptr,"%s: adding %d bytes of header info to each PDU\n",ModuleName,agent_header_size);
     }



  fprintf(LogFile_ptr,"%s: end initialization process\n",ModuleName);
}



// if already available, read new RTP packet from file, compress the header, form a PDU and pass it to the
// calling module
// return values: 0: succeeded
//                1: failed: input file still contains data, but the timestamp is younger than the current simulation time
//                2: failed: end of input file already reached 
int32 PACKET_DATA_AGENT::get_PDU(int32 current_time,VIRTUAL_PDU *PDU_in)
{
  int32 packet_size, packet_timestamp, compressed_packet_size;
  fpos_t FilePosition;


  // check for possible RTP buffer overflow before reading new RTP packet from file
  if ( RTP_buffer_length >= PACKET_BUFFER_SIZE )
    {
      fprintf(stderr,"!!error in module %s: RTP buffer overflow -> increase the value for PACKET_BUFFER_SIZE in the source code\n",ModuleName);
      exit(-1);
    }

  // check, if the end of the input file has already been reached
  if ( feof(InputFile_ptr) != 0 )
    {
      fprintf(LogFile_ptr,"%s: end of input file %s has already been reached before\n",ModuleName,InputFile);
      PDU_in->internal_identifier = -1;
      PDU_in->size = 0;
      return 2;
    }

  // store actual read position in file for later use
  if ( fgetpos(InputFile_ptr,&FilePosition) != 0 )
    {
      fprintf(stderr,"!!error in module %s: could not get actual read position in file %s\n",ModuleName,InputFile);
      exit(-1);
    }

  packet_size = 0;
  packet_timestamp = 0;
  // read the size and timestamp of the next RTP packet, and check the timestamp with respect to the current time
  if ( fread(&packet_size,sizeof(int32),1,InputFile_ptr) != 1 )
    {
      if ( feof(InputFile_ptr) != 0 )
	{
          fprintf(LogFile_ptr,"%s: end of input file %s has been reached\n",ModuleName,InputFile);
          PDU_in->internal_identifier = -1;
          PDU_in->size = 0;
          return 2;
	}
      else
        {
          fprintf(stderr,"!!error in module %s: could not read size of next RTP packet from file %s\n",ModuleName,InputFile);
          exit(-1);
	}
    }
  else if ( packet_size <= 0 )
    {
      fprintf(stderr,"!!error in module %s: illegal value %d for the RTP packet size\n",ModuleName,packet_size);
      exit(-1);
    }
  else if ( fread(&packet_timestamp,sizeof(int32),1,InputFile_ptr) != 1 )
   {
      fprintf(stderr,"!!error in module %s: could not read timestamp of next RTP packet from file %s\n",ModuleName,InputFile);
      exit(-1);
   }
  else if ( packet_timestamp > current_time )
    {
      fprintf(LogFile_ptr,"%s: incorrect timing between RTP stream and simulation time scale\n",ModuleName);
      if ( fsetpos(InputFile_ptr,&FilePosition) != 0 )
	{
	  fprintf(stderr,"!!error in module %s: could not restore old read position in file $s\n",ModuleName,InputFile);
	  exit(-1);
	}
      PDU_in->internal_identifier = -1;
      PDU_in->size = 0;
      return 1;
    }

  // timestamp is valid -> read new RTP packet data from file and store it in the buffer
  RTP_Buffer[RTP_buffer_write_position].size = packet_size;
  RTP_Buffer[RTP_buffer_write_position].timestamp = packet_timestamp;
  if ( (RTP_Buffer[RTP_buffer_write_position].data = (byte *)malloc(packet_size)) == NULL )
    {
      fprintf(stderr,"!!error in module %s: cannot allocate enough memory to store new RTP packet\n",ModuleName);
      exit(-1);
    }
  else if ( fread(RTP_Buffer[RTP_buffer_write_position].data,sizeof(byte),packet_size,InputFile_ptr) != packet_size )
    {
      fprintf(stderr,"!!error in module %s: could not read %d data bytes from file %s\n",ModuleName,packet_size,InputFile);
      exit(-1);
    }

//   printf("size before compression: %d\n",RTP_Buffer[RTP_buffer_write_position].size);
  // perform header compression on the new RTP packet
  compressed_packet_size = compress_Internet_header(&(RTP_Buffer[RTP_buffer_write_position]));

  // generate PDU for calling module
  PDU_in->internal_identifier = RTP_buffer_write_position;
  PDU_in->size = compressed_packet_size + agent_header_size;

//   printf("size after compression: %d\n",PDU_in->size);

  // adjust buffer length and position markers
  RTP_buffer_length++;
  RTP_buffer_write_position++;
  if ( RTP_buffer_write_position == PACKET_BUFFER_SIZE )
    {
      RTP_buffer_write_position = 0;  // wrap around circular RTP buffer
    }

  return 0;
}



// remove RTP packet that corresponds to succesfully transmitted PDU from buffer, adjust the timestamp, and write
// it to file; update statistics; adjust buffer status
void PACKET_DATA_AGENT::put_PDU(int32 current_time,VIRTUAL_PDU *PDU_out)
{
  int32 packet_size;

  // check, if next RTP packet in buffer corresponds to the PDU
  if ( PDU_out->internal_identifier != RTP_buffer_read_position )
    {
      fprintf(stderr,"!!error in module %s: buffer out of sync while reading\n",ModuleName);
      exit(-1);
    }
  else
    {
      packet_size = RTP_Buffer[RTP_buffer_read_position].size;
    }

  // adjust timestamp
  if ( RTP_Buffer[RTP_buffer_read_position].timestamp <= current_time )
    {
      RTP_Buffer[RTP_buffer_read_position].timestamp = current_time;
    }
  else
    {
      fprintf(stderr,"!!error in module %s: time reference corrupted\n",ModuleName);
      exit(-1);
    }

  // write RTP packet to file
  if ( fwrite(&(RTP_Buffer[RTP_buffer_read_position].size),sizeof(int32),1,OutputFile_ptr) != 1 )
    {
      fprintf(stderr,"!!error in module %s: could not write size of next RTP packet to file %s\n",ModuleName,OutputFile);
      exit(-1);
    }
  else if ( fwrite(&(RTP_Buffer[RTP_buffer_read_position].timestamp),sizeof(int32),1,OutputFile_ptr) != 1 )
   {
      fprintf(stderr,"!!error in module %s: could not write timestamp of next RTP packet to file %s\n",ModuleName,OutputFile);
      exit(-1);
   }
  else if ( fwrite(RTP_Buffer[RTP_buffer_read_position].data,sizeof(byte),packet_size,OutputFile_ptr) != packet_size )
    {
      fprintf(stderr,"!!error in module %s: could not write %d data bytes to file %s\n",ModuleName,packet_size,OutputFile);
      exit(-1);
    } 

  //update statistics
  total_packets_counter++;
  total_correct_bits_counter += packet_size*8;
  total_correct_payload_bits_counter += (PDU_out->size - agent_header_size - compressed_Internet_header_size)*8;

  simulation_time = current_time;


  // adjust buffer content, length and position markers
  free(RTP_Buffer[RTP_buffer_read_position].data);
  RTP_Buffer[RTP_buffer_read_position].size = 0;
  RTP_Buffer[RTP_buffer_read_position].timestamp = 0;

  RTP_buffer_length--;
  RTP_buffer_read_position++;
  if ( RTP_buffer_read_position == PACKET_BUFFER_SIZE )
    {
      RTP_buffer_read_position = 0;  // wrap around circular RTP buffer
    }

//   printf("actual time: %d\n",simulation_time);
//   if ( total_packets_counter == 12 )
//     {
//       //     exit(0);
//     }
}



// remove RTP packet that corresponds to corrupted PDU from buffer; update statistics; adjust buffer status
void PACKET_DATA_AGENT::discard_PDU(int32 current_time, VIRTUAL_PDU *PDU_out)
{

  // check, if next RTP packet in buffer corresponnds to the PDU
  if ( PDU_out->internal_identifier != RTP_buffer_read_position )
    {
      fprintf(stderr,"!!error in module %s: buffer out of sync while discarding\n",ModuleName);
      exit(-1);
    }


  //update statistics
  total_packets_counter++;
  total_lost_packets_counter++;

  simulation_time = current_time;


  // adjust buffer content, length and position markers
  free(RTP_Buffer[RTP_buffer_read_position].data);
  RTP_Buffer[RTP_buffer_read_position].size = 0;
  RTP_Buffer[RTP_buffer_read_position].timestamp = 0;

  RTP_buffer_length--;
  RTP_buffer_read_position++;
  if ( RTP_buffer_read_position == PACKET_BUFFER_SIZE )
    {
      RTP_buffer_read_position = 0;  // wrap around circular RTP buffer
    }

}



// write transmission statistics at the end of the simulation
void PACKET_DATA_AGENT::write_statistics(FILE *StatisticsFile_ptr)
{
  //calculate statistics first
  packet_loss_rate = (double)total_lost_packets_counter/(double)total_packets_counter;
  effective_bitrate = (double)total_correct_bits_counter/(double)simulation_time;
  effective_net_bitrate = (double)total_correct_payload_bits_counter/(double)simulation_time;


  // write statistics to file
  fprintf(StatisticsFile_ptr,"----------------------------------------------------------------------------\n");
  fprintf(StatisticsFile_ptr,"%s: Statistics:\n\n",ModuleName);

  fprintf(StatisticsFile_ptr,"total number of RTP packets transmitted:      %10d\n",total_packets_counter);
  fprintf(StatisticsFile_ptr,"number of lost RTP packets:                   %10d\n",total_lost_packets_counter);
  fprintf(StatisticsFile_ptr,"packet loss rate:                           %e\n\n",packet_loss_rate);
  
  fprintf(StatisticsFile_ptr,"effective bitrate (including RTP header):      %f kbit/s\n",effective_bitrate);
  fprintf(StatisticsFile_ptr,"effective net bitrate (excluding RTP header):  %f kbit/s\n",effective_net_bitrate);

  //fprintf(StatisticsFile_ptr,"----------------------------------------------------------------------------\n");

}



// simplified procedure for compressing RTP/UDP/IP header
// return value: total size of compressed packet in bytes
int32 PACKET_DATA_AGENT::compress_Internet_header(RTP_PACKET *Uncompressed_RTP_Buffer)
{
  int32 header_size, payload_size;

  // up to now, only the standard RTP header is compressed (together with the UDP/IP header)
  // all extensions and CSRC fields are left untouched
  header_size = MIN_RTP_HEADER_SIZE;
  payload_size = Uncompressed_RTP_Buffer->size - header_size;

  if ( payload_size <= 0 )
    {
      fprintf(stderr,"!!error in module %s: RTP packet does not contain any data part\n",ModuleName);
    }

  return (payload_size + compressed_Internet_header_size);
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲人妖av一区二区| 成人av电影在线| 日韩欧美亚洲另类制服综合在线| 亚洲在线成人精品| 欧美色男人天堂| 免费不卡在线观看| 精品国产乱码久久久久久浪潮| 经典三级一区二区| 国产精品欧美一区二区三区| av在线不卡网| 亚洲成人激情av| 欧美一个色资源| 国产麻豆91精品| 最新国产精品久久精品| 欧美影院一区二区三区| 亚洲综合成人在线| 日韩午夜在线观看视频| 美脚の诱脚舐め脚责91 | 国产色爱av资源综合区| 国产黄色成人av| 亚洲欧洲日韩综合一区二区| 欧美四级电影网| 精品一区二区三区av| 中文字幕日本不卡| 7777精品伊人久久久大香线蕉| 国内偷窥港台综合视频在线播放| 欧美国产日韩a欧美在线观看| 色婷婷综合久久久久中文一区二区 | 色综合久久88色综合天天免费| 亚洲一区二区三区四区中文字幕 | 黄色成人免费在线| 国产精品夫妻自拍| 欧美一级日韩免费不卡| 成人一区二区三区在线观看| 亚洲国产aⅴ天堂久久| 国产亚洲欧美色| 欧美三级韩国三级日本一级| 国产精品一区二区在线观看网站| 1区2区3区欧美| 精品剧情在线观看| 欧美午夜影院一区| 成人精品高清在线| 蜜桃视频一区二区| 亚洲国产日日夜夜| 中文字幕av一区二区三区免费看| 欧美日韩一级黄| www.久久精品| 国产美女娇喘av呻吟久久| 亚洲成av人片一区二区三区| 国产日韩欧美高清在线| 欧美一区二区视频在线观看2022| 色乱码一区二区三区88| 国产精品亚洲综合一区在线观看| 日韩精品三区四区| 亚洲国产欧美在线人成| 国产精品久久久久久久午夜片 | 极品少妇xxxx偷拍精品少妇| 亚洲午夜成aⅴ人片| 国产精品国模大尺度视频| 日韩欧美三级在线| 69堂亚洲精品首页| 欧美日本高清视频在线观看| 色综合久久久久网| 91美女在线视频| 91在线码无精品| 99re66热这里只有精品3直播| 国产在线精品一区在线观看麻豆| 日本中文在线一区| 午夜私人影院久久久久| 一区二区三区免费看视频| 国产精品美女一区二区在线观看| 久久精品在线免费观看| 26uuu精品一区二区三区四区在线 26uuu精品一区二区在线观看 | 夜夜爽夜夜爽精品视频| 亚洲三级在线看| 精品亚洲成a人| 看片网站欧美日韩| 蜜臀av一区二区| 久久er99热精品一区二区| 欧美一区二区三区四区在线观看| 午夜精品久久久久影视| 亚洲一区二区三区不卡国产欧美| 亚洲欧美一区二区三区孕妇| 亚洲人精品一区| 亚洲在线一区二区三区| 午夜精品免费在线| 麻豆国产欧美日韩综合精品二区| 日本亚洲电影天堂| 狠狠色狠狠色合久久伊人| 激情五月播播久久久精品| 国产一区二区三区高清播放| 国产美女视频一区| bt7086福利一区国产| 在线观看亚洲成人| 91精品在线观看入口| 精品久久久久一区二区国产| 国产日韩影视精品| 尤物在线观看一区| 污片在线观看一区二区| 韩国av一区二区| caoporn国产精品| 欧美日韩国产综合一区二区| 欧美一区二区久久久| 久久久久久久久97黄色工厂| 国产精品麻豆99久久久久久| 亚洲综合无码一区二区| 美腿丝袜亚洲色图| 成人av资源站| 欧美一区二区视频在线观看| 欧美精品一区二区精品网| 中文字幕一区二区三区不卡| 一区二区三区高清| 久久av中文字幕片| 91网站在线播放| 欧美一区二区播放| 国产精品二区一区二区aⅴ污介绍| 亚洲观看高清完整版在线观看| 另类调教123区| 色综合天天在线| 精品免费视频一区二区| 日韩久久一区二区| 成人性生交大片免费看在线播放| 国产精品视频yy9299一区| 中文字幕一区二区三区四区不卡| 一区二区日韩av| 国产在线乱码一区二区三区| 91黄色免费看| 国产亚洲美州欧州综合国| 亚洲国产成人av网| 成人一区二区三区中文字幕| 欧美美女直播网站| 国产精品理论在线观看| 秋霞成人午夜伦在线观看| 日韩欧美在线综合网| 亚洲免费三区一区二区| 极品少妇一区二区三区精品视频| 欧美亚洲综合一区| 成人免费在线观看入口| 国产一区二区在线免费观看| 欧美日韩精品久久久| 最新不卡av在线| 成人性生交大片免费看在线播放| 日韩小视频在线观看专区| 一区二区三区精品在线观看| 懂色av中文字幕一区二区三区| 日韩精品中文字幕在线不卡尤物| 亚洲综合一区二区三区| 99视频一区二区| 国产欧美综合在线观看第十页 | 色香蕉久久蜜桃| 国产精品免费人成网站| 国产一区二区三区久久悠悠色av| 欧美精品色一区二区三区| 亚洲综合色区另类av| 不卡的av在线| 欧美国产日韩精品免费观看| 国产在线精品一区在线观看麻豆| 欧美一级免费观看| 午夜视频一区二区| 欧美日韩精品福利| 亚洲国产一区二区三区青草影视| 色婷婷综合久久久| 久久久无码精品亚洲日韩按摩| 日韩成人av影视| 欧美久久久影院| 日韩高清一级片| 日韩欧美一级精品久久| 在线视频国内一区二区| 有坂深雪av一区二区精品| 91视视频在线观看入口直接观看www | 国产一区二区电影| 精品少妇一区二区三区视频免付费| 日一区二区三区| 欧美一区二区三区四区久久| 丝袜脚交一区二区| 欧美一级在线视频| 九九国产精品视频| 久久久精品国产99久久精品芒果 | 国产成人免费视频网站| 国产日韩三级在线| 成人av在线观| 一级中文字幕一区二区| 欧美三级在线播放| 亚洲chinese男男1069| 欧美一二三区在线| 国产一区二三区好的| 韩国在线一区二区| 国产亚洲一二三区| www..com久久爱| 一区二区三区蜜桃| 91麻豆精品国产综合久久久久久| 日韩精品一二三| 久久久国产综合精品女国产盗摄| 丁香五精品蜜臀久久久久99网站| 国产精品欧美一区喷水| 91福利小视频| 精品在线播放免费| 亚洲视频免费在线| 欧美一区二区三区免费在线看| 久久国内精品自在自线400部|