//--------------------------------------------------------------------------- #include #pragma hdrstop #include "FrmIcsCameraF.h" #include "AppGlobalF.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "cxContainer" #pragma link "cxControls" #pragma link "cxEdit" #pragma link "cxGraphics" #pragma link "cxLabel" #pragma link "cxLookAndFeelPainters" #pragma link "cxLookAndFeels" #pragma link "dxSkinsCore" #pragma link "dxSkinBlack" #pragma link "dxSkinBlue" #pragma link "ICSVIEWLib_TLB" #pragma resource "*.dfm" TFrmIcsCamera *FrmIcsCamera = NULL; //--------------------------------------------------------------------------- __fastcall TFrmIcsCamera::TFrmIcsCamera(TComponent* Owner, TXCctv *ACctv, bool AAutoPlay) : TForm(Owner) { FPlay = false; FAutoPlay = AAutoPlay; FConHandle = 0; FInstalled = false; IcsView = new TIcsView(PnlCamera); IcsView->Parent = PnlCamera; IcsView->Align = alClient; IcsView->Visible = false; InitCamera(ACctv, FAutoPlay); } //--------------------------------------------------------------------------- void __fastcall TFrmIcsCamera::MnuConnectClick(TObject *Sender) { FAutoPlay = true; Connect(); } //--------------------------------------------------------------------------- void __fastcall TFrmIcsCamera::MnuDisconnectClick(TObject *Sender) { FAutoPlay = false; Disconnect(); } //--------------------------------------------------------------------------- void __fastcall TFrmIcsCamera::MnuReleaseClick(TObject *Sender) { CameraRelease(); } //--------------------------------------------------------------------------- void __fastcall TFrmIcsCamera::Connect() { Disconnect(); if (FId.IsEmpty()) return; if (FViewAddress.IsEmpty()) return; PnlCamera->Caption = "¿¬°áÁß..."; if (IcsView) IcsView->Visible = true; try { if (IcsView) { String sSvr = FWebCamPswd; IcsView->Username = FWebCamUser; //root IcsView->Password = FWebCamUser; //dw2001 IcsView->UseTCP = true; IcsView->UseRtspOverHttp = false; IcsView->RtspOverHttpPort = 80; IcsView->RenderOption = 1;//0 IcsView->UseBuffer = 1;//0 IcsView->Play(sSvr.c_str(), 0); } } catch(...) { } FPlay = true; } //--------------------------------------------------------------------------- void __fastcall TFrmIcsCamera::Disconnect() { if (!FPlay) return; try { //if (FConHandle) { if (IcsView) IcsView->Stop(); } FConHandle = 0; } catch(...) { } PnlCamera->Caption = "Disconnected"; if (IcsView) IcsView->Visible = false; FConHandle = 0; FPlay = false; } //--------------------------------------------------------------------------- void __fastcall TFrmIcsCamera::CameraRelease() { Disconnect(); PnlCamera->Caption = ""; if (IcsView) IcsView->Visible = false; } //--------------------------------------------------------------------------- void __fastcall TFrmIcsCamera::InitCamera(TXCctv *ACctv, bool AAutoPlay/*=true*/) { FAutoPlay = AAutoPlay; PopupMenu = NULL; if (!ACctv) { FId = ""; FGroup = ""; FName = ""; FStreamingType = ""; FViewAddress = ""; FFullAddress = ""; FWebCamIp = ""; FWebCamUser = ""; FWebCamPswd = ""; PnlCamera->Caption = "-Empty-"; DisplayName(" "); FInstalled = false; IcsView->Visible = false; try { String sImageFile = ExtractFilePath(Application->ExeName) + "\\image\\vmscam.bmp"; ImgNoData->Picture->LoadFromFile(sImageFile); ImgNoData->Align = alClient; ImgNoData->Visible = true; LblName->Visible = false; } catch(Exception &e) { ImgNoData->Visible = false; } } else { FId = ACctv->Id; FGroup = ACctv->Group; FName = ACctv->Name; FStreamingType = ACctv->StreamingType; FViewAddress = ACctv->ViewAddress; FFullAddress = ACctv->FullAddress; FWebCamIp = ACctv->WebCamIp; FWebCamUser = ACctv->WebCamUser; FWebCamPswd = ACctv->WebCamPswd; PnlCamera->Caption = "Disconnected"; DisplayName(FName); FInstalled = true; if (FWebCamIp.IsEmpty()) { IcsView->Visible = false; PnlCamera->Caption = "½ºÆ®¸®¹ÖÁÖ¼Ò ¿À·ù"; } else { PopupMenu = PopupMenu1; } } } //--------------------------------------------------------------------------- void __fastcall TFrmIcsCamera::DisplayName(String AName) { LblName->Visible = false; LblName->Caption = FName; LblName->Transparent = false; LblName->Transparent = true; LblName->Visible = true; LblName->Refresh(); LblName->BringToFront(); } //--------------------------------------------------------------------------- void __fastcall TFrmIcsCamera::TmrPlayTimer(TObject *Sender) { TmrStop->Enabled = false; TmrPlay->Enabled = false; Connect(); } //--------------------------------------------------------------------------- void __fastcall TFrmIcsCamera::TmrStopTimer(TObject *Sender) { TmrPlay->Enabled = false; TmrStop->Enabled = false; Disconnect(); } //---------------------------------------------------------------------------