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.

110 lines
3.0KB

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