//--------------------------------------------------------------------------- #include #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 resource "*.dfm" #define LICENSE_KEY "FSXXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX" 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; 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; } } 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 = CCAM_ID + ": " + 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 { FFPlayer1->AspectRatio = -1; FFPlayer1->TryOpen(STRM_ADDR, PnlCamera->Handle); FConHandle = (long)FFPlayer1->ScreenHandle; Application->ProcessMessages(); } catch(Exception &e) { } FPlay = true; } //--------------------------------------------------------------------------- void __fastcall TFrmCameraPlayer::Stop() { if (!FPlay) return; FPlay = false; PnlCamera->Caption = "Try disconnect"; try { if (FFPlayer1->ScreenHandle != NULL) { FFPlayer1->Stop(true); PostMessage(FFPlayer1->ScreenHandle, CM_INVALIDATE, 0, 0); UpdateWindow(FFPlayer1->ScreenHandle); } Application->ProcessMessages(); FConHandle = 0; } catch(Exception &e) { } PnlCamera->Caption = "Disconnected"; FConHandle = 0; FPlay = false; } //--------------------------------------------------------------------------- void __fastcall TFrmCameraPlayer::InitCamera(bool AInstalled, String ACtlrNmbr, String AName, String AStrmAddr, String AFullStrmAddr, int AViewMode) { FAutoPlay = true; Installed = AInstalled; CCAM_ID = 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 FrmCameraScreen->TmrFullScreen->Enabled = false; FrmCameraScreen->FFullScreenIdx = Tag; FrmCameraScreen->TmrFullScreen->Enabled = true; #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 = CCAM_ID; FrmCameraInfo->Edit2->Text = NAME; FrmCameraInfo->Edit3->Text = STRM_ADDR; FrmCameraInfo->Edit4->Text = FULL_STRM_ADDR; FrmCameraInfo->ShowModal(); FrmCameraInfo = NULL; } //---------------------------------------------------------------------------