1
0

decklink-device-mode.cpp 1.7 KB

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