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 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 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; }
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 ObjectFilter::transmitObjects(std::vector<Object> const & objects, cOutputPin & output_pin) { // ------------------------------------------------------------------------------------------------- cObjectPtr<IMediaSample> objects_sample; RETURN_IF_FAILED(AllocMediaSample(&objects_sample)); RETURN_IF_FAILED(objects_sample->AllocBuffer(sizeof(tUInt32) + sizeof(Object) * objects.size())); tUInt32* dest_buffer = NULL; RETURN_IF_FAILED(objects_sample->WriteLock((tVoid**)&dest_buffer)); (*dest_buffer) = (tUInt32)objects.size(); dest_buffer++; cMemoryBlock::MemCopy(dest_buffer, &(objects[0]), sizeof(Object) * objects.size()); RETURN_IF_FAILED(objects_sample->Unlock((tVoid*)dest_buffer)); output_pin.Transmit(objects_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::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 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 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; }