| 868 | extern "C" { |
| 869 | |
| 870 | av_cold int ff_decklink_write_header(AVFormatContext *avctx) |
| 871 | { |
| 872 | struct decklink_cctx *cctx = (struct decklink_cctx *)avctx->priv_data; |
| 873 | struct decklink_ctx *ctx; |
| 874 | unsigned int n; |
| 875 | int ret; |
| 876 | |
| 877 | ctx = (struct decklink_ctx *) av_mallocz(sizeof(struct decklink_ctx)); |
| 878 | if (!ctx) |
| 879 | return AVERROR(ENOMEM); |
| 880 | ctx->list_devices = cctx->list_devices; |
| 881 | ctx->list_formats = cctx->list_formats; |
| 882 | ctx->preroll = cctx->preroll; |
| 883 | ctx->duplex_mode = cctx->duplex_mode; |
| 884 | ctx->first_pts = AV_NOPTS_VALUE; |
| 885 | if (cctx->link > 0 && (unsigned int)cctx->link < FF_ARRAY_ELEMS(decklink_link_conf_map)) |
| 886 | ctx->link = decklink_link_conf_map[cctx->link]; |
| 887 | cctx->ctx = ctx; |
| 888 | #if CONFIG_LIBKLVANC |
| 889 | if (klvanc_context_create(&ctx->vanc_ctx) < 0) { |
| 890 | av_log(avctx, AV_LOG_ERROR, "Cannot create VANC library context\n"); |
| 891 | return AVERROR(ENOMEM); |
| 892 | } |
| 893 | ctx->supports_vanc = 1; |
| 894 | #endif |
| 895 | |
| 896 | /* List available devices and exit. */ |
| 897 | if (ctx->list_devices) { |
| 898 | ff_decklink_list_devices_legacy(avctx, 0, 1); |
| 899 | return AVERROR_EXIT; |
| 900 | } |
| 901 | |
| 902 | ret = ff_decklink_init_device(avctx, avctx->url); |
| 903 | if (ret < 0) |
| 904 | return ret; |
| 905 | |
| 906 | /* Get output device. */ |
| 907 | if (ctx->dl->QueryInterface(IID_IDeckLinkOutput_v14_2_1, (void **) &ctx->dlo) != S_OK) { |
| 908 | av_log(avctx, AV_LOG_ERROR, "Could not open output device from '%s'\n", |
| 909 | avctx->url); |
| 910 | ret = AVERROR(EIO); |
| 911 | goto error; |
| 912 | } |
| 913 | |
| 914 | /* List supported formats. */ |
| 915 | if (ctx->list_formats) { |
| 916 | ff_decklink_list_formats(avctx); |
| 917 | ret = AVERROR_EXIT; |
| 918 | goto error; |
| 919 | } |
| 920 | |
| 921 | /* Setup streams. */ |
| 922 | ret = AVERROR(EIO); |
| 923 | for (n = 0; n < avctx->nb_streams; n++) { |
| 924 | AVStream *st = avctx->streams[n]; |
| 925 | AVCodecParameters *c = st->codecpar; |
| 926 | if (c->codec_type == AVMEDIA_TYPE_AUDIO) { |
| 927 | if (decklink_setup_audio(avctx, st)) |
nothing calls this directly
no test coverage detected