39 NDIlib_recv_create_t *
recv;
58 av_log(avctx,
AV_LOG_DEBUG,
"%s: pkt->dts = pkt->pts = %"PRId64
", duration=%"PRId64
", timecode=%"PRId64
"\n",
64 memcpy(pkt->
data, v->p_data, pkt->
size);
74 NDIlib_audio_frame_interleaved_16s_t dst;
83 av_log(avctx,
AV_LOG_DEBUG,
"%s: pkt->dts = pkt->pts = %"PRId64
", duration=%"PRId64
", timecode=%"PRId64
"\n",
89 dst.reference_level = 0;
90 dst.p_data = (
short *)pkt->
data;
91 NDIlib_util_audio_to_interleaved_16s(a, &dst);
101 const NDIlib_source_t *ndi_srcs =
NULL;
102 const NDIlib_find_create_t find_create_desc = { .show_local_sources =
true,
106 ctx->
ndi_find = NDIlib_find_create2(&find_create_desc);
116 f = NDIlib_find_wait_for_sources(ctx->
ndi_find, t);
122 ndi_srcs = NDIlib_find_get_current_sources(ctx->
ndi_find, &n);
127 for (i = 0; i <
n; i++) {
129 av_log(avctx,
AV_LOG_INFO,
"\t'%s'\t'%s'\n", ndi_srcs[i].p_ndi_name, ndi_srcs[i].p_ip_address);
131 if (!strcmp(name, ndi_srcs[i].p_ndi_name)) {
132 *source_to_connect_to = ndi_srcs[i];
143 NDIlib_recv_create_t recv_create_desc;
144 const NDIlib_tally_t tally_state = { .on_program =
true, .on_preview =
false };
147 if (!NDIlib_initialize()) {
161 recv_create_desc.color_format = NDIlib_recv_color_format_e_UYVY_RGBA;
162 recv_create_desc.bandwidth = NDIlib_recv_bandwidth_highest;
166 ctx->
recv = NDIlib_recv_create(&recv_create_desc);
173 NDIlib_recv_set_tally(ctx->
recv, &tally_state);
207 if (NDIlib_FourCC_type_UYVY == v->FourCC || NDIlib_FourCC_type_UYVA == v->FourCC) {
210 if (NDIlib_FourCC_type_UYVA == v->FourCC)
212 }
else if (NDIlib_FourCC_type_BGRA == v->FourCC) {
215 }
else if (NDIlib_FourCC_type_BGRX == v->FourCC) {
218 }
else if (NDIlib_FourCC_type_RGBA == v->FourCC) {
221 }
else if (NDIlib_FourCC_type_RGBX == v->FourCC) {
225 av_log(avctx,
AV_LOG_ERROR,
"Unsupported video stream format, v->FourCC=%d\n", v->FourCC);
265 NDIlib_video_frame_t v;
266 NDIlib_audio_frame_t
a;
267 NDIlib_metadata_frame_t m;
268 NDIlib_frame_type_e t;
271 t = NDIlib_recv_capture(ctx->
recv, &v, &a, &m, 40);
274 if (t == NDIlib_frame_type_video) {
279 NDIlib_recv_free_video(ctx->
recv, &v);
282 else if (t == NDIlib_frame_type_audio) {
287 NDIlib_recv_free_audio(ctx->
recv, &a);
290 else if (t == NDIlib_frame_type_metadata)
291 NDIlib_recv_free_metadata(ctx->
recv, &m);
292 else if (t == NDIlib_frame_type_error){
306 NDIlib_recv_destroy(ctx->
recv);
314 #define OFFSET(x) offsetof(struct NDIContext, x) 315 #define DEC AV_OPT_FLAG_DECODING_PARAM 334 .
name =
"libndi_newtek",
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
enum AVFieldOrder field_order
Video only.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define LIBAVUTIL_VERSION_INT
AVRational sample_aspect_ratio
Video only.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
int index
stream index in AVFormatContext
const char * av_default_item_name(void *ptr)
Return the context name.
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
static const AVOption options[]
int ctx_flags
Flags signalling stream properties.
static int ndi_read_packet(AVFormatContext *avctx, AVPacket *pkt)
AVInputFormat ff_libndi_newtek_demuxer
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
static int ndi_read_header(AVFormatContext *avctx)
NDIlib_recv_create_t * recv
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
char * url
input or output URL.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
enum AVMediaType codec_type
General type of the encoded data.
static int ndi_create_video_stream(AVFormatContext *avctx, NDIlib_video_frame_t *v)
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
int flags
A combination of AV_PKT_FLAG values.
static int ndi_read_close(AVFormatContext *avctx)
NDIlib_find_instance_t ndi_find
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
static const AVClass libndi_newtek_demuxer_class
static int ndi_find_sources(AVFormatContext *avctx, const char *name, NDIlib_source_t *source_to_connect_to)
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
#define AV_LOG_INFO
Standard information.
static AVRational av_make_q(int num, int den)
Create an AVRational.
Describe the class of an AVClass context structure.
static int ndi_create_audio_stream(AVFormatContext *avctx, NDIlib_audio_frame_t *a)
Rational number (pair of numerator and denominator).
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
static int ndi_set_video_packet(AVFormatContext *avctx, NDIlib_video_frame_t *v, AVPacket *pkt)
static int ndi_set_audio_packet(AVFormatContext *avctx, NDIlib_audio_frame_t *a, AVPacket *pkt)
AVRational av_d2q(double d, int max)
Convert a double precision floating point number to a rational.
int sample_rate
Audio only.
void * priv_data
Format private data.
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later.That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another.Frame references ownership and permissions
#define MKTAG(a, b, c, d)
AVRational r_frame_rate
Real base framerate of the stream.
#define AVERROR_EXTERNAL
Generic error in an external library.
This structure stores compressed data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...