FrmMainF.cpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "FrmMainF.h"
  5. //---------------------------------------------------------------------------
  6. #pragma package(smart_init)
  7. #pragma link "FFBaseComponent"
  8. #pragma link "FFBasePlay"
  9. #pragma link "FFPlay"
  10. #pragma resource "*.dfm"
  11. TForm1 *Form1;
  12. #define LICENSE_KEY "FSXXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX"
  13. //---------------------------------------------------------------------------
  14. __fastcall TForm1::TForm1(TComponent* Owner)
  15. : TForm(Owner)
  16. {
  17. FStrmUrl[0] = "";
  18. FStrmUrl[1] = "rtsp://118.40.176.110:1935/live/CCAM0140.stream";
  19. FStrmUrl[2] = "rtsp://118.40.176.110:1935/live/CCAM0150.stream";
  20. FStrmUrl[3] = "rtsp://118.40.176.110:1935/live/CCAM0160.stream";
  21. FStrmUrl[4] = "rtsp://118.40.176.110:1935/live/CCAM0170.stream";
  22. FStrmUrl[5] = "rtsp://118.40.176.110:1935/live/CCAM0010.stream";
  23. FStrmUrl[6] = "rtsp://118.40.176.110:1935/live/CCAM0020.stream";
  24. FStrmUrl[7] = "rtsp://118.40.176.110:1935/live/CCAM0030.stream";
  25. FStrmUrl[8] = "rtsp://118.40.176.110:1935/live/CCAM0040.stream";
  26. FStrmUrl[9] = "rtsp://118.40.176.110:1935/live/CCAM0050.stream";
  27. FStrmUrl[10] = "rtsp://118.40.176.110:1935/live/CCAM0060.stream";
  28. FStrmUrl[11] = "rtsp://118.40.176.110:1935/live/CCAM0070.stream";
  29. FStrmUrl[12] = "rtsp://118.40.176.110:1935/live/CCAM0080.stream";
  30. FStrmUrl[13] = "rtsp://118.40.176.110:1935/live/CCAM0090.stream";
  31. FStrmUrl[14] = "rtsp://118.40.176.110:1935/live/CCAM0100.stream";
  32. FStrmUrl[15] = "rtsp://118.40.176.110:1935/live/CCAM0110.stream";
  33. String g_sAppDir = ExtractFilePath(Application->ExeName);
  34. for (int ii = 0; ii < MAX_STREAM; ii++) {
  35. FStrmPnl[ii] = (TPanel*)FindComponent("Panel"+IntToStr(ii+1));
  36. if (FStrmPnl[ii]) {
  37. FStrmPnl[ii]->Caption = FStrmUrl[ii];
  38. }
  39. FFPlayer[ii] = (TFFPlayer*)FindComponent("FFPlayer"+IntToStr(ii+1));
  40. if (FFPlayer[ii]) {
  41. FFPlayer[ii]->SetLicenseKey(LICENSE_KEY);
  42. FFPlayer[ii]->DisableFPUExceptions();
  43. if (!FFPlayer[ii]->AVLibLoaded())
  44. {
  45. String sAVILibDir = g_sAppDir + "LibAV";
  46. if (!FFPlayer[ii]->LoadAVLib(sAVILibDir))
  47. {
  48. Application->MessageBox(L"영상표출 라이브러리를 로드하지 못하였습니다.", L"영상표출 오류", MB_OK|MB_ICONERROR|MB_APPLMODAL);
  49. return;
  50. }
  51. }
  52. }
  53. }
  54. }
  55. //---------------------------------------------------------------------------
  56. void __fastcall TForm1::Button1Click(TObject *Sender)
  57. {
  58. try
  59. {
  60. for (int ii = 0; ii < MAX_STREAM; ii++) {
  61. if (!FFPlayer[ii] || !FStrmPnl[ii]) continue;
  62. if (FStrmUrl[ii] == "") continue;
  63. FFPlayer[ii]->OnPosition = NULL;
  64. FFPlayer[ii]->OnFrameHook = NULL;
  65. FFPlayer[ii]->OnVideoHook = NULL;
  66. FFPlayer[ii]->AspectRatio = -1;
  67. FFPlayer[ii]->TryOpen(FStrmUrl[ii], FStrmPnl[ii]->Handle);
  68. Application->ProcessMessages();
  69. }
  70. }
  71. catch(Exception &e)
  72. {
  73. }
  74. }
  75. //---------------------------------------------------------------------------
  76. void __fastcall TForm1::Button2Click(TObject *Sender)
  77. {
  78. try
  79. {
  80. for (int ii = 0; ii < MAX_STREAM; ii++) {
  81. if (!FFPlayer[ii] || !FStrmPnl[ii]) continue;
  82. if (FFPlayer[ii]->ScreenHandle != NULL)
  83. {
  84. FFPlayer[ii]->Stop(true);
  85. PostMessage(FFPlayer[ii]->ScreenHandle, CM_INVALIDATE, 0, 0);
  86. UpdateWindow(FFPlayer[ii]->ScreenHandle);
  87. }
  88. Application->ProcessMessages();
  89. }
  90. }
  91. catch(Exception &e)
  92. {
  93. }
  94. }
  95. //---------------------------------------------------------------------------