decklink_common.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * Blackmagic DeckLink common code
  3. * Copyright (c) 2013-2014 Ramiro Polla, Luca Barbato, Deti Fliegl
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * FFmpeg is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #include "decklink_common_c.h"
  22. class decklink_output_callback;
  23. class decklink_input_callback;
  24. typedef struct AVPacketQueue {
  25. AVPacketList *first_pkt, *last_pkt;
  26. int nb_packets;
  27. unsigned long long size;
  28. int abort_request;
  29. pthread_mutex_t mutex;
  30. pthread_cond_t cond;
  31. AVFormatContext *avctx;
  32. } AVPacketQueue;
  33. struct decklink_ctx {
  34. /* DeckLink SDK interfaces */
  35. IDeckLink *dl;
  36. IDeckLinkOutput *dlo;
  37. IDeckLinkInput *dli;
  38. decklink_output_callback *output_callback;
  39. decklink_input_callback *input_callback;
  40. /* DeckLink mode information */
  41. BMDTimeValue bmd_tb_den;
  42. BMDTimeValue bmd_tb_num;
  43. BMDDisplayMode bmd_mode;
  44. int bmd_width;
  45. int bmd_height;
  46. int bmd_field_dominance;
  47. /* Capture buffer queue */
  48. AVPacketQueue queue;
  49. /* Streams present */
  50. int audio;
  51. int video;
  52. /* Status */
  53. int playback_started;
  54. int capture_started;
  55. int64_t last_pts;
  56. unsigned long frameCount;
  57. unsigned int dropped;
  58. AVStream *audio_st;
  59. AVStream *video_st;
  60. /* Options */
  61. int list_devices;
  62. int list_formats;
  63. double preroll;
  64. int frames_preroll;
  65. int frames_buffer;
  66. sem_t semaphore;
  67. int channels;
  68. };
  69. typedef enum { DIRECTION_IN, DIRECTION_OUT} decklink_direction_t;
  70. #ifdef _WIN32
  71. typedef unsigned long buffercount_type;
  72. IDeckLinkIterator *CreateDeckLinkIteratorInstance(void);
  73. #else
  74. typedef uint32_t buffercount_type;
  75. #endif
  76. HRESULT ff_decklink_get_display_name(IDeckLink *This, const char **displayName);
  77. int ff_decklink_set_format(AVFormatContext *avctx, int width, int height, int tb_num, int tb_den, decklink_direction_t direction = DIRECTION_OUT, int num = 0);
  78. int ff_decklink_set_format(AVFormatContext *avctx, decklink_direction_t direction, int num);
  79. int ff_decklink_list_devices(AVFormatContext *avctx);
  80. int ff_decklink_list_formats(AVFormatContext *avctx, decklink_direction_t direction = DIRECTION_OUT);