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 cParkingDirection::SendSignalValueMessage(cObjectPtr<cOutputPin> pOutputPin, tFloat32 value, tUInt32 timeStamp)
{
    //create new media sample
    cObjectPtr<IMediaSample> pMediaSampleOut;
    AllocMediaSample((tVoid**)&pMediaSampleOut);
    
    //allocate memory with the size given by the descriptor
    cObjectPtr<IMediaSerializer> pSerializer;
    m_pCoderDescValue_send->GetMediaSampleSerializer(&pSerializer);
    tInt nSize = pSerializer->GetDeserializedSize();
    pMediaSampleOut->AllocBuffer(nSize);
    
    //write date to the media sample with the coder of the descriptor
    cObjectPtr<IMediaCoder> pCoderOutput;
    m_pCoderDescValue_send->WriteLock(pMediaSampleOut, &pCoderOutput);
    
    pCoderOutput->Set("f32Value", (tVoid*)&(value));
    pCoderOutput->Set("ui32ArduinoTimestamp", (tVoid*)&timeStamp);
    m_pCoderDescValue_send->Unlock(pCoderOutput);
    
    //transmit media sample over output pin
    tTimeStamp tmStreamTime = _clock ? _clock->GetStreamTime() : adtf_util::cHighResTimer::GetTime();
    pMediaSampleOut->SetTime(tmStreamTime);
    pOutputPin->Transmit(pMediaSampleOut);
    
    RETURN_NOERROR;
}
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::initMediaType(const char *mediaTypeDescriptionName, cObjectPtr<IMediaType> &mediaType, cObjectPtr<IMediaTypeDescription> &coderDescription)
{
	tChar const *descriptionSignalValue = this->descriptionManager->GetMediaDescription(mediaTypeDescriptionName);
    RETURN_IF_POINTER_NULL(descriptionSignalValue);        

	mediaType = new cMediaType(0, 0, 0, mediaTypeDescriptionName, descriptionSignalValue, IMediaDescription::MDF_DDL_DEFAULT_VERSION);	
	RETURN_IF_FAILED(mediaType->GetInterface(IID_ADTF_MEDIA_TYPE_DESCRIPTION, (tVoid**) &coderDescription));

	RETURN_NOERROR;
}
tResult Emergency::initOutputPins(cObjectPtr<IMediaType> &typeSignalOut)
{
    std::string signalValueName = "tSteeringAngleData";

    tChar const *descriptionSignalValue = this->descriptionManager->GetMediaDescription(signalValueName.c_str());
    RETURN_IF_POINTER_NULL(descriptionSignalValue);

    typeSignalOut = new cMediaType(0, 0, 0, signalValueName.c_str(), descriptionSignalValue, IMediaDescription::MDF_DDL_DEFAULT_VERSION);
    RETURN_IF_FAILED(typeSignalOut->GetInterface(IID_ADTF_MEDIA_TYPE_DESCRIPTION, (tVoid**) &this->coderDescriptionSignalOutput));

    RETURN_NOERROR;
}
tResult Emergency::initInputPins(IException** __exception_ptr, cObjectPtr<IMediaType> &typeSignal)
{
    std::string signalValueName = "tSignalValue";

    RETURN_IF_FAILED(_runtime->GetObject(OID_ADTF_MEDIA_DESCRIPTION_MANAGER, IID_ADTF_MEDIA_DESCRIPTION_MANAGER, (tVoid**) &this->descriptionManager, __exception_ptr));

    tChar const *descriptionSignalValue = this->descriptionManager->GetMediaDescription(signalValueName.c_str());
    RETURN_IF_POINTER_NULL(descriptionSignalValue);

    typeSignal = new cMediaType(0, 0, 0, signalValueName.c_str(), descriptionSignalValue, IMediaDescription::MDF_DDL_DEFAULT_VERSION);
    RETURN_IF_FAILED(typeSignal->GetInterface(IID_ADTF_MEDIA_TYPE_DESCRIPTION, (tVoid**) &this->coderDescriptionSignalInput));

    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;
}
Exemple #8
0
LPFFilter::~LPFFilter()
{

}

tResult LPFFilter::Init(tInitStage eStage, __exception)
{
	// never miss calling the parent implementation!!
	RETURN_IF_FAILED(cFilter::Init(eStage, __exception_ptr))

	// in StageFirst you can create and register your static pins.
	if (eStage == StageFirst)
	{
		// create and register the input pin
		cObjectPtr<IMediaDescriptionManager> pDescManager;
		RETURN_IF_FAILED(_runtime->GetObject(OID_ADTF_MEDIA_DESCRIPTION_MANAGER, IID_ADTF_MEDIA_DESCRIPTION_MANAGER, (tVoid**)&pDescManager, __exception_ptr));

		// phase 1
		tChar const * strDescSignalValueInput = pDescManager->GetMediaDescription("tSignalValue");
		RETURN_IF_POINTER_NULL(strDescSignalValueInput);
		cObjectPtr<IMediaType> pTypeSignalValueInput = new cMediaType(0, 0, 0, "tSignalValue", strDescSignalValueInput, IMediaDescription::MDF_DDL_DEFAULT_VERSION);
		RETURN_IF_FAILED(pTypeSignalValueInput->GetInterface(IID_ADTF_MEDIA_TYPE_DESCRIPTION, (tVoid**)&m_pCoderDescSignalInput));

		// phase 2
		RETURN_IF_FAILED(m_oInputMeas.Create("input_sample", pTypeSignalValueInput, static_cast<IPinEventSink*> (this)));
		RETURN_IF_FAILED(RegisterPin(&m_oInputMeas));

		// create and register the output pin
		// phase 1
		tChar const * strDescSignalValueOutput = pDescManager->GetMediaDescription("tSignalValue");