| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3862 人关注过本帖
标题:“类型的条件表达式是非法的”这样的错误怎么解决,求高手解
只看楼主 加入收藏
as0601
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2013-3-31
结帖率:100%
收藏
已结贴  问题点数:10 回复次数:8 
“类型的条件表达式是非法的”这样的错误怎么解决,求高手解
程序运行到下面这段代码的时候,
void CRemotePlaybackDlg::OnDestroy()
{
     
    vector<H264_DVR_FILE_DATA*>::iterator p=m_pstrFileVector.begin();
     if ( p )
     {
         H264_DVR_FILE_DATA* pData = (*p);
         delete pData;
         pData = NULL;
     }
     
    ClearResult();
     ClearMapResult();
     KillTimer(1);
     CDialog::OnDestroy();
 }
系统提示“if (p)”这里出现提示“类型的条件表达式是非法的”这样的错误,如下:
error C2451: “std::_Vector_iterator<_Ty,_Alloc>
with
1>        [
1>            _Ty=H264_DVR_FILE_DATA *,
1>            _Alloc=std::allocator<H264_DVR_FILE_DATA *>
1>        ]
1>        没有可用于执行该转换的用户定义的转换运算符,或者无法调用该运算符
求高手来帮忙解答一下
搜索更多相关主题的帖子: 表达式 
2013-04-04 16:58
邓士林
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:淮河河畔
等 级:贵宾
威 望:61
帖 子:2392
专家分:13384
注 册:2013-3-3
收藏
得分:2 
能把源码拷贝上去 么?这样确实看不到头绪,

Maybe
2013-04-04 21:22
as0601
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2013-3-31
收藏
得分:0 
// RemotePlaybackDlg.cpp : implementation file
//

#include "stdafx.h"
#include "ClientDemo.h"
#include "RemotePlaybackDlg.h"
#include "ClientDemoDlg.h"
#include <vector>
#include <IO.H>

#ifdef _DEBUG
//#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif


int CRemotePlaybackDlg::s_sSlowType = 0;
int CRemotePlaybackDlg::s_sFastType = 0;

/////////////////////////////////////////////////////////////////////////////
// CRemotePlaybackDlg dialog
//SDK download position callback
void __stdcall CRemotePlaybackDlg::SDKDownLoadPosCallback ( long lPlayHandle,
                                                           long lTotalSize,
                                                           long lDownLoadSize,
                                                           long dwUser)
{   
    CRemotePlaybackDlg * pDeviceChannel = (CRemotePlaybackDlg*)dwUser;
   
    if ( NULL== pDeviceChannel)
    {
        ASSERT(FALSE);
        
        return;
    }
   
    if ( 0xffffffff == lDownLoadSize )
    {
        // data callback finished
        //    pDeviceChannel->SetPlayPos(1);
    }
}

int __stdcall
CRemotePlaybackDlg::NetDataCallBack( long lRealHandle, long dwDataType, unsigned char *pBuffer,long lbufsize,long dwUser)
{   
    BOOL bResult = TRUE;
    try
    {
        CRemotePlaybackDlg *pDataChnl = (CRemotePlaybackDlg*)dwUser;
        
        if ( 0 == dwDataType )
        {
            if ( pDataChnl->m_nPlaybackDecHandle >= 0 )
            {
                return H264_PLAY_InputData( pDataChnl->m_nPlaybackDecHandle ,pBuffer, lbufsize );
            }   
        }
    }
    catch (...)
    {
        TRACE("\n the input data to decoder is abnormal\n");
    }
   
    // it must return TRUE if decode successfully,or the SDK will consider the decode is failed
    return bResult;
   
}

int __stdcall
CRemotePlaybackDlg::NetDataCallBack_V2(long lRealHandle, const PACKET_INFO_EX *pFrame, unsigned int dwUser)
{   
    BOOL bResult = TRUE;
    try
    {
        CRemotePlaybackDlg *pDataChnl = (CRemotePlaybackDlg*)dwUser;
        if ( pDataChnl->m_nPlaybackDecHandle >= 0 )
        {
            bResult = H264_PLAY_InputData( pDataChnl->m_nPlaybackDecHandle , (unsigned char*)pFrame->pPacketBuffer, pFrame->dwPacketSize);
            if (bResult)
            {
#if 0
                TRACE("timestamp: %d, year: %d, nMonth: %d, nDay: %d, nHour: %d, nMinute: %d, nSecond: %d\n",
                    pFrame->dwTimeStamp, pFrame->nYear, pFrame->nMonth,
                    pFrame->nDay, pFrame->nHour, pFrame->nMinute, pFrame->nSecond);
               
                if (pFrame->nPacketType == AUDIO_PACKET)
                {
                    fwrite(pFrame->pPacketBuffer, pFrame->dwPacketSize, 1, fp);
                    fclose(fp);
                }
            }
            else
            {
                char filename[256];
                static int index = 0;
                static int iFrame = 0;
               
                FILE *fp = NULL;
                if (pFrame->nPacketType == VIDEO_I_FRAME)
                {
                    sprintf(filename, "stream/stream_%02d.idx", index++);
                    fp = fopen(filename, "ab+");
                    if (fp)
                    {
                        fwrite(pFrame->pPacketBuffer, pFrame->dwPacketSize, 1, fp);
                        fclose(fp);
                    }
                    char filename[256];
                    static int index = 0;
                    
                    sprintf(filename, "stream/Audio%02d.idx", index++);
                    fp = fopen(filename, "ab+");
                    if (fp)
                    {
                        fwrite(pFrame->pPacketBuffer, pFrame->dwPacketSize, 1, fp);
                        fclose(fp);
                    }
                }
                else
                {
                    char filename[256];
                    static int index = 0;
                    static int iFrame = 0;
                    
                    FILE *fp = NULL;
                    if (pFrame->nPacketType == VIDEO_I_FRAME)
                    {
                        sprintf(filename, "stream/stream_%02d.idx", index++);
                        fp = fopen(filename, "ab+");
                        if (fp)
                        {
                            fwrite(pFrame->pPacketBuffer, pFrame->dwPacketSize, 1, fp);
                            fclose(fp);
                        }
                        iFrame = 1;
                    }
                    
                    if (iFrame == 1)
                    {
                        fp = fopen("stream/StreamTotal.h264", "ab+");
                        if (fp)
                        {
                            fwrite(pFrame->pPacketBuffer, pFrame->dwPacketSize, 1, fp);
                            fclose(fp);
                        }
                    }
                }
#endif
            }
            return bResult;
        }   
    }
    catch (...)
    {
        TRACE("\n the input data to decoder is abnormal\n");
    }
   
    // it must return TRUE if decode successfully,or the SDK will consider the decode is failed
    return bResult;
   
}

