123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #include "AppGlobalF.h"
- #include "ITSLangTransF.h"
- #pragma hdrstop
- #include "FrmCrsCmraF.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma link "AcesTechXPlayer2Lib_OCX"
- #pragma link "FFBaseComponent"
- #pragma link "FFBasePlay"
- #pragma link "FFPlay"
- #pragma resource "*.dfm"
- #define LICENSE_KEY "FSXXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX"
- //TFrmCrsCamra *FrmCrsCamra;
- //---------------------------------------------------------------------------
- __fastcall TFrmCrsCamra::TFrmCrsCamra(TComponent* Owner, TCrossCam *ACmra)
- : TForm(Owner)
- {
- FCmra = ACmra;
- FPlay = false;
- if (FCmra == NULL) {
- PnlTitle->Visible = false;
- }
- #if FFPLAY
- AcesTechXPlayer2->Visible = false;
- FFPlayer->SetLicenseKey(LICENSE_KEY);
- FFPlayer->DisableFPUExceptions();
- #endif
- #if ACES
- AcesTechXPlayer2->Align = alClient;
- AcesTechXPlayer2->Visible = true;
- #endif
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCrsCamra::FormClose(TObject *Sender, TCloseAction &Action)
- {
- Action = caFree;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCrsCamra::FormDestroy(TObject *Sender)
- {
- Disconnect();
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCrsCamra::FFPlayerState(TObject *Sender, TPlayState APlayState)
- {
- enum TPlayState { psPlay, psPause, psResume, psStep, psStop, psEnd };
- if (APlayState == Ffbasecomponent::psStop || APlayState == Ffbasecomponent::psEnd)
- {
- PnlTitle->Caption = FCmra->CAM_NM + " : Disconnected";
- Timer1->Enabled = true;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCrsCamra::FormShow(TObject *Sender)
- {
- Refresh();
- if (FCmra == NULL)
- {
- return;
- }
- PnlTitle->Caption = FCmra->CAM_NM;
- if (FCmra->RTSP_URL == "")
- {
- return;
- }
- #if FFPLAY
- String sAVILibDir = g_sAppDir + "LibAV";
- if (!FFPlayer->AVLibLoaded())
- {
- if (!FFPlayer->LoadAVLib(sAVILibDir))
- {
- PnlTitle->Caption = FCmra->CAM_NM + ": 영상표출 라이브러리를 로드 실패!!";
- return;
- }
- }
- #endif
- Timer1->Enabled = true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCrsCamra::Timer1Timer(TObject *Sender)
- {
- Timer1->Enabled = false;
- Connect();
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCrsCamra::Connect()
- {
- Disconnect();
- try
- {
- PnlStream->Caption = "Connecting...";
- PnlTitle->Caption = FCmra->CAM_NM;
- #if FFPLAY
- FFPlayer->AspectRatio = -1;
- FFPlayer->TryOpen(FCmra->RTSP_URL, PnlStream->Handle);
- FConHandle = (long)FFPlayer->ScreenHandle;
- #endif
- #if ACES
- AcesTechXPlayer2->URL = FCmra->RTSP_URL;
- FConHandle = AcesTechXPlayer2->ConnectAsync();
- if (FConHandle > 0)
- {
- }
- #endif
- FPlay = true;
- Application->ProcessMessages();
- }
- catch(Exception &e)
- {
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCrsCamra::Disconnect()
- {
- if (!FPlay) return;
- FPlay = false;
- try
- {
- #if FFPLAY
- if (FFPlayer->ScreenHandle != NULL)
- {
- FFPlayer->Stop(true);
- PostMessage(FFPlayer->ScreenHandle, CM_INVALIDATE, 0, 0);
- UpdateWindow(FFPlayer->ScreenHandle);
- FFPlayer->ScreenHandle = NULL;
- }
- #endif
- #if ACES
- if (FConHandle > 0)
- {
- AcesTechXPlayer2->Close();
- }
- #endif
- FConHandle = 0;
- PnlStream->Caption = "Disconnected";
- Application->ProcessMessages();
- }
- catch(Exception &e)
- {
- }
- }
- //---------------------------------------------------------------------------
|