-
Notifications
You must be signed in to change notification settings - Fork 19
Deflect stereo streaming API refactoring #153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
94d695a
to
68168b1
Compare
deflect/SegmentParameters.h
Outdated
/** Is the image raw pixel data or compressed in jpeg format */ | ||
bool compressed = true; | ||
|
||
View view = View::mono; //!< Eye pass for the segment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had started like this but this breaks compatibility with older clients because the serialization code uses sizeof(SegmentParameters). I don't think a workaround is possible for all use cases without a proper protocol version exchange, which we don't have.
611595d
to
3cbdfbd
Compare
Should be 90% there now. Please review. |
Btw, DesktopStreamer async streaming helps perf :) |
Ouch, I hadn't noticed that DesktopStreamer was NOT using the async send before...! That must help indeed... Will have a look at the changes. |
deflect/ReceiveBuffer.h
Outdated
* finishFrameForSource() has already been called for all existing | ||
* sources (TODO DISCL-241). | ||
* finishFrameForSource() | ||
* has already been called for all existing source (TODO DISCL-241). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
broken indentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
/** Parameters of the segment. */ | ||
SegmentParameters parameters; | ||
|
||
View view = View::mono; //!< Eye pass for the segment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment style consistency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just a style remark but all other 3 fields in this class use the /** ... */ syntax, and this one in the middle has a //!< ... on the side. The //!< syntax is more compact, but then I would expect all fields to follow the same style... but it's not a big deal ;-)
deflect/Stream.h
Outdated
* referenced must remain valid until the send is finished | ||
* @return true if the image data could be sent, false otherwise. | ||
* @see send() | ||
* @version 1.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Version 1.6 also for send() and finishFrame()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Stream::Future enqueueImage(const ImageWrapper& image); | ||
Stream::Future enqueueImage(const ImageWrapper& image, bool finish); | ||
|
||
Stream::Future enqueueFinish(); //!< Enqueue a finishFrame() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doc style consistency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand what you mean here. It's standard doxygen, and we use it everywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is new to me though, I've never used that anywhere ;-) what rule do you apply to choose between //!< and /** ... */, you check if it can fit on one line? It just does not look very consistent to me when I look at the entire file but I can live with it if you like it :-)
doc/StereoStreaming.md
Outdated
The ImageWrapper takes an additional View parameter. | ||
|
||
API changes to the Stream class: | ||
* asyncSend is deprecated but work as before, but only for mono views |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
work -> works
doc/StereoStreaming.md
Outdated
On the server side, no changes to the Server API (except some cleanups). Each | ||
Frame dispatched now contains the View information. | ||
Frame dispatched now contains the View information. A frame is considered | ||
complete when all connected clients did send a finish. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did send -> have sent
## Examples | ||
|
||
Example of a stereo 3D client application using the blocking Stream API: | ||
Example of a stereo 3D client application using synchronous operations: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this section must be corrected to .wait() or be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
must they? If executed as is, each call should be synchronous, or am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually you made me realize yesterday that std::future destructor does not wait(), execpt in the special case of std::async(std::launch::async). http://en.cppreference.com/w/cpp/thread/future/%7Efuture
So I think this is not the same as the previous synchronous api. In fact, if the sending takes longer than the rendering this will queue up send requests indefinitely, or more likely crash because an ImageWrapper will point to invalid data...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gah, you're right. Changing it.
leftFuture = deflect::qt::make_ready_future<bool>( true ); | ||
rightFuture = deflect::qt::make_ready_future<bool>( true ); | ||
|
||
ImageData leftData, rightData; // must remain valid until sending completes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why remove this? I think it is important to show the correct usage of the api. Without those variables the renderLoop below does not make sense because the "auto future" goes out of scope.
Furthermore there should be a third future for the deflectStream->finishFrame();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I interpreted it differently. Re-adding.
tests/cpp/perf/benchmarkStreamer.cpp
Outdated
deflectImage.compressionPolicy = deflect::COMPRESSION_OFF; | ||
|
||
return _stream->send(deflectImage) && _stream->finishFrame(); | ||
return _stream->send(deflectImage).get() && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sendAndFinish().get()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
damn, one slipped through.
tests/cpp/perf/benchmarkStreamer.cpp
Outdated
deflectImage.compressionQuality = _options.quality; | ||
|
||
return _stream->send(deflectImage) && _stream->finishFrame(); | ||
return _stream->send(deflectImage).get() && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what? ;)
FYI Tide adaptation: rdumusc/Tide@0e4d1b4 |
Ready to squash & merge, as far as I can see. |
Please review two last commits, RTM from my side. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good otherwise
deflect/StreamSendWorker.cpp
Outdated
const Request& request = _requests.front(); | ||
const ImageWrapper image(request.image); | ||
const uint32_t tasks(request.tasks); | ||
PromisePtr promise(request.promise); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find the way the request is copied quite confusing. I didn't see at first that "image" was a copy, I thought it was wrapping around "request.image". I would simply do in two lines:
const auto request = _requests.front();
_requests.pop_front();
Or if for some reason you prefer having individual variables then I would still suggest C++11 style with auto for readability:
const auto& request = _requests.front();
const auto image = request.image;
const auto tasks = request.tasks;
const auto promise = request.promise;
_requests.pop_front();
Not really needed as those objects are cheap to copy, but it could even be:
auto& request = _requests.front();
const auto image = std::move(request.image);
const auto tasks = std::move(request.tasks);
const auto promise = std::move(request.promise);
_requests.pop_front();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
deflect/StreamSendWorker.cpp
Outdated
{ | ||
request.promise->set_value(false); | ||
promise->set_value(false); | ||
_requests.pop_back(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think those two pop_back() should no longer be here!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch
@rdumusc : I'll let you manage the merge of this, Equalizer and Tide. |
@eile I'll handle Tide later today, but it would be easier if you could just update the sha1 of Deflect in the Equalizer PR and merge |
Will do |
FYI @rdumusc @tribal-tec: This is WIP and not fully tested yet. Just opening the PR in case you want to comment already.