FrmCameraF.cpp 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "FrmCameraF.h"
  5. #include "AppGlobalF.h"
  6. //---------------------------------------------------------------------------
  7. #pragma package(smart_init)
  8. #pragma link "AcesTechXPlayer2Lib_OCX"
  9. #pragma link "cxContainer"
  10. #pragma link "cxControls"
  11. #pragma link "cxEdit"
  12. #pragma link "cxGraphics"
  13. #pragma link "cxLabel"
  14. #pragma link "cxLookAndFeelPainters"
  15. #pragma link "cxLookAndFeels"
  16. #pragma link "dxSkinsCore"
  17. #pragma link "dxSkinBlack"
  18. #pragma link "dxSkinBlue"
  19. #pragma resource "*.dfm"
  20. TFrmCamera *FrmCamera = NULL;
  21. //---------------------------------------------------------------------------
  22. __fastcall TFrmCamera::TFrmCamera(TComponent* Owner, TXCctv *ACctv, bool AAutoPlay)
  23. : TForm(Owner)
  24. {
  25. FPlay = false;
  26. FAutoPlay = AAutoPlay;
  27. FConHandle = 0;
  28. FInstalled = false;
  29. #if 0
  30. AcesTechXPlayer21 = NULL;
  31. #else
  32. //AcesTechXPlayer21->DoubleBuffered = true;
  33. #endif
  34. InitCamera(ACctv, FAutoPlay);
  35. }
  36. //---------------------------------------------------------------------------
  37. void __fastcall TFrmCamera::MnuConnectClick(TObject *Sender)
  38. {
  39. FAutoPlay = true;
  40. Connect();
  41. }
  42. //---------------------------------------------------------------------------
  43. void __fastcall TFrmCamera::MnuDisconnectClick(TObject *Sender)
  44. {
  45. FAutoPlay = false;
  46. Disconnect();
  47. }
  48. //---------------------------------------------------------------------------
  49. void __fastcall TFrmCamera::MnuReleaseClick(TObject *Sender)
  50. {
  51. CameraRelease();
  52. }
  53. //---------------------------------------------------------------------------
  54. void __fastcall TFrmCamera::Connect()
  55. {
  56. Disconnect();
  57. if (FId.IsEmpty()) return;
  58. if (FViewAddress.IsEmpty()) return;
  59. PnlCamera->Caption = "연결중...";
  60. if (AcesTechXPlayer21) AcesTechXPlayer21->Visible = true;
  61. try
  62. {
  63. if (AcesTechXPlayer21)
  64. {
  65. AcesTechXPlayer21->URL = FViewAddress;
  66. FConHandle = AcesTechXPlayer21->ConnectAsync();
  67. }
  68. }
  69. catch(...)
  70. {
  71. }
  72. FPlay = true;
  73. }
  74. //---------------------------------------------------------------------------
  75. void __fastcall TFrmCamera::Disconnect()
  76. {
  77. if (!FPlay) return;
  78. try
  79. {
  80. //if (FConHandle)
  81. {
  82. if (AcesTechXPlayer21) AcesTechXPlayer21->Close();
  83. }
  84. FConHandle = 0;
  85. }
  86. catch(...)
  87. {
  88. }
  89. PnlCamera->Caption = "Disconnected";
  90. if (AcesTechXPlayer21) AcesTechXPlayer21->Visible = false;
  91. FConHandle = 0;
  92. FPlay = false;
  93. }
  94. //---------------------------------------------------------------------------
  95. void __fastcall TFrmCamera::CameraRelease()
  96. {
  97. Disconnect();
  98. PnlCamera->Caption = "";
  99. if (AcesTechXPlayer21) AcesTechXPlayer21->Visible = false;
  100. }
  101. //---------------------------------------------------------------------------
  102. void __fastcall TFrmCamera::InitCamera(TXCctv *ACctv, bool AAutoPlay/*=true*/)
  103. {
  104. FAutoPlay = AAutoPlay;
  105. PopupMenu = NULL;
  106. if (!ACctv)
  107. {
  108. FId = "";
  109. FGroup = "";
  110. FName = "";
  111. FStreamingType = "";
  112. FViewAddress = "";
  113. FFullAddress = "";
  114. PnlCamera->Caption = "-Empty-";
  115. DisplayName(" ");
  116. FInstalled = false;
  117. AcesTechXPlayer21->Visible = false;
  118. try
  119. {
  120. String sImageFile = ExtractFilePath(Application->ExeName) + "\\image\\vmscam.bmp";
  121. ImgNoData->Picture->LoadFromFile(sImageFile);
  122. ImgNoData->Align = alClient;
  123. ImgNoData->Visible = true;
  124. LblName->Visible = false;
  125. }
  126. catch(Exception &e)
  127. {
  128. ImgNoData->Visible = false;
  129. }
  130. }
  131. else
  132. {
  133. #if 0
  134. AcesTechXPlayer21 = new TAcesTechXPlayer2(this);
  135. AcesTechXPlayer21->Parent = PnlCamera;
  136. AcesTechXPlayer21->Align = alClient;
  137. //AcesTechXPlayer21->DoubleBuffered = true;
  138. #endif
  139. //AcesTechXPlayer21->Visible = true;
  140. FId = ACctv->Id;
  141. FGroup = ACctv->Group;
  142. FName = ACctv->Name;
  143. FStreamingType = ACctv->StreamingType;
  144. FViewAddress = ACctv->ViewAddress;
  145. FFullAddress = ACctv->FullAddress;
  146. PnlCamera->Caption = "Disconnected";
  147. DisplayName(FName);
  148. FInstalled = true;
  149. if (FViewAddress.IsEmpty())
  150. {
  151. AcesTechXPlayer21->Visible = false;
  152. PnlCamera->Caption = "스트리밍주소 오류";
  153. }
  154. else
  155. {
  156. PopupMenu = PopupMenu1;
  157. }
  158. }
  159. }
  160. //---------------------------------------------------------------------------
  161. void __fastcall TFrmCamera::DisplayName(String AName)
  162. {
  163. LblName->Visible = false;
  164. LblName->Caption = FName;
  165. LblName->Transparent = false;
  166. LblName->Transparent = true;
  167. LblName->Visible = true;
  168. LblName->Refresh();
  169. LblName->BringToFront();
  170. }
  171. //---------------------------------------------------------------------------
  172. void __fastcall TFrmCamera::TmrPlayTimer(TObject *Sender)
  173. {
  174. TmrStop->Enabled = false;
  175. TmrPlay->Enabled = false;
  176. Connect();
  177. }
  178. //---------------------------------------------------------------------------
  179. void __fastcall TFrmCamera::TmrStopTimer(TObject *Sender)
  180. {
  181. TmrPlay->Enabled = false;
  182. TmrStop->Enabled = false;
  183. Disconnect();
  184. }
  185. //---------------------------------------------------------------------------