- // asfdemuxtest.cpp : ¶¨Òå¿ØÖÆÌ¨Ó¦ÓóÌÐòµÄÈë¿Úµã¡£
- //
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- #include <memory.h>
- #include "asfdemux.h"
- #define SRCFILE "stream"
- #define DATABUFLEN 1024 * 100
- int main()
- {
- unsigned char *databuf = NULL;
- unsigned int rtsp_len = 0;
- int ret = 0;
- FILE *fp = NULL;
- databuf = (unsigned char *)malloc(sizeof(char)*DATABUFLEN);
- if(databuf == NULL)
- {
- printf("error malloc \n");
- return -1;
- }
- memset(databuf,0,DATABUFLEN);
- fp = fopen(SRCFILE,"rb");
- if(fp == NULL)
- {
- printf("error open file\n");
- free(databuf);
- return -1;
- }
- while(!feof(fp))
- {
- ret = fread(databuf,1,4,fp);
- if(databuf[0] != 0x24)
- {
- printf("error NOT supper this format\n");
- break;
- }
- rtsp_len = (databuf[2] < 8) | databuf[3];
- ret = fread(databuf,1,rtsp_len,fp);
- ret = asfdemux(databuf+20,rtsp_len-20);
- if(ret 0)
- {
- printf("error asfdemux demux asf \n");
- break;
- }
- }
- free(databuf);
- fclose(fp);