Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #2735 from davilla/add-avformat_network-bits

fixed, add avformat_network_init/avformat_network_deinit
  • Loading branch information...
commit 474a8e5180be422322919de3b1aa05f89777385f 2 parents bf91362 + b8bfb1c
@davilla davilla authored
View
39 lib/DllAvFormat.h
@@ -65,6 +65,8 @@ class DllAvFormatInterface
public:
virtual ~DllAvFormatInterface() {}
virtual void av_register_all_dont_call(void)=0;
+ virtual void avformat_network_init_dont_call(void)=0;
+ virtual void avformat_network_deinit_dont_call(void)=0;
virtual AVInputFormat *av_find_input_format(const char *short_name)=0;
virtual void avformat_close_input(AVFormatContext **s)=0;
virtual int av_read_frame(AVFormatContext *s, AVPacket *pkt)=0;
@@ -116,6 +118,8 @@ class DllAvFormat : public DllDynamic, DllAvFormatInterface
return ::av_register_all();
}
virtual void av_register_all_dont_call() { *(volatile int* )0x0 = 0; }
+ virtual void avformat_network_init_dont_call() { *(volatile int* )0x0 = 0; }
+ virtual void avformat_network_deinit_dont_call() { *(volatile int* )0x0 = 0; }
virtual AVInputFormat *av_find_input_format(const char *short_name) { return ::av_find_input_format(short_name); }
virtual void avformat_close_input(AVFormatContext **s) { ::avformat_close_input(s); }
virtual int av_read_frame(AVFormatContext *s, AVPacket *pkt) { return ::av_read_frame(s, pkt); }
@@ -162,9 +166,19 @@ class DllAvFormat : public DllDynamic, DllAvFormatInterface
#if !defined(TARGET_DARWIN)
CLog::Log(LOGDEBUG, "DllAvFormat: Using libavformat system library");
#endif
+ CSingleLock lock(DllAvCodec::m_critSection);
+ if (++m_avformat_refcnt == 1)
+ ::avformat_network_init();
return true;
}
- virtual void Unload() {}
+ virtual void Unload() {
+ CSingleLock lock(DllAvCodec::m_critSection);
+ if (--m_avformat_refcnt == 0)
+ ::avformat_network_deinit();
+ }
+
+protected:
+ static int m_avformat_refcnt;
};
#else
@@ -176,6 +190,8 @@ class DllAvFormat : public DllDynamic, DllAvFormatInterface
LOAD_SYMBOLS()
DEFINE_METHOD0(void, av_register_all_dont_call)
+ DEFINE_METHOD0(void, avformat_network_init_dont_call)
+ DEFINE_METHOD0(void, avformat_network_deinit_dont_call)
DEFINE_METHOD1(AVInputFormat*, av_find_input_format, (const char *p1))
DEFINE_METHOD1(void, avformat_close_input, (AVFormatContext **p1))
DEFINE_METHOD1(int, av_read_play, (AVFormatContext *p1))
@@ -212,6 +228,8 @@ class DllAvFormat : public DllDynamic, DllAvFormatInterface
DEFINE_METHOD2(int, av_write_frame , (AVFormatContext *p1, AVPacket *p2))
BEGIN_METHOD_RESOLVE()
RESOLVE_METHOD_RENAME(av_register_all, av_register_all_dont_call)
+ RESOLVE_METHOD_RENAME(avformat_network_init, avformat_network_init_dont_call)
+ RESOLVE_METHOD_RENAME(avformat_network_deinit, avformat_network_deinit_dont_call)
RESOLVE_METHOD(av_find_input_format)
RESOLVE_METHOD(avformat_close_input)
RESOLVE_METHOD(av_read_frame)
@@ -265,8 +283,25 @@ class DllAvFormat : public DllDynamic, DllAvFormatInterface
{
if (!m_dllAvCodec.Load())
return false;
- return DllDynamic::Load();
+ bool loaded = DllDynamic::Load();
+
+ CSingleLock lock(DllAvCodec::m_critSection);
+ if (++m_avformat_refcnt == 1 && loaded)
+ avformat_network_init_dont_call();
+ return loaded;
}
+
+ virtual void Unload()
+ {
+ CSingleLock lock(DllAvCodec::m_critSection);
+ if (--m_avformat_refcnt == 0 && DllDynamic::IsLoaded())
+ avformat_network_deinit_dont_call();
+
+ DllDynamic::Unload();
+ }
+
+protected:
+ static int m_avformat_refcnt;
};
#endif
View
1  xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
@@ -92,6 +92,7 @@ void CDemuxStreamSubtitleFFmpeg::GetStreamInfo(std::string& strInfo)
// these need to be put somewhere that are compiled, we should have some better place for it
+int DllAvFormat::m_avformat_refcnt = 0;
CCriticalSection DllAvCodec::m_critSection;
static CCriticalSection m_logSection;
std::map<uintptr_t, CStdString> g_logbuffer;
Please sign in to comment.
Something went wrong with that request. Please try again.