首页 > 代码库 > rtsp 播放器

rtsp 播放器

http://blog.csdn.net/niu_gao/article/details/7753672

 


/******************************************************************************
* INCLUDE FILES
******************************************************************************/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/stat.h>
int main(int argc,char *argv[])
{
FILE *fp =NULL;
FILE *fd = NULL;

//unsigned char stream_buffer[14*1024*1024];//={0};
unsigned char *stream_buffer;//={0};

//unsigned char *steam =stream_buffer;
int x=0;
int y=0;
int stream_len=0;
int mycount = 0;
int temp = 0;
struct stat stat_buf;
int file_len =0;
int flag =0;

stat("video-H264-1.h264",&stat_buf);
file_len = stat_buf.st_size;
stream_buffer = malloc(file_len);
memset(stream_buffer,0,sizeof(stream_buffer));
fp = fopen("video-H264-1.h264","rb");
if(fp ==NULL)
{
exit(-1);
}

fd = fopen("tvvideo.h264","wb");
/*
while((x=fgetc(fp))!=EOF)
{
stream_buffer[y++]=x;
printf("size:%d\n",y);
};*/
fread(stream_buffer,1,file_len,fp);
y = file_len;
printf("size:%d\n",y);
stream_len = y;
x =0;

while(x<y)//1 char
{
flag =0;
temp = stream_buffer[x];
mycount = x;

if ((stream_buffer[mycount++] == 0 && stream_buffer[mycount++] == 0 &&
stream_buffer[mycount++] == 0 && stream_buffer[mycount++] == 0x01))//detect 00 00 00 01
{
if ((stream_buffer[mycount++] == 0 && stream_buffer[mycount++] == 0 &&
stream_buffer[mycount++] == 0 && stream_buffer[mycount++] == 0x01))
{
x=x+3;
flag =1;
}
printf("xx\n");

//NewNalType = stream_buffer[loopCount++] & 0x1f;
//firstMbInSliceFlag = stream_buffer[loopCount++] & 0x80;
}
x++;
if(flag==0)fputc(temp,fd);

}
free(stream_buffer);

fclose(fp);
fclose(fd);
return 0;
}

 

rtsp 播放器