decklink-device-mode.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #include "decklink-device-mode.hpp"
  2. DeckLinkDeviceMode::DeckLinkDeviceMode(IDeckLinkDisplayMode *mode,
  3. long long id) : id(id), mode(mode)
  4. {
  5. if (mode == nullptr)
  6. return;
  7. mode->AddRef();
  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), mode(nullptr), name(name)
  14. {
  15. }
  16. DeckLinkDeviceMode::~DeckLinkDeviceMode(void)
  17. {
  18. if (mode != nullptr)
  19. mode->Release();
  20. }
  21. BMDDisplayMode DeckLinkDeviceMode::GetDisplayMode(void) const
  22. {
  23. if (mode != nullptr)
  24. return mode->GetDisplayMode();
  25. return bmdModeUnknown;
  26. }
  27. int DeckLinkDeviceMode::GetWidth()
  28. {
  29. if (mode != nullptr)
  30. return mode->GetWidth();
  31. return 0;
  32. }
  33. int DeckLinkDeviceMode::GetHeight()
  34. {
  35. if (mode != nullptr)
  36. return mode->GetHeight();
  37. return 0;
  38. }
  39. BMDDisplayModeFlags DeckLinkDeviceMode::GetDisplayModeFlags(void) const
  40. {
  41. if (mode != nullptr)
  42. return mode->GetFlags();
  43. return (BMDDisplayModeFlags)0;
  44. }
  45. long long DeckLinkDeviceMode::GetId(void) const
  46. {
  47. return id;
  48. }
  49. const std::string& DeckLinkDeviceMode::GetName(void) const
  50. {
  51. return name;
  52. }
  53. void DeckLinkDeviceMode::SetMode(IDeckLinkDisplayMode *mode_)
  54. {
  55. IDeckLinkDisplayMode *old = mode;
  56. if (old != nullptr)
  57. old->Release();
  58. mode = mode_;
  59. if (mode != nullptr)
  60. mode->AddRef();
  61. }