CRemotePlaybackDlg::CRemotePlaybackDlg(CWnd* pParent /*=NULL*/)
: CDialog(CRemotePlaybackDlg::IDD, pParent)
{
    //{{AFX_DATA_INIT(CRemotePlaybackDlg)
    m_endData = 0;
    m_begData = 0;
    m_begTime = 0;
    m_endTime = 0;
    m_bDownloadByTime = FALSE;
    m_bDownloadByName = TRUE;
    //}}AFX_DATA_INIT
   
    m_nPlaybackDecHandle = -1;
    m_lSaveHandle = -1;
    m_nPlayHandle = -1;
    m_lFileHandle = -1;
    m_hFileThread = NULL;
    m_bPause = FALSE;
    m_nCurRecNum=0;   
    m_mapNum=0;
   
}


void CRemotePlaybackDlg::DoDataExchange(CDataExchange* pDX)
{
    CDialog::DoDataExchange(pDX);
    //{{AFX_DATA_MAP(CRemotePlaybackDlg)
    DDX_Control(pDX, IDC_LIST1, m_fileList);
    DDX_Control(pDX, IDC_STATIC_VIDEO, m_videoWnd);
    DDX_Control(pDX, IDC_PROGRESS1, m_progress);
    DDX_Control(pDX, IDC_COMBO_TYPE, m_cmbType);
    DDX_Control(pDX, IDC_COMBO_CHANNEL, m_cmbChannel);
    DDX_Control(pDX, IDC_COMBO_DEVICE, m_cmbDevice);
    DDX_DateTimeCtrl(pDX, IDC_DATE_END, m_endData);
    DDX_DateTimeCtrl(pDX, IDC_DATE_BEGIN, m_begData);
    DDX_DateTimeCtrl(pDX, IDC_TIME_BEGIN, m_begTime);
    DDX_DateTimeCtrl(pDX, IDC_TIME_END, m_endTime);
    DDX_Check(pDX, IDC_CHECK_TIME, m_bDownloadByTime);
    DDX_Check(pDX, IDC_CHECK_NAME, m_bDownloadByName);
    //}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CRemotePlaybackDlg, CDialog)
//{{AFX_MSG_MAP(CRemotePlaybackDlg)
ON_CBN_SELCHANGE(IDC_COMBO_DEVICE, OnSelchangeComboDevice)
ON_BN_CLICKED(IDC_SEARCH, OnSearch)
ON_BN_CLICKED(IDC_DOWNLOAD, OnDownload)
ON_BN_CLICKED(IDC_PLAY, OnPlay)
ON_BN_CLICKED(IDC_STOP, OnStop)
ON_BN_CLICKED(IDC_FAST, OnFast)
ON_BN_CLICKED(IDC_SLOW, OnSlow)
ON_BN_CLICKED(IDC_PAUSE, OnPause)
ON_WM_DESTROY()
ON_WM_TIMER()
ON_BN_CLICKED(IDC_CHECK_NAME, OnCheckDownLoadByName)
ON_BN_CLICKED(IDC_CHECK_TIME, OnCheckDownLoadByTime)
ON_BN_CLICKED(IDC_PAGE_UP, OnPageUp)
ON_BN_CLICKED(IDC_PAGE_DOWN, OnPageDown)
ON_NOTIFY(NM_DBLCLK, IDC_LIST1, OnDblclkList1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CRemotePlaybackDlg message handlers

BOOL CRemotePlaybackDlg::OnInitDialog()
{
    CDialog::OnInitDialog();
   
    _CWndCS(this);
   
    m_fileList.SetExtendedStyle( m_fileList.GetExtendedStyle() | LVS_EX_FULLROWSELECT);
   
    int nIndex = m_cmbDevice.AddString(_CS("PlayBack.SelectDevice"));
    m_cmbDevice.SetItemData(nIndex, 1);
   
    //get device info
    CClientDemoDlg *pMain = (CClientDemoDlg *)AfxGetApp()->m_pMainWnd;
    if ( pMain )
    {
        Devc_Map *pMap = pMain->GetDeviceMap();
        if ( pMap )
        {
            Devc_Map::iterator bIter;
            for ( bIter = pMap->begin(); bIter != pMap->end(); bIter ++ )
            {
                DEV_INFO *pDev = bIter->second;
                if ( pDev )
                {
                    nIndex = m_cmbDevice.AddString(pDev->szDevName);
                    m_cmbDevice.SetItemData(nIndex, (DWORD)pDev );
                }
            }
        }
    }   
    if (m_cmbDevice.GetCount() > 1)
    {
        m_cmbDevice.SetCurSel(1);
    }
    else
    {
        m_cmbDevice.SetCurSel(0);
    }
    OnSelchangeComboDevice();
   
    m_cmbType.AddString(_CS("PlayBack.ALL"));
    m_cmbType.AddString(_CS("PlayBack.AlarmRecordFile"));
    m_cmbType.AddString(_CS("PlayBack.DetectRecordfile"));
    m_cmbType.AddString(_CS("PlayBack.GeneralRecordFile"));
    m_cmbType.AddString(_CS("PlayBack.HandRecordFile"));
    m_cmbType.SetCurSel(0);
   
    CTime cur_time = CTime::GetCurrentTime();
    CTime time = CTime(cur_time.GetYear(),cur_time.GetMonth(), cur_time.GetDay(),
        cur_time.GetHour(),cur_time.GetMinute(),cur_time.GetSecond());
   
    m_begData = m_endData = m_endTime = time;
   
    CTime bTime = CTime( cur_time.GetYear(),cur_time.GetMonth(), cur_time.GetDay(), 0 , 0 , 0 );
    m_begTime = bTime;
   
    UpdateData( FALSE );
   
    m_fileList.InsertColumn(0, _CS("PlayBack.NO"),  LVCFMT_LEFT, 80,-1 );
    m_fileList.InsertColumn(1, _CS("PlayBack.File"), LVCFMT_LEFT,200,-1);
   
    m_progress.SetRange(0,100);
   
   
    m_nGetPage=0;
    m_nCurPage=-1;
    m_nTotalPage=-1;
   
    return TRUE;  // return TRUE unless you set the focus to a control
    // EXCEPTION: OCX Property Pages should return FALSE
}

void CRemotePlaybackDlg::OnSelchangeComboDevice()
{
    int nSelectedIndex = m_cmbDevice.GetCurSel();
    if ( nSelectedIndex <= 0 )
    {
        return;
    }
   
    DEV_INFO *pDev = (DEV_INFO *)m_cmbDevice.GetItemData(nSelectedIndex);
    if ( pDev )
    {
        m_cmbChannel.ResetContent();
        
        CString strChannel("");
        for ( int i = 0; i < pDev->nTotalChannel; i ++ )
        {
            strChannel.Format("%d", i + 1);
            m_cmbChannel.AddString(strChannel);
        }
        m_lLoginID = pDev->lLoginID;
    }
    m_cmbChannel.SetCurSel(0);
}

void CRemotePlaybackDlg::OnSearch()
{
    m_nGetPage=0;
    m_nCurPage=-1;
    m_nTotalPage=-1;
   
    UpdateData();
   
    OnStop();  //查询之前先关闭所有的播放

    int nSelectedIndex = m_cmbDevice.GetCurSel();
    if ( nSelectedIndex <= 0)
    {
        MessageBox(_CS("PlayBack.SelectDevice"));
        return;
    }
   
    ClearResult();
   
    ClearMapResult();
   
    int nChannel = m_cmbChannel.GetCurSel();    //channel No.
    int nFileType = m_cmbType.GetCurSel();        //file type
   
    H264_DVR_TIME StartTime;
    H264_DVR_TIME StopTime;
   
    StartTime.dwYear = (WORD)m_begData.GetYear();
    StartTime.dwMonth = (WORD)m_begData.GetMonth();
    StartTime.dwDay = (WORD)m_begData.GetDay();
    StartTime.dwHour = (char)m_begTime.GetHour();
    StartTime.dwMinute = (char)m_begTime.GetMinute();
    StartTime.dwSecond = (char)m_begTime.GetSecond();
    StopTime.dwYear = (WORD)m_endData.GetYear();
    StopTime.dwMonth = (WORD)m_endData.GetMonth();
    StopTime.dwDay = (WORD)m_endData.GetDay();
    StopTime.dwHour = (char)m_endTime.GetHour();
    StopTime.dwMinute = (char)m_endTime.GetMinute();
    StopTime.dwSecond = (char)m_endTime.GetSecond();
   
    DEV_INFO *pDevTemp=(DEV_INFO*)m_cmbDevice.GetItemData(nSelectedIndex);
   
    H264_DVR_FILE_DATA *szSend=new H264_DVR_FILE_DATA[100];
   
   
    if (pDevTemp)
    {
        m_lLoginID=pDevTemp->lLoginID;
        
        int nMaxLen = 100 * sizeof(H264_DVR_FILE_DATA);
        
        const int WAITTIME = 4000;   //waitting time
        int nNum = 0; //number of files return
        
        H264_DVR_FINDINFO searchInfo;
        searchInfo.nChannelN0 = nChannel;
        searchInfo.nFileType = nFileType;
        memcpy( &searchInfo.startTime, &StartTime, sizeof(searchInfo.startTime));
        memcpy( &searchInfo.endTime, &StopTime, sizeof(searchInfo.endTime));
        
        GetDlgItem(IDC_SEARCH)->EnableWindow(FALSE);
        
        int nRet=H264_DVR_FindFile(m_lLoginID,&searchInfo,szSend,100,&nNum);
        
        m_nCurRecNum=nNum;
        
        memcpy(&m_mapTemp[m_mapNum++],&searchInfo,sizeof(H264_DVR_FINDINFO));
        
        if ( nRet > 0 && nNum > 0)  //处理没有录象的情况下
        {
            m_nGetPage ++;
            m_nCurPage = 1;
            
            m_pstrFileVector.reserve(m_nCurRecNum);
            
            for(int i=0;i<m_nCurRecNum;i++)
            {
                m_pstrFileVector.push_back(szSend+i);
            }
            
            m_nSearchInfo.nChannelN0=nChannel;
            m_nSearchInfo.nFileType=nFileType;
            m_nSearchInfo.startTime.dwYear=szSend[m_nCurRecNum-1].stEndTime.year;
            m_nSearchInfo.startTime.dwMonth=szSend[m_nCurRecNum-1].stEndTime.month;
            m_nSearchInfo.startTime.dwDay=szSend[m_nCurRecNum-1].stEndTime.day;
            m_nSearchInfo.startTime.dwHour=szSend[m_nCurRecNum-1].stEndTime.hour;
            m_nSearchInfo.startTime.dwMinute=szSend[m_nCurRecNum-1].stEndTime.minute;
            m_nSearchInfo.startTime.dwSecond=szSend[m_nCurRecNum-1].stEndTime.second;
            memcpy(&m_nSearchInfo.endTime,&searchInfo.endTime,sizeof(m_nSearchInfo.endTime));
            
            if(nNum<PLAYBACK_MAX_FILE_NUM)
            {
                m_nTotalPage=m_nGetPage;
            }
            
            AddFileListInfo(m_nCurRecNum);//add list item
            SetPageBtnState();
        }else
        {
            if (szSend)
            {
                delete szSend;
                szSend = NULL;
            }
            MessageBox(_CS("PlayBack.SearchFail"));
        }
        GetDlgItem(IDC_SEARCH)->EnableWindow(TRUE);
    }
}

void CRemotePlaybackDlg::OnDownload()
{
    UpdateData();
   
    int nSelectedIndex = m_cmbDevice.GetCurSel();
    if ( nSelectedIndex <= 0 )
    {
        MessageBox(_CS("PlayBack.SelectDevice"));
        return;
    }
   
    if (m_bDownloadByTime)
    {
        OnDownloadByTime();
    }
    else
    {
        OnDownloadByName();
    }
}

void CRemotePlaybackDlg::OnDownloadByName()
{
    UpdateData(TRUE);
   
    if ( m_lSaveHandle > 0 )
    {
        KillTimer(1);
        H264_DVR_StopGetFile(m_lSaveHandle);
        m_lSaveHandle = -1;
        m_progress.SetPos(0);
        
        GetDlgItem(IDC_DOWNLOAD)->SetWindowText(_CS("PlayBack.Download"));
        
        return;
    }
   
    CString csFileName;
   
    int nSelectedIndex = m_fileList.GetSelectionMark();
    if ( nSelectedIndex < 0 )
    {
        MessageBox(_CS("PlayBack.SelectFile"));
        return;
    }
   
    H264_DVR_FILE_DATA *pstrFileInfo = (H264_DVR_FILE_DATA *)m_fileList.GetItemData(nSelectedIndex);
    if (  !pstrFileInfo )
    {
        return;
    }
   
    CString strSaveName("");
    //strSaveName.Format("c:\\record\\record.h264");
    nSelectedIndex = m_cmbDevice.GetCurSel();
    if ( nSelectedIndex <= 0)
    {
        MessageBox(_CS("PlayBack.SelectDevice"));
        return;
    }
    DEV_INFO *pDevTemp=(DEV_INFO*)m_cmbDevice.GetItemData(nSelectedIndex);
   
    CString strInitDir;
   
    strInitDir = GET_MODULE_FILE_INFO.strPath;
    if (strInitDir.Right(1) == '\\')
    {
        strInitDir += "Download";
    }
    else
    {
        strInitDir += "\\Download";
    }   
    if (-1 == _access(strInitDir, 0))
    {
        CreateDirectory(strInitDir, NULL);
    }
   
    CString strFileTpye("h264");
    CString strFileName("");
    if (strstr(pstrFileInfo->sFileName, ".h264"))
    {
        strFileTpye = _T("h264");
    }
    else
    {
        strFileTpye = _T("jpg");
    }
    strFileName.Format("%s_%02d_%04d%02d%02d_%02d%02d%02d.%s",
        pDevTemp->szDevName, pstrFileInfo->ch + 1,
        pstrFileInfo->stBeginTime.year, pstrFileInfo->stBeginTime.month,
        pstrFileInfo->stBeginTime.day, pstrFileInfo->stBeginTime.hour,
        pstrFileInfo->stBeginTime.minute, pstrFileInfo->stBeginTime.second, strFileTpye);
   
    CFileDialog dlg( FALSE , strFileTpye, strFileName , OFN_OVERWRITEPROMPT|OFN_HIDEREADONLY,
        "All File(*.h264;*.jpg)|*.*||" , this );
    dlg.m_ofn.lpstrInitialDir = strInitDir;        //默认路径
    if( dlg.DoModal() == IDOK )
    {
        strSaveName = dlg.GetPathName();
        //m_lSaveHandle = H264_DVR_GetFileByName(m_lLoginID, pstrFileInfo,strSaveName.GetBuffer(0),SDKDownLoadPosCallback,(DWORD)this);
        m_lSaveHandle = H264_DVR_GetFileByName(m_lLoginID, pstrFileInfo,strSaveName.GetBuffer(0));
        if(m_lSaveHandle >= 0)
        {
            m_progress.SetPos(0);
            GetDlgItem(IDC_DOWNLOAD)->SetWindowText(_CS("PlayBack.Stop"));
            //update the progress control
            SetTimer(1,0,NULL);
        }
        else
        {
        CString sTemp;
        sTemp.Format("dowload fail ERROR = %d",H264_DVR_GetLastError());
        AfxMessageBox(sTemp);
        }
    }
}

void CRemotePlaybackDlg::OnDownloadByTime()
{
    UpdateData(TRUE);
   
    if ( m_lSaveHandle > 0 )
    {
        KillTimer(1);
        H264_DVR_StopGetFile(m_lSaveHandle);
        m_lSaveHandle = -1;
        m_progress.SetPos(0);
        
        GetDlgItem(IDC_DOWNLOAD)->SetWindowText(_CS("PlayBack.Download"));
        
        return;
    }
   
    CString strSaveName("");
    //strSaveName.Format("c:\\record");
    strSaveName = BrowseForFolder(GetSafeHwnd()) ;
   
    if ( strSaveName == _T(""))  //未选择路径时退出
    {
        return;
    }
    H264_DVR_FINDINFO info;
   
    memset(&info, 0, sizeof(info));
    info.nChannelN0 = m_cmbChannel.GetCurSel();    //channel No.
    info.nFileType = m_cmbType.GetCurSel();        //file type
    info.startTime.dwYear = (WORD)m_begData.GetYear();
    info.startTime.dwMonth = (WORD)m_begData.GetMonth();
    info.startTime.dwDay = (WORD)m_begData.GetDay();
    info.startTime.dwHour = (char)m_begTime.GetHour();
    info.startTime.dwMinute = (char)m_begTime.GetMinute();
    info.startTime.dwSecond = (char)m_begTime.GetSecond();
    info.endTime.dwYear = (WORD)m_endData.GetYear();
    info.endTime.dwMonth = (WORD)m_endData.GetMonth();
    info.endTime.dwDay = (WORD)m_endData.GetDay();
    info.endTime.dwHour = (char)m_endTime.GetHour();
    info.endTime.dwMinute = (char)m_endTime.GetMinute();
    info.endTime.dwSecond = (char)m_endTime.GetSecond();
    int nRecordFileType = m_cmbType.GetCurSel();
    info.nFileType = (nRecordFileType <= SDK_RECORD_MANUAL) ?  nRecordFileType : (SDK_PIC_ALL + nRecordFileType - SDK_RECORD_MANUAL - 1);
   
    m_lSaveHandle = H264_DVR_GetFileByTime(m_lLoginID, &info, strSaveName.GetBuffer(0));
    if(m_lSaveHandle > 0)
    {
        m_progress.SetPos(0);
        
        GetDlgItem(IDC_DOWNLOAD)->SetWindowText(_CS("PlayBack.Stop"));
        
        //update the progress control
        SetTimer(1,0,NULL);
    }
    else
    {
        CString sTemp;
        sTemp.Format("dowload fail ERROR = %d",H264_DVR_GetLastError());
        AfxMessageBox(sTemp);
    }
}

void CRemotePlaybackDlg::OnPlay()
{
    UpdateData();
   
    int nSelectedIndex = m_cmbDevice.GetCurSel();
    if ( nSelectedIndex <= 0 )
    {
        MessageBox(_CS("PlayBack.SelectDevice"));
        return;
    }
   
    if (m_bDownloadByTime)
    {
        OnPlayByTime();
    }
    else
    {
        OnPlayByName();
    }
}

void CRemotePlaybackDlg::OnPlayByTime()
{
    if(m_nPlayHandle == -1)
    {
        H264_DVR_FINDINFO info;
        
        memset(&info, 0, sizeof(info));
        info.nChannelN0 = m_cmbChannel.GetCurSel();    //channel No.
        info.nFileType = m_cmbType.GetCurSel();        //file type
        info.startTime.dwYear = (WORD)m_begData.GetYear();
        info.startTime.dwMonth = (WORD)m_begData.GetMonth();
        info.startTime.dwDay = (WORD)m_begData.GetDay();
        
        info.startTime.dwHour = (char)m_begTime.GetHour();
        info.startTime.dwMinute = (char)m_begTime.GetMinute();
        info.startTime.dwSecond = (char)m_begTime.GetSecond();
        info.endTime.dwYear = (WORD)m_endData.GetYear();
        info.endTime.dwMonth = (WORD)m_endData.GetMonth();
        info.endTime.dwDay = (WORD)m_endData.GetDay();
        info.endTime.dwHour = (char)m_endTime.GetHour();
        info.endTime.dwMinute = (char)m_endTime.GetMinute();
        info.endTime.dwSecond = (char)m_endTime.GetSecond();
        
        //open decode channel
        if ( m_nPlaybackDecHandle == -1 )
        {
            BYTE byFileHeadBuf;
            if (H264_PLAY_OpenStream(40, &byFileHeadBuf, 1, SOURCE_BUF_MIN*50))
            {   
                H264_PLAY_SetStreamOpenMode(40, STREAME_FILE);   
                H264_PLAY_Play(40, m_videoWnd.m_hWnd);
               
                m_nPlaybackDecHandle = 40;
            }   
        }
        if ( m_nPlaybackDecHandle < 0 )
        {
            return;
        }
        
        //         m_nPlayHandle = H264_DVR_PlayBackByTimeEx(m_lLoginID, info.nChannelN0,
        //             &info.startTime, &info.endTime,
        //             NetDataCallBack, (DWORD)this, SDKDownLoadPosCallback, (DWORD)this);
        m_nPlayHandle = H264_DVR_PlayBackByTime(m_lLoginID, &info,
            SDKDownLoadPosCallback, NetDataCallBack, (DWORD)this);
        
        if(m_nPlayHandle <= 0 )
        {
            AfxMessageBox(_CS("Playback fail"));
            m_nPlayHandle = -1;
            return;
        }
    }
    else
    {
        //if in pause, normal it
        if (m_bPause)
        {
            H264_DVR_PlayBackControl(m_nPlayHandle, SDK_PLAY_BACK_CONTINUE, 0 );
            H264_PLAY_Pause(m_nPlaybackDecHandle, !m_bPause);
            m_bPause = !m_bPause;
        }
        //set play speed to normal
        H264_DVR_PlayBackControl(m_nPlayHandle, SDK_PLAY_BACK_FAST, 0);
        //set decode speed to normal
        H264_PLAY_Play(m_nPlaybackDecHandle, m_videoWnd.m_hWnd);
        s_sFastType = 0;
        s_sSlowType = 0;
    }
}
2013-04-04 21:43
as0601
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2013-3-31
收藏
得分:0 
void CRemotePlaybackDlg::OnPlayByName()
{
    if(m_nPlayHandle == -1)
    {
        CString csFileName;
        
        int nSelectedIndex = m_fileList.GetSelectionMark();
        if ( nSelectedIndex < 0 )
        {
            MessageBox(_CS("PlayBack.SelectFile"));
            return;
        }
        
        H264_DVR_FILE_DATA *pstrFileInfo = (H264_DVR_FILE_DATA *)m_fileList.GetItemData(nSelectedIndex);
        if (  !pstrFileInfo )
        {
            return;
        }
        
        //open decode channel
        if ( m_nPlaybackDecHandle == -1 )
        {
            BYTE byFileHeadBuf;
            if (H264_PLAY_OpenStream(40, &byFileHeadBuf, 1, SOURCE_BUF_MIN*50))
            {   
                H264_PLAY_SetStreamOpenMode(40, STREAME_FILE);   
                H264_PLAY_Play(40, m_videoWnd.m_hWnd);
               
                m_nPlaybackDecHandle = 40;
            }   
        }
        if ( m_nPlaybackDecHandle < 0 )
        {
            return;
        }        
        //m_nPlayHandle = H264_DVR_PlayBackByName(m_lLoginID, pstrFileInfo, SDKDownLoadPosCallback, NetDataCallBack, (DWORD)this );
        m_nPlayHandle = H264_DVR_PlayBackByName_V2(m_lLoginID, pstrFileInfo, SDKDownLoadPosCallback, NetDataCallBack_V2, (DWORD)this );
        if(m_nPlayHandle <= 0 )
        {
            AfxMessageBox(_CS("Playback fail"));
            return;
        }
    }
    else
    {
        //if in pause, normal it
        if (m_bPause)
        {
            H264_DVR_PlayBackControl(m_nPlayHandle, SDK_PLAY_BACK_CONTINUE, 0 );
            H264_PLAY_Pause(m_nPlaybackDecHandle, !m_bPause);
            m_bPause = !m_bPause;
        }
        //set play speed to normal
        H264_DVR_PlayBackControl(m_nPlayHandle, SDK_PLAY_BACK_FAST, 0);
        //set decode speed to normal
        H264_PLAY_Play(m_nPlaybackDecHandle, m_videoWnd.m_hWnd);
        s_sFastType = 0;
        s_sSlowType = 0;
    }
}

void CRemotePlaybackDlg::OnStop()
{
    if(m_nPlayHandle >= 0)
    {
        H264_DVR_StopPlayBack(m_nPlayHandle);
        m_nPlayHandle = -1;
    }
    if ( m_nPlaybackDecHandle)
    {
        H264_PLAY_CloseStream(m_nPlaybackDecHandle);
        H264_PLAY_Stop(m_nPlaybackDecHandle);
        m_nPlaybackDecHandle = -1;
    }
    Invalidate();
}

void CRemotePlaybackDlg::OnFast()
{
    if (++s_sFastType > 4)
    {
        s_sFastType = 1;
    }
    s_sSlowType = 0;
    H264_DVR_PlayBackControl(m_nPlayHandle, SDK_PLAY_BACK_FAST, s_sFastType);
    H264_PLAY_Fast(m_nPlaybackDecHandle);
}

void CRemotePlaybackDlg::OnSlow()
{
    if (++s_sSlowType > 4)
    {
        s_sSlowType = 1;
    }
    s_sFastType = 0;
    H264_DVR_PlayBackControl(m_nPlayHandle, SDK_PLAY_BACK_SLOW, s_sSlowType);
    H264_PLAY_Slow(m_nPlaybackDecHandle);
}

void CRemotePlaybackDlg::OnPause()
{
    if (!m_bPause)
        H264_DVR_PlayBackControl(m_nPlayHandle, SDK_PLAY_BACK_PAUSE, 0 );
    else
        H264_DVR_PlayBackControl(m_nPlayHandle, SDK_PLAY_BACK_CONTINUE, 0 );
    H264_PLAY_Pause(m_nPlaybackDecHandle, !m_bPause);
    m_bPause = !m_bPause;
}

void CRemotePlaybackDlg::OnDestroy()
{
   
    vector<H264_DVR_FILE_DATA*>::iterator p=m_pstrFileVector.begin();
    if  ( p=m_pstrFileVector.end() )
    {
        H264_DVR_FILE_DATA* pData = *p;
        delete pData;
        pData = NULL;
    }
   
    ClearResult();
    ClearMapResult();
    KillTimer(1);
    CDialog::OnDestroy();
}

void CRemotePlaybackDlg::ClearResult()
{
    m_fileList.DeleteAllItems();
   
    int nTotal = m_cmbChannel.GetCount();
   
    for ( int i = 0; i < nTotal; i ++ )
    {
        DEV_INFO *pInfo = (DEV_INFO *)m_cmbChannel.GetItemData(i);
        if ( pInfo )
        {
            delete pInfo;
            pInfo = NULL;
        }
    }
    m_cmbChannel.Clear();
    m_pstrFileVector.clear();
}


void CRemotePlaybackDlg::OnTimer(UINT nIDEvent)
{
    if( m_lSaveHandle > 0 )
    {
        int nPos = H264_DVR_GetDownloadPos(m_lSaveHandle);
        if(nPos < 0)        //fail
        {
            H264_DVR_StopGetFile(m_lSaveHandle);
            m_progress.SetPos(0);
            m_lSaveHandle = -1;
            GetDlgItem(IDC_DOWNLOAD)->SetWindowText(_CS("PlayBack.Download"));
            AfxMessageBox("get download process fail");
        }
        if(nPos == 100)        //download end
        {
            H264_DVR_StopGetFile(m_lSaveHandle);
            m_lSaveHandle = -1;
            KillTimer(1);
            m_progress.SetPos(0);
            GetDlgItem(IDC_DOWNLOAD)->SetWindowText(_CS("PlayBack.Download"));
            AfxMessageBox(_CS("PlayBack.DownloadFinish"));
        }
        if(nPos > 100)        //abnormal
        {
            H264_DVR_StopGetFile(m_lSaveHandle);
            m_lSaveHandle = -1;
            m_progress.SetPos(0);
            GetDlgItem(IDC_DOWNLOAD)->SetWindowText(_CS("PlayBack.Download"));
            AfxMessageBox(_CS("PlayBack.DownloadError"));
        }
        else
        {
            m_progress.SetPos(nPos);
        }
    }
    //KillTimer(1);
    //UpdateProgressCtrl(m_dwDownSize,m_dwTotalSize);
    CDialog::OnTimer(nIDEvent);
}

void CRemotePlaybackDlg::OnCheckDownLoadByName()
{
    // TODO: Add your control notification handler code here
    UpdateData();
    if (m_bDownloadByName)
    {
        m_bDownloadByTime = FALSE;
    }
    UpdateData(FALSE);
}

void CRemotePlaybackDlg::OnCheckDownLoadByTime()
{
    // TODO: Add your control notification handler code here
    UpdateData();
    if (m_bDownloadByTime)
    {
        m_bDownloadByName = FALSE;
    }
    UpdateData(FALSE);
}

void CRemotePlaybackDlg::OnPageUp()
{
   
    // TODO: Add your control notification handler code here   
    if ( m_nGetPage <= 1 || m_nCurPage <= 1)
    {
        return;
    }
   
    m_nCurPage --;
    m_nGetPage --;
   
    ClearResult();
   
    m_mapNum=m_mapNum-1;
   
    if(GetNextPageInfo(&m_mapTemp[--m_mapNum]))
    {
        H264_DVR_FILE_DATA *szSend = new H264_DVR_FILE_DATA[100];
        
        int nNum=0;
        
        int nRet=H264_DVR_FindFile(m_lLoginID,&m_mapTemp[m_mapNum],szSend,100,&nNum);
        
        m_nCurRecNum=nNum;
        
        if(nRet > 0 && nNum > 0) //处理没有录象的情况
        {
            m_pstrFileVector.reserve(m_nCurRecNum);
            
            for ( int i = 0; i < m_nCurRecNum; i ++)
            {
                m_pstrFileVector.push_back(szSend+i);
            }
            m_nSearchInfo.nChannelN0=m_nSearchInfo.nChannelN0;
            m_nSearchInfo.nFileType=m_nSearchInfo.nFileType;
            m_nSearchInfo.startTime.dwYear=szSend[m_nCurRecNum-1].stEndTime.year;
            m_nSearchInfo.startTime.dwMonth=szSend[m_nCurRecNum-1].stEndTime.month;
            m_nSearchInfo.startTime.dwDay=szSend[m_nCurRecNum-1].stEndTime.day;
            m_nSearchInfo.startTime.dwHour=szSend[m_nCurRecNum-1].stEndTime.hour;
            m_nSearchInfo.startTime.dwMinute=szSend[m_nCurRecNum-1].stEndTime.minute;
            m_nSearchInfo.startTime.dwSecond=szSend[m_nCurRecNum-1].stEndTime.second;
            memcpy(&m_nSearchInfo.endTime,&m_mapTemp[m_mapNum].endTime,sizeof(m_nSearchInfo.endTime));
            
            m_mapNum++;
        }else
        {
            if (szSend)
            {
                delete szSend;
                szSend = NULL;
            }
        }
        AddFileListInfo(m_nCurRecNum);
        SetPageBtnState();
    }
}

void CRemotePlaybackDlg::OnPageDown()
{
   
    // TODO: Add your control notification handler code here
    if ( m_nGetPage <= 0 )
    {
        return;
    }
   
    if((m_nTotalPage!=-1)&&(m_nCurPage == m_nTotalPage))
    {
        SetPageBtnState();
        return;
    }
   
    ClearResult();
   
    if ( GetNextPageInfo(&m_nSearchInfo)&&(m_nCurPage == m_nGetPage))
    {
        H264_DVR_FILE_DATA *szSend = new H264_DVR_FILE_DATA[100];
        
        int nNum=0;
        
        int nRet=H264_DVR_FindFile(m_lLoginID,&m_nSearchInfo,szSend,100,&nNum);
        
        m_nCurRecNum=nNum;
        
        if (nRet> 0 && nNum > 0)  //处理没有录象的情况
        {
            m_nGetPage ++;
            
            memcpy(&m_mapTemp[m_mapNum++],&m_nSearchInfo,sizeof(H264_DVR_FINDINFO));
            
            m_pstrFileVector.reserve(m_nCurRecNum);
            
            for ( int i = 0; i < m_nCurRecNum; i ++ )
            {
                m_pstrFileVector.push_back(szSend+i);
            }
            
            m_nSearchInfo.nChannelN0=m_nSearchInfo.nChannelN0;
            m_nSearchInfo.nFileType=m_nSearchInfo.nFileType;
            m_nSearchInfo.startTime.dwYear=szSend[m_nCurRecNum-1].stEndTime.year;
            m_nSearchInfo.startTime.dwMonth=szSend[m_nCurRecNum-1].stEndTime.month;
            m_nSearchInfo.startTime.dwDay=szSend[m_nCurRecNum-1].stEndTime.day;
            m_nSearchInfo.startTime.dwHour=szSend[m_nCurRecNum-1].stEndTime.hour;
            m_nSearchInfo.startTime.dwMinute=szSend[m_nCurRecNum-1].stEndTime.minute;
            m_nSearchInfo.startTime.dwSecond=szSend[m_nCurRecNum-1].stEndTime.second;
            memcpy(&m_nSearchInfo.endTime,&m_nSearchInfo.endTime,sizeof(m_nSearchInfo.endTime));
            
            if ( m_nCurRecNum <PLAYBACK_MAX_FILE_NUM)
            {
                m_nTotalPage = m_nGetPage;
            }
            
            m_nCurPage ++;
            
            AddFileListInfo(m_nCurRecNum);
            
            SetPageBtnState();
        }
        else
        {
            if (szSend)
            {
                delete szSend;
                szSend = NULL;
            }
        }
    }
}
void CRemotePlaybackDlg::AddFileListInfo(int iNum)
{
    if ( m_bDownloadByTime )
    {
        iNum = 1;
        m_nCurPage=1;
        m_nTotalPage=1;
    }
   
    for ( int i = 0; i < iNum ; i++)
    {
        CString tempstring;
        tempstring.Format("%d", i + 1);
        m_fileList.InsertItem(i,tempstring);
        
        CString strBtme,strEtime;
        if ( m_bDownloadByTime )
        {
            strBtme.Format("%04d-%02d-%02d-%02d:%02d:%02d",m_begData.GetYear(),
                m_begData.GetMonth(),
                m_begData.GetDay(),
                m_begTime.GetHour(),
                m_begTime.GetMinute(),
                m_begTime.GetSecond());
            
            strEtime.Format("%04d-%02d-%02d-%02d:%02d:%02d",m_endData.GetYear(),
                m_endData.GetMonth(),
                m_endData.GetDay(),
                m_endTime.GetHour(),
                m_endTime.GetMinute(),
                m_endTime.GetSecond());
            
            tempstring.Format("%s-%s", strBtme, strEtime);
        }else
        {
            strBtme.Format("%04d-%02d-%02d-%02d:%02d:%02d",m_pstrFileVector[i]->stBeginTime.year,
                m_pstrFileVector[i]->stBeginTime.month,
                m_pstrFileVector[i]->stBeginTime.day,
                m_pstrFileVector[i]->stBeginTime.hour,
                m_pstrFileVector[i]->stBeginTime.minute,
                m_pstrFileVector[i]->stBeginTime.second);
            
            strEtime.Format("%04d-%02d-%02d-%02d:%02d:%02d",
                m_pstrFileVector[i]->stEndTime.year,
                m_pstrFileVector[i]->stEndTime.month,
                m_pstrFileVector[i]->stEndTime.day,
                m_pstrFileVector[i]->stEndTime.hour,
                m_pstrFileVector[i]->stEndTime.minute,
                m_pstrFileVector[i]->stEndTime.second);
            
            tempstring.Format("%s-%s(%dKB)", strBtme, strEtime, m_pstrFileVector[i]->size);
        }
        
        m_fileList.SetItemText(i, 1, tempstring);
        
        DWORD addr=(DWORD)(m_pstrFileVector[i]);
        
        m_fileList.SetItemData(i,addr);
    }
}

void CRemotePlaybackDlg::SetPageBtnState()
{
    if ( m_nTotalPage == -1 || m_nGetPage < m_nTotalPage)
    {
        GetDlgItem(IDC_PAGE_DOWN)->EnableWindow(TRUE);
    }
    else
    {
        if ( m_nCurPage < m_nGetPage )
        {
            GetDlgItem(IDC_PAGE_DOWN)->EnableWindow(TRUE);
        }
        else
        {
            GetDlgItem(IDC_PAGE_DOWN)->EnableWindow(FALSE);
        }
    }
   
    if ( m_nCurPage > 1 )
    {
        GetDlgItem(IDC_PAGE_UP)->EnableWindow(TRUE);
    }
    else
    {
        GetDlgItem(IDC_PAGE_UP)->EnableWindow(FALSE);
    }
}


int CRemotePlaybackDlg::GetNextPageInfo(H264_DVR_FINDINFO* searchInfo)
{
    H264_DVR_FILE_DATA *szSend = new H264_DVR_FILE_DATA[100];
    int nNum=0;
   
    if (!searchInfo)
    {
        return 0;
    }
   
    int ret = H264_DVR_FindFile(m_lLoginID,searchInfo,szSend,100,&nNum);
   
    delete []szSend;
   
    return ( ret > 0 );
}

void CRemotePlaybackDlg::ClearMapResult()
{
    m_mapTemp.clear();
    m_mapNum=0;
}

void CRemotePlaybackDlg::OnDblclkList1(NMHDR* pNMHDR, LRESULT* pResult)
{
    // TODO: Add your control notification handler code here   
    *pResult = 0;
    if(m_nPlayHandle >= 0)
    {
        H264_DVR_StopPlayBack(m_nPlayHandle);
        m_nPlayHandle = -1;
    }
    if (m_nPlaybackDecHandle)
    {
        H264_PLAY_CloseStream(m_nPlaybackDecHandle);
        H264_PLAY_Stop(m_nPlaybackDecHandle);
        m_nPlaybackDecHandle = -1;
    }
    Invalidate();
    OnPlay();
}

CString CRemotePlaybackDlg::BrowseForFolder(HWND hWnd)
{
    TCHAR szTitle[] = _T("Select a folder");
    TCHAR szDisplayName[MAX_PATH] = _T("");
    TCHAR szPath[MAX_PATH] = _T("");
    BROWSEINFO bi;
   
    bi.hwndOwner= hWnd;
    bi.pidlRoot= NULL;
    bi.lpszTitle= szTitle;
    bi.pszDisplayName = szDisplayName;
    bi.ulFlags= BIF_RETURNONLYFSDIRS;
    bi.lpfn= NULL;
    bi.lParam= 0;
   
    LPITEMIDLIST pItemIDList = SHBrowseForFolder( &bi );
    if( pItemIDList )
    {
        SHGetPathFromIDList(pItemIDList,szPath);
        
        IMalloc *pMalloc;
        if( SHGetMalloc( &pMalloc ) != NOERROR )
        {
            //TRACE( "Failed to get pointer to shells task allocator" ) ;
            return szPath;
        }
        pMalloc->Free( pItemIDList );
        if( pMalloc )
            pMalloc->Release();
    }
    return szPath;
}
2013-04-04 21:43
as0601
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2013-3-31
收藏
得分:0 
上面是全部的源码,望有高手来指导
2013-04-04 21:44
fxbszj
Rank: 5Rank: 5
来 自:阿修罗界
等 级:职业侠客
威 望:4
帖 子:163
专家分:331
注 册:2012-10-8
收藏
得分:2 
好长一段的
2013-04-04 22:51
rjsp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:528
帖 子:9025
专家分:54030
注 册:2011-1-18
收藏
得分:2 
vector<H264_DVR_FILE_DATA*>::iterator p=m_pstrFileVector.begin();
if ( p )
------------- 不知道你想表达什么含义?我只看过 if( p != m_pstrFileVector.end() )
2013-04-07 08:40
peach5460
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:武汉
等 级:贵宾
威 望:30
帖 子:2780
专家分:6060
注 册:2008-1-28
收藏
得分:2 
好大一坨代码呀...

迭代器不能隐式的转为bool

我总觉得授人以鱼不如授人以渔...
可是总有些SB叫嚣着:要么给代码给答案,要么滚蛋...
虽然我知道不要跟SB一般见识,但是我真的没修炼到宠辱不惊...
2013-04-07 09:00
puergg
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2013-4-14
收藏
得分:0 
今天也遇到这个问题了,还是不知道答案啊,
VC++环境下估计可以,到VS2008环境下调试出错。

请哪位老师给解答一下。
2013-04-14 19:58
快速回复:“类型的条件表达式是非法的”这样的错误怎么解决,求高手解
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020536 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved