Mir

Merge lp://qastaging/~albaguirre/mir/add-screencast-size-and-region-support into lp://qastaging/mir

Proposed by Alberto Aguirre
Status: Merged
Approved by: Alexandros Frantzis
Approved revision: no longer in the source branch.
Merged at revision: 1465
Proposed branch: lp://qastaging/~albaguirre/mir/add-screencast-size-and-region-support
Merge into: lp://qastaging/mir
Diff against target: 1211 lines (+335/-247)
19 files modified
include/server/mir/frontend/screencast.h (+3/-1)
include/shared/mir_toolkit/client_types.h (+23/-3)
include/test/mir_test_doubles/mock_screencast.h (+4/-2)
include/test/mir_test_doubles/null_screencast.h (+3/-1)
src/client/CMakeLists.txt (+1/-0)
src/client/mir_screencast.cpp (+20/-23)
src/client/mir_screencast.h (+4/-2)
src/client/mir_screencast_api.cpp (+9/-19)
src/server/compositor/compositing_screencast.cpp (+14/-37)
src/server/compositor/compositing_screencast.h (+6/-4)
src/server/compositor/screencast_display_buffer.cpp (+3/-2)
src/server/frontend/session_mediator.cpp (+9/-4)
src/shared/protobuf/mir_protobuf.proto (+9/-1)
src/utils/screencast.cpp (+14/-12)
tests/acceptance-tests/test_client_screencast.cpp (+72/-39)
tests/integration-tests/client/test_screencast.cpp (+5/-1)
tests/unit-tests/client/test_mir_screencast.cpp (+91/-79)
tests/unit-tests/compositor/test_compositing_screencast.cpp (+28/-17)
tests/unit-tests/compositor/test_screencast_display_buffer.cpp (+17/-0)
To merge this branch: bzr merge lp://qastaging/~albaguirre/mir/add-screencast-size-and-region-support
Reviewer Review Type Date Requested Status
Alan Griffiths Approve
Daniel van Vugt Approve
PS Jenkins bot (community) continuous-integration Approve
Alexandros Frantzis (community) Approve
Review via email: mp+209380@code.qastaging.launchpad.net

Commit message

Add wiring to support screencasting a region of the screen and capturing at
a user supplied size.

This is useful to capture at a lower resolution to improve screencasting
performance or to capture only a region of interest.

Description of the change

A different MP will add options to the mirscreencast utility so users can take advantage of this functionality.

To post a comment you must log in.
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

What you call "MirScreenRegion" is always a rectangle. Often "Region" refers to a more free-form region than that. So I suggest renaming "MirScreenRegion" to "MirRectangle".

Revision history for this message
Alberto Aguirre (albaguirre) wrote :

> What you call "MirScreenRegion" is always a rectangle. Often "Region" refers
> to a more free-form region than that. So I suggest renaming "MirScreenRegion"
> to "MirRectangle".

Agree, I've changed it.

Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

Since we are now moving to capturing arbitrary portions of the output(s), I propose the following interface:

typedef struct MirRectangle
{
    int32_t left; /* Note signed int */
    int32_t top; /* Note signed int */
    uint32_t width;
    uint32_t height;
} MirRectangle;

typedef struct MirScreencastParameters
{
    MirRectangle region;
    uint32_t width;
    uint32_t height;
    MirPixelFormat pixel_format;
} MirScreencastParameters;

That is, remove the OutputId parameter (will need changes in all relevant interfaces across the stack) and allow the user to capture an arbitrary rectangle in the *virtual coordinate space*. The mirscreencast utility can still keep the '-o' (output-id) parameter for convenience; we will just need to get the position/size of that output (we have that info in MirDisplayOutput) and use them as the region when creating the screencast.

This change will also allow capturing the contents of multiple outputs in the same screencast session.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

There's no need to constrain ints while we already have the requirement that the client and server are on the same machine. As such, we should change:
    int32_t --> int
    uint32_t --> unsigned

On some 64-bit platforms this will yield better performance too.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alberto Aguirre (albaguirre) wrote :

^---those failures seem unrelated to the MP.

Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

Functionally looks good (tested on desktop).

