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.

104 lines
2.9KB

  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 <DeckLinkAPIVersion.h>
  22. #include "decklink_common_c.h"
  23. class decklink_output_callback;
  24. class decklink_input_callback;
  25. typedef struct AVPacketQueue {
  26. AVPacketList *first_pkt, *last_pkt;
  27. int nb_packets;
  28. unsigned long long size;
  29. int abort_request;
  30. pthread_mutex_t mutex;
  31. pthread_cond_t cond;
  32. AVFormatContext *avctx;
  33. } AVPacketQueue;
  34. struct decklink_ctx {
  35. /* DeckLink SDK interfaces */
  36. IDeckLink *dl;
  37. IDeckLinkOutput *dlo;
  38. IDeckLinkInput *dli;
  39. decklink_output_callback *output_callback;
  40. decklink_input_callback *input_callback;
  41. /* DeckLink mode information */
  42. BMDTimeValue bmd_tb_den;
  43. BMDTimeValue bmd_tb_num;
  44. BMDDisplayMode bmd_mode;
  45. int bmd_width;
  46. int bmd_height;
  47. int bmd_field_dominance;
  48. /* Capture buffer queue */
  49. AVPacketQueue queue;
  50. /* Streams present */
  51. int audio;
  52. int video;
  53. /* Status */
  54. int playback_started;
  55. int capture_started;
  56. int64_t last_pts;
  57. unsigned long frameCount;
  58. unsigned int dropped;
  59. AVStream *audio_st;
  60. AVStream *video_st;
  61. /* Options */
  62. int list_devices;
  63. int list_formats;
  64. double preroll;
  65. int frames_preroll;
  66. int frames_buffer;
  67. sem_t semaphore;
  68. int channels;
  69. };
  70. typedef enum { DIRECTION_IN, DIRECTION_OUT} decklink_direction_t;
  71. #ifdef _WIN32
  72. #if BLACKMAGIC_DECKLINK_API_VERSION < 0x0a040000
  73. typedef unsigned long buffercount_type;
  74. #else
  75. typedef unsigned int buffercount_type;
  76. #endif
  77. IDeckLinkIterator *CreateDeckLinkIteratorInstance(void);
  78. #else
  79. typedef uint32_t buffercount_type;
  80. #endif
  81. HRESULT ff_decklink_get_display_name(IDeckLink *This, const char **displayName);
  82. 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);
  83. int ff_decklink_set_format(AVFormatContext *avctx, decklink_direction_t direction, int num);
  84. int ff_decklink_list_devices(AVFormatContext *avctx);
  85. int ff_decklink_list_formats(AVFormatContext *avctx, decklink_direction_t direction = DIRECTION_OUT);