io: add MediaIO::createForUrl(). add doc

This commit is contained in:
wang-bin
2015-06-17 18:21:40 +08:00
parent 772c2a8c55
commit 73b2be8d57
2 changed files with 30 additions and 0 deletions
+18
View File
@@ -29,6 +29,18 @@
namespace QtAV {
/*!
* \brief MediaIO
* Built-in io (use MediaIO::create(name), example: MediaIO *qio = MediaIO::create("QIODevice"))
* "QIODevice":
* properties:
* device - read/write. parameter: QIODevice*. example: io->setDevice(mydev)
* "QFile"
* properties:
* device - read only. example: io->device()
* protocols: "", "qrc"
*/
typedef int MediaIOId;
class MediaIO;
FACTORY_DECLARE(MediaIO)
@@ -56,6 +68,12 @@ public:
* \return Null if none of registered MediaIO supports the protocol
*/
static MediaIO* createForProtocol(const QString& protocol);
/*!
* \brief createForUrl
* Create a MediaIO and setUrl(url) if protocol of url is supported.
* Example: MediaIO *qrc = MediaIO::createForUrl("qrc:/icon/test.mkv");
* \return MediaIO instance with url set. Null if protocol is not supported.
*/
static MediaIO* createForUrl(const QString& url);
MediaIO();
+12
View File
@@ -59,6 +59,18 @@ MediaIO* MediaIO::createForProtocol(const QString &protocol)
return 0;
}
MediaIO* MediaIO::createForUrl(const QString &url)
{
const int p = url.indexOf(":");
if (p < 0)
return 0;
MediaIO *io = MediaIO::createForProtocol(url.left(p));
if (!io)
return 0;
io->setUrl(url);
return io;
}
static int av_read(void *opaque, unsigned char *buf, int buf_size)
{
MediaIO* io = static_cast<MediaIO*>(opaque);