If I receive bytes in socket and then wrap it to IMFSample then I can not set the sampleTime right?
- 1.in SOCKET SERVER read h264 data and send it to SOCKET CLIENT
-
- in SOCKET CLIENT recv the bytes and create IMFSample.
- 3.ProcessInput
but the receive buffer length is 3096(or other) and the lenght of a sample is others.
I do not know the sample’s time.
while(true){
char buf[3096]={0};
memset(buffer,0,3096);
int bytes=recv(socket,buf,3096,0);
IMFSample *sample=NULL;
hr=MFCreateSample(&sample);
sample.SetSampleDuration(duration);
IMFMediaBuffer* buffer=NULL;
hr=MFCreateMemoryBuffer(bytes,&buffer);
sample.AddBuffer(buffer);
BYTE*ppBuffer;
DWORD pcbMaxLength=0,pcbCurrentLength=0;
buffer.Lock(&ppBuffer,&pcbMaxLength,&pcbCurrentLength);
memcpy_s(ppBuffer,bytes,buffer,bytes);
buffer.Unlock();
buffer.SetCurrentLength(bytes);
hr=transform.ProcessInput(0,sample,0);
}
the hr is S_OK
;
while(true){
if(sampleSize){
IMFMediaBuffer*buffer1=NULL;
hr = MFCreateMemoryBuffer(static_cast<DWORD>(sampleSize.load()), &buffer1);
if (FAILED(hr)) {
sample1->Release();
sample1 = NULL;
break;
}
sample1->AddBuffer(buffer1)
}
DOWRD sampleSize=0;
MFT_OUTPUT_DATA_BUFFER outputDataBuffer{ 0,sample1 };
DWORD status = 0;
auto const processOutput = transform_->ProcessOutput(0, 1, &outputDataBuffer, &status);
if(processOutput==MF_E_TRANSFORM_STREAM_CHANGE){
//set mediaType and get sampleSize.
}
hr = sample1->ConvertToContiguousBuffer(&buffer1);
}
processOutput
is S_OK
but hr=buffer1.GetCurrentLength(&currLength);
returns S_OK
but currLength
is 0;