you probably need to send the stream start message. Also, don't realease the buffer until you've processed the sample.
On 30 November 2012 14:47, ManuN <notifications@codeplex.com> wrote:
From: ManuN
So, I need your help.
I created this procedure from a c + + example
I came across an error (HResult): The called 0xC00D35B5 no longer accept additional input.
You know of this error?IMFSourceReader retSourceReader = null;
int hr = 0;// ADD Constant Guid MF_MT_ALL_SAMPLES_INDEPENDENT = new Guid("c9173739-5e56-461c-b713-46fb995cb95f");// see MFErreurconstint MF_E_TRANSFORM_NEED_MORE_INPUT = unchecked((int)0xC00D6D72);// FOR TEST HERE :: Audio Format Output (todo properties) WaveFormat wfOutput = new WaveFormat(44100, 2);/* 1 Initialization */ MediaFoundationInterop.MFStartup(MediaFoundationInterop.MF_VERSION);/* 2. Create Resampler MFT Object CComPtr<IUnknown> spTransformUnk; IMFTransform *pTransform = NULL; //< this is Resampler MFT hr = CoCreateInstance(CLSID_CResamplerMediaObject, NULL, CLSCTX_INPROC_SERVER, IID_IUnknown, (void**)&spTransformUnk); */ CLSID_CResamplerMediaObject mediaComObject; mediaComObject = new CLSID_CResamplerMediaObject();//hr = spTransformUnk->QueryInterface(IID_PPV_ARGS(&pTransform)); IMFTransform pTransform = null; pTransform = (IMFTransform)mediaComObject; //rsampler.Transform;/* 3. Specify input/output PCM format to Resampler MFT */ IMFMediaType mediaType = null;// Create MediaType MediaFoundationInterop.MFCreateMediaType(out mediaType);// hr = pMediaType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio)); mediaType.SetGUID(MediaFoundationAttributes.MF_MT_MAJOR_TYPE, NAudio.MediaFoundation.MediaTypes.MFMediaType_Audio);// hr = pMediaType->SetGUID(MF_MT_SUBTYPE, (fmt.sampleFormat == MyBitFormatInt) ? MFAudioFormat_PCM : MFAudioFormat_Float);if (wfOutput.Encoding == WaveFormatEncoding.Pcm) mediaType.SetGUID(MediaFoundationAttributes.MF_MT_SUBTYPE, AudioSubtypes.MFAudioFormat_PCM);else mediaType.SetGUID(MediaFoundationAttributes.MF_MT_SUBTYPE, AudioSubtypes.MFAudioFormat_Float);// hr = pMediaType->SetUINT32(MF_MT_AUDIO_NUM_CHANNELS, fmt.nChannels); mediaType.SetUINT32(MediaFoundationAttributes.MF_MT_AUDIO_NUM_CHANNELS, wfOutput.Channels);// hr = pMediaType->SetUINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, fmt.sampleRate); mediaType.SetUINT32(MediaFoundationAttributes.MF_MT_AUDIO_SAMPLES_PER_SECOND, wfOutput.SampleRate);// hr = pMediaType->SetUINT32(MF_MT_AUDIO_BLOCK_ALIGNMENT, fmt.FrameBytes()); mediaType.SetUINT32(MediaFoundationAttributes.MF_MT_AUDIO_BLOCK_ALIGNMENT, wfOutput.BlockAlign);// hr = pMediaType->SetUINT32(MF_MT_AUDIO_AVG_BYTES_PER_SECOND, fmt.BytesPerSec()); mediaType.SetUINT32(MediaFoundationAttributes.MF_MT_AUDIO_AVG_BYTES_PER_SECOND, wfOutput.AverageBytesPerSecond);// hr = pMediaType->SetUINT32(MF_MT_AUDIO_BITS_PER_SAMPLE, fmt.bits);//mediaType.SetUINT32(MediaFoundationInterop.MF_MT_AUDIO_BITS_PER_SAMPLE, wfOutput.BitsPerSample);// hr = pMediaType->SetUINT32(MF_MT_ALL_SAMPLES_INDEPENDENT, TRUE); mediaType.SetUINT32(MF_MT_ALL_SAMPLES_INDEPENDENT, -1);/* * if (0 != fmt.dwChannelMask) { * hr = pMediaType->SetUINT32(MF_MT_AUDIO_CHANNEL_MASK, fmt.dwChannelMask); * } */if (wfOutput.Encoding == WaveFormatEncoding.Pcm) {/* if (fmt.bits != fmt.validBitsPerSample) { hr = pMediaType->SetUINT32(MF_MT_AUDIO_VALID_BITS_PER_SAMPLE, fmt.validBitsPerSample); } */ mediaType.SetUINT32(MediaFoundationAttributes.MF_MT_AUDIO_BITS_PER_SAMPLE, wfOutput.BitsPerSample); } // pTransform->SetInputType(0, spOutputType, 0); pTransform.SetInputType(0, mediaType, 0);/* 4. Send stream start message to Resampler MFT */// hr = pTransform->ProcessMessage(MFT_MESSAGE_COMMAND_FLUSH, NULL); pTransform.ProcessMessage(MFT_MESSAGE_TYPE.MFT_MESSAGE_COMMAND_FLUSH, IntPtr.Zero);// hr = pTransform->ProcessMessage(MFT_MESSAGE_NOTIFY_BEGIN_STREAMING, NULL);// Erreur ????????????//pTransform.ProcessMessage(MFT_MESSAGE_TYPE.MFT_MESSAGE_NOTIFY_BEGIN_STREAMING, IntPtr.Zero);// hr = pTransform->ProcessMessage(MFT_MESSAGE_NOTIFY_START_OF_STREAM, NULL); pTransform.ProcessMessage(MFT_MESSAGE_TYPE.MFT_MESSAGE_NOTIFY_START_OF_STREAM, IntPtr.Zero);/* 5. Create IMFSample from uncompressed PCM input data *//* BYTE *data = ...; //< input PCM data DWORD bytes = ...; //< bytes need to be smaller than approx. 1Mbytes IMFMediaBuffer *pBuffer = NULL; hr = MFCreateMemoryBuffer(bytes , &pBuffer); */// IMFMediaBuffer *pBuffer = NULL; IMFMediaBuffer pBuffer = null;// hr = MFCreateMemoryBuffer(bytes , &pBuffer); MFCreateMemoryBuffer(wfOutput.AverageBytesPerSecond*4, out pBuffer);// BYTE *pByteBufferTo = NULL;// hr = pBuffer->Lock(&pByteBufferTo, NULL, NULL); IntPtr pByteBufferTo;int maxLength;int currentLength; pBuffer.Lock(out pByteBufferTo, out maxLength, out currentLength);//memcpy(pByteBufferTo, data, bytes);byte[] data = newbyte[maxLength]; Marshal.Copy(pByteBufferTo,data,0, maxLength); // pBuffer->Unlock(); pBuffer.Unlock();// pByteBufferTo = NULL; pByteBufferTo = IntPtr.Zero;//hr = pBuffer->SetCurrentLength(bytes); pBuffer.SetCurrentLength(maxLength); //IMFSample *pSample = NULL; IMFSample pSample = null;//hr = MFCreateSample(&pSample); MediaFoundationInterop.MFCreateSample(out pSample);//hr = pSample->AddBuffer(pBuffer); pSample.AddBuffer(pBuffer);// SafeRelease(&pBuffer); Marshal.ReleaseComObject(pBuffer);/* 6. Set input data to Resampler MFT */// hr = pTransform->ProcessInput(0, pSample, 0);hr = pTransform.ProcessInput(0, pSample, 0); // <- ERREUR !!!!! MFError.ThrowExceptionForHR(hr);Read the full discussion online.
To add a post to this discussion, reply to this email (naudio@discussions.codeplex.com)
To start a new discussion for this project, email naudio@discussions.codeplex.com
You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.
Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online atcodeplex.com