asf test

本文介绍了一个使用C/C++编写的ASF文件解析程序,通过读取指定文件并利用asfdemux函数进行ASF格式的数据分离处理。程序首先检查文件头是否符合ASF格式,然后解析并分离ASF流。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  1. // asfdemuxtest.cpp : ¶¨Òå¿ØÖÆÌ¨Ó¦ÓóÌÐòµÄÈë¿Úµã¡£   
  2. //   
  3.    
  4.    
  5. #include <stdlib.h>   
  6. #include <stdio.h>   
  7. #include <string.h>   
  8. #include <memory.h>   
  9.    
  10. #include "asfdemux.h"   
  11.    
  12.    
  13. #define SRCFILE "stream"   
  14. #define DATABUFLEN    1024 * 100   
  15.    
  16.    
  17. int main()   
  18. {   
  19.     unsigned char *databuf  = NULL;   
  20.     unsigned int    rtsp_len = 0;   
  21.     int ret  = 0;   
  22.     FILE *fp = NULL;   
  23.    
  24.    
  25.     databuf = (unsigned char *)malloc(sizeof(char)*DATABUFLEN);   
  26.     if(databuf  == NULL)   
  27.     {   
  28.         printf("error malloc \n");   
  29.         return -1;   
  30.     }   
  31.     memset(databuf,0,DATABUFLEN);   
  32.        
  33.     fp = fopen(SRCFILE,"rb");   
  34.    
  35.     if(fp == NULL)   
  36.     {   
  37.         printf("error open file\n");   
  38.         free(databuf);   
  39.         return -1;   
  40.     }   
  41.    
  42.     while(!feof(fp))   
  43.     {   
  44.    
  45.         ret = fread(databuf,1,4,fp);   
  46.         if(databuf[0] != 0x24)   
  47.         {   
  48.             printf("error NOT supper this format\n");   
  49.             break;   
  50.         }   
  51.    
  52.        
  53.         rtsp_len  = (databuf[2] < 8) | databuf[3];   
  54.         ret = fread(databuf,1,rtsp_len,fp);   
  55.        
  56.         ret = asfdemux(databuf+20,rtsp_len-20);   
  57.         if(ret  0)   
  58.         {   
  59.             printf("error  asfdemux demux asf \n");   
  60.             break;   
  61.         }   
  62.    
  63.    
  64.    
  65.     }   
  66.    
  67.     free(databuf);   
  68.     fclose(fp);   
  69.        
  70.    
  71.    
  72.    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值