首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
您找到你想要的搜索结果了吗?
是的
没有找到

最近做RTSP流媒体的实时广播节目

//h264视频流打包代码 // NALDecoder.cpp : Defines the entry point for the console application. #include <stdio.h> #include <stdlib.h> #include <string.h> #include <memory.h> #include “h264.h” #include “initsock.h” CInitSock initSock;  // 初始化Winsock库 //为NALU_t结构体分配内存空间 NALU_t *AllocNALU(int buffersize) {  NALU_t *pNalu;  if ((pNalu = (NALU_t*)calloc (1, sizeof (NALU_t))) == NULL) {   printf(“AllocNALU: Nalu”);   exit(0);  }  pNalu->max_size=buffersize;  if ((pNalu->buf = (char*)calloc (buffersize, sizeof (char))) == NULL) {   free (pNalu);   printf (“AllocNALU: Nalu->buf”);   exit(0);  }  return pNalu; } //释放 void FreeNALU(NALU_t *pNalu) {  if (pNalu) {   if (pNalu->buf) {    free(pNalu->buf);    pNalu->buf=NULL;   }   free (pNalu);  } } static int FindStartCode2 (unsigned char *Buf) {  if(Buf[0]!=0 Buf[1]!=0 Buf[2] !=1) return 0; //推断是否为0x000001,假设是返回1  else return 1; } static int FindStartCode3 (unsigned char *Buf) {  if(Buf[0]!=0 Buf[1]!=0 Buf[2] !=0 Buf[3] !=1) return 0;//推断是否为0x00000001,假设是返回1  else return 1; } // 这个函数输入为一个NAL结构体。主要功能为得到一个完整的NALU并保存在NALU_t的buf中,获取他的长度。填充F,IDC,TYPE位。 // 而且返回两个開始字符之间间隔的字节数,即包括有前缀的NALU的长度 int GetAnnexbNALU (NALU_t *pNalu, FILE *bits) {  int info2=0, info3=0;  int pos = 0;  int StartCodeFound, rewind;  unsigned char *Buf;  if ((Buf = (unsigned char*)calloc (pNalu->max_size , sizeof(char))) == NULL)   printf (“GetAnnexbNALU: Could not allocate Buf memory\n”);  if (3 != fread (Buf, 1, 3, bits)) {  //从码流中读3个字节   free(Buf);   return -1;     }  if (Buf[0]!=0 Buf[1]!=0) {   free(Buf);   return -1;  }  if (Buf[2]==1) {   pNalu->startcodeprefix_len=3;   //初始化码流序列的開始字符为3个字节   pos =3;  }else {   if (1 != fread (Buf+3, 1, 1, bits)) {  //从码流中读1个字节    free(Buf);    return -1;   }   if (Buf[2]!=0 Buf[3]!=1) {    free(Buf);    return -1;   }   pos = 4;   pNalu->startcodeprefix_len = 4;  }  //查找下一个開始字符的标志位  StartCodeFound = 0;  info2 = 0;  info3 = 0;     while (!StartCodeFound)  {   if (feof (bits)) { //推断是否到了文件尾    break;   }   Buf[pos++] = fgetc (bits);//读一个字节到BUF中   info3 = FindStartCod

01

pcap文件格式及文件解析[通俗易懂]

文件头结构体 sturct pcap_file_header { DWORD magic; DWORD version_major; DWORD version_minor; DWORD thiszone; DWORD sigfigs; DWORD snaplen; DWORD linktype; } 说明: 1、标识位:32位的,这个标识位的值是16进制的 0xa1b2c3d4。 a 32-bit magic number ,The magic number has the value hex a1b2c3d4. 2、主版本号:16位, 默认值为0x2。 a 16-bit major version number,The major version number should have the value 2. 3、副版本号:16位,默认值为0x04。 a 16-bit minor version number,The minor version number should have the value 4. 4、区域时间:32位,实际上该值并未使用,因此可以将该位设置为0。 a 32-bit time zone offset field that actually not used, so you can (and probably should) just make it 0; 5、精确时间戳:32位,实际上该值并未使用,因此可以将该值设置为0。 a 32-bit time stamp accuracy field tha not actually used,so you can (and probably should) just make it 0; 6、数据包最大长度:32位,该值设置所抓获的数据包的最大长度,如果所有数据包都要抓获,将该值设置为65535;例如:想获取数据包的前64字节,可将该值设置为64。 a 32-bit snapshot length” field;The snapshot length field should be the maximum number of bytes perpacket that will be captured. If the entire packet is captured, make it 65535; if you only capture, for example, the first 64 bytes of the packet, make it 64. 7、链路层类型:32位, 数据包的链路层包头决定了链路层的类型。 a 32-bit link layer type field.The link-layer type depends on the type of link-layer header that the packets in the capture file have: 以下是数据值与链路层类型的对应表 0 BSD loopback devices, except for later OpenBSD 1 Ethernet, and Linux loopback devices 以太网类型,大多数的数据包为这种类型。 6 802.5 Token Ring 7 ARCnet 8 SLIP 9 PPP 10 FDDI 100 LLC/SNAP-encapsulated ATM 101 raw IP, with no link 102 BSD/OS SLIP 103 BSD/OS PPP 104 Cisco HDLC 105 802.11 108 later OpenBSD loopback devices (with the AF_value in network byte order) 113 special Linux cooked capture 114 LocalTalk

03

“365算法每日学计划”:04打卡-自己动手写一个单链表

一、概述 单向链表(单链表)是链表的一种,其特点是链表的链接方向是单向的,对链表的访问要通过顺序读取从头部开始。 链式存储结构的线性表将采用一组任意的存储单元存放线性表中的数据元素。由于不需要按顺序存储,链表在插入、删除数据元素时比顺序存储要快,但是在查找一个节点时则要比顺序存储要慢 使用链式存储可以克服顺序线性表需要预先知道数据大小的缺点,链表结构可以充分利用内存空间,实现灵活的内存动态管理。但是链式存储失去了数组随机存取的特点,同时增加了节点的指针域,空间开销较大。 二、图解 下图就是最简单最一般的

03
领券