///
/// 单个通道的录像
///
///
///
private void tsButtonRecord_Click(object sender, EventArgs e)
{
UInt32 ulRet = 0;
//检查用户登录状态
if(null == m_player.m_mainForm)
{
MessageBox.Show("请先登录!");
return;
}
//当前选中的用户控制面板
selectedSubCtrl = m_player.m_mainForm.g_userCtrlList[m_player.m_mainForm.tabControl1.SelectedIndex];
//当前选中的播放通道
PlayerPanel selectedPanel = selectedSubCtrl.imosPlayer.m_playerUnit[PlayerPanel.SelectedIndex];
if (false == m_bIsRecord)//未处于录像过程中
{
if (null != LocalConfig.vodDownloadLoc)//设置录像的保存位置
{
ConfigClass.OptionSetting.RecordPath = LocalConfig.vodDownloadLoc;
}
if(null != selectedPanel.channelCode)
{
//开始录像
ulRet = IMOSSDK.IMOS_StartRecord(ref selectedSubCtrl.sdkManager.stLoginInfo.stUserLoginIDInfo,//用户登录信息
Encoding.Default.GetBytes(selectedPanel.channelCode),//播放通道号
Encoding.Default.GetBytes(ConfigClass.OptionSetting.RecordPath),//录像文件存放路径
0);//录像文件的格式
}
if (0 != ulRet)
{
log.Info("本地录像失败,错误码为:" + ulRet.ToString());
MessageBox.Show("本地录像失败,错误码为:" + ulRet.ToString());
}
else
{
m_bIsRecord = true;
tsButtonRecord.ToolTipText = "停止录像";
}
}
else
{
if(null != selectedPanel.channelCode)//当前播放通道不为空
{
//停止录像
ulRet = IMOSSDK.IMOS_StopRecord(ref selectedSubCtrl.sdkManager.stLoginInfo.stUserLoginIDInfo,//用户标识信息
Encoding.Default.GetBytes(selectedPanel.channelCode));//播放通道编码
}
if (0 != ulRet)
{
log.Info("停止本地录像失败,错误码为:" + ulRet.ToString());
MessageBox.Show("停止本地录像失败,错误码为:" + ulRet.ToString());
}
else
{
m_bIsRecord = false;
tsButtonRecord.ToolTipText = "开始录像";
MessageBox.Show("本地录像保存成功!录像保存在" + ConfigClass.OptionSetting.RecordPath);
}
}
}
调用sdk中的方法
///
/// 开始录像,录像文件名由播放器生成
///
/// 用户标识
/// 播放通道号
/// 文件存放路径(不包含文件名,且路径不带斜杠)
/// 录像文件的格式
///
[DllImport("xp_frame.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 IMOS_StartRecord(ref USER_LOGIN_ID_INFO_S stUserLoginInfo, byte[] szChannelCode, byte[] szFileName, UInt32 ulFileFormat);
///
/// 开始录像,录像文件名由用户指定
///
/// 用户标识
/// 播放通道编码
/// 要保存的录像文件名(不带扩展名)
/// 录像文件的格式
/// 存放录像文件后缀的指针
///
[DllImport("xp_frame.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 IMOS_StartRecordEx(ref USER_LOGIN_ID_INFO_S stUserLoginInfo, byte[] szChannelCode, byte[] szFileName, UInt32 ulFileFormat, IntPtr ptrFilePostfix);
///
/// 停止录象
///
/// 用户标识
/// 播放通道号
///
[DllImport("xp_frame.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 IMOS_StopRecord(ref USER_LOGIN_ID_INFO_S stUserLoginInfo, byte[] szChannelCode);