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