Skip to content
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

Add auto, hide and always three background drawing mode support. #50

Merged
merged 1 commit into from
Jan 4, 2020

Conversation

taoyuan
Copy link

@taoyuan taoyuan commented Dec 24, 2019

This PR extended raop_callback_s to provide two more callbacks: conn_init and conn_destroy.

So we can listen the connection activity to render background when first connection connected and remove background when last connection disconnected.

@moda20
Copy link

moda20 commented Dec 24, 2019

So technically we can now not have to deal with the black screen and just render the incoming flow when it comes ?

@taoyuan
Copy link
Author

taoyuan commented Dec 24, 2019

This may be make #37 possible.

@taoyuan
Copy link
Author

taoyuan commented Dec 24, 2019

@moda20 It should be.

Copy link
Owner

@FD- FD- left a comment

Choose a reason for hiding this comment

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

Thanks for your PR! I have a few suggestions for your changes before merging them:

  1. It seems your IDE modified the indentation in a lot of places. I have now streamlined many project files to consistently use four spaces instead of tabs, so please rebase on that commit and remove your modifications to indentation. It’s difficult to figure out the actual changes you made since there are lots of line replacements highlighted that are really just the indentation.

  2. For my use case, I still want the background to be visible independent of whether there is an active connection. Thus, please add a command line option for setting the background behavior. I suggest this to be an additional argument to the -b flag that indicates the desired background mode: "0": Don’t draw any background, "1": Draw background only while there’s an active connection, "2": Always draw background. Probably strings for the different modes would be better than numbers (and more in line with the audio sink selection), but I can’t come up with any short descriptive names. Let me know if you have any ideas!
 For the case that the user chooses to always draw the background, please move the call to video_renderer_render_background into rpiplay.cpp, to the place immediately after the video renderer is initialised. That way, it's always rpiplay.cpp's responsibility to manage the background, instead of having it spread around in rpiplay.cpp and the renderer itself. This should also allow us to remove the background argument to the renderer initialisation.

