You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

154 lines
4.5KB

  1. /*
  2. * Blackmagic DeckLink common code
  3. * Copyright (c) 2013-2014 Ramiro Polla, Luca Barbato, Deti Fliegl
  4. * Copyright (c) 2017 Akamai Technologies, Inc.
  5. *
  6. * This file is part of FFmpeg.
  7. *
  8. * FFmpeg is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2.1 of the License, or (at your option) any later version.
  12. *
  13. * FFmpeg is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with FFmpeg; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. #ifndef AVDEVICE_DECKLINK_COMMON_H
  23. #define AVDEVICE_DECKLINK_COMMON_H
  24. #include <DeckLinkAPIVersion.h>
  25. #include "libavutil/thread.h"
  26. #include "decklink_common_c.h"
  27. #ifdef _WIN32
  28. #define DECKLINK_BOOL BOOL
  29. #else
  30. #define DECKLINK_BOOL bool
  31. #endif
  32. class decklink_output_callback;
  33. class decklink_input_callback;
  34. typedef struct AVPacketQueue {
  35. AVPacketList *first_pkt, *last_pkt;
  36. int nb_packets;
  37. unsigned long long size;
  38. int abort_request;
  39. pthread_mutex_t mutex;
  40. pthread_cond_t cond;
  41. AVFormatContext *avctx;
  42. int64_t max_q_size;
  43. } AVPacketQueue;
  44. struct decklink_ctx {
  45. /* DeckLink SDK interfaces */
  46. IDeckLink *dl;
  47. IDeckLinkOutput *dlo;
  48. IDeckLinkInput *dli;
  49. IDeckLinkConfiguration *cfg;
  50. IDeckLinkAttributes *attr;
  51. decklink_output_callback *output_callback;
  52. decklink_input_callback *input_callback;
  53. /* DeckLink mode information */
  54. BMDTimeValue bmd_tb_den;
  55. BMDTimeValue bmd_tb_num;
  56. BMDDisplayMode bmd_mode;
  57. BMDVideoConnection video_input;
  58. BMDAudioConnection audio_input;
  59. int bmd_width;
  60. int bmd_height;
  61. int bmd_field_dominance;
  62. /* Capture buffer queue */
  63. AVPacketQueue queue;
  64. /* Streams present */
  65. int audio;
  66. int video;
  67. /* Status */
  68. int playback_started;
  69. int capture_started;
  70. int64_t last_pts;
  71. unsigned long frameCount;
  72. unsigned int dropped;
  73. AVStream *audio_st;
  74. AVStream *video_st;
  75. AVStream *teletext_st;
  76. /* Options */
  77. int list_devices;
  78. int list_formats;
  79. int64_t teletext_lines;
  80. double preroll;
  81. int duplex_mode;
  82. DecklinkPtsSource audio_pts_source;
  83. DecklinkPtsSource video_pts_source;
  84. int draw_bars;
  85. int frames_preroll;
  86. int frames_buffer;
  87. pthread_mutex_t mutex;
  88. pthread_cond_t cond;
  89. int frames_buffer_available_spots;
  90. int autodetect;
  91. int channels;
  92. int audio_depth;
  93. };
  94. typedef enum { DIRECTION_IN, DIRECTION_OUT} decklink_direction_t;
  95. #ifdef _WIN32
  96. #if BLACKMAGIC_DECKLINK_API_VERSION < 0x0a040000
  97. typedef unsigned long buffercount_type;
  98. #else
  99. typedef unsigned int buffercount_type;
  100. #endif
  101. IDeckLinkIterator *CreateDeckLinkIteratorInstance(void);
  102. #else
  103. typedef uint32_t buffercount_type;
  104. #endif
  105. static const BMDAudioConnection decklink_audio_connection_map[] = {
  106. (BMDAudioConnection)0,
  107. bmdAudioConnectionEmbedded,
  108. bmdAudioConnectionAESEBU,
  109. bmdAudioConnectionAnalog,
  110. bmdAudioConnectionAnalogXLR,
  111. bmdAudioConnectionAnalogRCA,
  112. bmdAudioConnectionMicrophone,
  113. };
  114. static const BMDVideoConnection decklink_video_connection_map[] = {
  115. (BMDVideoConnection)0,
  116. bmdVideoConnectionSDI,
  117. bmdVideoConnectionHDMI,
  118. bmdVideoConnectionOpticalSDI,
  119. bmdVideoConnectionComponent,
  120. bmdVideoConnectionComposite,
  121. bmdVideoConnectionSVideo,
  122. };
  123. HRESULT ff_decklink_get_display_name(IDeckLink *This, const char **displayName);
  124. int ff_decklink_set_configs(AVFormatContext *avctx, decklink_direction_t direction);
  125. int ff_decklink_set_format(AVFormatContext *avctx, int width, int height, int tb_num, int tb_den, enum AVFieldOrder field_order, decklink_direction_t direction = DIRECTION_OUT, int num = 0);
  126. int ff_decklink_set_format(AVFormatContext *avctx, decklink_direction_t direction, int num);
  127. int ff_decklink_list_devices(AVFormatContext *avctx, struct AVDeviceInfoList *device_list, int show_inputs, int show_outputs);
  128. void ff_decklink_list_devices_legacy(AVFormatContext *avctx, int show_inputs, int show_outputs);
  129. int ff_decklink_list_formats(AVFormatContext *avctx, decklink_direction_t direction = DIRECTION_OUT);
  130. void ff_decklink_cleanup(AVFormatContext *avctx);
  131. int ff_decklink_init_device(AVFormatContext *avctx, const char* name);
  132. #endif /* AVDEVICE_DECKLINK_COMMON_H */