inputformat.hpp 4.97 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
// Copyright (c) 2012-2017 VideoStitch SAS
// Copyright (c) 2018 stitchEm

#pragma once

#include <QString>
#include <QCoreApplication>

namespace VideoStitch {
namespace InputFormat {

static const QString& VIDEO_FORMATS("(*.mp4 *.mov *.mpg *.avi *.mkv *.mp2 *.3gp *.m4v *.mpeg *.ogv *.ogg *.wmv)");
static const QString& IMAGE_FORMATS("(*.jpeg *.jpg *.png)");

/**
 * @brief The available input formats. (Vahana and Studio)
 */
enum class InputFormatEnum {
  PROCEDURAL,
  MEDIA,
  MAGEWELL,
  MAGEWELLPRO,
  DECKLINK,
  XIMEA,
  PORTAUDIO,
  AUDIOPROCEDURAL,
  AJA,
  NETWORK,
  V4L2,
  INVALID
};

/**
 * @brief Gets the translated string for the UI.
 * @param value The codec.
 * @return The UI string.
 */
static inline QString getDisplayNameFromEnum(const InputFormatEnum& value) {
  switch (value) {
    case InputFormatEnum::PROCEDURAL:
      return QCoreApplication::translate("InputFormat", "Test inputs");
    case InputFormatEnum::MEDIA:
      return QCoreApplication::translate("InputFormat", "Media files");
    case InputFormatEnum::MAGEWELL:
      return QCoreApplication::translate("InputFormat", "Magewell");
    case InputFormatEnum::MAGEWELLPRO:
      return QCoreApplication::translate("InputFormat", "Magewell Pro");
    case InputFormatEnum::DECKLINK:
      return QCoreApplication::translate("InputFormat", "Blackmagic DeckLink");
    case InputFormatEnum::XIMEA:
      return QCoreApplication::translate("InputFormat", "Ximea (BETA)");
    case InputFormatEnum::PORTAUDIO:
      return QCoreApplication::translate("InputFormat", "Portable Audio IO");
    case InputFormatEnum::AUDIOPROCEDURAL:
      return QCoreApplication::translate("InputFormat", "Audio Test input");
    case InputFormatEnum::AJA:
      return QCoreApplication::translate("InputFormat", "AJA (BETA)");
    case InputFormatEnum::NETWORK:
      return QCoreApplication::translate("InputFormat", "RTSP inputs");
    case InputFormatEnum::V4L2:
      return QCoreApplication::translate("InputFormat", "Video for Linux Two");
    case InputFormatEnum::INVALID:
      return QCoreApplication::translate("InputFormat", "Invalid");
    default:
      return QStringLiteral("");
  }
}

/**
 * @brief Gets the string prepared for configuration.
 * @param value The codec.
 * @return The configuration string.
 */
static inline QString getStringFromEnum(const InputFormatEnum& value) {
  switch (value) {
    case InputFormatEnum::PROCEDURAL:
      return QStringLiteral("procedural");
    case InputFormatEnum::MEDIA:
      return QStringLiteral("media");
    case InputFormatEnum::MAGEWELL:
      return QStringLiteral("magewell");
    case InputFormatEnum::MAGEWELLPRO:
      return QStringLiteral("magewellpro");
    case InputFormatEnum::DECKLINK:
      return QStringLiteral("decklink");
    case InputFormatEnum::XIMEA:
      return QStringLiteral("ximea");
    case InputFormatEnum::PORTAUDIO:
      return QStringLiteral("portaudio");
    case InputFormatEnum::AUDIOPROCEDURAL:
      return QStringLiteral("audio procedural");
    case InputFormatEnum::AJA:
      return QStringLiteral("aja");
    case InputFormatEnum::NETWORK:
      return QStringLiteral("network");
    case InputFormatEnum::V4L2:
      return QStringLiteral("v4l2");
    case InputFormatEnum::INVALID:
      return QStringLiteral("invalid");
    default:
      return QStringLiteral("");
  }
}

/**
 * @brief Gets the enum value from a configuration string.
 * @param value The configuration string.
 * @return The enumerator.
 */
static inline InputFormatEnum getEnumFromString(const QString& value) {
  if (value == "procedural") {
    return InputFormatEnum::PROCEDURAL;
  } else if (value == "media") {
    return InputFormatEnum::MEDIA;
  } else if (value == "magewell") {
    return InputFormatEnum::MAGEWELL;
  } else if (value == "magewellpro") {
    return InputFormatEnum::MAGEWELLPRO;
  } else if (value == "decklink") {
    return InputFormatEnum::DECKLINK;
  } else if (value == "ximea") {
    return InputFormatEnum::XIMEA;
  } else if (value == "portaudio") {
    return InputFormatEnum::PORTAUDIO;
  } else if (value == "audio procedural") {
    return InputFormatEnum::AUDIOPROCEDURAL;
  } else if (value == "aja") {
    return InputFormatEnum::AJA;
  } else if (value == "network") {
    return InputFormatEnum::NETWORK;
  } else if (value == "v4l2") {
    return InputFormatEnum::V4L2;
  } else {
    return InputFormatEnum::INVALID;
  }
}

/**
 * @brief Determines if an input format is a video.
 * @param input The input format string.
 * @return True if it's a video input.
 */
static inline bool isVideoFile(const QString& input) {
  return input.endsWith(".mp4", Qt::CaseInsensitive) || input.endsWith(".mov", Qt::CaseInsensitive);
}

/**
 * @brief Determines if an input format is a stream.
 * @param input The input format string.
 * @return True if it's a stream input.
 */
static inline bool isVideoStream(const QString& input) {
  return input.startsWith("rtsp://", Qt::CaseInsensitive) || input.startsWith("rtmp://", Qt::CaseInsensitive);
}
}  // namespace InputFormat
}  // namespace VideoStitch