Linux下H.264码流实时RTP打包与发送

来源:互联网 发布:java中final是什么意思 编辑:程序博客网 时间:2024/05/21 15:43

 


由于项目要求在DM6467T平台上添加实时RTP打包发送模块,这才找了找有没有人分享 这方面的经验。这里需要感谢网友:yanyuan9527,他写的文章对我帮助很大,可以说让一个完全小白的人了解了RTP打包,链接在此:http://www.chinavideo.org/forum.php?mod=viewthread&tid=7575

    一、请大家阅读上面提到的文章,我这里就不详细写了,读了之后应该对RTP打包有一定了解了。不过那篇文章是在windows下实现的,我要说的是linux。首先说linux与windows下socket的几点区别:1.linux下的socket不用初始换。2.linux下定义socketfd直接是Int型,而windows下是SOCKET结构体。下图是linux和windows下socket的区别



    二、在linux系统下移植好那篇文章提供的源代码,应该就可以跑通发包了,可以用抓包工具Wireshark抓下包试试。下面上代码:

1.rtp.h

[cpp] view plaincopy在CODE上查看代码片派生到我的代码片
  1. // MPEG2RTP.h  
  2. #include <stdio.h>  
  3. #include <stdlib.h>  
  4.   
  5. #include <string.h>  
  6.   
  7. #include <sys/socket.h>  
  8.   
  9. //#include "mem.h"  
  10.   
  11. //  
  12.   
  13.   
  14. #define PACKET_BUFFER_END            (unsigned int)0x00000000  
  15.   
  16.   
  17. #define MAX_RTP_PKT_LENGTH     1400  
  18.   
  19. #define DEST_IP                "192.168.0.30"  
  20. #define DEST_PORT            1234  
  21.   
  22. #define H264                    96  
  23.   
  24. typedef int SOCKET;  
  25.   
  26. typedef struct   
  27. {  
  28.     /**//* byte 0 */  
  29.     unsigned char csrc_len:4;        /**//* expect 0 */  
  30.     unsigned char extension:1;        /**//* expect 1, see RTP_OP below */  
  31.     unsigned char padding:1;        /**//* expect 0 */  
  32.     unsigned char version:2;        /**//* expect 2 */  
  33.     /**//* byte 1 */  
  34.     unsigned char payload:7;        /**//* RTP_PAYLOAD_RTSP */  
  35.     unsigned char marker:1;        /**//* expect 1 */  
  36.     /**//* bytes 2, 3 */  
  37.     unsigned short seq_no;              
  38.     /**//* bytes 4-7 */  
  39.     unsigned  long timestamp;          
  40.     /**//* bytes 8-11 */  
  41.     unsigned long ssrc;            /**//* stream number is used here. */  
  42. } RTP_FIXED_HEADER;  
  43.   
  44. typedef struct {  
  45.     //byte 0  
  46.     unsigned char TYPE:5;  
  47.     unsigned char NRI:2;  
  48.     unsigned char F:1;      
  49.            
  50. } NALU_HEADER; /**//* 1 BYTES */  
  51.   
  52. typedef struct {  
  53.     //byte 0  
  54.     unsigned char TYPE:5;  
  55.     unsigned char NRI:2;   
  56.     unsigned char F:1;      
  57.               
  58.                
  59. } FU_INDICATOR; /**//* 1 BYTES */  
  60.   
  61. typedef struct {  
  62.     //byte 0  
  63.     unsigned char TYPE:5;  
  64.     unsigned char R:1;  
  65.     unsigned char E:1;  
  66.     unsigned char S:1;      
  67. } FU_HEADER; /**//* 1 BYTES */  
  68.   
  69.   
  70.   
  71.   
  72. //BOOL InitWinsock();  

