#include <stdio.h>
class A
{
public:
virtual ~A()
{
}
};
class B
{
public:
virtual ~B()
{
}
};
class C
{
public:
virtual void dump() = 0;
virtual ~C()
{
}
};
class D: public A, public C
{
public:
virtual void dump()
{
printf("D: %p\n", this);
}
};
class E: public B, public C
{
public:
virtual void dump()
{
printf("E: %p\n", this);
}
};
void f(void *p)
{
C *pc1 = dynamic_cast<C*>((A*)p);
C *pc2 = dynamic_cast<C*>((B*)p);
C *pc3 = dynamic_cast<C*>((C*)p);
if (pc1)
pc1->dump();
else if (pc2)
pc2->dump();
else if (pc3)
pc3->dump();
}
int main()
{
D d;
E e;
printf("d: %p, e: %p\n", &d, &e);
A *pa = &d;
f(pa);
B *pb = &e;
f(pb);
C *pc1 = &d;
f(pc1);
C *pc2 = &e;
f(pc2);
D *pd = &d;
f(pd);
E *pe = &e;
f(pe);
return 0;
}
extern "C"
{
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
}
...
const char *url = "http://localhost/test.mp3";
AVFormatContext *pFormatCtx = NULL;
int ret = avformat_open_input(&pFormatCtx, url, NULL, NULL);
if (ret >= 0) {
avformat_find_stream_info(pFormatCtx, NULL);
int seconds = (pFormatCtx->duration / AV_TIME_BASE);
int64_t size = avio_size(pFormatCtx->pb);
avformat_close_input(&pFormatCtx);
avformat_free_context(pFormatCtx);
}