lib/raop.h Outdated
@@ -28,19 +28,22 @@ extern "C" {


typedef struct raop_s raop_t;
typedef struct raop_conn_s raop_conn_t;
Copy link
Owner

Choose a reason for hiding this comment

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

What's that for?

Copy link
Author

Choose a reason for hiding this comment

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

It is used in new added callbacks conn_init and conn_destory for generic usage. In terms of drawing background, it is not necessary.

What do you think?

Copy link
Owner

Choose a reason for hiding this comment

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

Oh, I see, this is just the typedef. At first glance, I thought it was a global variable. Still, just for the background rendering, I'd prefer not to expose library internals. If we need it at a later point, we can still add it back in pretty easily. So, I'd suggest to remove the raop_conn_t argument from the two new callback functions.

Copy link
Author

Choose a reason for hiding this comment

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

OK

Copy link
Author

Choose a reason for hiding this comment

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

Removed the conn parameter from conn_init and conn_destroy and the conn typedef in the latest commit

@@ -117,7 +133,7 @@ int video_renderer_init_decoder(video_renderer_t *renderer) {

bcm_host_init();

if (renderer->background) video_renderer_draw_background();
Copy link
Owner

Choose a reason for hiding this comment

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

For my use case, I still want the background to be drawn independent of whether there is an actual connection. Thus, please add a command line option for toggling the background mode, more details in the discussion thread.

Copy link
Owner

Choose a reason for hiding this comment

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

For the case that the user chooses to always draw the background, please move the call to video_renderer_render_background into rpiplay.cpp, to the place immediately after the video renderer is initialised. That way, it's always rpiplay.cpp's responsibility to manage the background, instead of having it spread around in rpiplay.cpp and the renderer itself. This should also allow us to remove the background argument to the renderer initialisation.

Copy link
Author

Choose a reason for hiding this comment

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

In latest commit, there is a new function video_renderer_update_background will be called in video_renderer_init to support always background drawing mode.

rpiplay.cpp is responsable to call video_renderer_update_background in conn_init and conn_destroy that seems only can be set to raop_t instance in start_server of rpiplay.cpp.

If there is better way to move all background details to video renderer, please tell me, I will do it.

@@ -59,36 +59,52 @@ struct video_renderer_s {
uint64_t input_frames;
};

DISPMANX_ELEMENT_HANDLE_T background = 0;
Copy link
Owner

Choose a reason for hiding this comment

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

Please move this into the video_renderer_s struct.

Copy link
Author

Choose a reason for hiding this comment

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

It has been done in latest commit

@taoyuan
Copy link
Author

taoyuan commented Jan 3, 2020

Thanks for your review. I will take some time to make some explanations and changes these days for this PR.

@taoyuan
Copy link
Author

taoyuan commented Jan 4, 2020

Thanks for your PR! I have a few suggestions for your changes before merging them:

  1. It seems your IDE modified the indentation in a lot of places. I have now streamlined many project files to consistently use four spaces instead of tabs, so please rebase on that commit and remove your modifications to indentation. It’s difficult to figure out the actual changes you made since there are lots of line replacements highlighted that are really just the indentation.

It may be that I see inconsistencies in the indentation and habitually reformat it. In future collaborations, I will keep the original format as much as possible, and only submit logic change code.

By the way, we can use (EditorConfig)[https://editorconfig.org] that helps maintain consistent coding styles for multiple developers working on the same project across various editors and IDEs.

  1. For my use case, I still want the background to be visible independent of whether there is an active connection. Thus, please add a command line option for setting the background behavior. I suggest this to be an additional argument to the -b flag that indicates the desired background mode: "0": Don’t draw any background, "1": Draw background only while there’s an active connection, "2": Always draw background. Probably strings for the different modes would be better than numbers (and more in line with the audio sink selection), but I can’t come up with any short descriptive names. Let me know if you have any ideas!
 For the case that the user chooses to always draw the background, please move the call to video_renderer_render_background into rpiplay.cpp, to the place immediately after the video renderer is initialised. That way, it's always rpiplay.cpp's responsibility to manage the background, instead of having it spread around in rpiplay.cpp and the renderer itself. This should also allow us to remove the background argument to the renderer initialisation.

I have refactored -b flag to add auto, hide and always to support three background modes. And also refactor video_renderer_s->background to int type:

0: no background
1: draw background only while there's an active connection
2: always draw background

Copy link
Owner

@FD- FD- left a comment

Choose a reason for hiding this comment

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

Thanks for your modifications!

Before I can merge this, please also correct the indentation to match the four spaces that are used in most of the rest of the project.

EditorConfig seems like a good way to automatically maintain a coding style. If you have experience setting it up, please submit a separate PR for that. Please note that since this project includes files from various different origins, they adhere to different coding styles at the moment. I tried to streamline them all, but some make use of kind of ASCII-art formatting that would look weird if imposing a different coding style. Ideally, they'd have to manually be corrected.

rpiplay.cpp Outdated
@@ -36,13 +36,13 @@
#define VERSION "1.2"

#define DEFAULT_NAME "RPiPlay"
#define DEFAULT_SHOW_BACKGROUND true
#define DEFAULT_BACKGROUND 1
Copy link
Owner

Choose a reason for hiding this comment

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

Please make it default to always/on, to keep backwards-compatibility.

Copy link
Author

Choose a reason for hiding this comment

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

It has been done.

@FD-
Copy link
Owner

FD- commented Jan 4, 2020

Great, thanks! Please squash your commits so we don't have all these small commits cluttering the commit history and I'll happily merge it!

@taoyuan taoyuan changed the title Render background only when have connections if background enabled Add auto, hide and always three background drawing mode support. Jan 4, 2020
@taoyuan
Copy link
Author

taoyuan commented Jan 4, 2020

The commits has been squashed and renamed the name of the PR.

@FD- FD- merged commit cd69266 into FD-:master Jan 4, 2020
@FD-
Copy link
Owner

FD- commented Jan 4, 2020

Merged into master and working fine. Thanks again for your contribution!

@FD- FD- mentioned this pull request Jan 4, 2020
@moda20
Copy link

moda20 commented Jan 5, 2020

is the compilation process still the same ? how to choose between the new parameters when launching ?

@horge
Copy link

horge commented Jan 5, 2020

@moda20 compilation process has not changed. take a look at the updated README.md usage section for new parameters

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.

4 participants