#ifndef _AUDIO_ENCODER_H
#define _AUDIO_ENCODER_H 1
+#include <assert.h>
#include <stddef.h>
#include <stdint.h>
#include <string>
extern "C" {
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
-#include <libavresample/avresample.h>
+#include <libswresample/swresample.h>
#include <libavutil/frame.h>
}
-#include "ffmpeg_raii.h"
+#include "shared/ffmpeg_raii.h"
class Mux;
~AudioEncoder();
void add_mux(Mux *mux) { // Does not take ownership.
+ assert(mux != nullptr);
muxes.push_back(mux);
}
void encode_audio(const std::vector<float> &audio, int64_t audio_pts);
void encode_last_audio();
+ const AVCodec *get_codec() const { return ctx->codec; }
AVCodecParametersWithDeleter get_codec_parameters();
private:
int64_t last_pts = 0; // The first pts after all audio we've encoded.
AVCodecContext *ctx;
- AVAudioResampleContext *resampler;
+ SwrContext *resampler;
AVFrame *audio_frame = nullptr;
std::vector<Mux *> muxes;
};