Merge remote-tracking branch 'origin/stable' into dev
Change-Id: I15d0b9f03136840aff189ffb9de6e3899c204ca2
This commit is contained in:
@@ -183,8 +183,9 @@ void QDeclarativeAudio::setSource(const QUrl &url)
|
||||
return;
|
||||
|
||||
m_source = url;
|
||||
m_content = m_source.isEmpty() ? QMediaContent() : m_source;
|
||||
m_loaded = false;
|
||||
if (m_complete && (m_autoLoad || url.isEmpty() || m_autoPlay)) {
|
||||
if (m_complete && (m_autoLoad || m_content.isNull() || m_autoPlay)) {
|
||||
if (m_error != QMediaPlayer::ServiceMissingError && m_error != QMediaPlayer::NoError) {
|
||||
m_error = QMediaPlayer::NoError;
|
||||
m_errorString = QString();
|
||||
@@ -192,7 +193,7 @@ void QDeclarativeAudio::setSource(const QUrl &url)
|
||||
emit errorChanged();
|
||||
}
|
||||
|
||||
m_player->setMedia(m_source, 0);
|
||||
m_player->setMedia(m_content, 0);
|
||||
m_loaded = true;
|
||||
}
|
||||
else
|
||||
@@ -245,7 +246,7 @@ void QDeclarativeAudio::setPlaybackState(QMediaPlayer::State playbackState)
|
||||
switch (playbackState){
|
||||
case (QMediaPlayer::PlayingState):
|
||||
if (!m_loaded) {
|
||||
m_player->setMedia(m_source, 0);
|
||||
m_player->setMedia(m_content, 0);
|
||||
m_player->setPosition(m_position);
|
||||
m_loaded = true;
|
||||
}
|
||||
@@ -254,7 +255,7 @@ void QDeclarativeAudio::setPlaybackState(QMediaPlayer::State playbackState)
|
||||
|
||||
case (QMediaPlayer::PausedState):
|
||||
if (!m_loaded) {
|
||||
m_player->setMedia(m_source, 0);
|
||||
m_player->setMedia(m_content, 0);
|
||||
m_player->setPosition(m_position);
|
||||
m_loaded = true;
|
||||
}
|
||||
@@ -681,8 +682,8 @@ void QDeclarativeAudio::componentComplete()
|
||||
if (!qFuzzyCompare(m_playbackRate, qreal(1.0)))
|
||||
m_player->setPlaybackRate(m_playbackRate);
|
||||
|
||||
if (!m_source.isEmpty() && (m_autoLoad || m_autoPlay)) {
|
||||
m_player->setMedia(m_source, 0);
|
||||
if (!m_content.isNull() && (m_autoLoad || m_autoPlay)) {
|
||||
m_player->setMedia(m_content, 0);
|
||||
m_loaded = true;
|
||||
if (m_position > 0)
|
||||
m_player->setPosition(m_position);
|
||||
@@ -691,7 +692,7 @@ void QDeclarativeAudio::componentComplete()
|
||||
m_complete = true;
|
||||
|
||||
if (m_autoPlay) {
|
||||
if (m_source.isEmpty()) {
|
||||
if (m_content.isNull()) {
|
||||
m_player->stop();
|
||||
} else {
|
||||
m_player->play();
|
||||
|
||||
@@ -257,6 +257,7 @@ private:
|
||||
QMediaPlayer::Error m_error;
|
||||
QString m_errorString;
|
||||
QUrl m_source;
|
||||
QMediaContent m_content;
|
||||
|
||||
QScopedPointer<QDeclarativeMediaMetaData> m_metaData;
|
||||
|
||||
|
||||
@@ -428,6 +428,7 @@ int QAndroidCameraSession::capture(const QString &fileName)
|
||||
m_camera->requestPreviewFrame();
|
||||
m_camera->takePicture();
|
||||
} else {
|
||||
//: Drive mode is the camera's shutter mode, for example single shot, continuos exposure, etc.
|
||||
emit imageCaptureError(m_lastImageCaptureId, QCameraImageCapture::NotSupportedFeatureError,
|
||||
tr("Drive mode not supported"));
|
||||
}
|
||||
|
||||
@@ -125,7 +125,12 @@ void MFAudioDecoderControl::setSourceFilename(const QString &fileName)
|
||||
if (!m_sourceFilename.isEmpty()) {
|
||||
m_sourceResolver->shutdown();
|
||||
QMediaResourceList rl;
|
||||
rl.push_back(QMediaResource(QUrl::fromLocalFile(m_sourceFilename)));
|
||||
QUrl url;
|
||||
if (m_sourceFilename.startsWith(':'))
|
||||
url = QUrl(QStringLiteral("qrc%1").arg(m_sourceFilename));
|
||||
else
|
||||
url = QUrl::fromLocalFile(m_sourceFilename);
|
||||
rl.push_back(QMediaResource(url));
|
||||
m_sourceResolver->load(rl, 0);
|
||||
m_loadingSource = true;
|
||||
} else {
|
||||
|
||||
@@ -521,18 +521,67 @@ STDMETHODIMP MFTransform::ProcessOutput(DWORD dwFlags, DWORD cOutputBufferCount,
|
||||
if (!m_sample)
|
||||
return MF_E_TRANSFORM_NEED_MORE_INPUT;
|
||||
|
||||
if (pOutputSamples[0].pSample)
|
||||
pOutputSamples[0].pSample->Release();
|
||||
IMFMediaBuffer *input = NULL;
|
||||
IMFMediaBuffer *output = NULL;
|
||||
|
||||
pOutputSamples[0].pSample = m_sample;
|
||||
pOutputSamples[0].pSample->AddRef();
|
||||
DWORD sampleLength = 0;
|
||||
m_sample->GetTotalLength(&sampleLength);
|
||||
|
||||
// If the sample length is null, it means we're getting DXVA buffers.
|
||||
// In that case just pass on the sample we got as input.
|
||||
// Otherwise we need to copy the input buffer into the buffer the sink
|
||||
// is giving us.
|
||||
if (pOutputSamples[0].pSample && sampleLength > 0) {
|
||||
|
||||
if (FAILED(m_sample->ConvertToContiguousBuffer(&input)))
|
||||
goto done;
|
||||
|
||||
if (FAILED(pOutputSamples[0].pSample->ConvertToContiguousBuffer(&output)))
|
||||
goto done;
|
||||
|
||||
DWORD inputLength = 0;
|
||||
DWORD outputLength = 0;
|
||||
input->GetMaxLength(&inputLength);
|
||||
output->GetMaxLength(&outputLength);
|
||||
|
||||
if (outputLength < inputLength) {
|
||||
pOutputSamples[0].pSample->RemoveAllBuffers();
|
||||
output->Release();
|
||||
output = NULL;
|
||||
if (SUCCEEDED(MFCreateMemoryBuffer(inputLength, &output)))
|
||||
pOutputSamples[0].pSample->AddBuffer(output);
|
||||
}
|
||||
|
||||
if (output)
|
||||
m_sample->CopyToBuffer(output);
|
||||
|
||||
LONGLONG hnsDuration = 0;
|
||||
LONGLONG hnsTime = 0;
|
||||
if (SUCCEEDED(m_sample->GetSampleDuration(&hnsDuration)))
|
||||
pOutputSamples[0].pSample->SetSampleDuration(hnsDuration);
|
||||
if (SUCCEEDED(m_sample->GetSampleTime(&hnsTime)))
|
||||
pOutputSamples[0].pSample->SetSampleTime(hnsTime);
|
||||
|
||||
|
||||
} else {
|
||||
if (pOutputSamples[0].pSample)
|
||||
pOutputSamples[0].pSample->Release();
|
||||
pOutputSamples[0].pSample = m_sample;
|
||||
pOutputSamples[0].pSample->AddRef();
|
||||
}
|
||||
|
||||
done:
|
||||
pOutputSamples[0].dwStatus = 0;
|
||||
*pdwStatus = 0;
|
||||
|
||||
m_sample->Release();
|
||||
m_sample = 0;
|
||||
|
||||
if (input)
|
||||
input->Release();
|
||||
if (output)
|
||||
output->Release();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -1875,11 +1875,22 @@ void MFPlayerSession::handleSessionEvent(IMFMediaEvent *sessionEvent)
|
||||
emit error(QMediaPlayer::FormatError, tr("Unsupported media, a codec is missing."), true);
|
||||
} else {
|
||||
if (m_audioSampleGrabberNode) {
|
||||
IMFMediaType *mediaType = 0;
|
||||
hr = MFGetTopoNodeCurrentType(m_audioSampleGrabberNode, 0, FALSE, &mediaType);
|
||||
if (SUCCEEDED(hr)) {
|
||||
m_audioSampleGrabber->setFormat(audioFormatForMFMediaType(mediaType));
|
||||
mediaType->Release();
|
||||
IUnknown *obj = 0;
|
||||
if (SUCCEEDED(m_audioSampleGrabberNode->GetObject(&obj))) {
|
||||
IMFStreamSink *streamSink = 0;
|
||||
if (SUCCEEDED(obj->QueryInterface(IID_PPV_ARGS(&streamSink)))) {
|
||||
IMFMediaTypeHandler *typeHandler = 0;
|
||||
if (SUCCEEDED(streamSink->GetMediaTypeHandler((&typeHandler)))) {
|
||||
IMFMediaType *mediaType = 0;
|
||||
if (SUCCEEDED(typeHandler->GetCurrentMediaType(&mediaType))) {
|
||||
m_audioSampleGrabber->setFormat(audioFormatForMFMediaType(mediaType));
|
||||
mediaType->Release();
|
||||
}
|
||||
typeHandler->Release();
|
||||
}
|
||||
streamSink->Release();
|
||||
}
|
||||
obj->Release();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -175,19 +175,16 @@ void SourceResolver::load(QMediaResourceList& resources, QIODevice* stream)
|
||||
qWarning() << "Failed to create Source Resolver!";
|
||||
emit error(hr);
|
||||
} else if (stream) {
|
||||
if (resources.count() > 0) {
|
||||
QMediaResource resource = resources.takeFirst();
|
||||
QUrl url = resource.url();
|
||||
m_stream = new MFStream(stream, false);
|
||||
hr = m_sourceResolver->BeginCreateObjectFromByteStream(m_stream, reinterpret_cast<const OLECHAR *>(url.toString().utf16()),
|
||||
MF_RESOLUTION_MEDIASOURCE, NULL, &m_cancelCookie, this, new State(m_sourceResolver, true));
|
||||
if (FAILED(hr)) {
|
||||
qWarning() << "Unsupported stream!";
|
||||
emit error(hr);
|
||||
}
|
||||
} else {
|
||||
hr = MF_E_UNSUPPORTED_BYTESTREAM_TYPE;
|
||||
qWarning() << "Can't load stream without a hint of MIME type in a url";
|
||||
QString url;
|
||||
if (!resources.isEmpty())
|
||||
url = resources.takeFirst().url().toString();
|
||||
m_stream = new MFStream(stream, false);
|
||||
hr = m_sourceResolver->BeginCreateObjectFromByteStream(
|
||||
m_stream, url.isEmpty() ? 0 : reinterpret_cast<LPCWSTR>(url.utf16()),
|
||||
MF_RESOLUTION_MEDIASOURCE | MF_RESOLUTION_CONTENT_DOES_NOT_HAVE_TO_MATCH_EXTENSION_OR_MIME_TYPE
|
||||
, NULL, &m_cancelCookie, this, new State(m_sourceResolver, true));
|
||||
if (FAILED(hr)) {
|
||||
qWarning() << "Unsupported stream!";
|
||||
emit error(hr);
|
||||
}
|
||||
} else {
|
||||
@@ -203,8 +200,10 @@ void SourceResolver::load(QMediaResourceList& resources, QIODevice* stream)
|
||||
stream = new QFile(url.path().mid(1), this);
|
||||
if (stream->open(QIODevice::ReadOnly)) {
|
||||
m_stream = new MFStream(stream, true);
|
||||
hr = m_sourceResolver->BeginCreateObjectFromByteStream(m_stream, reinterpret_cast<const OLECHAR *>(url.toString().utf16()),
|
||||
MF_RESOLUTION_MEDIASOURCE, NULL, &m_cancelCookie, this, new State(m_sourceResolver, true));
|
||||
hr = m_sourceResolver->BeginCreateObjectFromByteStream(
|
||||
m_stream, reinterpret_cast<const OLECHAR *>(url.toString().utf16()),
|
||||
MF_RESOLUTION_MEDIASOURCE | MF_RESOLUTION_CONTENT_DOES_NOT_HAVE_TO_MATCH_EXTENSION_OR_MIME_TYPE,
|
||||
NULL, &m_cancelCookie, this, new State(m_sourceResolver, true));
|
||||
if (FAILED(hr)) {
|
||||
qWarning() << "Unsupported stream!";
|
||||
emit error(hr);
|
||||
@@ -221,8 +220,10 @@ void SourceResolver::load(QMediaResourceList& resources, QIODevice* stream)
|
||||
stream = new QFile(QLatin1Char(':') + url.path(), this);
|
||||
if (stream->open(QIODevice::ReadOnly)) {
|
||||
m_stream = new MFStream(stream, true);
|
||||
hr = m_sourceResolver->BeginCreateObjectFromByteStream(m_stream, reinterpret_cast<const OLECHAR *>(url.toString().utf16()),
|
||||
MF_RESOLUTION_MEDIASOURCE, NULL, &m_cancelCookie, this, new State(m_sourceResolver, true));
|
||||
hr = m_sourceResolver->BeginCreateObjectFromByteStream(
|
||||
m_stream, reinterpret_cast<const OLECHAR *>(url.toString().utf16()),
|
||||
MF_RESOLUTION_MEDIASOURCE | MF_RESOLUTION_CONTENT_DOES_NOT_HAVE_TO_MATCH_EXTENSION_OR_MIME_TYPE,
|
||||
NULL, &m_cancelCookie, this, new State(m_sourceResolver, true));
|
||||
if (FAILED(hr)) {
|
||||
qWarning() << "Unsupported stream!";
|
||||
emit error(hr);
|
||||
@@ -232,8 +233,10 @@ void SourceResolver::load(QMediaResourceList& resources, QIODevice* stream)
|
||||
emit error(QMediaPlayer::FormatError);
|
||||
}
|
||||
} else {
|
||||
hr = m_sourceResolver->BeginCreateObjectFromURL(reinterpret_cast<const OLECHAR *>(url.toString().utf16()),
|
||||
MF_RESOLUTION_MEDIASOURCE, NULL, &m_cancelCookie, this, new State(m_sourceResolver, false));
|
||||
hr = m_sourceResolver->BeginCreateObjectFromURL(
|
||||
reinterpret_cast<const OLECHAR *>(url.toString().utf16()),
|
||||
MF_RESOLUTION_MEDIASOURCE | MF_RESOLUTION_CONTENT_DOES_NOT_HAVE_TO_MATCH_EXTENSION_OR_MIME_TYPE,
|
||||
NULL, &m_cancelCookie, this, new State(m_sourceResolver, false));
|
||||
if (FAILED(hr)) {
|
||||
qWarning() << "Unsupported url scheme!";
|
||||
emit error(hr);
|
||||
|
||||
Reference in New Issue
Block a user