Add more consts

Some decoder and recorder functions must not write to AVCodec and
AVPacket.
This commit is contained in:
Romain Vimont 2019-03-03 11:59:31 +01:00
parent f7efafd846
commit a7b3901c31
4 changed files with 7 additions and 7 deletions

View file

@ -39,7 +39,7 @@ decoder_init(struct decoder *decoder, struct video_buffer *vb) {
} }
bool bool
decoder_open(struct decoder *decoder, AVCodec *codec) { decoder_open(struct decoder *decoder, const AVCodec *codec) {
decoder->codec_ctx = avcodec_alloc_context3(codec); decoder->codec_ctx = avcodec_alloc_context3(codec);
if (!decoder->codec_ctx) { if (!decoder->codec_ctx) {
LOGC("Could not allocate decoder context"); LOGC("Could not allocate decoder context");
@ -62,7 +62,7 @@ decoder_close(struct decoder *decoder) {
} }
bool bool
decoder_push(struct decoder *decoder, AVPacket *packet) { decoder_push(struct decoder *decoder, const AVPacket *packet) {
// the new decoding/encoding API has been introduced by: // the new decoding/encoding API has been introduced by:
// <http://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=7fc329e2dd6226dfecaa4a1d7adf353bf2773726> // <http://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=7fc329e2dd6226dfecaa4a1d7adf353bf2773726>
#ifdef SCRCPY_LAVF_HAS_NEW_ENCODING_DECODING_API #ifdef SCRCPY_LAVF_HAS_NEW_ENCODING_DECODING_API

View file

@ -15,13 +15,13 @@ void
decoder_init(struct decoder *decoder, struct video_buffer *vb); decoder_init(struct decoder *decoder, struct video_buffer *vb);
bool bool
decoder_open(struct decoder *decoder, AVCodec *codec); decoder_open(struct decoder *decoder, const AVCodec *codec);
void void
decoder_close(struct decoder *decoder); decoder_close(struct decoder *decoder);
bool bool
decoder_push(struct decoder *decoder, AVPacket *packet); decoder_push(struct decoder *decoder, const AVPacket *packet);
void void
decoder_interrupt(struct decoder *decoder); decoder_interrupt(struct decoder *decoder);

View file

@ -59,7 +59,7 @@ recorder_get_format_name(enum recorder_format format) {
} }
bool bool
recorder_open(struct recorder *recorder, AVCodec *input_codec) { recorder_open(struct recorder *recorder, const AVCodec *input_codec) {
const char *format_name = recorder_get_format_name(recorder->format); const char *format_name = recorder_get_format_name(recorder->format);
SDL_assert(format_name); SDL_assert(format_name);
const AVOutputFormat *format = find_muxer(format_name); const AVOutputFormat *format = find_muxer(format_name);
@ -128,7 +128,7 @@ recorder_close(struct recorder *recorder) {
} }
static bool static bool
recorder_write_header(struct recorder *recorder, AVPacket *packet) { recorder_write_header(struct recorder *recorder, const AVPacket *packet) {
AVStream *ostream = recorder->ctx->streams[0]; AVStream *ostream = recorder->ctx->streams[0];
uint8_t *extradata = av_malloc(packet->size * sizeof(uint8_t)); uint8_t *extradata = av_malloc(packet->size * sizeof(uint8_t));

View file

@ -27,7 +27,7 @@ void
recorder_destroy(struct recorder *recorder); recorder_destroy(struct recorder *recorder);
bool bool
recorder_open(struct recorder *recorder, AVCodec *input_codec); recorder_open(struct recorder *recorder, const AVCodec *input_codec);
void void
recorder_close(struct recorder *recorder); recorder_close(struct recorder *recorder);