//--------------------------------------------------------------------------- #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 link "dxGDIPlusClasses" #pragma link "IdBaseComponent" #pragma link "IdComponent" #pragma link "IdExplicitTLSClientServerBase" #pragma link "IdFTP" #pragma link "IdTCPClient" #pragma link "IdTCPConnection" #pragma link "FFLog" #pragma resource "*.dfm" #define LICENSE_KEY "FSXXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX" #define FFPLAYER 1 TFrmCameraPlayer *FrmCameraPlayer = NULL; //--------------------------------------------------------------------------- __fastcall TFrmCameraPlayer::TFrmCameraPlayer(TComponent* Owner) : TForm(Owner) { IsTerm = false; FPlay = false; FAutoPlay = true; FConHandle = 0; FFullScreen = false; FParent = this->Parent; PnlCamera->Tag = (int)this; //mmLog->Lines->Clear(); FFPlayer1->SetLicenseKey(LICENSE_KEY); FFPlayer1->DisableFPUExceptions(); //FFPlayer1->ReadTimeout = 30 * 1000; //FFPlayer1->opt_default("fpsprobesize", "200000"); //FFPlayer1->opt_default("probesize", "200000"); if (!FFPlayer1->AVLibLoaded()) { String sAVILibDir = g_sAppDir + "LibAV"; if (!FFPlayer1->LoadAVLib(sAVILibDir)) { Application->MessageBox(L"¿µ»óÇ¥Ãâ ¶óÀ̺귯¸®¸¦ ·ÎµåÇÏÁö ¸øÇÏ¿´½À´Ï´Ù.", L"¿µ»óÇ¥Ãâ ¿À·ù", MB_OK|MB_ICONERROR|MB_APPLMODAL); return; } } } //--------------------------------------------------------------------------- void __fastcall TFrmCameraPlayer::TmrShowTimer(TObject *Sender) { TmrShow->Enabled = false; if (IsTerm) { return; } if (Installed) { PopupMenu = PopupMenu1; ImgNoData->Visible = false; PnlName->Caption = CTLR_NMBR + ": " + NAME; Play(); } else { PopupMenu = NULL; PnlCamera->Caption = NAME; LoadEmptyImage(); } } //--------------------------------------------------------------------------- void __fastcall TFrmCameraPlayer::LoadEmptyImage() { try { #if 0 String sImageFile = g_AppCfg.sEmptyImg; if (sImageFile != "") { ImgNoData->Picture->LoadFromFile(sImageFile); ImgNoData->Align = alClient; } #endif 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(); if (STRM_ADDR == "") { PnlCamera->Caption = "¿µ»óÁ¤º¸°¡ ¾ø½À´Ï´Ù"; return; } PnlCamera->Caption = "¿µ»ó ¿¬°á Áß..."; try { FFPlayer1->AspectRatio = -1; FFPlayer1->TryOpen(STRM_ADDR, PnlCamera->Handle); FConHandle = (long)FFPlayer1->ScreenHandle; Application->ProcessMessages(); } catch(Exception &e) { } FPlay = true; } //--------------------------------------------------------------------------- void __fastcall TFrmCameraPlayer::Term() { IsTerm = true; Stop(); } //--------------------------------------------------------------------------- void __fastcall TFrmCameraPlayer::Stop() { if (!FPlay) return; FPlay = false; if (STRM_ADDR == "") { return; } PnlCamera->Caption = "¿µ»ó ¿¬°á ÇØÁ¦..."; 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 = "¿µ»ó ¿¬°á Á¾·á"; FConHandle = 0; FPlay = false; } //--------------------------------------------------------------------------- void __fastcall TFrmCameraPlayer::InitCamera(bool AInstalled, String 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) { // ¿©±â¼­ ´õºíŬ¸¯Àº ÃÖ´ëÈ­¸éÀ» È£ÃâÇÏ´Â °ÍÀÓ FrmCameraScreen->TmrFullScreen->Enabled = false; FrmCameraScreen->FFullScreenIdx = Tag; FrmCameraScreen->TmrFullScreen->Enabled = true; } //--------------------------------------------------------------------------- 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) { FPlay = false; if (FFPlayer1->ScreenHandle != NULL) { PostMessage(FFPlayer1->ScreenHandle, CM_INVALIDATE, 0, 0); UpdateWindow(FFPlayer1->ScreenHandle); } Application->ProcessMessages(); FConHandle = 0; Caption = Caption + " : ¿¬°áÁ¾·á"; PnlCamera->Caption = "¿¬°áÀÌ Á¾·áµÊ"; TmrShow->Enabled = true; } } #if 0 if (APlayState == Ffbasecomponent::psPlay) { mmLog->Lines->Add("psPlay"); } else if (APlayState == Ffbasecomponent::psPause) { mmLog->Lines->Add("psPause"); } else if (APlayState == Ffbasecomponent::psResume) { mmLog->Lines->Add("psResume"); } else if (APlayState == Ffbasecomponent::psStep) { mmLog->Lines->Add("psStep"); } else if (APlayState == Ffbasecomponent::psStop) { mmLog->Lines->Add("psStop"); } else if (APlayState == Ffbasecomponent::psEnd) { mmLog->Lines->Add("psEnd"); } #endif } //--------------------------------------------------------------------------- void __fastcall TFrmCameraPlayer::MnuInfoClick(TObject *Sender) { FrmCameraInfo = new TFrmCameraInfo(this); FrmCameraInfo->Edit1->Text = CTLR_NMBR; FrmCameraInfo->Edit2->Text = NAME; FrmCameraInfo->Edit3->Text = STRM_ADDR; FrmCameraInfo->Edit4->Text = FULL_STRM_ADDR; FrmCameraInfo->ShowModal(); FrmCameraInfo = NULL; } //---------------------------------------------------------------------------