天天看点

视频监控 封装[PlayCtrl.dll]的API

前言

  playctrl.dll都忘记到底是朋友翻的还是自己翻的了,有朋友需要,我就贴上来吧。

正文

  一、文件下载

    注意:文件可能随时更新,欢迎使用中遇到问题及时反馈给我。下载后把后缀改成.cs就行了。

  二、部分api

视频监控 封装[PlayCtrl.dll]的API

    /// <summary>

    /// 播放器

    /// </summary>

    public sealed class hikplayer

    {

        #region const member variables

        // #define winver 

        // 0x0700 windows 7

        // 0x0600 windows vista

        // 0x0502 windows 2003 server

        // 0x0410 windows xp

        //<0x0400 windows 98/windows 2000

        public static readonly int winver = 0x0502;

        public static readonly uint wm_user = 0x0400;

        public static readonly uint wm_file_end = wm_user + 33;

        public static readonly uint wm_enc_change = wm_user + 100;

        public static readonly int color_default = 64;

        public static readonly int player_slider_max = 200;

        public static readonly int max_display_device = 4;

        public static readonly int width_pal = 352;

        public static readonly int height_pal = 288;

        #region source buffer

        //#define source_buf_max

        public static readonly uint source_buf_max = 1024 * 100000;

        //#define source_buf_min    1024*50

        public static readonly uint source_buf_min = 1024 * 50;

        #endregion

        #region frame type

        /// <summary>

        /// 音频数据;采样率16khz,单声道,每个采样点16位表示。

        /// </summary>

        public static readonly int t_audio16 = 101;

        public static readonly int t_audio8 = 100;

        /// 视频数据,uyvy格式。“u0-y0-v0-y1-u2-y2-v2-y3….”,第一个像素位于图像左上角。 

        public static readonly int t_uyvy = 1;

        /// 视频数据,yv12格式。排列顺序“y0-y1-……”,“v0-v1….”,“u0-u1-…..”。 

        public static readonly int t_yv12 = 3;

        /// 视频数据。每个像素4个字节,排列方式与位图相似,“b-g-r-0 ……”,第一个像素位于图像左下角。 

        public static readonly int t_rgb32 = 7;

        #region stream type

        /// 实时模式,适合播放网络实时数据,解码器会立刻解码。

        public static readonly int streame_realtime = 0;

        /// 文件模式,适合用户把文件数据用流方式输入。

        /// 注意:当playm4_inputdata()返回false时,用户要等一下重新输入。

        public static readonly int streame_file = 1;

        #region error code

        /// 没有错误

        /// no error

        public static readonly int playm4_noerror = 0;

        /// 输入参数非法

        /// input parameter is invalid;

        public static readonly int playm4_para_over = 1;

        /// 调用顺序不对

        /// the order of the function to be called is error.

        public static readonly int playm4_order_error = 2;

        /// 多媒体时钟设置失败

        /// create multimedia clock failed;

        public static readonly int playm4_timer_error = 3;

        /// 视频解码失败

        /// decode video data failed.

        public static readonly int playm4_dec_video_error = 4;

        /// 音频解码失败

        /// decode audio data failed.

        public static readonly int playm4_dec_audio_error = 5;

        /// 分配内存失败

        /// allocate memory failed.

        public static readonly int playm4_alloc_memory_error = 6;

        /// 文件操作失败

        /// open the file failed.

        public static readonly int playm4_open_file_error = 7;

        /// 创建线程事件等失败

        /// create thread or event failed.

        public static readonly int playm4_create_obj_error = 8;

        /// 创建directdraw失败

        /// create directdraw object failed.

        public static readonly int playm4_create_ddraw_error = 9;

        /// 创建后端缓存失败

        /// failed when creating off-screen surface.

        public static readonly int playm4_create_offscreen_error = 10;

        /// 缓冲区满,输入流失败

        /// buffer is overflow.

        public static readonly int playm4_buf_over = 11;

        /// 创建音频设备失败

        /// failed when creating audio device.

        public static readonly int playm4_create_sound_error = 12;

        /// 设置音量失败

        /// set volume failed.

        public static readonly int playm4_set_volume_error = 13;

        /// 只能在播放文件时才能使用此接口

        /// the function only support play file.

        public static readonly int playm4_support_file_only = 14;

        /// 只能在播放流时才能使用此接口

        /// the function only support play stream.

        public static readonly int playm4_support_stream_only = 15;

        /// 系统不支持,解码器只能工作在pentium 3以上

        /// system not support.

        public static readonly int playm4_sys_not_support = 16;

        /// 没有文件头

        /// no file header.

        public static readonly int playm4_fileheader_unknown = 17;

        /// 解码器和编码器版本不对应

        /// the version of decoder and encoder is not adapted.  

        public static readonly int playm4_version_incorrect = 18;

        /// 初始化解码器失败

        /// initialize decoder failed.

        public static readonly int hik_palym4_init_decoder_error = 19;

        /// 文件太短或码流无法识别

        /// the file data is unknown.

        public static readonly int playm4_check_file_error = 20;

        /// 初始化多媒体时钟失败

        /// initialize multimedia clock failed.

        public static readonly int playm4_init_timer_error = 21;

        /// 位拷贝失败

        /// blt failed.

        public static readonly int playm4_blt_error = 22;

        /// 显示overlay失败

        /// update failed.

        public static readonly int playm4_update_error = 23;

        /// 打开文件错误

        /// open file error, stream type is multi.

        public static readonly int playm4_open_file_error_multi = 24;

        /// open file error, stream type is video.

        public static readonly int playm4_open_file_error_video = 25;

        /// jpeg格式压缩错误

        /// jpeg compress error.

        public static readonly int playm4_jpeg_compress_error = 26;

        /// 不支持此文件的版本

        /// don't support the version of this file.

        public static readonly int playm4_extract_not_support = 27;

        /// 提取视频数据失败

        /// extract video data failed.

        public static readonly int playm4_extract_data_error = 28;

        #region display buffers

        /// 播放缓冲最大值

        public static readonly int max_dis_frames = 50;

        /// 播放缓冲最小值

        public static readonly int min_dis_frames = 6;

        #region locate by

        /// 帧号

        public static readonly int by_framenum = 1;

        /// 时间

        public static readonly int by_frametime = 2;

        #region display type

        /// 正常分辨率数据送显卡显示。

        public static readonly int display_normal = 1;

        /// 1/4分辨率数据送显卡显示。

        public static readonly int display_quarter = 2;

        #region timer type

        /// 一个进程中只能使用16个,定时比较准,画面流畅。

        /// only 16 timers for every process.default timer;

        public static readonly int timer_1 = 1;

        /// 使用数目没有限制,定时没有timer_1准。

        /// not limit;but the precision less than timer_1; 

        public static readonly int timer_2 = 2;

        #region buffer type

        /// 视频数据源缓冲区,缓冲解码之前视频数据,只对流模式有效,单位byte。

        public static readonly ushort buf_video_src = 1;

        /// 音频数据源缓冲区,缓冲解码之前音频数据,只对流模式有效, 单位byte。 

        public static readonly ushort buf_audio_src = 2;

        /// 解码后视频数据缓冲区,单位帧数。 

        public static readonly ushort buf_video_render = 3;

        /// 解码后音频数据缓冲区,单位帧数,音频40ms数据定为一帧。 

        public static readonly ushort buf_audio_render = 4;

        #region hikplayer

        /// 1、 bool playm4_initddraw(hwnd hwnd);

        /// 初始化directdraw表面。在使用vb,delphi开发时请注意,它们生成的对话框具有ws_clipchildren

        /// 窗口风格,必须去掉这种风格,否则显示画面会被对话框上的控件覆盖。注意:1.1版以上不需要调用。

        /// <param name="hwnd">hwnd 应用程序主窗口的句柄。</param>

        /// <returns></returns>

        [dllimport("playctrl.dll")]

        public static extern bool playm4_initddraw(intptr hwnd);

        /// 2、 bool playm4_realeseddraw(); 

        /// 释放directdraw表面;注意:1.1版以上不需要调用。

        public static extern bool playm4_realeseddraw();

        /// 3、 bool playm4_openfile(long nport,lpstr sfilename); 

        /// 打开播放文件

        /// <param name="nport"></param>

        /// <param name="sfilename">文件名,文件不能超过4g或小于4k</param>

        public static extern bool playm4_openfile(int nport, string sfilename);

        /// 4、 bool playm4_closefile(long nport); 

        /// 关闭播放文件

        public static extern bool playm4_closefile(int nport);

        /// 5、 bool playm4_play(long nport, hwnd hwnd); 

        /// 播放开始,播放视频画面大小将根据hwnd窗口调整,要全屏显示,只要把hwnd窗口放大到全屏。

        /// 如果已经播放,只是改变当前播放速度为正常速度。 

        /// <param name="hwnd">hwnd 播放视频的窗口句柄</param>

        public static extern bool playm4_play(int nport, intptr hwnd);

        /// 6、 bool playm4_stop(long nport); 

        /// 播放结束

        public static extern bool playm4_stop(int nport);

        /// 7、 bool playm4_pause(long nport,dword npause); 

        /// 播放暂停/恢复

        /// <param name="npause">npause=true暂停,否则恢复</param>

        public static extern bool playm4_pause(int nport, bool npause);

        /// 8、 bool playm4_fast(long nport); 

        /// 快速播放,每次调用将使当前播放速度加快一倍,最多调用4次;要恢复正常播放调用playm4_play(),

        /// 从当前位置开始正常播放

        public static extern bool playm4_fast(int nport);

        /// 9、 bool playm4_slow(long nport); 

        /// 慢速播放,每次调用将使当前播放速度慢一倍;最多调用4次;要恢复正常播放调用playm4_play()

        public static extern bool playm4_slow(int nport);

        /// 10、bool playm4_setplaypos(long nport,float frelativepos); 

        /// 设置文件播放指针的相对位置(百分比)。 

        /// <param name="frelativepos">范围0-100%</param>

        public static extern bool playm4_setplaypos(int nport, float frelativepos);

视频监控 封装[PlayCtrl.dll]的API

结束语

  最近学习c++,所积累的还没达到可以写文章的水平,所以近段时间的文章会比较少。 

转载:http://www.cnblogs.com/over140/archive/2010/03/12/1683973.html

继续阅读