QMediaplayer流从自定义QIODevice在Mac OS(10.9)加密 [英] QMediaplayer streaming from a custom QIODevice with encryption on Mac OS (10.9)

查看:1319
本文介绍了QMediaplayer流从自定义QIODevice在Mac OS(10.9)加密的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在将一个应用程序从Qt4(.8.4)移植到Qt5(.2.0)。
我几乎完成了所有已知的更改,如deprecated toAscii() - 函数,缺少QtGui等。现在我们有一个使用phonon框架的音乐播放器,它不再支持,并被QtMultimedia模块(包括QMediaPlayer和一些Audio-Handling类)取代。

i'm currently porting an application from Qt4(.8.4) to Qt5(.2.0). I'm nearly done with all the known changes like deprecated toAscii()-function, missing QtGui and so on. Now we had a music player using the phonon framework which is not supported any more and got replaced by the QtMultimedia module including the QMediaPlayer and a bunch of Audio-Handling classes.

我们的播放器的实现需要一个自定义的QIODevice。此设备为磁盘上的加密音频文件提供接口。现在播放器向设备请求x字节,设备从加密的文件读取,解密播放器请求的字节并返回它们。

Our implementation of the player takes a custom QIODevice. This device provides an interface to encrypted audiofiles on the disk. Now the player asks the device for x bytes, the device reads from the encrypted file, decrypts the bytes the player asked for and returns them.

现在我在多媒体模块中搜索了一个函数来重用我的IODevice,并找到了以下函数:

Now I searched for a function in the multimedia-module to reuse my IODevice and found the following function:

void setMedia(const QMediaContent & media, QIODevice * stream = 0)


$ b b

并使用它如下:

and used it as follows:

m_pDecryptingMediaDevice = new BYIODevice(filename);    
m_pDecryptingMediaDevice->open(QIODevice::ReadOnly);    
m_pPlayer->setMedia(0, m_pDecryptingMediaDevice);

其中m_pDecryptingMediaDevice是QIODevice子类,m_pPlayer是QMediaPlayer。

where m_pDecryptingMediaDevice is the QIODevice-subclass and m_pPlayer the QMediaPlayer.

现在在Windows上一切正常工作。 QMediaplayer将其MediaStatus更改为QMediaPlayer :: LoadingMedia并询问我的设备的字节。然后更改为QMediaPlayer :: State PlayingState,状态设置为BufferedMedia。
Everythings罚款。
Mac上的Unfortunalety(10.9.1)我只能得到QMediaPlayer :: PlayingState,没有更多。播放器/ audiobackend从不问我的设备的字节,不调用任何其他功能。
我不认为这个错误是关于自定义QIODevice,但在给它的方式QMediaPlayer,因为播放器甚至不要求任何字节或调用任何功能的设备上。

Now on Windows everything works as expected. The QMediaplayer changes its MediaStatus to QMediaPlayer::LoadingMedia and asks my device for bytes. Then changes to the QMediaPlayer::State PlayingState and the status is set to BufferedMedia. Everythings fine. Unfortunalety on Mac OS (10.9.1) I only get QMediaPlayer::PlayingState and nothing more. The player/audiobackend never asks my device for bytes and doesn't call any other function. I don't think that the mistake is concerned to the custom QIODevice but in the way it is given to the QMediaPlayer because the player doesn't even ask for any bytes or calls any function on the device.

我只是试图将它分解成一个小的测试项目:

I just tried to break it down to a little testproject:

QMediaPlayer *player = new QMediaPlayer(this);
QFile *music = new QFile("C:/Users/.../Music/Test.mp3");
music->open(QIODevice::ReadOnly);
player->setMedia(0, music);
connect(ui->pushButton, SIGNAL(clicked()), player, SLOT(play()));
connect(player, SIGNAL(stateChanged(QMediaPlayer::State)), this, SLOT(stateChanged(QMediaPlayer::State)));




总是工作是像播放器一样给出一个URL

Curiously this does not play at all - not on windows, not on Mac OS. What always works is giving an URL to the player like

有人有类似的情况下的任何经验,根据流出QIODevice到QMediaPlayer使用函数setMedia(const QMediaContent& media,QIODevice * stream = 0)?我坚持这一点。

Has someone any experience in a similar case according to streaming out of an QIODevice to QMediaPlayer using the function setMedia(const QMediaContent & media, QIODevice * stream = 0)? I am stuck with this.

最好的问候和许多感谢。

Best regards and many thanks in advance.

Jan

推荐答案

刚刚来到页面。下面列出了每个平台的可用/选择的音频后端:

Just came to this page. There the available/chosen audio-backends for each platform are listed:

正如你可以看到DirectShow-Plugin(Windows)支持流源,而AVM Foundation / Quicktime 7没有流媒体支持。所以我想唯一的解决方案似乎运送一个自定义后端与应用程序(gstreamer,vlc)。

As you can see the DirectShow-Plugin (Windows) does support stream sources whereas AVM Foundation/Quicktime 7 (OSX) don't have streaming support. So I guess the only solution seems to ship a custom backend with the application (gstreamer, vlc).

这篇关于QMediaplayer流从自定义QIODevice在Mac OS(10.9)加密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