1
0

FFmpegFormat.hpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 FFmpegCodec;
  22. struct FFmpegFormat {
  23. const char *name;
  24. const char *long_name;
  25. const char *mime_type;
  26. const char *extensions;
  27. AVCodecID audio_codec;
  28. AVCodecID video_codec;
  29. const AVCodecTag *const *codec_tags;
  30. FFmpegFormat() = default;
  31. FFmpegFormat(const char *name, const char *mime_type)
  32. : name(name),
  33. long_name(nullptr),
  34. mime_type(mime_type),
  35. extensions(nullptr),
  36. audio_codec(AV_CODEC_ID_NONE),
  37. video_codec(AV_CODEC_ID_NONE),
  38. codec_tags(nullptr)
  39. {
  40. }
  41. FFmpegFormat(const AVOutputFormat *av_format)
  42. : name(av_format->name),
  43. long_name(av_format->long_name),
  44. mime_type(av_format->mime_type),
  45. extensions(av_format->extensions),
  46. audio_codec(av_format->audio_codec),
  47. video_codec(av_format->video_codec),
  48. codec_tags(av_format->codec_tag)
  49. {
  50. }
  51. FFmpegCodec GetDefaultEncoder(FFmpegCodecType codec_type) const;
  52. bool HasAudio() const { return audio_codec != AV_CODEC_ID_NONE; }
  53. bool HasVideo() const { return video_codec != AV_CODEC_ID_NONE; }
  54. bool operator==(const FFmpegFormat &format) const
  55. {
  56. if (!strequal(name, format.name))
  57. return false;
  58. return strequal(mime_type, format.mime_type);
  59. }
  60. };
  61. Q_DECLARE_METATYPE(FFmpegFormat)
  62. std::vector<FFmpegFormat> GetSupportedFormats();