]> git.sesse.net Git - ffmpeg/blob - libavdevice/decklink_common.h
Merge commit '58c3720a3cc71142b5d48d8ccdc9213f9a66cd33'
[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 #include <DeckLinkAPIVersion.h>
23
24 #include "decklink_common_c.h"
25
26 class decklink_output_callback;
27 class decklink_input_callback;
28
29 typedef struct AVPacketQueue {
30     AVPacketList *first_pkt, *last_pkt;
31     int nb_packets;
32     unsigned long long size;
33     int abort_request;
34     pthread_mutex_t mutex;
35     pthread_cond_t cond;
36     AVFormatContext *avctx;
37 } AVPacketQueue;
38
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
47     /* DeckLink mode information */
48     BMDTimeValue bmd_tb_den;
49     BMDTimeValue bmd_tb_num;
50     BMDDisplayMode bmd_mode;
51     int bmd_width;
52     int bmd_height;
53     int bmd_field_dominance;
54
55     /* Capture buffer queue */
56     AVPacketQueue queue;
57
58     /* Streams present */
59     int audio;
60     int video;
61
62     /* Status */
63     int playback_started;
64     int capture_started;
65     int64_t last_pts;
66     unsigned long frameCount;
67     unsigned int dropped;
68     AVStream *audio_st;
69     AVStream *video_st;
70
71     /* Options */
72     int list_devices;
73     int list_formats;
74     double preroll;
75
76     int frames_preroll;
77     int frames_buffer;
78
79     sem_t semaphore;
80
81     int channels;
82 };
83
84 typedef enum { DIRECTION_IN, DIRECTION_OUT} decklink_direction_t;
85
86 #ifdef _WIN32
87 #if BLACKMAGIC_DECKLINK_API_VERSION < 0x0a040000
88 typedef unsigned long buffercount_type;
89 #else
90 typedef unsigned int buffercount_type;
91 #endif
92 IDeckLinkIterator *CreateDeckLinkIteratorInstance(void);
93 #else
94 typedef uint32_t buffercount_type;
95 #endif
96
97
98 HRESULT ff_decklink_get_display_name(IDeckLink *This, const char **displayName);
99 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);
100 int ff_decklink_set_format(AVFormatContext *avctx, decklink_direction_t direction, int num);
101 int ff_decklink_list_devices(AVFormatContext *avctx);
102 int ff_decklink_list_formats(AVFormatContext *avctx, decklink_direction_t direction = DIRECTION_OUT);
103