libavdevice/decklink_common.h
a5e040ee
 /*
  * Blackmagic DeckLink common code
  * Copyright (c) 2013-2014 Ramiro Polla, Luca Barbato, Deti Fliegl
f3913dcc
  * Copyright (c) 2017 Akamai Technologies, Inc.
a5e040ee
  *
  * This file is part of FFmpeg.
  *
  * FFmpeg is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
  *
  * FFmpeg is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with FFmpeg; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
44304ae3
 #ifndef AVDEVICE_DECKLINK_COMMON_H
 #define AVDEVICE_DECKLINK_COMMON_H
 
ce36cb08
 #include <DeckLinkAPIVersion.h>
9c41126e
 
9e86a618
 #include "libavutil/thread.h"
a5e040ee
 #include "decklink_common_c.h"
 
e8e9306b
 #ifdef _WIN32
 #define DECKLINK_BOOL BOOL
 #else
 #define DECKLINK_BOOL bool
 #endif
 
a5e040ee
 class decklink_output_callback;
 class decklink_input_callback;
 
 typedef struct AVPacketQueue {
     AVPacketList *first_pkt, *last_pkt;
     int nb_packets;
     unsigned long long size;
     int abort_request;
     pthread_mutex_t mutex;
     pthread_cond_t cond;
     AVFormatContext *avctx;
f3913dcc
     int64_t max_q_size;
a5e040ee
 } AVPacketQueue;
 
 struct decklink_ctx {
     /* DeckLink SDK interfaces */
     IDeckLink *dl;
     IDeckLinkOutput *dlo;
     IDeckLinkInput *dli;
8f9fa49b
     IDeckLinkConfiguration *cfg;
     IDeckLinkAttributes *attr;
a5e040ee
     decklink_output_callback *output_callback;
     decklink_input_callback *input_callback;
 
     /* DeckLink mode information */
     BMDTimeValue bmd_tb_den;
     BMDTimeValue bmd_tb_num;
     BMDDisplayMode bmd_mode;
da89c6e3
     BMDVideoConnection video_input;
     BMDAudioConnection audio_input;
a5e040ee
     int bmd_width;
     int bmd_height;
     int bmd_field_dominance;
 
     /* Capture buffer queue */
     AVPacketQueue queue;
 
     /* Streams present */
     int audio;
     int video;
 
     /* Status */
     int playback_started;
     int capture_started;
     int64_t last_pts;
     unsigned long frameCount;
     unsigned int dropped;
     AVStream *audio_st;
     AVStream *video_st;
995c7a6f
     AVStream *teletext_st;
a5e040ee
 
     /* Options */
     int list_devices;
     int list_formats;
995c7a6f
     int64_t teletext_lines;
a5e040ee
     double preroll;
8f9fa49b
     int duplex_mode;
cf0a0566
     DecklinkPtsSource audio_pts_source;
     DecklinkPtsSource video_pts_source;
2f3015c2
     int draw_bars;
a5e040ee
 
     int frames_preroll;
     int frames_buffer;
 
9e86a618
     pthread_mutex_t mutex;
     pthread_cond_t cond;
     int frames_buffer_available_spots;
e8e9306b
     int autodetect;
a5e040ee
 
     int channels;
89cc4855
     int audio_depth;
a5e040ee
 };
 
 typedef enum { DIRECTION_IN, DIRECTION_OUT} decklink_direction_t;
 
 #ifdef _WIN32
9c41126e
 #if BLACKMAGIC_DECKLINK_API_VERSION < 0x0a040000
a5e040ee
 typedef unsigned long buffercount_type;
9c41126e
 #else
 typedef unsigned int buffercount_type;
 #endif
a5e040ee
 IDeckLinkIterator *CreateDeckLinkIteratorInstance(void);
 #else
 typedef uint32_t buffercount_type;
 #endif
 
da89c6e3
 static const BMDAudioConnection decklink_audio_connection_map[] = {
b18d6c58
     (BMDAudioConnection)0,
da89c6e3
     bmdAudioConnectionEmbedded,
     bmdAudioConnectionAESEBU,
     bmdAudioConnectionAnalog,
     bmdAudioConnectionAnalogXLR,
     bmdAudioConnectionAnalogRCA,
     bmdAudioConnectionMicrophone,
 };
 
 static const BMDVideoConnection decklink_video_connection_map[] = {
b18d6c58
     (BMDVideoConnection)0,
da89c6e3
     bmdVideoConnectionSDI,
     bmdVideoConnectionHDMI,
     bmdVideoConnectionOpticalSDI,
     bmdVideoConnectionComponent,
     bmdVideoConnectionComposite,
     bmdVideoConnectionSVideo,
 };
a5e040ee
 
 HRESULT ff_decklink_get_display_name(IDeckLink *This, const char **displayName);
aa7b0329
 int ff_decklink_set_configs(AVFormatContext *avctx, decklink_direction_t direction);
48f8ad32
 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);
a5e040ee
 int ff_decklink_set_format(AVFormatContext *avctx, decklink_direction_t direction, int num);
278588cd
 int ff_decklink_list_devices(AVFormatContext *avctx, struct AVDeviceInfoList *device_list, int show_inputs, int show_outputs);
 void ff_decklink_list_devices_legacy(AVFormatContext *avctx, int show_inputs, int show_outputs);
a5e040ee
 int ff_decklink_list_formats(AVFormatContext *avctx, decklink_direction_t direction = DIRECTION_OUT);
1fc85d85
 void ff_decklink_cleanup(AVFormatContext *avctx);
38d75fe9
 int ff_decklink_init_device(AVFormatContext *avctx, const char* name);
a5e040ee
 
44a50fee
 #endif /* AVDEVICE_DECKLINK_COMMON_H */