2. rtp.c
[cpp] view plaincopy在CODE上查看代码片派生到我的代码片
  1. // NALDecoder.cpp : Defines the entry point for the console application.  
  2. //  
  3.   
  4.   
  5. #include <stdio.h>  
  6. #include <stdlib.h>  
  7. #include <string.h>  
  8. #include <memory.h>  
  9. #include "rtp.h"  
  10.   
  11. #include <sys/types.h>  
  12. #include <sys/socket.h>  
  13. #include <netinet/in.h>  
  14.   
  15. typedef struct  
  16. {  
  17.   int startcodeprefix_len;      //! 4 for parameter sets and first slice in picture, 3 for everything else (suggested)  
  18.   unsigned len;                 //! Length of the NAL unit (Excluding the start code, which does not belong to the NALU)  
  19.   unsigned max_size;            //! Nal Unit Buffer size  
  20.   int forbidden_bit;            //! should be always FALSE  
  21.   int nal_reference_idc;        //! NALU_PRIORITY_xxxx  
  22.   int nal_unit_type;            //! NALU_TYPE_xxxx      
  23.   char *buf;                    //! contains the first byte followed by the EBSP  
  24.   unsigned short lost_packets;  //! true, if packet loss is detected  
  25. } NALU_t;  
  26.   
  27. FILE *bits = NULL;                //!< the bit stream file  
  28. static int FindStartCode2 (unsigned char *Buf);//查找开始字符0x000001  
  29. static int FindStartCode3 (unsigned char *Buf);//查找开始字符0x00000001  
  30. //static bool flag = true;  
  31. static int info2=0, info3=0;  
  32. RTP_FIXED_HEADER        *rtp_hdr;  
  33.   
  34. NALU_HEADER     *nalu_hdr;  
  35. FU_INDICATOR    *fu_ind;  
  36. FU_HEADER       *fu_hdr;  
  37.   
  38. /*BOOL InitWinsock() 
  39. { 
  40.     int Error; 
  41.     WORD VersionRequested; 
  42.     WSADATA WsaData; 
  43.     VersionRequested=MAKEWORD(2,2); 
  44.     Error=WSAStartup(VersionRequested,&WsaData); //启动WinSock2 
  45.     if(Error!=0) 
  46.     { 
  47.         return FALSE; 
  48.     } 
  49.     else 
  50.     { 
  51.         if(LOBYTE(WsaData.wVersion)!=2||HIBYTE(WsaData.wHighVersion)!=2) 
  52.         { 
  53.             WSACleanup(); 
  54.             return FALSE; 
  55.         } 
  56.          
  57.     } 
  58.     return TRUE; 
  59. }*/  
  60.   
  61. //为NALU_t结构体分配内存空间  
  62. NALU_t *AllocNALU(int buffersize)  
  63. {  
  64.   NALU_t *n;  
  65.   
  66.   if ((n = (NALU_t*)calloc (1, sizeof (NALU_t))) == NULL)  
  67.   {  
  68.       printf("AllocNALU: n");  
  69.       exit(0);  
  70.   }  
  71.   
  72.   n->max_size=buffersize;  
  73.   
  74.   if ((n->buf = (char*)calloc (buffersize, sizeof (char))) == NULL)  
  75.   {  
  76.     free (n);  
  77.     printf ("AllocNALU: n->buf");  
  78.     exit(0);  
  79.   }  
  80.   
  81.   return n;  
  82. }  
  83. //释放  
  84. void FreeNALU(NALU_t *n)  
  85. {  
  86.   if (n)  
  87.   {  
  88.     if (n->buf)  
  89.     {  
  90.       free(n->buf);  
  91.       n->buf=NULL;  
  92.     }  
  93.     free (n);  
  94.   }  
  95. }  
  96.   
  97. void OpenBitstreamFile (char *fn)  
  98. {  
  99.   if (NULL == (bits=fopen(fn, "rb")))  
  100.   {  
  101.       printf("open file error\n");  
  102.       exit(0);  
  103.   }  
  104. }  
  105. //这个函数输入为一个NAL结构体,主要功能为得到一个完整的NALU并保存在NALU_t的buf中,获取他的长度,填充F,IDC,TYPE位。  
  106. //并且返回两个开始字符之间间隔的字节数,即包含有前缀的NALU的长度  
  107. int GetAnnexbNALU (NALU_t *nalu)  
  108. {  
  109.   int pos = 0;  
  110.   int StartCodeFound, rewind;  
  111.   unsigned char *Buf;  
  112.       
  113.   if ((Buf = (unsigned char*)calloc (nalu->max_size , sizeof(char))) == NULL)   
  114.       printf ("GetAnnexbNALU: Could not allocate Buf memory\n");  
  115.   
  116.   nalu->startcodeprefix_len=3;//初始化码流序列的开始字符为3个字节  
  117.     
  118.    if (3 != fread (Buf, 1, 3, bits))//从码流中读3个字节  
  119.        {  
  120.         free(Buf);  
  121.         return 0;  
  122.        }  
  123.    info2 = FindStartCode2 (Buf);//判断是否为0x000001   
  124.    if(info2 != 1)   
  125.    {  
  126.     //如果不是,再读一个字节  
  127.     if(1 != fread(Buf+3, 1, 1, bits))//读一个字节  
  128.         {  
  129.          free(Buf);  
  130.          return 0;  
  131.         }  
  132.     info3 = FindStartCode3 (Buf);//判断是否为0x00000001  
  133.     if (info3 != 1)//如果不是,返回-1  
  134.         {   
  135.          free(Buf);  
  136.          return -1;  
  137.         }  
  138.     else   
  139.         {  
  140.         //如果是0x00000001,得到开始前缀为4个字节  
  141.          pos = 4;  
  142.          nalu->startcodeprefix_len = 4;  
  143.         }  
  144.    }  
  145.      
  146.    else  
  147.        {  
  148.        //如果是0x000001,得到开始前缀为3个字节  
  149.         nalu->startcodeprefix_len = 3;  
  150.         pos = 3;  
  151.        }  
  152.    //查找下一个开始字符的标志位  
  153.    StartCodeFound = 0;  
  154.    info2 = 0;  
  155.    info3 = 0;  
  156.     
  157.   while (!StartCodeFound)  
  158.   {  
  159.     if (feof (bits))//判断是否到了文件尾  
  160.     {  
  161.       nalu->len = (pos-1)-nalu->startcodeprefix_len;  
  162.       memcpy (nalu->buf, &Buf[nalu->startcodeprefix_len], nalu->len);       
  163.       nalu->forbidden_bit = nalu->buf[0] & 0x80; //1 bit  
  164.       nalu->nal_reference_idc = nalu->buf[0] & 0x60; // 2 bit  
  165.       nalu->nal_unit_type = (nalu->buf[0]) & 0x1f;// 5 bit  
  166.       free(Buf);  
  167.       return pos-1;  
  168.     }  
  169.     Buf[pos++] = fgetc (bits);//读一个字节到BUF中  
  170.     info3 = FindStartCode3(&Buf[pos-4]);//判断是否为0x00000001  
  171.     if(info3 != 1)  
  172.       info2 = FindStartCode2(&Buf[pos-3]);//判断是否为0x000001  
  173.     StartCodeFound = (info2 == 1 || info3 == 1);  
  174.   }  
  175.     
  176.   
  177.    
  178.   // Here, we have found another start code (and read length of startcode bytes more than we should  
  179.   // have.  Hence, go back in the file  
  180.   rewind = (info3 == 1)? -4 : -3;  
  181.   
  182.   if (0 != fseek (bits, rewind, SEEK_CUR))//把文件指针指向前一个NALU的末尾  
  183.   {  
  184.     free(Buf);  
  185.     printf("GetAnnexbNALU: Cannot fseek in the bit stream file");  
  186.   }  
  187.   
  188.   // Here the Start code, the complete NALU, and the next start code is in the Buf.    
  189.   // The size of Buf is pos, pos+rewind are the number of bytes excluding the next  
  190.   // start code, and (pos+rewind)-startcodeprefix_len is the size of the NALU excluding the start code  
  191.   
  192.   nalu->len = (pos+rewind)-nalu->startcodeprefix_len;  
  193.   memcpy (nalu->buf, &Buf[nalu->startcodeprefix_len], nalu->len);//拷贝一个完整NALU,不拷贝起始前缀0x000001或0x00000001  
  194.   nalu->forbidden_bit = nalu->buf[0] & 0x80; //1 bit  
  195.   nalu->nal_reference_idc = nalu->buf[0] & 0x60; // 2 bit  
  196.   nalu->nal_unit_type = (nalu->buf[0]) & 0x1f;// 5 bit  
  197.   free(Buf);  
  198.    
  199.   return (pos+rewind);//返回两个开始字符之间间隔的字节数,即包含有前缀的NALU的长度  
  200. }  
  201. //输出NALU长度和TYPE  
  202. void dump(NALU_t *n)  
  203. {  
  204.     if (!n)return;  
  205.     //printf("a new nal:");  
  206.     printf(" len: %d  ", n->len);  
  207.     printf("nal_unit_type: %x\n", n->nal_unit_type);  
  208. }  
  209.   
  210. int main(int argc, char* argv[])  
  211. {  
  212.         //FILE *stream;  
  213.         //stream=fopen("Test.264", "wb");  
  214.   
  215.     OpenBitstreamFile("./-a.264");//打开264文件,并将文件指针赋给bits,在此修改文件名实现打开别的264文件。  
  216.     NALU_t *n;  
  217.     char* nalu_payload;    
  218.     char sendbuf[1500];  
  219.       
  220.     unsigned short seq_num =0;  
  221.         //printf("seq_num=%d\n",seq_num);//added by  
  222.     int bytes=0;  
  223.     //InitWinsock(); //初始化套接字库  
  224.     SOCKET    socket1;  
  225.     struct sockaddr_in server;  
  226.         int len =sizeof(server);  
  227.     float framerate=25;  
  228.     unsigned int timestamp_increase=0,ts_current=0;  
  229.     timestamp_increase=(unsigned int)(90000.0 / framerate); //+0.5);  
  230.   
  231.     server.sin_family=AF_INET;  
  232.     server.sin_port=htons(DEST_PORT);            
  233.     server.sin_addr.s_addr=inet_addr(DEST_IP);   
  234.     socket1=socket(AF_INET,SOCK_DGRAM,0);  
  235.     connect(socket1, (const struct sockaddr *)&server, len) ;//申请UDP套接字  
  236.     n = AllocNALU(8000000);//为结构体nalu_t及其成员buf分配空间。返回值为指向nalu_t存储空间的指针  
  237.       
  238.   
  239.   
  240.     while(!feof(bits))   
  241.     {  
  242.         GetAnnexbNALU(n);//每执行一次,文件的指针指向本次找到的NALU的末尾,下一个位置即为下个NALU的起始码0x000001  
  243.         dump(n);//输出NALU长度和TYPE  
  244.           
  245.         memset(sendbuf,0,1500);//清空sendbuf;此时会将上次的时间戳清空,因此需要ts_current来保存上次的时间戳值  
  246.     //rtp固定包头,为12字节,该句将sendbuf[0]的地址赋给rtp_hdr,以后对rtp_hdr的写入操作将直接写入sendbuf。  
  247.         rtp_hdr =(RTP_FIXED_HEADER*)&sendbuf[0];   
  248.         //设置RTP HEADER,  
  249.         rtp_hdr->payload     = H264;  //负载类型号,  
  250.         rtp_hdr->version     = 2;  //版本号,此版本固定为2  
  251.         rtp_hdr->marker    = 0;   //标志位,由具体协议规定其值。  
  252.         rtp_hdr->ssrc        = htonl(10);    //随机指定为10,并且在本RTP会话中全局唯一  
  253.           
  254.     //  当一个NALU小于1400字节的时候,采用一个单RTP包发送  
  255.         if(n->len<=1400)  
  256.         {     
  257.             //设置rtp M 位;  
  258.             rtp_hdr->marker=1;  
  259.             rtp_hdr->seq_no     = htons(seq_num ++); //序列号,每发送一个RTP包增1  
  260.             //设置NALU HEADER,并将这个HEADER填入sendbuf[12]  
  261.             nalu_hdr =(NALU_HEADER*)&sendbuf[12]; //将sendbuf[12]的地址赋给nalu_hdr,之后对nalu_hdr的写入就将写入sendbuf中;  
  262.             nalu_hdr->F=n->forbidden_bit;  
  263.             nalu_hdr->NRI=n->nal_reference_idc>>5;//有效数据在n->nal_reference_idc的第6,7位,需要右移5位才能将其值赋给nalu_hdr->NRI。  
  264.             nalu_hdr->TYPE=n->nal_unit_type;  
  265.   
  266.             nalu_payload=&sendbuf[13];//同理将sendbuf[13]赋给nalu_payload  
  267.             memcpy(nalu_payload,n->buf+1,n->len-1);//去掉nalu头的nalu剩余内容写入sendbuf[13]开始的字符串。  
  268.           
  269.             ts_current=ts_current+timestamp_increase;  
  270.             rtp_hdr->timestamp=htonl(ts_current);  
  271.             bytes=n->len + 13 ;                      //获得sendbuf的长度,为nalu的长度(包含NALU头但除去起始前缀)加上rtp_header的固定长度12字节  
  272.             send( socket1, sendbuf, bytes, 0 );//发送rtp包  
  273.             //sleep(1);  
  274. //fwrite(sendbuf,bytes, 1, stream);   
  275.         }  
  276.           
  277.         else if(n->len>1400)  
  278.         {  
  279.             //得到该nalu需要用多少长度为1400字节的RTP包来发送  
  280.             int k=0,l=0;  
  281.             k=n->len/1400;//需要k个1400字节的RTP包  
  282.             l=n->len%1400;//最后一个RTP包的需要装载的字节数  
  283.             int t=0;//用于指示当前发送的是第几个分片RTP包  
  284.             ts_current=ts_current+timestamp_increase;  
  285.             rtp_hdr->timestamp=htonl(ts_current);  
  286.             while(t<=k)  
  287.             {  
  288.                 rtp_hdr->seq_no = htons(seq_num ++); //序列号,每发送一个RTP包增1  
  289.                 if(!t)//发送一个需要分片的NALU的第一个分片,置FU HEADER的S位  
  290.                 {  
  291.                     //设置rtp M 位;  
  292.                     rtp_hdr->marker=0;  
  293.                     //设置FU INDICATOR,并将这个HEADER填入sendbuf[12]  
  294.                     fu_ind =(FU_INDICATOR*)&sendbuf[12]; //将sendbuf[12]的地址赋给fu_ind,之后对fu_ind的写入就将写入sendbuf中;  
  295.                     fu_ind->F=n->forbidden_bit;  
  296.                     fu_ind->NRI=n->nal_reference_idc>>5;  
  297.                     fu_ind->TYPE=28;  
  298.                       
  299.                     //设置FU HEADER,并将这个HEADER填入sendbuf[13]  
  300.                     fu_hdr =(FU_HEADER*)&sendbuf[13];  
  301.                     fu_hdr->E=0;  
  302.                     fu_hdr->R=0;  
  303.                     fu_hdr->S=1;  
  304.                     fu_hdr->TYPE=n->nal_unit_type;  
  305.                       
  306.                   
  307.                     nalu_payload=&sendbuf[14];//同理将sendbuf[14]赋给nalu_payload  
  308.                     memcpy(nalu_payload,n->buf+1,1400);//去掉NALU头  
  309.                       
  310.                     bytes=1400+14;                      //获得sendbuf的长度,为nalu的长度(除去起始前缀和NALU头)加上rtp_header,fu_ind,fu_hdr的固定长度14字节  
  311.                     send( socket1, sendbuf, bytes, 0 );//发送rtp包  
  312. //fwrite(sendbuf,bytes, 1, stream);  
  313.                                         //sleep(1);  
  314.                     t++;  
  315.                       
  316.                 }  
  317.                 //发送一个需要分片的NALU的非第一个分片,清零FU HEADER的S位,如果该分片是该NALU的最后一个分片,置FU HEADER的E位  
  318.                 else if(k==t)//发送的是最后一个分片,注意最后一个分片的长度可能超过1400字节(当l>1386时)。  
  319.                 {  
  320.                       
  321.                     //设置rtp M 位;当前传输的是最后一个分片时该位置1  
  322.                     rtp_hdr->marker=1;  
  323.                     //设置FU INDICATOR,并将这个HEADER填入sendbuf[12]  
  324.                     fu_ind =(FU_INDICATOR*)&sendbuf[12]; //将sendbuf[12]的地址赋给fu_ind,之后对fu_ind的写入就将写入sendbuf中;  
  325.                     fu_ind->F=n->forbidden_bit;  
  326.                     fu_ind->NRI=n->nal_reference_idc>>5;  
  327.                     fu_ind->TYPE=28;  
  328.                           
  329.                     //设置FU HEADER,并将这个HEADER填入sendbuf[13]  
  330.                     fu_hdr =(FU_HEADER*)&sendbuf[13];  
  331.                     fu_hdr->R=0;  
  332.                     fu_hdr->S=0;  
  333.                     fu_hdr->TYPE=n->nal_unit_type;  
  334.                     fu_hdr->E=1;  
  335.   
  336.                     nalu_payload=&sendbuf[14];//同理将sendbuf[14]的地址赋给nalu_payload  
  337.                     memcpy(nalu_payload,n->buf+t*1400+1,l-1);//将nalu最后剩余的l-1(去掉了一个字节的NALU头)字节内容写入sendbuf[14]开始的字符串。  
  338.                     bytes=l-1+14;       //获得sendbuf的长度,为剩余nalu的长度l-1加上rtp_header,FU_INDICATOR,FU_HEADER三个包头共14字节  
  339.                     send( socket1, sendbuf, bytes, 0 );//发送rtp包  
  340. //fwrite(sendbuf,bytes, 1, stream);  
  341.                     t++;  
  342.                     //sleep(1);  
  343.                 }  
  344.                 else if(t<k&&0!=t)  
  345.                 {  
  346.                     //设置rtp M 位;  
  347.                     rtp_hdr->marker=0;  
  348.                     //设置FU INDICATOR,并将这个HEADER填入sendbuf[12]  
  349.                     fu_ind =(FU_INDICATOR*)&sendbuf[12]; //将sendbuf[12]的地址赋给fu_ind,之后对fu_ind的写入就将写入sendbuf中;  
  350.                     fu_ind->F=n->forbidden_bit;  
  351.                     fu_ind->NRI=n->nal_reference_idc>>5;  
  352.                     fu_ind->TYPE=28;  
  353.                           
  354.                     //设置FU HEADER,并将这个HEADER填入sendbuf[13]  
  355.                     fu_hdr =(FU_HEADER*)&sendbuf[13];  
  356.                     //fu_hdr->E=0;  
  357.                     fu_hdr->R=0;  
  358.                     fu_hdr->S=0;  
  359.                     fu_hdr->E=0;  
  360.                     fu_hdr->TYPE=n->nal_unit_type;  
  361.                   
  362.                     nalu_payload=&sendbuf[14];//同理将sendbuf[14]的地址赋给nalu_payload  
  363.                     memcpy(nalu_payload,n->buf+t*1400+1,1400);//去掉起始前缀的nalu剩余内容写入sendbuf[14]开始的字符串。  
  364.                     bytes=1400+14;                      //获得sendbuf的长度,为nalu的长度(除去原NALU头)加上rtp_header,fu_ind,fu_hdr的固定长度14字节  
  365.                     send( socket1, sendbuf, bytes, 0 );//发送rtp包  
  366. //fwrite(sendbuf,bytes, 1, stream);  
  367.                                         //sleep(1);  
  368.                     t++;  
  369.                 }  
  370.             }  
  371.         }  
  372.         //usleep(40000);  
  373.     }  
  374.     FreeNALU(n);  
  375.     return 0;  
  376. }  
  377.   
  378. static int FindStartCode2 (unsigned char *Buf)  
  379. {  
  380.  if(Buf[0]!=0 || Buf[1]!=0 || Buf[2] !=1) return 0; //判断是否为0x000001,如果是返回1  
  381.  else return 1;  
  382. }  
  383.   
  384. static int FindStartCode3 (unsigned char *Buf)  
  385. {  
  386.  if(Buf[0]!=0 || Buf[1]!=0 || Buf[2] !=0 || Buf[3] !=1) return 0;//判断是否为0x00000001,如果是返回1  
  387.  else return 1;  
  388. }  


    三、程序跑通之后下一步,就是要移植到DM6467T下encode工程中进行实时打包,也就是编码一帧完成后直接RTP打包,而不是读取文件流。在encode工程中有个writer线程,里面的fwrite函数就是writer线程的核心,这里我将fwrite替换成rtp()打包函数。

    列出几点注意事项:

        1. 移植过程中将所有对文件的操作改成对BUFFER指针的操作

        2. 注意对RTP头中seq_no的修改

        3. 注意对时间戳的修改

        4. 由于实时发送需要不停地调用rtp打包程序,就需要将建立socket的部分程序移到循环之外。这是因为linux的文件操作符是有限的,不停地创建会用光文件操作符,而对socket的close不能立即释放资源,会有延时,即使close也解决不了问题(至少我没能解决,如果有解决的朋友希望不吝赐教)。

    第三部分只是简单列出移植过程中所遇到的问题以及解决思路,未上详尽解释以及代码,不过网上应该都有具体方法,有问题也可以留言讨论,我用的是UDP包。

    将程序移植完成以后通过VLC实时解码,可能还会出现1秒钟的延迟,那是由于VLC默认的网络缓存时间是1000ms,网络条件好的可以改成300ms,延时将大大减小。


附件内容是将文中所提到的网友的windows程序做简单修改移植linux下的RTP打包发送程序:点击打开链接

0 0
原创粉丝点击