2014-09-21 23:39:50 +00:00
|
|
|
/*
|
|
|
|
* Blackmagic DeckLink common code
|
|
|
|
* Copyright (c) 2013-2014 Ramiro Polla, Luca Barbato, Deti Fliegl
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2016-01-29 02:00:33 +00:00
|
|
|
#ifndef AVDEVICE_DECKLINK_COMMON_H
|
|
|
|
#define AVDEVICE_DECKLINK_COMMON_H
|
|
|
|
|
2016-01-24 20:42:39 +00:00
|
|
|
#include <DeckLinkAPIVersion.h>
|
2015-07-19 19:32:49 +00:00
|
|
|
|
2014-09-21 23:39:50 +00:00
|
|
|
#include "decklink_common_c.h"
|
|
|
|
|
|
|
|
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;
|
|
|
|
} AVPacketQueue;
|
|
|
|
|
|
|
|
struct decklink_ctx {
|
|
|
|
/* DeckLink SDK interfaces */
|
|
|
|
IDeckLink *dl;
|
|
|
|
IDeckLinkOutput *dlo;
|
|
|
|
IDeckLinkInput *dli;
|
2016-06-11 11:41:29 +00:00
|
|
|
IDeckLinkConfiguration *cfg;
|
|
|
|
IDeckLinkAttributes *attr;
|
2014-09-21 23:39:50 +00:00
|
|
|
decklink_output_callback *output_callback;
|
|
|
|
decklink_input_callback *input_callback;
|
|
|
|
|
|
|
|
/* DeckLink mode information */
|
|
|
|
BMDTimeValue bmd_tb_den;
|
|
|
|
BMDTimeValue bmd_tb_num;
|
|
|
|
BMDDisplayMode bmd_mode;
|
2016-06-18 10:04:15 +00:00
|
|
|
BMDVideoConnection video_input;
|
|
|
|
BMDAudioConnection audio_input;
|
2014-09-21 23:39:50 +00:00
|
|
|
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;
|
2016-01-12 02:09:37 +00:00
|
|
|
AVStream *teletext_st;
|
2014-09-21 23:39:50 +00:00
|
|
|
|
|
|
|
/* Options */
|
|
|
|
int list_devices;
|
|
|
|
int list_formats;
|
2016-01-12 02:09:37 +00:00
|
|
|
int64_t teletext_lines;
|
2014-09-21 23:39:50 +00:00
|
|
|
double preroll;
|
2016-06-11 11:41:29 +00:00
|
|
|
int duplex_mode;
|
2016-06-18 22:35:44 +00:00
|
|
|
DecklinkPtsSource audio_pts_source;
|
|
|
|
DecklinkPtsSource video_pts_source;
|
2016-10-13 21:56:45 +00:00
|
|
|
int draw_bars;
|
2014-09-21 23:39:50 +00:00
|
|
|
|
|
|
|
int frames_preroll;
|
|
|
|
int frames_buffer;
|
|
|
|
|
|
|
|
sem_t semaphore;
|
|
|
|
|
|
|
|
int channels;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef enum { DIRECTION_IN, DIRECTION_OUT} decklink_direction_t;
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
2015-07-19 19:32:49 +00:00
|
|
|
#if BLACKMAGIC_DECKLINK_API_VERSION < 0x0a040000
|
2014-09-21 23:39:50 +00:00
|
|
|
typedef unsigned long buffercount_type;
|
2015-07-19 19:32:49 +00:00
|
|
|
#else
|
|
|
|
typedef unsigned int buffercount_type;
|
|
|
|
#endif
|
2014-09-21 23:39:50 +00:00
|
|
|
IDeckLinkIterator *CreateDeckLinkIteratorInstance(void);
|
|
|
|
#else
|
|
|
|
typedef uint32_t buffercount_type;
|
|
|
|
#endif
|
|
|
|
|
2016-06-18 10:04:15 +00:00
|
|
|
static const BMDAudioConnection decklink_audio_connection_map[] = {
|
2016-06-26 23:11:50 +00:00
|
|
|
(BMDAudioConnection)0,
|
2016-06-18 10:04:15 +00:00
|
|
|
bmdAudioConnectionEmbedded,
|
|
|
|
bmdAudioConnectionAESEBU,
|
|
|
|
bmdAudioConnectionAnalog,
|
|
|
|
bmdAudioConnectionAnalogXLR,
|
|
|
|
bmdAudioConnectionAnalogRCA,
|
|
|
|
bmdAudioConnectionMicrophone,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const BMDVideoConnection decklink_video_connection_map[] = {
|
2016-06-26 23:11:50 +00:00
|
|
|
(BMDVideoConnection)0,
|
2016-06-18 10:04:15 +00:00
|
|
|
bmdVideoConnectionSDI,
|
|
|
|
bmdVideoConnectionHDMI,
|
|
|
|
bmdVideoConnectionOpticalSDI,
|
|
|
|
bmdVideoConnectionComponent,
|
|
|
|
bmdVideoConnectionComposite,
|
|
|
|
bmdVideoConnectionSVideo,
|
|
|
|
};
|
2014-09-21 23:39:50 +00:00
|
|
|
|
|
|
|
HRESULT ff_decklink_get_display_name(IDeckLink *This, const char **displayName);
|
2017-02-18 01:33:05 +00:00
|
|
|
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);
|
2014-09-21 23:39:50 +00:00
|
|
|
int ff_decklink_set_format(AVFormatContext *avctx, decklink_direction_t direction, int num);
|
|
|
|
int ff_decklink_list_devices(AVFormatContext *avctx);
|
|
|
|
int ff_decklink_list_formats(AVFormatContext *avctx, decklink_direction_t direction = DIRECTION_OUT);
|
2016-06-18 13:49:01 +00:00
|
|
|
void ff_decklink_cleanup(AVFormatContext *avctx);
|
2016-06-18 14:55:47 +00:00
|
|
|
int ff_decklink_init_device(AVFormatContext *avctx, const char* name);
|
2014-09-21 23:39:50 +00:00
|
|
|
|
2016-01-29 11:49:46 +00:00
|
|
|
#endif /* AVDEVICE_DECKLINK_COMMON_H */
|