| 805 | } |
| 806 | |
| 807 | static int decklink_write_audio_packet(AVFormatContext *avctx, AVPacket *pkt) |
| 808 | { |
| 809 | struct decklink_cctx *cctx = (struct decklink_cctx *)avctx->priv_data; |
| 810 | struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx; |
| 811 | AVStream *st = avctx->streams[pkt->stream_index]; |
| 812 | int sample_count; |
| 813 | uint32_t buffered; |
| 814 | uint8_t *outbuf = NULL; |
| 815 | int ret = 0; |
| 816 | |
| 817 | ctx->dlo->GetBufferedAudioSampleFrameCount(&buffered); |
| 818 | if (pkt->pts > 1 && !buffered) |
| 819 | av_log(avctx, AV_LOG_WARNING, "There's no buffered audio." |
| 820 | " Audio will misbehave!\n"); |
| 821 | |
| 822 | if (st->codecpar->codec_id == AV_CODEC_ID_AC3) { |
| 823 | /* Encapsulate AC3 syncframe into SMPTE 337 packet */ |
| 824 | int outbuf_size; |
| 825 | ret = create_s337_payload(pkt, &outbuf, &outbuf_size); |
| 826 | if (ret < 0) |
| 827 | return ret; |
| 828 | sample_count = outbuf_size / 4; |
| 829 | } else { |
| 830 | sample_count = pkt->size / (ctx->channels << 1); |
| 831 | outbuf = pkt->data; |
| 832 | } |
| 833 | |
| 834 | if (ctx->dlo->ScheduleAudioSamples(outbuf, sample_count, pkt->pts, |
| 835 | bmdAudioSampleRate48kHz, NULL) != S_OK) { |
| 836 | av_log(avctx, AV_LOG_ERROR, "Could not schedule audio samples.\n"); |
| 837 | ret = AVERROR(EIO); |
| 838 | } |
| 839 | |
| 840 | if (st->codecpar->codec_id == AV_CODEC_ID_AC3) |
| 841 | av_freep(&outbuf); |
| 842 | |
| 843 | return ret; |
| 844 | } |
| 845 | |
| 846 | static int decklink_write_subtitle_packet(AVFormatContext *avctx, AVPacket *pkt) |
| 847 | { |
no test coverage detected