tResult cUserAttitudeFilter::TransmitAngles(tTimeStamp sampleTimeStamp, const tTimeStamp timeStampValue, const tFloat32 yaw, const tFloat32 pitch, const tFloat32 roll) { //create new media sample cObjectPtr<IMediaSample> pMediaSampleYaw; cObjectPtr<IMediaSample> pMediaSamplePitch; cObjectPtr<IMediaSample> pMediaSampleRoll; AllocMediaSample((tVoid**)&pMediaSampleYaw); AllocMediaSample((tVoid**)&pMediaSamplePitch); AllocMediaSample((tVoid**)&pMediaSampleRoll); //allocate memory with the size given by the descriptor cObjectPtr<IMediaSerializer> pSerializer; m_pCoderDescSignal->GetMediaSampleSerializer(&pSerializer); tInt nSize = pSerializer->GetDeserializedSize(); pMediaSampleYaw->AllocBuffer(nSize); pMediaSamplePitch->AllocBuffer(nSize); pMediaSampleRoll->AllocBuffer(nSize); cObjectPtr<IMediaCoder> pCoderOutput; //write date to the media sample with the coder of the descriptor m_pCoderDescSignal->WriteLock(pMediaSampleYaw, &pCoderOutput); pCoderOutput->Set("f32Value", (tVoid*)&(yaw)); pCoderOutput->Set("ui32ArduinoTimestamp", (tVoid*)&timeStampValue); m_pCoderDescSignal->Unlock(pCoderOutput); //transmit media sample over output pin pMediaSampleYaw->SetTime(sampleTimeStamp); m_oOutputYaw.Transmit(pMediaSampleYaw); //write date to the media sample with the coder of the descriptor m_pCoderDescSignal->WriteLock(pMediaSamplePitch, &pCoderOutput); pCoderOutput->Set("f32Value", (tVoid*)&(pitch)); pCoderOutput->Set("ui32ArduinoTimestamp", (tVoid*)&timeStampValue); m_pCoderDescSignal->Unlock(pCoderOutput); //transmit media sample over output pin pMediaSamplePitch->SetTime(sampleTimeStamp); m_oOutputPitch.Transmit(pMediaSamplePitch); //write date to the media sample with the coder of the descriptor m_pCoderDescSignal->WriteLock(pMediaSampleRoll, &pCoderOutput); pCoderOutput->Set("f32Value", (tVoid*)&(roll)); pCoderOutput->Set("ui32ArduinoTimestamp", (tVoid*)&timeStampValue); m_pCoderDescSignal->Unlock(pCoderOutput); //transmit media sample over output pin pMediaSampleRoll->SetTime(sampleTimeStamp); m_oOutputRoll.Transmit(pMediaSampleRoll); RETURN_NOERROR; }
tResult StateControllerNew::SendValue(cOutputPin &pin, stateCar state, tInt16 maneuver) { if (!pin.IsConnected()) { RETURN_NOERROR; } cObjectPtr<IMediaSample> mediaSample; RETURN_IF_FAILED(AllocMediaSample((tVoid **) &mediaSample)); cObjectPtr<IMediaSerializer> driverSerializer; driveStructDescription->GetMediaSampleSerializer(&driverSerializer); tInt nSize = driverSerializer->GetDeserializedSize(); RETURN_IF_FAILED(mediaSample->AllocBuffer(nSize)); tInt8 carState = tInt8(state); { __adtf_sample_write_lock_mediadescription(driveStructDescription, mediaSample, pCoder); pCoder->Set("i8StateID", (tVoid *) &carState); pCoder->Set("i16ManeuverEntry", (tVoid *) &maneuver); } mediaSample->SetTime(_clock->GetStreamTime()); RETURN_IF_FAILED(pin.Transmit(mediaSample)); RETURN_NOERROR; }
tResult cJuryTransmitter::sendJuryStruct(juryActions actionID, tInt16 maneuverEntry) { cObjectPtr<IMediaSample> pMediaSample; RETURN_IF_FAILED(AllocMediaSample((tVoid**)&pMediaSample)); cObjectPtr<IMediaSerializer> pSerializer; m_pCoderDescJuryStruct->GetMediaSampleSerializer(&pSerializer); tInt nSize = pSerializer->GetDeserializedSize(); RETURN_IF_FAILED(pMediaSample->AllocBuffer(nSize)); { // focus for sample write lock __adtf_sample_write_lock_mediadescription(m_pCoderDescJuryStruct,pMediaSample,pCoder); pCoder->Set("i8ActionID", (tVoid*)&actionID); pCoder->Set("i16ManeuverEntry", (tVoid*)&maneuverEntry); } RETURN_IF_FAILED(pMediaSample->SetTime(_clock->GetStreamTime())); RETURN_IF_FAILED(m_JuryStructOutputPin.Transmit(pMediaSample)); if(m_bDebugModeEnabled) LOG_INFO(cString::Format("Jury Module: Send: Action %d, Maneuver %d", actionID, maneuverEntry)); RETURN_NOERROR; }
tResult cSimpleFusion::sendNewValue(tFloat32 flValue) { //tFloat32 flValue= value; tUInt32 timeStamp = 0; //create new media sample cObjectPtr<IMediaSample> pMediaSample; AllocMediaSample((tVoid**)&pMediaSample); //allocate memory with the size given by the descriptor cObjectPtr<IMediaSerializer> pSerializer; m_pCoderDescSignalInput->GetMediaSampleSerializer(&pSerializer); tInt nSize = pSerializer->GetDeserializedSize(); pMediaSample->AllocBuffer(nSize); //write date to the media sample with the coder of the descriptor cObjectPtr<IMediaCoder> pCoder; m_pCoderDescSignalInput->WriteLock(pMediaSample, &pCoder); pCoder->Set("f32Value", (tVoid*)&(flValue)); pCoder->Set("ui32ArduinoTimestamp", (tVoid*)&timeStamp); m_pCoderDescSignalInput->Unlock(pCoder); //transmit media sample over output pin pMediaSample->SetTime(_clock->GetStreamTime()); m_ir_fusion_out.Transmit(pMediaSample); // bitte noch drin lassen->brauch ich für die XML-Kalibrierung des Calibration Filter Extended //LOG_INFO(cString::Format("%f",flValue)); RETURN_NOERROR; }
void cBoolValueGenerator::OnTransmitValueTrue() { cObjectPtr<IMediaSample> pMediaSample; AllocMediaSample((tVoid**)&pMediaSample); //allocate memory with the size given by the descriptor cObjectPtr<IMediaSerializer> pSerializer; m_pDescriptionBool->GetMediaSampleSerializer(&pSerializer); pMediaSample->AllocBuffer(pSerializer->GetDeserializedSize()); tBool bValue = tTrue; tUInt32 ui32TimeStamp = 0; //write date to the media sample with the coder of the descriptor { __adtf_sample_write_lock_mediadescription(m_pDescriptionBool, pMediaSample, pCoderOutput); // set the id if not already done if(!m_bIDsBoolValueOutput) { pCoderOutput->GetID("bValue", m_szIDBoolValueOutput); pCoderOutput->GetID("ui32ArduinoTimestamp", m_szIDArduinoTimestampOutput); m_bIDsBoolValueOutput = tTrue; } // set value from sample pCoderOutput->Set(m_szIDBoolValueOutput, (tVoid*)&bValue); pCoderOutput->Set(m_szIDArduinoTimestampOutput, (tVoid*)&(ui32TimeStamp)); } pMediaSample->SetTime(_clock->GetStreamTime()); //transmit media sample over output pin m_oBoolValuePin.Transmit(pMediaSample); }
tResult cJuryModule::sendEmergencyStop() { if(m_bDebugModeEnabled) LOG_INFO("Jury Module: Emergency_Stop requested"); cObjectPtr<IMediaSample> pMediaSample; RETURN_IF_FAILED(AllocMediaSample((tVoid**)&pMediaSample)); cObjectPtr<IMediaSerializer> pSerializer; m_pDescNotAus->GetMediaSampleSerializer(&pSerializer); tInt nSize = pSerializer->GetDeserializedSize(); RETURN_IF_FAILED(pMediaSample->AllocBuffer(nSize)); tBool boolValue = true; { // focus for sample write lock __adtf_sample_write_lock_mediadescription(m_pDescNotAus,pMediaSample,pCoder); // get the IDs for the items in the media sample if(!m_bIDNotAusSet) { pCoder->GetID("bEmergencyStop", m_szIDNotAusbEmergencyStop); m_bIDNotAusSet = tTrue; } pCoder->Set(m_szIDNotAusbEmergencyStop, (tVoid*)&boolValue); } pMediaSample->SetTime(_clock->GetStreamTime()); m_NotAusOutputPin.Transmit(pMediaSample); RETURN_NOERROR; }
void cQrPlayer::OutputSpeed(tFloat32 val) { tUInt32 timeStamp = 0; //create new media sample cObjectPtr<IMediaSample> pMediaSample; AllocMediaSample((tVoid**)&pMediaSample); //allocate memory with the size given by the descriptor cObjectPtr<IMediaSerializer> pSerializer; m_pCoderDescSignalOutput->GetMediaSampleSerializer(&pSerializer); tInt nSize = pSerializer->GetDeserializedSize(); pMediaSample->AllocBuffer(nSize); //write date to the media sample with the coder of the descriptor cObjectPtr<IMediaCoder> pCoder; m_pCoderDescSignalOutput->WriteLock(pMediaSample, &pCoder); pCoder->Set("f32Value", (tVoid*)&val); pCoder->Set("ui32ArduinoTimestamp", (tVoid*)&timeStamp); m_pCoderDescSignalOutput->Unlock(pCoder); //transmit media sample over output pin pMediaSample->SetTime(_clock->GetStreamTime()); m_oPinAccelerateSignal.Transmit(pMediaSample); if (m_bConsoleOutputEnabled) LOG_INFO(adtf_util::cString::Format("QrPlayer: OutputSpeed %f", val)); }
void testPullOutFilter::OnTransmitIntValue(tInt32 pullOutType) { LOG_INFO(cString::Format("TPOF: Start pullOutType1 %i", pullOutType) ); cObjectPtr<IMediaSample> pMediaSample; AllocMediaSample((tVoid**)&pMediaSample); //allocate memory with the size given by the descriptor cObjectPtr<IMediaSerializer> pSerializer; m_pStartInput->GetMediaSampleSerializer(&pSerializer); pMediaSample->AllocBuffer(pSerializer->GetDeserializedSize()); { __adtf_sample_write_lock_mediadescription(m_pStartInput, pMediaSample, pCoder); if (!m_bIDsStartSet) { pCoder->GetID("intValue", m_szIDManeuvreStartInput); m_bIDsStartSet = tTrue; } // set value from sample pCoder->Set(m_szIDManeuvreStartInput, (tVoid*)&pullOutType); } LOG_INFO(cString::Format("TPOF: Start pullOutType2 %i", pullOutType) ); //transmit media sample over output pin m_oStartPullOut.Transmit(pMediaSample); LOG_INFO(cString::Format("TPOF: Start pullOutType3 %i", pullOutType) ); }
tResult YawToSteer::TransmitSignalValue(cOutputPin *outputPin, tFloat32 value) { __synchronized_obj(iosync); tUInt32 timeStamp = 0; cObjectPtr<IMediaSerializer> pSerializer; descriptionSignalValue->GetMediaSampleSerializer(&pSerializer); tInt nSize = pSerializer->GetDeserializedSize(); cObjectPtr<IMediaSample> newMediaSample; AllocMediaSample((tVoid **) &newMediaSample); newMediaSample->AllocBuffer(nSize); { __adtf_sample_write_lock_mediadescription(descriptionSignalValue, newMediaSample, pCoderOutput); if (!m_bIDsSignalSet) { pCoderOutput->GetID("f32Value", m_szIDSignalF32Value); pCoderOutput->GetID("ui32ArduinoTimestamp", m_szIDSignalArduinoTimestamp); m_bIDsSignalSet = tTrue; } // set values in new media sample pCoderOutput->Set(m_szIDSignalF32Value, (tVoid *) &(value)); pCoderOutput->Set(m_szIDSignalArduinoTimestamp, (tVoid *) &timeStamp); } newMediaSample->SetTime(_clock->GetTime()); outputPin->Transmit(newMediaSample); RETURN_NOERROR; }
tResult StateControllerNew::SendEnum(cOutputPin &pin, tInt value) { if (!pin.IsConnected()) { RETURN_NOERROR; } cObjectPtr<IMediaSample> mediaSample; RETURN_IF_FAILED(AllocMediaSample((tVoid **) &mediaSample)); cObjectPtr<IMediaSerializer> pSerializer; enumDescription->GetMediaSampleSerializer(&pSerializer); tInt nSize = pSerializer->GetDeserializedSize(); RETURN_IF_FAILED(mediaSample->AllocBuffer(nSize)); { __adtf_sample_write_lock_mediadescription(enumDescription, mediaSample, pCoder); pCoder->Set("tEnumValue", (tVoid *) &value); } mediaSample->SetTime(_clock->GetStreamTime()); RETURN_IF_FAILED(pin.Transmit(mediaSample)); RETURN_NOERROR; }
tResult ROI::SendRoi(const tRect &roi, cOutputPin &outputPin) { if (!outputPin.IsConnected()) { RETURN_NOERROR; } cObjectPtr<IMediaSample> mediaSample; RETURN_IF_FAILED(AllocMediaSample((tVoid **) &mediaSample)); cObjectPtr<IMediaSerializer> pSerializer; tRectDescriptionSignal->GetMediaSampleSerializer(&pSerializer); tInt nSize = pSerializer->GetDeserializedSize(); RETURN_IF_FAILED(mediaSample->AllocBuffer(nSize)); { __adtf_sample_write_lock_mediadescription(tRectDescriptionSignal, mediaSample, pCoder); pCoder->Set("tX", (tVoid *) &roi.tX); pCoder->Set("tY", (tVoid *) &roi.tY); pCoder->Set("tWidth", (tVoid *) &roi.tWidth); pCoder->Set("tHeight", (tVoid *) &roi.tHeight); } //transmit media sample over output pin mediaSample->SetTime(_clock->GetStreamTime()); RETURN_IF_FAILED(outputPin.Transmit(mediaSample)); RETURN_NOERROR; }
//############################################################################# tResult cMovementAnalyzer::Transmit(tFloat32 fValue, IMediaSample *pMediaSample, tUInt32 ui32TimeStamp, IPin *pSource) { //create new media sample cObjectPtr<IMediaSample> pNewMediaSample; AllocMediaSample((tVoid **) &pNewMediaSample); //allocate memory with the size given by the descriptor cObjectPtr<IMediaSerializer> pSerializer; m_pDescriptionSignal->GetMediaSampleSerializer(&pSerializer); tInt nSize = pSerializer->GetDeserializedSize(); pNewMediaSample->AllocBuffer(nSize); { // focus for sample write lock //write date to the media sample with the coder of the descriptor __adtf_sample_write_lock_mediadescription(m_pDescriptionSignal, pNewMediaSample, pCoderOutput); // get the IDs for the items in the media sample if (!m_bIDsSignalSet) { pCoderOutput->GetID("f32Value", m_szIDSignalF32Value); pCoderOutput->GetID("ui32ArduinoTimestamp", m_szIDSignalArduinoTimestamp); m_bIDsSignalSet = tTrue; } // set values in new media sample pCoderOutput->Set(m_szIDSignalF32Value, (tVoid *) &(fValue)); pCoderOutput->Set(m_szIDSignalArduinoTimestamp, (tVoid *) &ui32TimeStamp); } //transmit media sample over output pin pNewMediaSample->SetTime(pMediaSample->GetTime()); if (pSource == &this->m_oInputSpeed) { m_oOutputCalcSpeed.Transmit(pNewMediaSample); } if (pSource == &this->m_oInputAccX) { m_oOutputCalcAccX.Transmit(pNewMediaSample); } if (pSource == &this->m_oInputAccY) { m_oOutputCalcAccY.Transmit(pNewMediaSample); } if (pSource == &this->m_oInputDistance) { m_oOutputCalcDistance.Transmit(pNewMediaSample); } RETURN_NOERROR; }
tResult cDriverModule::OnSendState(stateCar stateID, tInt16 i16ManeuverEntry) { cObjectPtr<IMediaSample> pMediaSample; RETURN_IF_FAILED(AllocMediaSample((tVoid**)&pMediaSample)); cObjectPtr<IMediaSerializer> pSerializer; m_pDescDriverStruct->GetMediaSampleSerializer(&pSerializer); tInt nSize = pSerializer->GetDeserializedSize(); tInt8 value = tInt8(stateID); RETURN_IF_FAILED(pMediaSample->AllocBuffer(nSize)); { // focus for sample write lock __adtf_sample_write_lock_mediadescription(m_pDescDriverStruct,pMediaSample,pCoder); // get the IDs for the items in the media sample if(!m_bIDsDriverStructSet) { pCoder->GetID("i8StateID", m_szIDDriverStructI8StateID); pCoder->GetID("i16ManeuverEntry", m_szIDDriverStructI16ManeuverEntry); m_bIDsDriverStructSet = tTrue; } pCoder->Set(m_szIDDriverStructI8StateID, (tVoid*)&value); pCoder->Set(m_szIDDriverStructI16ManeuverEntry, (tVoid*)&i16ManeuverEntry); } pMediaSample->SetTime(_clock->GetStreamTime()); m_DriverStructOutputPin.Transmit(pMediaSample); if(m_bDebugModeEnabled) { switch (stateID) { case stateCar_READY: LOG_INFO(cString::Format("Driver Module: Send state: READY, Maneuver ID %d",i16ManeuverEntry)); break; case stateCar_RUNNING: LOG_INFO(cString::Format("Driver Module: Send state: RUNNING, Maneuver ID %d",i16ManeuverEntry)); break; case stateCar_COMPLETE: LOG_INFO(cString::Format("Driver Module: Send state: COMPLETE, Maneuver ID %d",i16ManeuverEntry)); break; case stateCar_ERROR: LOG_INFO(cString::Format("Driver Module: Send state: ERROR, Maneuver ID %d",i16ManeuverEntry)); break; case stateCar_STARTUP: break; } } RETURN_NOERROR; }
// ------------------------------------------------------------------------------------------------- tResult SensorPackageFilter::transmitSensorPackage(tTimeStamp time) { // ------------------------------------------------------------------------------------------------- cObjectPtr<IMediaSample> media_sample; RETURN_IF_FAILED(AllocMediaSample((tVoid**)&media_sample)); cObjectPtr<IMediaSerializer> serializer; sensor_package_description_->GetMediaSampleSerializer(&serializer); tInt size = serializer->GetDeserializedSize(); RETURN_IF_FAILED(media_sample->AllocBuffer(size)); float value_ir_l_fc = getMeanSensorValue(ir_l_fc_); float value_ir_l_fl = getMeanSensorValue(ir_l_fl_); float value_ir_l_fr = getMeanSensorValue(ir_l_fr_); float value_ir_s_fc = getMeanSensorValue(ir_s_fc_); float value_ir_s_fl = getMeanSensorValue(ir_s_fl_); float value_ir_s_fr = getMeanSensorValue(ir_s_fr_); float value_ir_s_l = getMeanSensorValue(ir_s_l_); float value_ir_s_r = getMeanSensorValue(ir_s_r_); float value_ir_s_rc = getMeanSensorValue(ir_s_rc_); float value_us_f_l = getMeanSensorValue(us_f_l_); float value_us_f_r = getMeanSensorValue(us_f_r_); float value_us_r_l = getMeanSensorValue(us_r_l_); float value_us_r_r = getMeanSensorValue(us_r_r_); { __adtf_sample_write_lock_mediadescription(sensor_package_description_, media_sample, coder); coder->Set("ir_l_fc", (tVoid*) &value_ir_l_fc); coder->Set("ir_l_fl", (tVoid*) &value_ir_l_fl); coder->Set("ir_l_fr", (tVoid*) &value_ir_l_fr); coder->Set("ir_s_fc", (tVoid*) &value_ir_s_fc); coder->Set("ir_s_fl", (tVoid*) &value_ir_s_fl); coder->Set("ir_s_fr", (tVoid*) &value_ir_s_fr); coder->Set("ir_s_l", (tVoid*) &value_ir_s_l); coder->Set("ir_s_r", (tVoid*) &value_ir_s_r); coder->Set("ir_s_rc", (tVoid*) &value_ir_s_rc); coder->Set("us_f_l", (tVoid*) &value_us_f_l); coder->Set("us_f_r", (tVoid*) &value_us_f_r); coder->Set("us_r_l", (tVoid*) &value_us_r_l); coder->Set("us_r_r", (tVoid*) &value_us_r_r); } sensor_package_output_.Transmit(media_sample); RETURN_NOERROR; }
void FunctionDriver::SendValue(IMediaSample *mediaSample, cOutputPin &outputPin, tFloat32 value) { cObjectPtr<IMediaSerializer> pSerializer; descriptionSignal->GetMediaSampleSerializer(&pSerializer); tInt nSize = pSerializer->GetDeserializedSize(); cObjectPtr<IMediaSample> newMediaSample; AllocMediaSample((tVoid **) &newMediaSample); newMediaSample->AllocBuffer(nSize); { __adtf_sample_write_lock_mediadescription(descriptionSignal, newMediaSample, outputCoder); outputCoder->Set("f32Value", (tVoid *) &(value)); } newMediaSample->SetTime(mediaSample->GetTime()); outputPin.Transmit(newMediaSample); }
tResult ImageCutter::transmitVideoOutput(Mat &image, cVideoPin &pin) { if (!pin.IsConnected()) { RETURN_NOERROR; } // Create new IMediaSample cObjectPtr<IMediaSample> sample; if (IS_OK(AllocMediaSample(&sample))) { tTimeStamp time = _clock ? _clock->GetStreamTime() : cHighResTimer::GetTime(); RETURN_IF_FAILED(sample->Update(time, image.data, this->videoOutputInfo.nSize, 0)); RETURN_IF_FAILED(pin.Transmit(sample)); } RETURN_NOERROR; }
// ------------------------------------------------------------------------------------------------- tResult LaneFilter::transmitLanePoints(std::vector<Vector2> const & mapped_points) { // ------------------------------------------------------------------------------------------------- cObjectPtr<IMediaSample> lane_points_sample; RETURN_IF_FAILED(AllocMediaSample(&lane_points_sample)); RETURN_IF_FAILED(lane_points_sample->AllocBuffer(sizeof(tUInt32) + sizeof(Vector2) * mapped_points.size())); tUInt32* dest_buffer = NULL; RETURN_IF_FAILED(lane_points_sample->WriteLock((tVoid**)&dest_buffer)); (*dest_buffer) = (tUInt32)mapped_points.size(); dest_buffer++; cMemoryBlock::MemCopy(dest_buffer, &(mapped_points[0]), sizeof(Vector2) * mapped_points.size()); RETURN_IF_FAILED(lane_points_sample->Unlock((tVoid*)dest_buffer)); lane_output_pin_.Transmit(lane_points_sample); RETURN_NOERROR; }
// ------------------------------------------------------------------------------------------------- tResult EmergencyFilter::transmitBool(cOutputPin & pin, bool value) { // ------------------------------------------------------------------------------------------------- cObjectPtr<IMediaSample> media_sample; RETURN_IF_FAILED(AllocMediaSample((tVoid**)&media_sample)); cObjectPtr<IMediaSerializer> serializer; bool_data_description_->GetMediaSampleSerializer(&serializer); tInt size = serializer->GetDeserializedSize(); RETURN_IF_FAILED(media_sample->AllocBuffer(size)); tUInt32 timeStamp = 0; { __adtf_sample_write_lock_mediadescription(bool_data_description_, media_sample, coder); coder->Set("bValue", (tVoid*) &value); coder->Set("ui32ArduinoTimestamp", (tVoid*) &timeStamp); } pin.Transmit(media_sample); RETURN_NOERROR; }
tResult DriverFilter::sendDriverState(const DriverState &driverState, const tInt16 &maneuverId) { cObjectPtr<IMediaSample> mediaSample; RETURN_IF_FAILED(AllocMediaSample((tVoid**) &mediaSample)); RETURN_IF_FAILED(mediaSample->AllocBuffer(this->ddlSizeDriver)); cObjectPtr<IMediaCoder> coder; RETURN_IF_FAILED(this->coderDescriptionDriver->WriteLock(mediaSample, &coder)); coder->Set("i8StateID", (tVoid*) &driverState); coder->Set("i16ManeuverEntry", (tVoid*) &maneuverId); RETURN_IF_FAILED(this->coderDescriptionDriver->Unlock(coder)); static tTimeStamp now; now = _clock ? _clock->GetStreamTime() : cHighResTimer::GetTime(); RETURN_IF_FAILED(mediaSample->SetTime(now)); RETURN_IF_FAILED(this->driverStatePin.Transmit(mediaSample)); RETURN_NOERROR; }
tResult pylonDetection::sendPylonInfo(float *distArray, float *angleArray) { cObjectPtr<IMediaSample> pMediaSample; RETURN_IF_FAILED(AllocMediaSample((tVoid**)&pMediaSample)); cObjectPtr<IMediaSerializer> pSerializer; m_pCoderDescPylonInfo->GetMediaSampleSerializer(&pSerializer); tInt nSize = pSerializer->GetDeserializedSize(); RETURN_IF_FAILED(pMediaSample->AllocBuffer(nSize)); tTimeStamp tmStreamTime = _clock ? _clock->GetStreamTime() : adtf_util::cHighResTimer::GetTime(); cObjectPtr<IMediaCoder> pCoder; RETURN_IF_FAILED(m_pCoderDescPylonInfo->WriteLock(pMediaSample, &pCoder)); pCoder->Set("f32Dist", (tVoid*) distArray); pCoder->Set("f32Angle", (tVoid*)angleArray); pCoder->Set("ui32ArduinoTimestamp", (tVoid*)&tmStreamTime); RETURN_IF_FAILED(m_pCoderDescPylonInfo->Unlock(pCoder)); RETURN_IF_FAILED(pMediaSample->SetTime(tmStreamTime)); RETURN_IF_FAILED(m_outputPin_PylonInfo.Transmit(pMediaSample)); RETURN_NOERROR; }
tResult DriverFilter::sendManeuver(cOutputPin &pin, const Maneuver &maneuver) { cObjectPtr<IMediaSample> mediaSample; RETURN_IF_FAILED(AllocMediaSample((tVoid**) &mediaSample)); RETURN_IF_FAILED(mediaSample->AllocBuffer(this->ddlSizeManeuver)); cObjectPtr<IMediaCoder> coder; RETURN_IF_FAILED(this->coderDescriptionDriver->WriteLock(mediaSample, &coder)); static tTimeStamp now; now = _clock ? _clock->GetStreamTime() : cHighResTimer::GetTime(); coder->Set("ui16Angle", (tVoid*) &maneuver); coder->Set("ui32ArduinoTimestamp", (tVoid*) &now); RETURN_IF_FAILED(this->coderDescriptionDriver->Unlock(coder)); RETURN_IF_FAILED_AND_LOG_ERROR_STR(mediaSample->SetTime(now), "cant set time to media sample"); RETURN_IF_FAILED_AND_LOG_ERROR_STR(pin.Transmit(mediaSample), "cant transmit media sample"); RETURN_NOERROR; }
tResult DriverFilter::sendManeuver(cOutputPin &pin, const Maneuver &manuever, const tTimeStamp &timeStamp) { // create new media sample cObjectPtr<IMediaSample> mediaSample; RETURN_IF_FAILED_AND_LOG_ERROR_STR(AllocMediaSample((tVoid**) &mediaSample), "cant alloc"); LOG_INFO(cString::Format("ddlSize: %d", this->ddlSizeManeuver)); RETURN_IF_FAILED_AND_LOG_ERROR_STR(mediaSample->AllocBuffer(this->ddlSizeManeuver), "cant alloc buffer size"); // write date to the media sample with the coder of the descriptor cObjectPtr<IMediaCoder> coder; RETURN_IF_FAILED_AND_LOG_ERROR_STR(this->coderDescriptionManeuver->WriteLock(mediaSample, &coder), "cant lock"); coder->Set("ui16Angle", (tVoid*) &manuever); coder->Set("ui32ArduinoTimestamp", (tVoid*) &timeStamp); RETURN_IF_FAILED_AND_LOG_ERROR_STR(this->coderDescriptionManeuver->Unlock(coder), "cant unlock"); // transmit media sample over output pin RETURN_IF_FAILED_AND_LOG_ERROR_STR(mediaSample->SetTime(timeStamp), "cant set time"); RETURN_IF_FAILED_AND_LOG_ERROR_STR(pin.Transmit(mediaSample), "cant transmit"); RETURN_NOERROR; }
tResult CurveDetector::transmitVideoOutput(Mat &image, cVideoPin &pin) { if (!pin.IsConnected()) { RETURN_NOERROR; } if (image.type() != CV_8UC3) { cvtColor(image, image, CV_GRAY2RGB); } cObjectPtr<IMediaSample> sample; if (IS_OK(AllocMediaSample(&sample))) { tTimeStamp time = _clock ? _clock->GetStreamTime() : cHighResTimer::GetTime(); RETURN_IF_FAILED(sample->Update(time, image.data, this->videoInputInfo.nSize, 0)); RETURN_IF_FAILED(pin.Transmit(sample)); } 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; }
/* tResult Emergency::transmitValue(cOutputPin &pin, const tFloat32 &value) { tUInt32 timeStamp = (tUInt32) (_clock ? _clock->GetStreamTime()/1000 : adtf_util::cHighResTimer::GetTime()/1000); // create new media sample cObjectPtr<IMediaSample> mediaSample; RETURN_IF_FAILED(AllocMediaSample((tVoid**) &mediaSample)); // allocate memory with the size given by the descriptor cObjectPtr<IMediaSerializer> serializer; RETURN_IF_FAILED(this->coderDescriptionSignalInput->GetMediaSampleSerializer(&serializer)); tInt size = serializer->GetDeserializedSize(); RETURN_IF_FAILED(mediaSample->AllocBuffer(size)); // write date to the media sample with the coder of the descriptor cObjectPtr<IMediaCoder> coder; RETURN_IF_FAILED(this->coderDescriptionSignalInput->WriteLock(mediaSample, &coder)); RETURN_IF_FAILED(coder->Set("f32Value", (tVoid*) &value)); RETURN_IF_FAILED(coder->Set("ui32ArduinoTimestamp", (tVoid*) &timeStamp)); RETURN_IF_FAILED(this->coderDescriptionSignalInput->Unlock(coder)); // transmit media sample over output pin RETURN_IF_FAILED(mediaSample->SetTime(_clock->GetStreamTime())); RETURN_IF_FAILED(pin.Transmit(mediaSample)); RETURN_NOERROR; } */ tResult Emergency::sendDecision(const Emergency_Decision &decision) { tTimeStamp timeStamp = (_clock ? _clock->GetStreamTime() : adtf_util::cHighResTimer::GetTime()); cObjectPtr<IMediaSample> mediaSample; RETURN_IF_FAILED(AllocMediaSample((tVoid**) &mediaSample)); RETURN_IF_FAILED(mediaSample->AllocBuffer(m_size)); cObjectPtr<IMediaCoder> coder; RETURN_IF_FAILED(this->coderDescriptionSignalOutput->WriteLock(mediaSample, &coder)); RETURN_IF_FAILED(coder->Set("ui16Angle", (tVoid*) &decision)); RETURN_IF_FAILED(coder->Set("ui32ArduinoTimestamp", (tVoid*) &timeStamp)); RETURN_IF_FAILED(this->coderDescriptionSignalOutput->Unlock(coder)); RETURN_IF_FAILED(mediaSample->SetTime(timeStamp)); RETURN_IF_FAILED(this->decisionPin.Transmit(mediaSample)); RETURN_NOERROR; }
void cBoolValueGenerator::OnTransmitValueTrue() { cObjectPtr<IMediaSample> pMediaSample; AllocMediaSample((tVoid**)&pMediaSample); //allocate memory with the size given by the descriptor cObjectPtr<IMediaSerializer> pSerializer; m_pCoderDescBool->GetMediaSampleSerializer(&pSerializer); pMediaSample->AllocBuffer(pSerializer->GetDeserializedSize()); tBool value = tTrue; //write date to the media sample with the coder of the descriptor { __adtf_sample_write_lock_mediadescription(m_pCoderDescBool, pMediaSample, pCoderOutput); pCoderOutput->Set("bValue",(tVoid*)&(value)); pCoderOutput->Set("ui32ArduinoTimestamp", 0); } pMediaSample->SetTime(_clock->GetStreamTime()); //transmit media sample over output pin m_oBoolValuePin.Transmit(pMediaSample); }
// ------------------------------------------------------------------------------------------------- tResult LaneFilter::transmitHeadLight(bool value) { // ------------------------------------------------------------------------------------------------- cObjectPtr<IMediaSample> pMediaSample; AllocMediaSample((tVoid**)&pMediaSample); //allocate memory with the size given by the descriptor cObjectPtr<IMediaSerializer> pSerializer; light_data_description_->GetMediaSampleSerializer(&pSerializer); tInt nSize = pSerializer->GetDeserializedSize(); pMediaSample->AllocBuffer(nSize); tUInt32 time_stamp = 0; { __adtf_sample_write_lock_mediadescription(light_data_description_, pMediaSample, coder); coder->Set("bValue", (tVoid*)&value); coder->Set("ui32ArduinoTimestamp", (tVoid*)&time_stamp); } //transmit media sample over output pin pMediaSample->SetTime(_clock->GetStreamTime()); light_output_.Transmit(pMediaSample); RETURN_NOERROR; }
tResult cUSSSensorBundle::TransmitData(tTimeStamp inputTimeStamp, tFloat32 front_left,tFloat32 front_right, tFloat32 rear_left, tFloat32 rear_right, tUInt32 timestampValue) { //create new media sample cObjectPtr<IMediaSample> pMediaSampleFrontLeft; cObjectPtr<IMediaSample> pMediaSampleFrontRight; cObjectPtr<IMediaSample> pMediaSampleRearLeft; cObjectPtr<IMediaSample> pMediaSampleRearRight; AllocMediaSample((tVoid**)&pMediaSampleFrontLeft); AllocMediaSample((tVoid**)&pMediaSampleFrontRight); AllocMediaSample((tVoid**)&pMediaSampleRearLeft); AllocMediaSample((tVoid**)&pMediaSampleRearRight); //allocate memory with the size given by the descriptor cObjectPtr<IMediaSerializer> pSerializer; m_pCoderDescSignalOutput->GetMediaSampleSerializer(&pSerializer); tInt nSize = pSerializer->GetDeserializedSize(); pMediaSampleFrontLeft->AllocBuffer(nSize); pMediaSampleFrontRight->AllocBuffer(nSize); pMediaSampleRearLeft->AllocBuffer(nSize); pMediaSampleRearRight->AllocBuffer(nSize); { // focus for sample write lock //write date to the media sample with the coder of the descriptor __adtf_sample_write_lock_mediadescription(m_pCoderDescSignalOutput,pMediaSampleFrontLeft,pCoderOutput); pCoderOutput->Set("f32Value", (tVoid*)&front_left); pCoderOutput->Set("ui32ArduinoTimestamp", (tVoid*)×tampValue); } pMediaSampleFrontLeft->SetTime(inputTimeStamp); //transmit media sample over output pin m_outputPin_front_left.Transmit(pMediaSampleFrontLeft); { // focus for sample write lock //write date to the media sample with the coder of the descriptor __adtf_sample_write_lock_mediadescription(m_pCoderDescSignalOutput,pMediaSampleFrontRight,pCoderOutput); pCoderOutput->Set("f32Value", (tVoid*)&front_right); pCoderOutput->Set("ui32ArduinoTimestamp", (tVoid*)×tampValue); } pMediaSampleFrontRight->SetTime(inputTimeStamp); //transmit media sample over output pin m_outputPin_front_right.Transmit(pMediaSampleFrontRight); { // focus for sample write lock //write date to the media sample with the coder of the descriptor __adtf_sample_write_lock_mediadescription(m_pCoderDescSignalOutput,pMediaSampleRearLeft,pCoderOutput); pCoderOutput->Set("f32Value", (tVoid*)&rear_left); pCoderOutput->Set("ui32ArduinoTimestamp", (tVoid*)×tampValue); } pMediaSampleRearLeft->SetTime(inputTimeStamp); //transmit media sample over output pin m_outputPin_rear_left.Transmit(pMediaSampleRearLeft); { // focus for sample write lock //write date to the media sample with the coder of the descriptor __adtf_sample_write_lock_mediadescription(m_pCoderDescSignalOutput,pMediaSampleRearRight,pCoderOutput); pCoderOutput->Set("f32Value", (tVoid*)&rear_right); pCoderOutput->Set("ui32ArduinoTimestamp", (tVoid*)×tampValue); } pMediaSampleRearRight->SetTime(inputTimeStamp); //transmit media sample over output pin m_outputPin_rear_right.Transmit(pMediaSampleRearRight); RETURN_NOERROR; }