ffmpeg-decode.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /******************************************************************************
  2. Copyright (C) 2014 by Hugh Bailey <[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. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. #include <obs.h>
  19. #ifdef _WIN32
  20. #pragma warning(push)
  21. #pragma warning(disable : 4244)
  22. #pragma warning(disable : 4204)
  23. #endif
  24. #include <libavcodec/avcodec.h>
  25. #include <libavutil/log.h>
  26. #ifdef _WIN32
  27. #pragma warning(pop)
  28. #endif
  29. struct ffmpeg_decode {
  30. AVCodecContext *decoder;
  31. AVCodec *codec;
  32. AVFrame *frame;
  33. uint8_t *packet_buffer;
  34. size_t packet_size;
  35. };
  36. extern int ffmpeg_decode_init(struct ffmpeg_decode *decode, enum AVCodecID id);
  37. extern void ffmpeg_decode_free(struct ffmpeg_decode *decode);
  38. extern int ffmpeg_decode_audio(struct ffmpeg_decode *decode,
  39. uint8_t *data, size_t size,
  40. struct obs_source_audio *audio,
  41. bool *got_output);
  42. extern int ffmpeg_decode_video(struct ffmpeg_decode *decode,
  43. uint8_t *data, size_t size, long long *ts,
  44. struct obs_source_frame *frame,
  45. bool *got_output);
  46. static inline bool ffmpeg_decode_valid(struct ffmpeg_decode *decode)
  47. {
  48. return decode->decoder != NULL;
  49. }
  50. #ifdef __cplusplus
  51. }
  52. #endif