本文整理汇总了C++中MediaSource::type方法的典型用法代码示例。如果您正苦于以下问题:C++ MediaSource::type方法的具体用法?C++ MediaSource::type怎么用?C++ MediaSource::type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MediaSource
的用法示例。
在下文中一共展示了MediaSource::type方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testIODevice
void MediaSourceTest::testIODevice()
{
const QByteArray data("0192380");
QBuffer *buffer = new QBuffer;
buffer->setData(data);
buffer->open(QIODevice::ReadOnly);
MediaSource a(buffer);
QCOMPARE(a.type(), MediaSource::Stream);
QCOMPARE(a.fileName(), QString());
QCOMPARE(a.url(), QUrl());
QCOMPARE(a.discType(), Phonon::NoDisc);
QVERIFY(a.stream() != 0);
QCOMPARE(a.deviceName(), QString());
//QCOMPARE(a.audioCaptureDevice(), AudioCaptureDevice());
//QCOMPARE(a.videoCaptureDevice(), VideoCaptureDevice());
MediaSource b(a);
MediaSource c;
c = a;
QCOMPARE(a, b);
QCOMPARE(a, c);
QCOMPARE(b, c);
QCOMPARE(b.type(), MediaSource::Stream);
QCOMPARE(b.fileName(), QString());
QCOMPARE(b.url(), QUrl());
QCOMPARE(b.discType(), Phonon::NoDisc);
QVERIFY(b.stream() != 0);
QCOMPARE(b.deviceName(), QString());
//QCOMPARE(b.audioCaptureDevice(), AudioCaptureDevice());
//QCOMPARE(b.videoCaptureDevice(), VideoCaptureDevice());
QCOMPARE(c.type(), MediaSource::Stream);
QCOMPARE(c.fileName(), QString());
QCOMPARE(c.url(), QUrl());
QCOMPARE(c.discType(), Phonon::NoDisc);
QVERIFY(c.stream() != 0);
QCOMPARE(c.deviceName(), QString());
//QCOMPARE(c.audioCaptureDevice(), AudioCaptureDevice());
//QCOMPARE(c.videoCaptureDevice(), VideoCaptureDevice());
delete buffer;
QCOMPARE(a.type(), MediaSource::Invalid);
QCOMPARE(b.type(), MediaSource::Invalid);
QCOMPARE(c.type(), MediaSource::Invalid);
const AbstractMediaStream *null = 0;
QCOMPARE(a.stream(), null);
QCOMPARE(b.stream(), null);
QCOMPARE(c.stream(), null);
}
示例2: setNextSource
void MediaObject::setNextSource(const MediaSource &source)
{
if (source.type() == MediaSource::Invalid &&
source.type() == MediaSource::Empty)
return;
m_nextSource = source;
}
示例3: testStream
void MediaSourceTest::testStream()
{
AbstractMediaStream *stream = new Stream;
MediaSource a(stream);
QCOMPARE(a.type(), MediaSource::Stream);
QCOMPARE(a.fileName(), QString());
QCOMPARE(a.url(), QUrl());
QCOMPARE(a.discType(), Phonon::NoDisc);
QCOMPARE(a.stream(), stream);
QCOMPARE(a.deviceName(), QString());
//QCOMPARE(a.audioCaptureDevice(), AudioCaptureDevice());
//QCOMPARE(a.videoCaptureDevice(), VideoCaptureDevice());
MediaSource b(a);
MediaSource c;
c = a;
QCOMPARE(a, b);
QCOMPARE(a, c);
QCOMPARE(b, c);
QCOMPARE(b.type(), MediaSource::Stream);
QCOMPARE(b.fileName(), QString());
QCOMPARE(b.url(), QUrl());
QCOMPARE(b.discType(), Phonon::NoDisc);
QCOMPARE(b.stream(), stream);
QCOMPARE(b.deviceName(), QString());
//QCOMPARE(b.audioCaptureDevice(), AudioCaptureDevice());
//QCOMPARE(b.videoCaptureDevice(), VideoCaptureDevice());
QCOMPARE(c.type(), MediaSource::Stream);
QCOMPARE(c.fileName(), QString());
QCOMPARE(c.url(), QUrl());
QCOMPARE(c.discType(), Phonon::NoDisc);
QCOMPARE(c.stream(), stream);
QCOMPARE(c.deviceName(), QString());
//QCOMPARE(c.audioCaptureDevice(), AudioCaptureDevice());
//QCOMPARE(c.videoCaptureDevice(), VideoCaptureDevice());
delete stream;
QCOMPARE(a.type(), MediaSource::Invalid);
QCOMPARE(b.type(), MediaSource::Invalid);
QCOMPARE(c.type(), MediaSource::Invalid);
const AbstractMediaStream *null = 0;
QCOMPARE(a.stream(), null);
QCOMPARE(b.stream(), null);
QCOMPARE(c.stream(), null);
}
示例4: testDiscType
void MediaSourceTest::testDiscType()
{
for (int i = 0; i <= Phonon::Vcd; ++i) {
Phonon::DiscType discType = static_cast<Phonon::DiscType>(i);
AbstractMediaStream *stream = 0;
MediaSource a(discType);
QCOMPARE(a.type(), MediaSource::Disc);
QCOMPARE(a.fileName(), QString());
QCOMPARE(a.url(), QUrl());
QCOMPARE(a.discType(), discType);
QCOMPARE(a.stream(), stream);
QCOMPARE(a.deviceName(), QString());
//QCOMPARE(a.audioCaptureDevice(), AudioCaptureDevice());
//QCOMPARE(a.videoCaptureDevice(), VideoCaptureDevice());
MediaSource b(a);
MediaSource c;
c = a;
QCOMPARE(a, b);
QCOMPARE(a, c);
QCOMPARE(b, c);
QCOMPARE(b.type(), MediaSource::Disc);
QCOMPARE(b.fileName(), QString());
QCOMPARE(b.url(), QUrl());
QCOMPARE(b.discType(), discType);
QCOMPARE(b.stream(), stream);
QCOMPARE(b.deviceName(), QString());
//QCOMPARE(b.audioCaptureDevice(), AudioCaptureDevice());
//QCOMPARE(b.videoCaptureDevice(), VideoCaptureDevice());
QCOMPARE(c.type(), MediaSource::Disc);
QCOMPARE(c.fileName(), QString());
QCOMPARE(c.url(), QUrl());
QCOMPARE(c.discType(), discType);
QCOMPARE(c.stream(), stream);
QCOMPARE(c.deviceName(), QString());
//QCOMPARE(c.audioCaptureDevice(), AudioCaptureDevice());
//QCOMPARE(c.videoCaptureDevice(), VideoCaptureDevice());
}
}
示例5: testUrl
void MediaSourceTest::testUrl()
{
QUrl url("http://www.example.com/music.ogg");
AbstractMediaStream *stream = 0;
MediaSource a(url);
QCOMPARE(a.type(), MediaSource::Url);
QCOMPARE(a.fileName(), QString());
QCOMPARE(a.url(), url);
QCOMPARE(a.discType(), Phonon::NoDisc);
QCOMPARE(a.stream(), stream);
QCOMPARE(a.deviceName(), QString());
//QCOMPARE(a.audioCaptureDevice(), AudioCaptureDevice());
//QCOMPARE(a.videoCaptureDevice(), VideoCaptureDevice());
MediaSource b(a);
MediaSource c;
c = a;
QCOMPARE(a, b);
QCOMPARE(a, c);
QCOMPARE(b, c);
QCOMPARE(b.type(), MediaSource::Url);
QCOMPARE(b.fileName(), QString());
QCOMPARE(b.url(), url);
QCOMPARE(b.discType(), Phonon::NoDisc);
QCOMPARE(b.stream(), stream);
QCOMPARE(b.deviceName(), QString());
//QCOMPARE(b.audioCaptureDevice(), AudioCaptureDevice());
//QCOMPARE(b.videoCaptureDevice(), VideoCaptureDevice());
QCOMPARE(c.type(), MediaSource::Url);
QCOMPARE(c.fileName(), QString());
QCOMPARE(c.url(), url);
QCOMPARE(c.discType(), Phonon::NoDisc);
QCOMPARE(c.stream(), stream);
QCOMPARE(c.deviceName(), QString());
//QCOMPARE(c.audioCaptureDevice(), AudioCaptureDevice());
//QCOMPARE(c.videoCaptureDevice(), VideoCaptureDevice());
}
示例6: testQtResource
void MediaSourceTest::testQtResource()
{
const QString filename(":/ogg/zero.ogg");
MediaSource a(filename);
QCOMPARE(a.type(), MediaSource::Stream);
QCOMPARE(a.fileName(), QString());
QCOMPARE(a.url(), QUrl());
QCOMPARE(a.discType(), Phonon::NoDisc);
QVERIFY(a.stream() != 0);
QCOMPARE(a.deviceName(), QString());
//QCOMPARE(a.audioCaptureDevice(), AudioCaptureDevice());
//QCOMPARE(a.videoCaptureDevice(), VideoCaptureDevice());
MediaSource b(a);
MediaSource c;
c = a;
QCOMPARE(a, b);
QCOMPARE(a, c);
QCOMPARE(b, c);
QCOMPARE(b.type(), MediaSource::Stream);
QCOMPARE(b.fileName(), QString());
QCOMPARE(b.url(), QUrl());
QCOMPARE(b.discType(), Phonon::NoDisc);
QVERIFY(b.stream() != 0);
QCOMPARE(b.deviceName(), QString());
//QCOMPARE(b.audioCaptureDevice(), AudioCaptureDevice());
//QCOMPARE(b.videoCaptureDevice(), VideoCaptureDevice());
QCOMPARE(c.type(), MediaSource::Stream);
QCOMPARE(c.fileName(), QString());
QCOMPARE(c.url(), QUrl());
QCOMPARE(c.discType(), Phonon::NoDisc);
QVERIFY(c.stream() != 0);
QCOMPARE(c.deviceName(), QString());
//QCOMPARE(c.audioCaptureDevice(), AudioCaptureDevice());
//QCOMPARE(c.videoCaptureDevice(), VideoCaptureDevice());
}
示例7: url
void MMF::MediaObject::createPlayer(const MediaSource &source)
{
TRACE_CONTEXT(MediaObject::createPlayer, EAudioApi);
TRACE_ENTRY("state %d source.type %d", state(), source.type());
TRACE_ENTRY("source.type %d", source.type());
MediaType mediaType = MediaTypeUnknown;
AbstractPlayer* oldPlayer = m_player.data();
const bool oldPlayerHasVideo = oldPlayer->hasVideo();
const bool oldPlayerSeekable = oldPlayer->isSeekable();
QString errorMessage;
// Determine media type
switch (source.type()) {
case MediaSource::LocalFile:
mediaType = fileMediaType(source.fileName());
break;
case MediaSource::Url:
{
const QUrl url(source.url());
if (url.scheme() == QLatin1String("file")) {
mediaType = fileMediaType(url.toLocalFile());
}
else {
// Streaming playback is generally not supported by the implementation
// of the audio player API, so we use CVideoPlayerUtility for both
// audio and video streaming.
mediaType = MediaTypeVideo;
}
}
break;
case MediaSource::Invalid:
case MediaSource::Disc:
case MediaSource::Stream:
errorMessage = tr("Error opening source: type not supported");
break;
case MediaSource::Empty:
TRACE_0("Empty media source");
break;
}
if (oldPlayer)
oldPlayer->close();
AbstractPlayer* newPlayer = 0;
// Construct newPlayer using oldPlayer (if not 0) in order to copy
// parameters (volume, prefinishMark, transitionTime) which may have
// been set on oldPlayer.
switch (mediaType) {
case MediaTypeUnknown:
TRACE_0("Media type could not be determined");
newPlayer = new DummyPlayer(oldPlayer);
errorMessage = tr("Error opening source: media type could not be determined");
break;
case MediaTypeAudio:
newPlayer = new AudioPlayer(this, oldPlayer);
break;
case MediaTypeVideo:
#ifdef PHONON_MMF_VIDEO_SURFACES
newPlayer = SurfaceVideoPlayer::create(this, oldPlayer);
#else
newPlayer = DsaVideoPlayer::create(this, oldPlayer);
#endif
break;
}
if (oldPlayer)
emit abstractPlayerChanged(0);
m_player.reset(newPlayer);
emit abstractPlayerChanged(newPlayer);
if (oldPlayerHasVideo != hasVideo()) {
emit hasVideoChanged(hasVideo());
}
if (oldPlayerSeekable != isSeekable()) {
emit seekableChanged(isSeekable());
}
connect(m_player.data(), SIGNAL(totalTimeChanged(qint64)), SIGNAL(totalTimeChanged(qint64)));
connect(m_player.data(), SIGNAL(stateChanged(Phonon::State,Phonon::State)), SIGNAL(stateChanged(Phonon::State,Phonon::State)));
connect(m_player.data(), SIGNAL(finished()), SIGNAL(finished()));
connect(m_player.data(), SIGNAL(bufferStatus(int)), SIGNAL(bufferStatus(int)));
connect(m_player.data(), SIGNAL(metaDataChanged(QMultiMap<QString,QString>)), SIGNAL(metaDataChanged(QMultiMap<QString,QString>)));
connect(m_player.data(), SIGNAL(aboutToFinish()), SIGNAL(aboutToFinish()));
connect(m_player.data(), SIGNAL(prefinishMarkReached(qint32)), SIGNAL(prefinishMarkReached(qint32)));
connect(m_player.data(), SIGNAL(prefinishMarkReached(qint32)), SLOT(handlePrefinishMarkReached(qint32)));
connect(m_player.data(), SIGNAL(tick(qint64)), SIGNAL(tick(qint64)));
// We need to call setError() after doing the connects, otherwise the
//.........这里部分代码省略.........
示例8: url
void MMF::AbstractMediaPlayer::open()
{
TRACE_CONTEXT(AbstractMediaPlayer::open, EAudioApi);
const MediaSource source = m_parent->source();
TRACE_ENTRY("state %d source.type %d", privateState(), source.type());
close();
changeState(GroundState);
TInt symbianErr = KErrNone;
QString errorMessage;
switch (source.type()) {
case MediaSource::LocalFile: {
RFile *const file = m_parent->file();
Q_ASSERT(file);
symbianErr = openFile(*file);
if (KErrNone != symbianErr)
errorMessage = tr("Error opening file");
break;
}
case MediaSource::Url: {
const QUrl url(source.url());
if (url.scheme() == QLatin1String("file")) {
RFile *const file = m_parent->file();
Q_ASSERT(file);
symbianErr = openFile(*file);
if (KErrNone != symbianErr)
errorMessage = tr("Error opening file");
}
#ifdef PHONON_MMF_PROGRESSIVE_DOWNLOAD
else if (url.scheme() == QLatin1String("http")) {
Q_ASSERT(!m_download);
m_download = new Download(url, this);
connect(m_download, SIGNAL(lengthChanged(qint64)),
this, SLOT(downloadLengthChanged(qint64)));
connect(m_download, SIGNAL(stateChanged(Download::State)),
this, SLOT(downloadStateChanged(Download::State)));
m_download->start();
}
#endif
else {
symbianErr = openUrl(url.toString());
if (KErrNone != symbianErr)
errorMessage = tr("Error opening URL");
}
break;
}
case MediaSource::Stream: {
QResource *const resource = m_parent->resource();
if (resource) {
m_buffer.Set(resource->data(), resource->size());
symbianErr = openDescriptor(m_buffer);
if (KErrNone != symbianErr)
errorMessage = tr("Error opening resource");
} else {
errorMessage = tr("Error opening source: resource not opened");
}
break;
}
// Other source types are handled in MediaObject::createPlayer
// Protection against adding new media types and forgetting to update this switch
default:
TRACE_PANIC(InvalidMediaTypePanic);
}
if (errorMessage.isEmpty()) {
changeState(LoadingState);
} else {
if (symbianErr)
setError(errorMessage, symbianErr);
else
setError(errorMessage);
}
TRACE_EXIT_0();
}
示例9: url
void MMF::AbstractMediaPlayer::setFileSource(const MediaSource &source, RFile& file)
{
TRACE_CONTEXT(AbstractMediaPlayer::setFileSource, EAudioApi);
TRACE_ENTRY("state %d source.type %d", privateState(), source.type());
close();
changeState(GroundState);
// TODO: is it correct to assign even if the media type is not supported in
// the switch statement below?
m_source = source;
TInt symbianErr = KErrNone;
switch (m_source.type()) {
case MediaSource::LocalFile: {
symbianErr = openFile(file);
break;
}
case MediaSource::Url: {
const QUrl url(source.url());
if (url.scheme() == QLatin1String("file")) {
symbianErr = openFile(file);
}
else {
TRACE_0("Source type not supported");
// TODO: support network URLs
symbianErr = KErrNotSupported;
}
break;
}
case MediaSource::Invalid:
case MediaSource::Disc:
case MediaSource::Stream:
TRACE_0("Source type not supported");
symbianErr = KErrNotSupported;
break;
case MediaSource::Empty:
TRACE_0("Empty source - doing nothing");
TRACE_EXIT_0();
return;
// Protection against adding new media types and forgetting to update this switch
default:
TRACE_PANIC(InvalidMediaTypePanic);
}
if (KErrNone == symbianErr) {
changeState(LoadingState);
} else {
TRACE("error %d", symbianErr)
setError(NormalError);
}
TRACE_EXIT_0();
}
示例10: testLocalFile
void MediaSourceTest::testLocalFile()
{
QString filename("/usr/share/sounds/KDE_Beep.ogg");
AbstractMediaStream *stream = 0;
MediaSource a(filename);
QCOMPARE(a.type(), MediaSource::LocalFile);
QCOMPARE(a.fileName(), filename);
QCOMPARE(a.url(), QUrl::fromLocalFile(filename));
QCOMPARE(a.discType(), Phonon::NoDisc);
QCOMPARE(a.stream(), stream);
QCOMPARE(a.deviceName(), QString());
//QCOMPARE(a.audioCaptureDevice(), AudioCaptureDevice());
//QCOMPARE(a.videoCaptureDevice(), VideoCaptureDevice());
MediaSource b(a);
MediaSource c;
c = a;
QCOMPARE(a, b);
QCOMPARE(a, c);
QCOMPARE(b, c);
QCOMPARE(b.type(), MediaSource::LocalFile);
QCOMPARE(b.fileName(), filename);
QCOMPARE(b.url(), QUrl::fromLocalFile(filename));
QCOMPARE(b.discType(), Phonon::NoDisc);
QCOMPARE(b.stream(), stream);
QCOMPARE(b.deviceName(), QString());
//QCOMPARE(b.audioCaptureDevice(), AudioCaptureDevice());
//QCOMPARE(b.videoCaptureDevice(), VideoCaptureDevice());
QCOMPARE(c.type(), MediaSource::LocalFile);
QCOMPARE(c.fileName(), filename);
QCOMPARE(c.url(), QUrl::fromLocalFile(filename));
QCOMPARE(c.discType(), Phonon::NoDisc);
QCOMPARE(c.stream(), stream);
QCOMPARE(c.deviceName(), QString());
//QCOMPARE(c.audioCaptureDevice(), AudioCaptureDevice());
//QCOMPARE(c.videoCaptureDevice(), VideoCaptureDevice());
// non-existing files should become invalid sources
filename = "/some/invalid/file.xyz";
MediaSource invalid(filename);
QCOMPARE(invalid.type(), MediaSource::Invalid);
QCOMPARE(invalid.fileName(), QString());
//test that a relative file path is correctly set as an absolute URL
QFile testFile("foo.ogg");
bool deleteFile = false;
if (!testFile.exists()) {
deleteFile = true;
testFile.open(QIODevice::WriteOnly);
testFile.close();
}
filename = "foo.ogg";
MediaSource relative(filename);
//QCOMPARE(relative.fileName(), filename);
QFileInfo urlInfo(relative.url().toLocalFile());
QVERIFY(urlInfo.isAbsolute());
QCOMPARE(urlInfo.fileName(), filename);
QCOMPARE(urlInfo.absolutePath(), QDir::currentPath());
if (deleteFile) {
testFile.remove();
}
}