libndi.h 2.5 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
libndi.h
Copyright (C) 2020 VideoLAN

This library 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.

This library 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 this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
*/

#ifndef LIBNDI_LIBNDI_H
#define LIBNDI_LIBNDI_H

#include <libavutil/buffer.h>

typedef struct ndi_ctx ndi_ctx;

ndi_ctx *libndi_init(void);

enum ndi_data_type
{
    NDI_DATA_VIDEO,
    NDI_DATA_AUDIO,
    NDI_DATA_TEXT
};

36
37
38
39
40
41
42
typedef enum ndi_tally_state
{
    NDI_TALLY_NONE = 0,
    NDI_TALLY_PREVIEW,
    NDI_TALLY_LIVE
} ndi_tally_state_t;

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#define NDI_NUM_DATA_POINTERS 16

typedef struct
{
    int data_type;

    /* Common */
    uint32_t fourcc;

    /* Video */
    uint8_t *data;
    int len;

    int fps_num;
    int fps_den;

    int width;
    int height;

    int picture_structure;

    /* Audio */
    AVBufferRef *buf[NDI_NUM_DATA_POINTERS];
    int samples;
    int num_channels;
    int sample_rate;
} ndi_data;

/* Discovery API */
typedef struct ndi_discovery_ctx ndi_discovery_ctx_t;
typedef struct ndi_discovery_item {
    char *name;
    char *ip;
    char *port;
} ndi_discovery_item_t;

static inline void libndi_discovery_item_destroy(ndi_discovery_item_t *item) {
    free(item->name);
    free(item->ip);
    free(item->port);
    free(item);
}

86
typedef void (*ndi_discovery_cb)(ndi_discovery_item_t *item, void *user_data);
87

88
ndi_discovery_ctx_t *libndi_discovery_init(ndi_discovery_cb callback, void *user_data);
89
90
91
92
93
94
95
96
97
98
int libndi_discovery_start(ndi_discovery_ctx_t *ctx);
int libndi_discovery_stop(ndi_discovery_ctx_t *ctx);
void libndi_discovery_destroy(ndi_discovery_ctx_t *ctx);

void libndi_list_sources(ndi_ctx *ndi_ctx);

typedef struct
{
    char *ip;
    char *port;
99
    ndi_tally_state_t initial_tally_state;
100
101
102
103
} ndi_opts;

int libndi_setup(ndi_ctx *ndi_ctx, ndi_opts *ndi_opts);

104
105
typedef void (*ndi_data_cb)(ndi_data *ndi_data, void *user_data);
void libndi_receive_data(ndi_ctx *ndi_ctx, ndi_data_cb callback, void *user_data);
106
107
108
109

void libndi_close(ndi_ctx *ndi_ctx);

#endif