123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 |
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #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();
- }
- //---------------------------------------------------------------------------
|