Skip to content

Conversation

eile
Copy link
Contributor

@eile eile commented Mar 7, 2017

FYI @rdumusc @tribal-tec: This is WIP and not fully tested yet. Just opening the PR in case you want to comment already.

@eile eile changed the title FYI @rdumusc @tribal-tec: This is WIP and not fully tested yet. Just opening the PR in case you want to comment already. Defect stereo streaming API refactoring Mar 7, 2017
@eile eile force-pushed the master branch 2 times, most recently from 94d695a to 68168b1 Compare March 7, 2017 14:48
/** Is the image raw pixel data or compressed in jpeg format */
bool compressed = true;

View view = View::mono; //!< Eye pass for the segment
Copy link

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.

@eile eile force-pushed the master branch 2 times, most recently from 611595d to 3cbdfbd Compare March 21, 2017 09:40
@eile
Copy link
Contributor Author

eile commented Mar 21, 2017

Should be 90% there now. Please review.

@eile
Copy link
Contributor Author

eile commented Mar 21, 2017

Btw, DesktopStreamer async streaming helps perf :)

@rdumusc
Copy link

rdumusc commented Mar 21, 2017

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.

* finishFrameForSource() has already been called for all existing
* sources (TODO DISCL-241).
* finishFrameForSource()
* has already been called for all existing source (TODO DISCL-241).
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

broken indentation

Copy link
Contributor Author

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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment style consistency

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link

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
Copy link

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()

Copy link
Contributor Author

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()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doc style consistency

Copy link
Contributor Author

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?

Copy link

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 :-)

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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

work -> works

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.
Copy link

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:
Copy link

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

Copy link
Contributor Author

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?

Copy link

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...

Copy link
Contributor Author

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
Copy link

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();

Copy link
Contributor Author

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.

deflectImage.compressionPolicy = deflect::COMPRESSION_OFF;

return _stream->send(deflectImage) && _stream->finishFrame();
return _stream->send(deflectImage).get() &&
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sendAndFinish().get()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

damn, one slipped through.

deflectImage.compressionQuality = _options.quality;

return _stream->send(deflectImage) && _stream->finishFrame();
return _stream->send(deflectImage).get() &&
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what? ;)

eile pushed a commit to eile/Deflect that referenced this pull request Mar 21, 2017
eile pushed a commit to eile/Deflect that referenced this pull request Mar 21, 2017
rdumusc pushed a commit to rdumusc/Deflect that referenced this pull request Mar 21, 2017
rdumusc pushed a commit to rdumusc/Deflect that referenced this pull request Mar 21, 2017
@rdumusc
Copy link

rdumusc commented Mar 22, 2017

FYI Tide adaptation: rdumusc/Tide@0e4d1b4

eile pushed a commit to eile/Deflect that referenced this pull request Mar 22, 2017
@eile
Copy link
Contributor Author

eile commented Mar 22, 2017

Ready to squash & merge, as far as I can see.

@eile eile changed the title Defect stereo streaming API refactoring Deflect stereo streaming API refactoring Mar 22, 2017
eile pushed a commit to eile/Tide that referenced this pull request Mar 22, 2017
@eile
Copy link
Contributor Author

eile commented Mar 23, 2017

Please review two last commits, RTM from my side.

Copy link

@rdumusc rdumusc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good otherwise

const Request& request = _requests.front();
const ImageWrapper image(request.image);
const uint32_t tasks(request.tasks);
PromisePtr promise(request.promise);
Copy link

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();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

{
request.promise->set_value(false);
promise->set_value(false);
_requests.pop_back();
Copy link

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!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch

@eile
Copy link
Contributor Author

eile commented Mar 24, 2017

@rdumusc : I'll let you manage the merge of this, Equalizer and Tide.

@rdumusc rdumusc merged commit 6c3d21c into BlueBrain:master Mar 24, 2017
@rdumusc
Copy link

rdumusc commented Mar 24, 2017

@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

eile pushed a commit to eile/Tide that referenced this pull request Mar 24, 2017
@eile
Copy link
Contributor Author

eile commented Mar 24, 2017

Will do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants