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.

142 lines
4.1KB

  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. #ifndef AVDEVICE_DECKLINK_COMMON_H
  22. #define AVDEVICE_DECKLINK_COMMON_H
  23. #include <DeckLinkAPIVersion.h>
  24. #include "libavutil/thread.h"
  25. #include "decklink_common_c.h"
  26. class decklink_output_callback;
  27. class decklink_input_callback;
  28. typedef struct AVPacketQueue {
  29. AVPacketList *first_pkt, *last_pkt;
  30. int nb_packets;
  31. unsigned long long size;
  32. int abort_request;
  33. pthread_mutex_t mutex;
  34. pthread_cond_t cond;
  35. AVFormatContext *avctx;
  36. } AVPacketQueue;
  37. struct decklink_ctx {
  38. /* DeckLink SDK interfaces */
  39. IDeckLink *dl;
  40. IDeckLinkOutput *dlo;
  41. IDeckLinkInput *dli;
  42. IDeckLinkConfiguration *cfg;
  43. IDeckLinkAttributes *attr;
  44. decklink_output_callback *output_callback;
  45. decklink_input_callback *input_callback;
  46. /* DeckLink mode information */
  47. BMDTimeValue bmd_tb_den;
  48. BMDTimeValue bmd_tb_num;
  49. BMDDisplayMode bmd_mode;
  50. BMDVideoConnection video_input;
  51. BMDAudioConnection audio_input;
  52. int bmd_width;
  53. int bmd_height;
  54. int bmd_field_dominance;
  55. /* Capture buffer queue */
  56. AVPacketQueue queue;
  57. /* Streams present */
  58. int audio;
  59. int video;
  60. /* Status */
  61. int playback_started;
  62. int capture_started;
  63. int64_t last_pts;
  64. unsigned long frameCount;
  65. unsigned int dropped;
  66. AVStream *audio_st;
  67. AVStream *video_st;
  68. AVStream *teletext_st;
  69. /* Options */
  70. int list_devices;
  71. int list_formats;
  72. int64_t teletext_lines;
  73. double preroll;
  74. int duplex_mode;
  75. DecklinkPtsSource audio_pts_source;
  76. DecklinkPtsSource video_pts_source;
  77. int draw_bars;
  78. int frames_preroll;
  79. int frames_buffer;
  80. pthread_mutex_t mutex;
  81. pthread_cond_t cond;
  82. int frames_buffer_available_spots;
  83. int channels;
  84. };
  85. typedef enum { DIRECTION_IN, DIRECTION_OUT} decklink_direction_t;
  86. #ifdef _WIN32
  87. #if BLACKMAGIC_DECKLINK_API_VERSION < 0x0a040000
  88. typedef unsigned long buffercount_type;
  89. #else
  90. typedef unsigned int buffercount_type;
  91. #endif
  92. IDeckLinkIterator *CreateDeckLinkIteratorInstance(void);
  93. #else
  94. typedef uint32_t buffercount_type;
  95. #endif
  96. static const BMDAudioConnection decklink_audio_connection_map[] = {
  97. (BMDAudioConnection)0,
  98. bmdAudioConnectionEmbedded,
  99. bmdAudioConnectionAESEBU,
  100. bmdAudioConnectionAnalog,
  101. bmdAudioConnectionAnalogXLR,
  102. bmdAudioConnectionAnalogRCA,
  103. bmdAudioConnectionMicrophone,
  104. };
  105. static const BMDVideoConnection decklink_video_connection_map[] = {
  106. (BMDVideoConnection)0,
  107. bmdVideoConnectionSDI,
  108. bmdVideoConnectionHDMI,
  109. bmdVideoConnectionOpticalSDI,
  110. bmdVideoConnectionComponent,
  111. bmdVideoConnectionComposite,
  112. bmdVideoConnectionSVideo,
  113. };
  114. HRESULT ff_decklink_get_display_name(IDeckLink *This, const char **displayName);
  115. 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);
  116. int ff_decklink_set_format(AVFormatContext *avctx, decklink_direction_t direction, int num);
  117. int ff_decklink_list_devices(AVFormatContext *avctx);
  118. int ff_decklink_list_formats(AVFormatContext *avctx, decklink_direction_t direction = DIRECTION_OUT);
  119. void ff_decklink_cleanup(AVFormatContext *avctx);
  120. int ff_decklink_init_device(AVFormatContext *avctx, const char* name);
  121. #endif /* AVDEVICE_DECKLINK_COMMON_H */