MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / decklink_write_audio_packet

Function decklink_write_audio_packet

libavdevice/decklink_enc.cpp:807–844  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

805}
806
807static 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
846static int decklink_write_subtitle_packet(AVFormatContext *avctx, AVPacket *pkt)
847{

Callers 1

ff_decklink_write_packetFunction · 0.85

Calls 3

av_logFunction · 0.85
create_s337_payloadFunction · 0.85
av_freepFunction · 0.85

Tested by

no test coverage detected