Status KinesisLogForwarder::setUp() { // Set up client Status s = makeAWSClient<Aws::Kinesis::KinesisClient>(client_); if (!s.ok()) { return s; } shard_id_ = getHostIdentifier(); if (FLAGS_aws_kinesis_stream.empty()) { return Status(1, "Stream name must be specified with --aws_kinesis_stream"); } // Make sure we can connect to designated stream Aws::Kinesis::Model::ListStreamsRequest r; auto result = client_->ListStreams(r).GetResult(); std::vector<std::string> stream_names = result.GetStreamNames(); if (std::find(stream_names.begin(), stream_names.end(), FLAGS_aws_kinesis_stream) == stream_names.end()) { return Status(1, "Could not find Kinesis stream: " + FLAGS_aws_kinesis_stream); } VLOG(1) << "Kinesis logging initialized with stream: " << FLAGS_aws_kinesis_stream; return Status(0); }
XnStatus XnDeviceBase::IsNewDataAvailable(const XnChar* StreamName, XnBool* pbNewDataAvailable, XnUInt64* pnTimestamp) { XnStatus nRetVal = XN_STATUS_OK; XN_VALIDATE_INPUT_PTR(StreamName); XN_VALIDATE_OUTPUT_PTR(pbNewDataAvailable); *pbNewDataAvailable = FALSE; if (strcmp(StreamName, XN_PRIMARY_STREAM_ANY) == 0) { const XnChar* aStreamNames[100]; XnUInt32 nCount = 100; nRetVal = GetStreamNames(aStreamNames, &nCount); XN_IS_STATUS_OK(nRetVal); for (XnUInt32 i = 0; i < nCount; ++i) { // find stream XnDeviceStream* pStream = NULL; nRetVal = FindStream(StreamName, &pStream); XN_IS_STATUS_OK(nRetVal); if (pStream->IsNewDataAvailable()) { *pbNewDataAvailable = TRUE; *pnTimestamp = pStream->GetLastTimestamp(); break; } } } else { // find stream XnDeviceStream* pStream = NULL; nRetVal = FindStream(StreamName, &pStream); XN_IS_STATUS_OK(nRetVal); if (pStream->IsNewDataAvailable()) { *pbNewDataAvailable = TRUE; *pnTimestamp = pStream->GetLastTimestamp(); } } return (XN_STATUS_OK); }
XnStatus XnSensor::OpenAllStreams() { XnStatus nRetVal = XN_STATUS_OK; xnLogVerbose(XN_MASK_DEVICE_SENSOR, "Opening all streams..."); // take a list of all the streams const XnChar* astrStreams[XN_SENSOR_MAX_STREAM_COUNT]; XnUInt32 nStreamCount = XN_SENSOR_MAX_STREAM_COUNT; XnDeviceStream* apStreams[XN_SENSOR_MAX_STREAM_COUNT]; XnSensorStreamHolder* apSensorStreams[XN_SENSOR_MAX_STREAM_COUNT]; nRetVal = GetStreamNames(astrStreams, &nStreamCount); XN_IS_STATUS_OK(nRetVal); for (XnUInt32 i = 0; i < nStreamCount; ++i) { XnDeviceModuleHolder* pHolder; nRetVal = FindStream(astrStreams[i], &pHolder); XN_IS_STATUS_OK(nRetVal); apSensorStreams[i] = (XnSensorStreamHolder*)(pHolder); apStreams[i] = apSensorStreams[i]->GetStream(); } // NOTE: the following is an ugly patch. When depth and IR both exist, Depth stream MUST be configured // and opened BEFORE IR stream. So, generally, if one of the streams is depth, we move it to be first. for (XnUInt32 i = 1; i < nStreamCount; ++i) { if (strcmp(apStreams[i]->GetType(), XN_STREAM_TYPE_DEPTH) == 0) { // switch it with the one in location 0 const XnChar* strTempName = astrStreams[0]; XnDeviceStream* pTempStream = apStreams[0]; XnSensorStreamHolder* pTempHolder = apSensorStreams[0]; astrStreams[0] = astrStreams[i]; apStreams[0] = apStreams[i]; apSensorStreams[0] = apSensorStreams[i]; astrStreams[i] = strTempName; apStreams[i] = pTempStream; apSensorStreams[i] = pTempHolder; break; } } // now configure them all for (XnUInt32 i = 0; i < nStreamCount; ++i) { if (!apStreams[i]->IsOpen()) { xnLogVerbose(XN_MASK_DEVICE_SENSOR, "Configuring stream %s...", apStreams[i]->GetName()); nRetVal = apSensorStreams[i]->Configure(); XN_IS_STATUS_OK(nRetVal); xnLogVerbose(XN_MASK_DEVICE_SENSOR, "Stream %s is configured", apStreams[i]->GetName()); } else { xnLogVerbose(XN_MASK_DEVICE_SENSOR, "Stream %s is already open.", apStreams[i]->GetName()); } } // and open them all for (XnUInt32 i = 0; i < nStreamCount; ++i) { if (!apStreams[i]->IsOpen()) { nRetVal = apSensorStreams[i]->FinalOpen(); XN_IS_STATUS_OK(nRetVal); } } return (XN_STATUS_OK); }