mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 823921 - Replaced _com_ptr_t usage by RefPtr r=paul
This commit is contained in:
parent
ab3a6849e2
commit
608c3c6165
@ -26,20 +26,12 @@ which makes Windows Media Foundation unavailable.
|
||||
#include <mfobjects.h>
|
||||
#include <stdio.h>
|
||||
#include <mferror.h>
|
||||
#include <comdef.h>
|
||||
#include <propvarutil.h>
|
||||
#include <wmcodecdsp.h>
|
||||
|
||||
#pragma comment(lib,"uuid.lib")
|
||||
#pragma comment(lib,"mfuuid.lib")
|
||||
|
||||
_COM_SMARTPTR_TYPEDEF(IMFSourceReader, IID_IMFSourceReader);
|
||||
_COM_SMARTPTR_TYPEDEF(IMFMediaType, IID_IMFMediaType);
|
||||
_COM_SMARTPTR_TYPEDEF(IMFSample, IID_IMFSample);
|
||||
_COM_SMARTPTR_TYPEDEF(IMFMediaBuffer, IID_IMFMediaBuffer);
|
||||
_COM_SMARTPTR_TYPEDEF(IMFAsyncResult, IID_IMFAsyncResult);
|
||||
_COM_SMARTPTR_TYPEDEF(IMF2DBuffer, IID_IMF2DBuffer);
|
||||
|
||||
namespace mozilla {
|
||||
namespace wmf {
|
||||
|
||||
|
@ -6,13 +6,14 @@
|
||||
|
||||
#include "WMF.h"
|
||||
|
||||
#include "Unknwn.h"
|
||||
#include <unknwn.h>
|
||||
#include <ole2.h>
|
||||
|
||||
#include "WMFByteStream.h"
|
||||
#include "WMFUtils.h"
|
||||
#include "MediaResource.h"
|
||||
#include "nsISeekableStream.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -139,15 +140,15 @@ WMFByteStream::BeginRead(BYTE *aBuffer,
|
||||
mOffset, mResource->Tell(), aLength);
|
||||
|
||||
// Create an object to store our state.
|
||||
IUnknownPtr requestState = new AsyncReadRequestState(mOffset, aBuffer, aLength);
|
||||
RefPtr<IUnknown> requestState = new AsyncReadRequestState(mOffset, aBuffer, aLength);
|
||||
|
||||
// Create an IMFAsyncResult, this is passed back to the caller as a token to
|
||||
// retrieve the number of bytes read.
|
||||
IMFAsyncResultPtr callersResult;
|
||||
RefPtr<IMFAsyncResult> callersResult;
|
||||
HRESULT hr = wmf::MFCreateAsyncResult(requestState,
|
||||
aCallback,
|
||||
aCallerState,
|
||||
&callersResult);
|
||||
byRef(callersResult));
|
||||
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
|
||||
|
||||
// Queue a work item on our Windows Media Foundation work queue to call
|
||||
@ -173,18 +174,18 @@ WMFByteStream::Invoke(IMFAsyncResult* aResult)
|
||||
// media resoure.
|
||||
|
||||
// Extract the caller's IMFAsyncResult object from the wrapping aResult object.
|
||||
IMFAsyncResultPtr callerResult;
|
||||
IUnknownPtr unknown;
|
||||
HRESULT hr = aResult->GetState(&unknown);
|
||||
RefPtr<IMFAsyncResult> callerResult;
|
||||
RefPtr<IUnknown> unknown;
|
||||
HRESULT hr = aResult->GetState(byRef(unknown));
|
||||
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
|
||||
callerResult = unknown;
|
||||
NS_ENSURE_TRUE(callerResult, E_FAIL);
|
||||
hr = unknown->QueryInterface(static_cast<IMFAsyncResult**>(byRef(callerResult)));
|
||||
NS_ENSURE_TRUE(SUCCEEDED(hr), E_FAIL);
|
||||
|
||||
// Get the object that holds our state information for the asynchronous call.
|
||||
hr = callerResult->GetObject(&unknown);
|
||||
hr = callerResult->GetObject(byRef(unknown));
|
||||
NS_ENSURE_TRUE(SUCCEEDED(hr) && unknown, hr);
|
||||
AsyncReadRequestState* requestState =
|
||||
static_cast<AsyncReadRequestState*>(unknown.GetInterfacePtr());
|
||||
static_cast<AsyncReadRequestState*>(unknown.get());
|
||||
|
||||
// Ensure the read head is at the correct offset in the resource. It may not
|
||||
// be if the SourceReader seeked.
|
||||
@ -256,13 +257,13 @@ WMFByteStream::EndRead(IMFAsyncResult* aResult, ULONG *aBytesRead)
|
||||
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
||||
|
||||
// Extract our state object.
|
||||
IUnknownPtr unknown;
|
||||
HRESULT hr = aResult->GetObject(&unknown);
|
||||
RefPtr<IUnknown> unknown;
|
||||
HRESULT hr = aResult->GetObject(byRef(unknown));
|
||||
if (FAILED(hr) || !unknown) {
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
AsyncReadRequestState* requestState =
|
||||
static_cast<AsyncReadRequestState*>(unknown.GetInterfacePtr());
|
||||
static_cast<AsyncReadRequestState*>(unknown.get());
|
||||
|
||||
// Important: Only advance the read cursor if the caller hasn't seeked
|
||||
// since it called BeginRead(). If it has seeked, we still must report
|
||||
|
@ -118,12 +118,12 @@ ConfigureSourceReaderStream(IMFSourceReader *aReader,
|
||||
NS_ENSURE_TRUE(aReader, E_POINTER);
|
||||
NS_ENSURE_TRUE(aAllowedInSubTypes, E_POINTER);
|
||||
|
||||
IMFMediaTypePtr nativeType;
|
||||
IMFMediaTypePtr type;
|
||||
RefPtr<IMFMediaType> nativeType;
|
||||
RefPtr<IMFMediaType> type;
|
||||
HRESULT hr;
|
||||
|
||||
// Find the native format of the stream.
|
||||
hr = aReader->GetNativeMediaType(aStreamIndex, 0, &nativeType);
|
||||
hr = aReader->GetNativeMediaType(aStreamIndex, 0, byRef(nativeType));
|
||||
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
|
||||
|
||||
// Get the native output subtype of the stream. This denotes the uncompressed
|
||||
@ -152,7 +152,7 @@ ConfigureSourceReaderStream(IMFSourceReader *aReader,
|
||||
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
|
||||
|
||||
// Define the output type.
|
||||
hr = wmf::MFCreateMediaType(&type);
|
||||
hr = wmf::MFCreateMediaType(byRef(type));
|
||||
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
|
||||
|
||||
hr = type->SetGUID(MF_MT_MAJOR_TYPE, majorType);
|
||||
@ -258,9 +258,9 @@ WMFReader::ConfigureVideoDecoder()
|
||||
return;
|
||||
}
|
||||
|
||||
IMFMediaTypePtr mediaType;
|
||||
RefPtr<IMFMediaType> mediaType;
|
||||
hr = mSourceReader->GetCurrentMediaType(MF_SOURCE_READER_FIRST_VIDEO_STREAM,
|
||||
&mediaType);
|
||||
byRef(mediaType));
|
||||
if (FAILED(hr)) {
|
||||
NS_WARNING("Failed to get configured video media type");
|
||||
return;
|
||||
@ -324,9 +324,9 @@ WMFReader::ConfigureAudioDecoder()
|
||||
return;
|
||||
}
|
||||
|
||||
IMFMediaTypePtr mediaType;
|
||||
RefPtr<IMFMediaType> mediaType;
|
||||
HRESULT hr = mSourceReader->GetCurrentMediaType(MF_SOURCE_READER_FIRST_AUDIO_STREAM,
|
||||
&mediaType);
|
||||
byRef(mediaType));
|
||||
if (FAILED(hr)) {
|
||||
NS_WARNING("Failed to get configured audio media type");
|
||||
return;
|
||||
@ -353,7 +353,7 @@ WMFReader::ReadMetadata(VideoInfo* aInfo,
|
||||
LOG("WMFReader::ReadMetadata()");
|
||||
HRESULT hr;
|
||||
|
||||
hr = wmf::MFCreateSourceReaderFromByteStream(mByteStream, NULL, &mSourceReader);
|
||||
hr = wmf::MFCreateSourceReaderFromByteStream(mByteStream, NULL, byRef(mSourceReader));
|
||||
NS_ENSURE_TRUE(SUCCEEDED(hr), NS_ERROR_FAILURE);
|
||||
|
||||
ConfigureVideoDecoder();
|
||||
@ -396,13 +396,13 @@ WMFReader::DecodeAudioData()
|
||||
LONGLONG timestampHns;
|
||||
HRESULT hr;
|
||||
|
||||
IMFSamplePtr sample;
|
||||
RefPtr<IMFSample> sample;
|
||||
hr = mSourceReader->ReadSample(MF_SOURCE_READER_FIRST_AUDIO_STREAM,
|
||||
0, // control flags
|
||||
nullptr, // read stream index
|
||||
&flags,
|
||||
×tampHns,
|
||||
&sample);
|
||||
byRef(sample));
|
||||
|
||||
if (FAILED(hr) ||
|
||||
(flags & MF_SOURCE_READERF_ERROR) ||
|
||||
@ -412,8 +412,8 @@ WMFReader::DecodeAudioData()
|
||||
return false;
|
||||
}
|
||||
|
||||
IMFMediaBufferPtr buffer;
|
||||
hr = sample->ConvertToContiguousBuffer(&buffer);
|
||||
RefPtr<IMFMediaBuffer> buffer;
|
||||
hr = sample->ConvertToContiguousBuffer(byRef(buffer));
|
||||
NS_ENSURE_TRUE(SUCCEEDED(hr), false);
|
||||
|
||||
BYTE* data = nullptr; // Note: *data will be owned by the IMFMediaBuffer, we don't need to free it.
|
||||
@ -461,13 +461,13 @@ WMFReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
||||
LONGLONG timestampHns;
|
||||
HRESULT hr;
|
||||
|
||||
IMFSamplePtr sample;
|
||||
RefPtr<IMFSample> sample;
|
||||
hr = mSourceReader->ReadSample(MF_SOURCE_READER_FIRST_VIDEO_STREAM,
|
||||
0, // control flags
|
||||
nullptr, // read stream index
|
||||
&flags,
|
||||
×tampHns,
|
||||
&sample);
|
||||
byRef(sample));
|
||||
if (flags & MF_SOURCE_READERF_ERROR) {
|
||||
NS_WARNING("WMFReader: Catastrophic failure reading video sample");
|
||||
// Future ReadSample() calls will fail, so give up and report end of stream.
|
||||
@ -498,10 +498,10 @@ WMFReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
||||
int64_t offset = mDecoder->GetResource()->Tell();
|
||||
int64_t duration = GetSampleDuration(sample);
|
||||
|
||||
IMFMediaBufferPtr buffer;
|
||||
RefPtr<IMFMediaBuffer> buffer;
|
||||
|
||||
// Must convert to contiguous buffer to use IMD2DBuffer interface.
|
||||
hr = sample->ConvertToContiguousBuffer(&buffer);
|
||||
hr = sample->ConvertToContiguousBuffer(byRef(buffer));
|
||||
if (FAILED(hr)) {
|
||||
NS_WARNING("ConvertToContiguousBuffer() failed!");
|
||||
return true;
|
||||
@ -512,8 +512,9 @@ WMFReader::DecodeVideoFrame(bool &aKeyframeSkip,
|
||||
// but only some systems (Windows 8?) support it.
|
||||
BYTE* data = nullptr;
|
||||
LONG stride = 0;
|
||||
IMF2DBufferPtr twoDBuffer = buffer;
|
||||
if (twoDBuffer) {
|
||||
RefPtr<IMF2DBuffer> twoDBuffer;
|
||||
hr = buffer->QueryInterface(static_cast<IMF2DBuffer**>(byRef(twoDBuffer)));
|
||||
if (SUCCEEDED(hr)) {
|
||||
hr = twoDBuffer->Lock2D(&data, &stride);
|
||||
NS_ENSURE_TRUE(SUCCEEDED(hr), false);
|
||||
} else {
|
||||
|
@ -50,7 +50,7 @@ private:
|
||||
void ConfigureAudioDecoder();
|
||||
void ConfigureVideoDecoder();
|
||||
|
||||
IMFSourceReaderPtr mSourceReader;
|
||||
RefPtr<IMFSourceReader> mSourceReader;
|
||||
RefPtr<WMFByteStream> mByteStream;
|
||||
|
||||
uint32_t mAudioChannels;
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "WMFUtils.h"
|
||||
#include "mozilla/StandardInteger.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "prlog.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
@ -193,8 +194,8 @@ nsCString GetGUIDName(const GUID& guid)
|
||||
bool
|
||||
SourceReaderHasStream(IMFSourceReader* aReader, const DWORD aIndex)
|
||||
{
|
||||
IMFMediaTypePtr nativeType;
|
||||
HRESULT hr = aReader->GetNativeMediaType(aIndex, 0, &nativeType);
|
||||
RefPtr<IMFMediaType> nativeType;
|
||||
HRESULT hr = aReader->GetNativeMediaType(aIndex, 0, byRef(nativeType));
|
||||
return FAILED(hr) ? false : true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user