140 + if (output_size.width.as_int() == 0 ||
141 + output_size.height.as_int() == 0 ||
142 + region.size.width.as_int() == 0 ||
143 + region.size.height.as_int() == 0 ||
144 + pixel_format == mir_pixel_format_invalid) {
145 + BOOST_THROW_EXCEPTION(std::runtime_error("Invalid parameters"));
146 + }

static const geom::Size null_size;
if (output_size == null_size || region.size == null_size ||
    pixel_format == mir_pixel_format_invalid)
{
...
}

391 + MirPixelFormat pixel_format = static_cast<MirPixelFormat>(parameters->pixel_format());

Could be const.

410 + required int32 region_top = 3;
411 + required int32 region_left = 4;
412 + required uint32 region_width = 5;
413 + required uint32 region_height = 6;

Perhaps we should have a Rectangle protobuf message?

review: Needs Fixing
Revision history for this message
Alberto Aguirre (albaguirre) wrote :

> 140 + if (output_size.width.as_int() == 0 ||
> 141 + output_size.height.as_int() == 0 ||
> 142 + region.size.width.as_int() == 0 ||
> 143 + region.size.height.as_int() == 0 ||
> 144 + pixel_format == mir_pixel_format_invalid) {
> 145 + BOOST_THROW_EXCEPTION(std::runtime_error("Invalid parameters"));
> 146 + }
>
> static const geom::Size null_size;
> if (output_size == null_size || region.size == null_size ||
> pixel_format == mir_pixel_format_invalid)
> {
> ...
> }
>

I want to test for cases where only one parameter was set to 0.

> 391 + MirPixelFormat pixel_format =
> static_cast<MirPixelFormat>(parameters->pixel_format());
>
> Could be const.

Ack.

> 410 + required int32 region_top = 3;
> 411 + required int32 region_left = 4;
> 412 + required uint32 region_width = 5;
> 413 + required uint32 region_height = 6;
>
> Perhaps we should have a Rectangle protobuf message?

Ack.

Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

> I want to test for cases where only one parameter was set to 0.

Right! In that case:

144 + pixel_format == mir_pixel_format_invalid) {
145 + BOOST_THROW_EXCEPTION(std::runtime_error("Invalid parameters"));
146 + }

Not our preferred brace style.

Revision history for this message
Alberto Aguirre (albaguirre) wrote :

> > I want to test for cases where only one parameter was set to 0.
>
> Right! In that case:
>
> 144 + pixel_format == mir_pixel_format_invalid) {
> 145 + BOOST_THROW_EXCEPTION(std::runtime_error("Invalid parameters"));
> 146 + }
>
> Not our preferred brace style.

Fixed.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

Looks good.

review: Approve
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

40 + MirRectangle region;
41 + unsigned int width;
42 + unsigned int height;

It looks odd to have a rectangle and width and height - at the least there should be some documentation (if not clearer names).

review: Needs Fixing
Revision history for this message
Alberto Aguirre (albaguirre) wrote :

> 40 + MirRectangle region;
> 41 + unsigned int width;
> 42 + unsigned int height;
>
> It looks odd to have a rectangle and width and height - at the least there
> should be some documentation (if not clearer names).

I added documentation. The main purpose of the seperate width/height from the region is to downscale the screencast independently of selecting a screen region to capture.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Minor concerns, but nothing blocking;

(1) Pointless cast of MirPixelFormat to MirPixelFormat:
405 + MirPixelFormat const pixel_format = static_cast<MirPixelFormat>(parameters->pixel_format());

(2) You're not meant to ever change "required" stuff but I don't see a better answer...
427 - required uint32 output_id = 1;
428 + required Rectangle region = 1;

(3) The new protocol doesn't need or use output_id so why print it?
500 + std::cout << "Starting screencast for output id " << output_id << std::endl;

review: Approve
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

OK

review: Approve
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

(1) Oops. That cast is not pointless at all. Ignore (1) :)

Revision history for this message
Alberto Aguirre (albaguirre) wrote :

> Minor concerns, but nothing blocking;

> (3) The new protocol doesn't need or use output_id so why print it?
> 500 + std::cout << "Starting screencast for output id " << output_id <<
> std::endl;

This is removed on the other MP - adding-extra-options-to-mirscreencast

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches