Skip to content

Commit

Permalink
Bugfix: Closes#1072412: Fix build with FFmpeg 7.0. write_packet() now…
Browse files Browse the repository at this point in the history
… with const buffer as of Libavformat 61+.
  • Loading branch information
nschlia committed Jun 10, 2024
1 parent dc02031 commit 288b745
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
5 changes: 3 additions & 2 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
FFmpegfs NEWS

Work on 2.16 in progress (2024-02-XX):
Important changes in 2.16 (2024-06-XX):

Coming soon...
* Bugfix: Closes#1072412: Fix build with FFmpeg 7.0. write_packet() now with
const buffer as of Libavformat 61+.

Important changes in 2.15 (2024-02-03):

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ A Windows version of FFmpegfs has frequently been requested; see issue [#76](htt

To see what's been done so far, checkout the [windows](https://github.com/nschlia/ffmpegfs/tree/windows) branch.

**Work on 2.16 in progress (2024-02-XX):**
**New in 2.16 (2024-06-XX):**

Coming soon...
- Bugfix: Closes [#160](https://github.com/nschlia/ffmpegfs/issues/160): Fix build with FFmpeg 7.0. [Debian Bug #1072412](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1072412). write_packet() now with const buffer as of Libavformat 61+.

**New in 2.15 (2024-02-03):**

Expand Down
6 changes: 6 additions & 0 deletions src/ffmpeg_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,12 @@
* as they are redundant with parsers.
*/
#define LAVC_DEP_FLAG_TRUNCATED (LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(59, 8, 0))
/**
* 2023-09-07 - 2a68d945cd7 - lavf 60.12.100 - avio.h
* Constify the buffer pointees in the write_packet and write_data_type
* callbacks of AVIOContext on the next major bump.
*/
#define LAVF_WRITEPACKET_CONST (LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(61, 0, 0))

/**
* 2023-05-xx - xxxxxxxxxx - lavc 60 - avcodec.h
Expand Down
8 changes: 8 additions & 0 deletions src/ffmpeg_transcoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6231,7 +6231,11 @@ int FFmpeg_Transcoder::input_read(void * opaque, unsigned char * data, int size)
return read;
}

#if LAVF_WRITEPACKET_CONST
int FFmpeg_Transcoder::output_write(void * opaque, const uint8_t * data, int size)
#else
int FFmpeg_Transcoder::output_write(void * opaque, unsigned char * data, int size)
#endif
{
Buffer * buffer = static_cast<Buffer *>(opaque);

Expand All @@ -6241,7 +6245,11 @@ int FFmpeg_Transcoder::output_write(void * opaque, unsigned char * data, int siz
return AVERROR(EINVAL);
}

#if LAVF_WRITEPACKET_CONST
int written = static_cast<int>(buffer->writeio(data, static_cast<size_t>(size)));
#else
int written = static_cast<int>(buffer->writeio(static_cast<const uint8_t*>(data), static_cast<size_t>(size)));
#endif
if (written != size)
{
// Write error
Expand Down
4 changes: 4 additions & 0 deletions src/ffmpeg_transcoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,11 @@ class FFmpeg_Transcoder : public FFmpeg_Base, FFmpeg_Profiles
* @param[in] size - Size of data block.
* @return On success, returns bytes written. On error, returns a negative AVERROR value.
*/
#if LAVF_WRITEPACKET_CONST
static int output_write(void * opaque, const uint8_t * data, int size);
#else
static int output_write(void * opaque, unsigned char * data, int size);
#endif
/**
* @brief Custom seek function for FFmpeg
*
Expand Down

0 comments on commit 288b745

Please sign in to comment.