123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293 |
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #include "AppGlobalF.h"
- #include "FrmCameraPlayerF.h"
- #include "FrmCameraFullScreenF.h"
- #include "FrmCameraInfoF.h"
- #include "FrmCameraScreenF.h"
- #pragma hdrstop
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma link "FFBaseComponent"
- #pragma link "FFBasePlay"
- #pragma link "FFPlay"
- #pragma link "cxContainer"
- #pragma link "cxControls"
- #pragma link "cxEdit"
- #pragma link "cxGraphics"
- #pragma link "cxLabel"
- #pragma link "cxLookAndFeelPainters"
- #pragma link "cxLookAndFeels"
- #pragma link "dxSkinBlack"
- #pragma link "dxSkinBlue"
- #pragma link "dxSkinsCore"
- #pragma link "AcesTechXPlayer2Lib_OCX"
- #pragma resource "*.dfm"
- #define LICENSE_KEY "FSXXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX"
- #define FFPLAYER 0
- #define ACES 1
- TFrmCameraPlayer *FrmCameraPlayer = NULL;
- //---------------------------------------------------------------------------
- __fastcall TFrmCameraPlayer::TFrmCameraPlayer(TComponent* Owner)
- : TForm(Owner)
- {
- FPlay = false;
- FAutoPlay = true;
- FConHandle = 0;
- FFullScreen = false;
- FParent = this->Parent;
- PnlCamera->Tag = (int)this;
- #if FFPLAYER
- AcesTechXPlayer21->Visible = false;
- FFPlayer1->SetLicenseKey(LICENSE_KEY);
- FFPlayer1->DisableFPUExceptions();
- if (!FFPlayer1->AVLibLoaded())
- {
- String sAVILibDir = g_sAppDir + "LibAV";
- if (!FFPlayer1->LoadAVLib(sAVILibDir))
- {
- if (g_AppCfg.sLang != "kr") Application->MessageBox(L"Stream display library load failed.", L"Stream display fail", MB_OK|MB_ICONERROR|MB_APPLMODAL);
- else Application->MessageBox(L"영상표출 라이브러리를 로드하지 못하였습니다.", L"영상표출 오류", MB_OK|MB_ICONERROR|MB_APPLMODAL);
- return;
- }
- }
- #endif
- #if ACES
- #endif
- if (g_AppCfg.sLang != "kr")
- {
- MnuConnect->Caption = "Connect";
- MnuDisconnect->Caption = "Disconnect";
- MnuInfo->Caption = "Information...";
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCameraPlayer::TmrShowTimer(TObject *Sender)
- {
- TmrShow->Enabled = false;
- if (Installed)
- {
- PopupMenu = PopupMenu1;
- ImgNoData->Visible = false;
- PnlName->Caption = String(CTLR_NMBR) + ": " + NAME;
- Play();
- }
- else
- {
- PopupMenu = NULL;
- PnlCamera->Caption = NAME;
- LoadEmptyImage();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCameraPlayer::LoadEmptyImage()
- {
- try
- {
- String sImageFile = g_AppCfg.sEmptyImg;
- if (sImageFile != "")
- {
- ImgNoData->Picture->LoadFromFile(sImageFile);
- ImgNoData->Align = alClient;
- ImgNoData->Visible = true;
- }
- }
- catch(Exception &e)
- {
- ImgNoData->Visible = true;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCameraPlayer::FormShow(TObject *Sender)
- {
- Refresh();
- this->FLastBounds = this->BoundsRect;
- // TmrShow->Enabled = true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCameraPlayer::FormClose(TObject *Sender, TCloseAction &Action)
- {
- try {
- Stop();
- } catch(...) {}
- Action = caFree;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCameraPlayer::FormDestroy(TObject *Sender)
- {
- try {
- Stop();
- } catch(...) {}
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCameraPlayer::MnuConnectClick(TObject *Sender)
- {
- FAutoPlay = true;
- Play();
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCameraPlayer::MnuDisconnectClick(TObject *Sender)
- {
- FAutoPlay = false;
- Stop();
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCameraPlayer::AutoPlay()
- {
- FAutoPlay = true;
- TmrShow->Enabled = true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCameraPlayer::Play()
- {
- Stop();
- PnlCamera->Caption = "Try connect...";
- try
- {
- #if FFPLAYER
- FFPlayer1->AspectRatio = -1;
- FFPlayer1->TryOpen(STRM_ADDR, PnlCamera->Handle);
- FConHandle = (long)FFPlayer1->ScreenHandle;
- #endif
- #if ACES
- AcesTechXPlayer21->URL = STRM_ADDR;
- FConHandle = AcesTechXPlayer21->ConnectAsync();
- if (FConHandle > 0)
- {
- }
- #endif
- Application->ProcessMessages();
- }
- catch(Exception &e)
- {
- }
- FPlay = true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCameraPlayer::Stop()
- {
- if (!FPlay) return;
- FPlay = false;
- PnlCamera->Caption = "Try disconnect";
- try
- {
- #if FFPLAYER
- if (FFPlayer1->ScreenHandle != NULL)
- {
- FFPlayer1->Stop(true);
- PostMessage(FFPlayer1->ScreenHandle, CM_INVALIDATE, 0, 0);
- UpdateWindow(FFPlayer1->ScreenHandle);
- }
- #endif
- #if ACES
- if (FConHandle > 0)
- {
- AcesTechXPlayer21->Close();
- }
- #endif
- Application->ProcessMessages();
- FConHandle = 0;
- }
- catch(Exception &e)
- {
- }
- PnlCamera->Caption = "Disconnected";
- FConHandle = 0;
- FPlay = false;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCameraPlayer::InitCamera(bool AInstalled, int ACtlrNmbr, String AName, String AStrmAddr, String AFullStrmAddr, int AViewMode)
- {
- FAutoPlay = true;
- Installed = AInstalled;
- CTLR_NMBR = ACtlrNmbr;
- NAME = AName;
- STRM_ADDR = AStrmAddr;
- FULL_STRM_ADDR = AFullStrmAddr;
- VIEW_MODE = AViewMode;
- Caption = NAME;
- PnlName->Caption = NAME;
- PnlCamera->Caption = AStrmAddr;
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCameraPlayer::PnlCameraDblClick(TObject *Sender)
- {
- // 여기서 더블클릭은 최대화면을 호출하는 것임
- #if 0
- TFrmCameraFullScreen *pFrmFullScreen = new TFrmCameraFullScreen(this);
- pFrmFullScreen->BoundsRect = this->Monitor->BoundsRect;
- pFrmFullScreen->PnlStream->Align = alNone;
- pFrmFullScreen->PnlStream->Align = alClient;
- pFrmFullScreen->RTSP_ADDR = FULL_STRM_ADDR;
- pFrmFullScreen->ShowModal();
- PnlCamera->Parent = this;
- PnlCamera->Tag = (int)this;
- delete pFrmFullScreen;
- pFrmFullScreen = NULL;
- #else
- #if FFPLAYER
- FrmCameraScreen->TmrFullScreen->Enabled = false;
- FrmCameraScreen->FFullScreenIdx = Tag;
- FrmCameraScreen->TmrFullScreen->Enabled = true;
- #endif
- #endif
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCameraPlayer::FFPlayer1State(TObject *Sender, TPlayState APlayState)
- {
- enum TPlayState { psPlay, psPause, psResume, psStep, psStop, psEnd };
- if (APlayState == Ffbasecomponent::psStop || APlayState == Ffbasecomponent::psEnd)
- {
- if (FPlay)
- {
- Caption = Caption + " : Disconnected";
- TmrShow->Enabled = true;
- }
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFrmCameraPlayer::MnuInfoClick(TObject *Sender)
- {
- FrmCameraInfo = new TFrmCameraInfo(this);
- FrmCameraInfo->Edit1->Text = String(CTLR_NMBR);
- FrmCameraInfo->Edit2->Text = NAME;
- FrmCameraInfo->Edit3->Text = STRM_ADDR;
- FrmCameraInfo->Edit4->Text = FULL_STRM_ADDR;
- FrmCameraInfo->ShowModal();
- FrmCameraInfo = NULL;
- }
- //---------------------------------------------------------------------------
|