IPCamera.rar

  • PUDN用户
    了解作者
  • Visual C++
    开发工具
  • 734KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 37
    下载次数
  • 2012-05-08 10:46
    上传日期
模拟客户端.cpp : 与摄像机建立连接后,启动新线程接收图片。 所有线程接收的图片放入一个队列里边,然后由主线程读取保存至硬盘。
IPCamera.rar
  • IP-Camera模拟客户端程序
  • Debug
  • StdAfx.obj
    2.2KB
  • save_jpg.sbr
    547KB
  • client_substream.obj
    41.5KB
  • save_jpg.obj
    37.1KB
  • StdAfx.sbr
    4KB
  • HiK_client.pdb
    177KB
  • vc60.pdb
    172KB
  • client_substream.sbr
    548.4KB
  • client.sbr
    549.1KB
  • vc60.idb
    121KB
  • client.pch
    208.9KB
  • client.obj
    44.1KB
  • HiK.h
    2.4KB
  • client.dsp
    4.6KB
  • STDAFX.H
    769B
  • HiK_client.ilk
    66KB
  • CYNET_API.H
    0B
  • client.opt
    48.5KB
  • STDAFX.CPP
    303B
  • client.bat
    37B
  • demux_mpg.c
    8.1KB
  • demux_mpg.h
    2.5KB
  • client.plg
    9.1KB
  • client.cpp
    25.7KB
  • save_jpg.cpp
    14.8KB
  • client.ncb
    57KB
  • client_substream.cpp
    21.4KB
  • client.dsw
    543B
