mirror of
https://github.com/wang-bin/QtAV.git
synced 2026-10-28 02:56:45 +08:00
io: add MediaIO::createForUrl(). add doc
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user