Permalink
Browse files

Using AVFormatContext->file_size is deprecated, use avio_size() instead

Fixes xbmc#437
  • Loading branch information...
tru committed Jan 18, 2013
1 parent 55fe370 commit fa31770c8ced06acdf2b9898d73332944b7a7a74
Showing with 18 additions and 2 deletions.
  1. +14 −0 lib/DllAvFormat.h
  2. +4 −2 xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
@@ -98,6 +98,10 @@ class DllAvFormatInterface
virtual int avformat_write_header (AVFormatContext *s, AVDictionary **options)=0;
virtual int av_write_trailer(AVFormatContext *s)=0;
virtual int av_write_frame (AVFormatContext *s, AVPacket *pkt)=0;
/* PLEX */
virtual int64_t avio_size(AVIOContext *s)=0;
/* END PLEX */
};
#if (defined USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN)
@@ -154,6 +158,10 @@ class DllAvFormat : public DllDynamic, DllAvFormatInterface
virtual int av_write_trailer(AVFormatContext *s) { return ::av_write_trailer(s); }
virtual int av_write_frame (AVFormatContext *s, AVPacket *pkt) { return ::av_write_frame(s, pkt); }
/* PLEX */
virtual int64_t avio_size(AVIOContext *s) { return ::avio_size(s); }
/* END PLEX */
// DLL faking.
virtual bool ResolveExports() { return true; }
virtual bool Load() {
@@ -209,6 +217,9 @@ class DllAvFormat : public DllDynamic, DllAvFormatInterface
DEFINE_METHOD2(int, avformat_write_header , (AVFormatContext *p1, AVDictionary **p2))
DEFINE_METHOD1(int, av_write_trailer, (AVFormatContext *p1))
DEFINE_METHOD2(int, av_write_frame , (AVFormatContext *p1, AVPacket *p2))
/* PLEX */
DEFINE_METHOD1(int64_t, avio_size, (AVIOContext *s))
/* END PLEX */
BEGIN_METHOD_RESOLVE()
RESOLVE_METHOD_RENAME(av_register_all, av_register_all_dont_call)
RESOLVE_METHOD(av_find_input_format)
@@ -243,6 +254,9 @@ class DllAvFormat : public DllDynamic, DllAvFormatInterface
RESOLVE_METHOD(avformat_write_header)
RESOLVE_METHOD(av_write_trailer)
RESOLVE_METHOD(av_write_frame)
/* PLEX */
RESOLVE_METHOD(avio_size)
/* END PLEX */
END_METHOD_RESOLVE()
/* dependencies of libavformat */
@@ -1373,10 +1373,12 @@ int CDVDDemuxFFmpeg::GetStreamBitrate()
missingStreamInfo = true;
}
if (overallBitrate == 0 && aggregateBitrate == 0 && m_pFormatContext->file_size > 0 && m_pFormatContext->duration != (uint32_t)AV_NOPTS_VALUE)
int64_t fileSize = m_dllAvFormat.avio_size(m_pFormatContext->pb);
if (overallBitrate == 0 && aggregateBitrate == 0 && fileSize > 0 && m_pFormatContext->duration != (uint32_t)AV_NOPTS_VALUE)
{
int64_t seconds = m_pFormatContext->duration / AV_TIME_BASE;
int bitsPerSecond = (int)(m_pFormatContext->file_size / seconds * 8);
int bitsPerSecond = (int)(fileSize / seconds * 8);
CLog::Log(LOGNOTICE, "Using file computed bitrate = %d", bitsPerSecond);
return (int)bitsPerSecond;

0 comments on commit fa31770

Please sign in to comment.