内容介绍
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "demux_mpg.h" #if 0 int main() { FILE *fin, *fout; int len, ret, ret2; char *buffer; int count; char name[128]; MPEG_DEMUX mpg_demux; fin = fopen("test.mp4", "rb"); fseek(fin, 0, SEEK_END); len = ftell(fin); fseek(fin, -len, SEEK_END); buffer = (char *)malloc(len); fread(buffer, 1, len, fin); fclose(fin); mpg_demux.status = MPEG_DEMUX_UNSYNC; mpg_demux.head = 0xffffffff; mpg_demux.pack_start = 0; mpg_demux.buffer = (unsigned char *)buffer; mpg_demux.buf_len = len; count = 0; fout = NULL; while(1) { ret = demux_mpg_parse_stream(&mpg_demux); if(ret == MPEG_DEMUX_RET_PSC) { printf("Pack Start Code\n"); // skip it mpg_demux.status = MPEG_DEMUX_UNSYNC; mpg_demux.head = 0xffffffff; if(fout != NULL) fclose(fout); sprintf(name, "t%04d.jpg", count++); fout = fopen(name, "wb"); } if(ret == MPEG_DEMUX_RET_PES) { printf("PES\n"); mpg_demux.status = MPEG_DEMUX_PES_PKTLEN; mpg_demux.wait_num = 2; mpg_demux.pkt_len = 0; ret2 = demux_mpg_parse_PES(&mpg_demux); if(ret2 > 0) { fwrite(mpg_demux.buffer, 1, mpg_demux.pkt_len, fout); mpg_demux.buffer += mpg_demux.pkt_len; mpg_demux.buf_len -= mpg_demux.pkt_len; // resync mpg_demux.status = MPEG_DEMUX_UNSYNC; mpg_demux.head = 0xffffffff; } } if(ret == MPEG_DEMUX_RET_EOF) { printf("End of Stream\n"); break; } } if(fout != NULL) fclose(fout); #if 0 do { ret = demux_mpg_parse_PES(&mpg_demux); } while(ret != 1); fwrite(mpg_demux.buffer, 1, mpg_demux.pkt_len, fout); mpg_demux.buffer += mpg_demux.pkt_len; mpg_demux.buf_len -= mpg_demux.pkt_len; mpg_demux.status = MPEG_DEMUX_UNSYNC; mpg_demux.head = 0xffffffff; do { ret = demux_mpg_parse_stream(&mpg_demux); } while(ret != 1); do { ret = demux_mpg_parse_PES(&mpg_demux); } while(ret != 1); fwrite(mpg_demux.buffer, 1, mpg_demux.pkt_len, fout); fclose(fout); #endif free(buffer); } #endif /* * Return MPEG_DEMUX_RET_EOF: end of buffer * Return MPEG_DEMUX_RET_PSC: find Pack Start Code * Return MPEG_DEMUX_RET_PES: find PES */ int demux_mpg_parse_stream(MPEG_DEMUX *demux) { int c, ret = MPEG_DEMUX_RET_NULL; do { // sync if(demux->status == MPEG_DEMUX_UNSYNC) { while(demux->buf_len > 0) { c = (int)*demux->buffer++; demux->buf_len--; demux->head <<= 8; if(demux->head != 0x100) { demux->head |= c; continue; } demux->head |= c; demux->status = MPEG_DEMUX_SYNCED; break; } } if(demux->status == MPEG_DEMUX_SYNCED) { switch(demux->head) { case 0x1BA: // pack start code demux->pack_start = 1; // mark start ret = MPEG_DEMUX_RET_PSC; break; case 0x1E0: // video if(demux->pack_start == 1) { ret = MPEG_DEMUX_RET_PES; } else { demux->status = MPEG_DEMUX_UNSYNC; // skip it demux->head = 0xffffffff; } break; //case 0x1BC: // psm, skip it default: demux->status = MPEG_DEMUX_UNSYNC; demux->head = 0xffffffff; } } if((demux->buf_len <= 0) && (demux->status == MPEG_DEMUX_UNSYNC)) { ret = MPEG_DEMUX_RET_EOF; } } while(ret == MPEG_DEMUX_RET_NULL); return ret; } /* * Return 1: find data * Return 0: Run out of buffer * Return <0: parse error */ int demux_mpg_parse_PES(MPEG_DEMUX *demux) { int c, ret = 0; do { // Read packet length if(demux->status == MPEG_DEMUX_PES_PKTLEN) { while(demux->buf_len > 0) { c = (int)*demux->buffer++; demux->buf_len--; demux->pkt_len <<= 8; demux->pkt_len |= c; demux->wait_num--; if(demux->wait_num > 0) { continue; } if(demux->pkt_len != 0) { demux->status = MPEG_DEMUX_PES_SKIP_STUFFING; } else { ret = -2; // bad format } break; } } // Skip stuFFing bytes if(demux->status == MPEG_DEMUX_PES_SKIP_STUFFING) { while((demux->buf_len > 0) && (demux->pkt_len > 0)) { c = (int)*demux->buffer++; demux->buf_len--; demux->pkt_len--; if(c != 0xff) { demux->status = MPEG_DEMUX_PES_SKIP_TIME_FLAG; break; } } } // Skip time flag if(demux->status == MPEG_DEMUX_PES_SKIP_TIME_FLAG) { if((c>>6) != 2) { ret = -1; // unsupported! break; } else { demux->status = MPEG_DEMUX_PES_SKIP_PTS_FLAG; } } // Skip PTS flag if(demux->status == MPEG_DEMUX_PES_SKIP_PTS_FLAG) { if((demux->buf_len > 0) && (demux->pkt_len > 0)) { demux->buffer++; demux->buf_len--; demux->pkt_len--; demux->status = MPEG_DEMUX_PES_HDRLEN; } } // read header len if(demux->status == MPEG_DEMUX_PES_HDRLEN) { if((demux->buf_len > 0) && (demux->pkt_len > 0)) { c = (int)*demux->buffer++; demux->buf_len--; demux->pkt_len--; if(c > demux->pkt_len) { ret = -2; // bad format break; } else { if(c > 0) { demux->status = MPEG_DEMUX_PES_SKIP_HDR; demux->wait_num = c; } else { demux->status = MPEG_DEMUX_PES_DATA; } } } } // skip header if(demux->status == MPEG_DEMUX_PES_SKIP_HDR) { while((demux->buf_len > 0) && (demux->pkt_len > 0)) { demux->buffer++; demux->buf_len--; demux->pkt_len--; demux->wait_num--; if(demux->wait_num > 0) { continue; } demux->status = MPEG_DEMUX_PES_DATA; break; } }
评论
    相关推荐
    • IPCamera.zip
      讲解如何基于TB-RK3399proD开发板进行RTSP推流,并可在远程使用vlc进行播放 开发板:TB-RK3399proD 系统、固件:采用fedora28系统(固件v1.5测试通过) 推流框架:live555 编解码库:rockchip mpp编解码库 ...
    • IPCamera.rar
      一个IPCamera的例子,非常的有意思,希望能够有帮助
    • IPCamera_linux:Smartfarm项目的海康威视ipcamera控制程序linux版本,将来用于伽利略开发板
      IPCamera_linux Smartfarm项目的海康威视ipcamera控制程序linux版本,将来用于伽利略开发板 这是海康威视IPCamera软件的linux版本。 之前做了一个windows上跑的,由于要移植到伽利略开发板上,所以需要linux版本。 ...
    • spydroid-ipcamera最新版源码
      spydroid-ipcamera最新版源码, spydroid-ipcamera支持Android H264硬件编码。
    • ipcamera-for-android
      一款将Android手机变成IP Camera的软件,在同一个网路,你可以在任意的浏览器查看手机监控视频。
    • ipcamera_测试例子
      资源 包含的是 android系统下ipcamera的测试例子。在局域网下可以ipcamera的ip地址加端口即可以访问。访问效果与网络情况关系很大。
    • IPcamera:视频监控demo
      IPcamera 视频监控demo 这是一个android项目,可以通过adt直接导入
    • emgu ipcamera demo.zip
      适用于libemgucv-windesktop-3.3.0.2824,代码已包含所需emgu包。vs2010 C#。亲测可用。需摄像头支持onvif格式,可发布出rtsp流。
    • ipcamera.rar
      简介:main.cpp main.rar
    • qpopper2.53.tar.Z
      pop3 server