tResult Test::getF32Value(IMediaSample *mediaSample, cObjectPtr<IMediaTypeDescription> &mediaType, tFloat32 &value) { static tFloat32 tmpValue; static tTimeStamp timeStamp; cObjectPtr<IMediaCoder> coder; RETURN_IF_FAILED_AND_LOG_ERROR_STR(mediaType->Lock(mediaSample, &coder), "Get32 Failed to lock f32"); coder->Get("f32Value", (tVoid*) &tmpValue); coder->Get("ui32ArduinoTimestamp", (tVoid*) &timeStamp); value = tmpValue; RETURN_IF_FAILED_AND_LOG_ERROR_STR(mediaType->Unlock(coder), "Get32 Failed to unlock f32"); RETURN_NOERROR; }
tResult Test::getManeuver(IMediaSample *mediaSample, cInputPin &pin, cObjectPtr<IMediaTypeDescription> &mediaType, tUInt16 &value) { static tUInt16 tmpValue; static tUInt32 timeStamp; cObjectPtr<IMediaCoder> coder; RETURN_IF_FAILED_AND_LOG_ERROR_STR(mediaType->Lock(mediaSample, &coder), "Get UI16 failed to unlock"); coder->Get("ui16Angle", (tVoid*) &tmpValue); coder->Get("ui32ArduinoTimestamp", (tVoid*) &timeStamp); value = tmpValue; RETURN_IF_FAILED_AND_LOG_ERROR_STR(mediaType->Unlock(coder), "Get UI16 failed to unlock"); RETURN_NOERROR; }
tResult Test::transmitF32Value(cOutputPin &pin, cObjectPtr<IMediaTypeDescription> &mediaType, const tFloat32 value) { cObjectPtr<IMediaSample> mediaSample; RETURN_IF_FAILED(AllocMediaSample((tVoid**) &mediaSample)); RETURN_IF_FAILED(mediaSample->AllocBuffer(this->ddlSizeUI16)); // write date to the media sample with the coder of the descriptor cObjectPtr<IMediaCoder> coder; RETURN_IF_FAILED_AND_LOG_ERROR_STR(mediaType->WriteLock(mediaSample, &coder), "Set F32 Failed to lock f32"); static tTimeStamp now; now = _clock ? _clock->GetStreamTime() : cHighResTimer::GetTime(); coder->Set("f32Value", (tVoid*) &value); coder->Set("ui32ArduinoTimestamp", (tVoid*) &now); RETURN_IF_FAILED_AND_LOG_ERROR_STR(mediaType->Unlock(coder), "Set F32 Failed to lock f32"); // transmit media sample over output pin RETURN_IF_FAILED(mediaSample->SetTime(now)); RETURN_IF_FAILED(pin.Transmit(mediaSample)); RETURN_NOERROR; }