FFmpegCodec.hpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /******************************************************************************
  2. Copyright (C) 2023 by Dennis Sädtler <[email protected]>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ******************************************************************************/
  14. #pragma once
  15. #include "FFmpegShared.hpp"
  16. extern "C" {
  17. #include <libavcodec/avcodec.h>
  18. #include <libavdevice/avdevice.h>
  19. }
  20. #include <qmetatype.h>
  21. struct FFmpegFormat;
  22. struct FFmpegCodec {
  23. const char *name;
  24. const char *long_name;
  25. int id;
  26. FFmpegCodecType type;
  27. FFmpegCodec() = default;
  28. FFmpegCodec(const char *name, int id, FFmpegCodecType type = UNKNOWN)
  29. : name(name),
  30. long_name(nullptr),
  31. id(id),
  32. type(type)
  33. {
  34. }
  35. FFmpegCodec(const AVCodec *codec) : name(codec->name), long_name(codec->long_name), id(codec->id)
  36. {
  37. switch (codec->type) {
  38. case AVMEDIA_TYPE_AUDIO:
  39. type = AUDIO;
  40. break;
  41. case AVMEDIA_TYPE_VIDEO:
  42. type = VIDEO;
  43. break;
  44. default:
  45. type = UNKNOWN;
  46. }
  47. }
  48. bool operator==(const FFmpegCodec &codec) const
  49. {
  50. if (id != codec.id)
  51. return false;
  52. return strequal(name, codec.name);
  53. }
  54. };
  55. Q_DECLARE_METATYPE(FFmpegCodec)
  56. std::vector<FFmpegCodec> GetFormatCodecs(const FFmpegFormat &format, bool ignore_compatibility);
  57. bool FFCodecAndFormatCompatible(const char *codec, const char *format);
  58. bool IsBuiltinCodec(const char *codec);
  59. bool ContainerSupportsCodec(const std::string &container, const std::string &codec);