Do small changes
This commit is contained in:
parent
c5dd47708e
commit
a0cf8fd902
|
@ -26,6 +26,7 @@
|
|||
#include "internal/motions.h"
|
||||
#include "internal/streams.h"
|
||||
#include "internal/strings.h"
|
||||
#include "internal/times.h"
|
||||
#include "internal/types.h"
|
||||
#include "uvc/uvc.h"
|
||||
|
||||
|
@ -419,13 +420,18 @@ void Device::StartVideoStreaming() {
|
|||
static std::uint8_t drop_count = 1;
|
||||
if (drop_count > 0) {
|
||||
--drop_count;
|
||||
continuation();
|
||||
return;
|
||||
}
|
||||
// auto &&time_beg = times::now();
|
||||
if (streams_->PushStream(Capabilities::STEREO, data)) {
|
||||
CallbackPushedStreamData(Stream::LEFT);
|
||||
CallbackPushedStreamData(Stream::RIGHT);
|
||||
}
|
||||
continuation();
|
||||
// VLOG(2) << "Stereo video callback cost "
|
||||
// << times::count<times::milliseconds>(times::now() - time_beg)
|
||||
// << " ms";
|
||||
});
|
||||
} else {
|
||||
LOG(FATAL) << "Not any stream capabilities are supported by this device";
|
||||
|
|
|
@ -259,20 +259,26 @@ void Streams::AllocStreamData(
|
|||
void Streams::AllocStreamData(
|
||||
const Stream &stream, const StreamRequest &request, const Format &format) {
|
||||
stream_data_t data;
|
||||
if (stream == Stream::LEFT || stream == Stream::RIGHT) {
|
||||
data.img = std::make_shared<ImgData>();
|
||||
} else {
|
||||
data.img = nullptr;
|
||||
}
|
||||
|
||||
if (HasStreamDatas(stream)) {
|
||||
// If cached equal to limits_max, drop the oldest one.
|
||||
if (stream_datas_map_.at(stream).size() == GetStreamDataMaxSize(stream)) {
|
||||
auto &&datas = stream_datas_map_[stream];
|
||||
data.frame = datas.front().frame; // reuse this frame
|
||||
// reuse the dropped data
|
||||
data.img = datas.front().img;
|
||||
data.frame = datas.front().frame;
|
||||
datas.erase(datas.begin());
|
||||
VLOG(2) << "Stream data of " << stream << " is dropped as out of limits";
|
||||
}
|
||||
}
|
||||
|
||||
if (stream == Stream::LEFT || stream == Stream::RIGHT) {
|
||||
if(!data.img) {
|
||||
data.img = std::make_shared<ImgData>();
|
||||
}
|
||||
} else {
|
||||
data.img = nullptr;
|
||||
}
|
||||
if (!data.frame) {
|
||||
data.frame = std::make_shared<frame_t>(
|
||||
request.width, request.height, format, nullptr);
|
||||
|
|
Loading…
Reference in New Issue
Block a user