1
0

decklink-device-mode.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #include "decklink-device-mode.hpp"
  2. DeckLinkDeviceMode::DeckLinkDeviceMode(IDeckLinkDisplayMode *mode, long long id) : id(id), mode(mode)
  3. {
  4. if (mode == nullptr)
  5. return;
  6. decklink_string_t decklinkStringName;
  7. if (mode->GetName(&decklinkStringName) == S_OK)
  8. DeckLinkStringToStdString(decklinkStringName, name);
  9. }
  10. DeckLinkDeviceMode::DeckLinkDeviceMode(const std::string &name, long long id) : id(id), mode(nullptr), name(name) {}
  11. DeckLinkDeviceMode::~DeckLinkDeviceMode(void) {}
  12. BMDDisplayMode DeckLinkDeviceMode::GetDisplayMode(void) const
  13. {
  14. if (mode != nullptr)
  15. return mode->GetDisplayMode();
  16. return bmdModeUnknown;
  17. }
  18. int DeckLinkDeviceMode::GetWidth()
  19. {
  20. if (mode != nullptr)
  21. return mode->GetWidth();
  22. return 0;
  23. }
  24. int DeckLinkDeviceMode::GetHeight()
  25. {
  26. if (mode != nullptr)
  27. return mode->GetHeight();
  28. return 0;
  29. }
  30. bool DeckLinkDeviceMode::GetFrameRate(BMDTimeValue *frameDuration, BMDTimeScale *timeScale)
  31. {
  32. if (mode != nullptr)
  33. return SUCCEEDED(mode->GetFrameRate(frameDuration, timeScale));
  34. return false;
  35. }
  36. BMDDisplayModeFlags DeckLinkDeviceMode::GetDisplayModeFlags(void) const
  37. {
  38. if (mode != nullptr)
  39. return mode->GetFlags();
  40. return (BMDDisplayModeFlags)0;
  41. }
  42. long long DeckLinkDeviceMode::GetId(void) const
  43. {
  44. return id;
  45. }
  46. const std::string &DeckLinkDeviceMode::GetName(void) const
  47. {
  48. return name;
  49. }
  50. bool DeckLinkDeviceMode::IsEqualFrameRate(int64_t num, int64_t den)
  51. {
  52. bool equal = false;
  53. if (mode) {
  54. BMDTimeValue frameDuration;
  55. BMDTimeScale timeScale;
  56. if (SUCCEEDED(mode->GetFrameRate(&frameDuration, &timeScale)))
  57. equal = timeScale * den == frameDuration * num;
  58. }
  59. return equal;
  60. }
  61. void DeckLinkDeviceMode::SetMode(IDeckLinkDisplayMode *mode_)
  62. {
  63. mode = mode_;
  64. }