Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
[json]: - added Player.SetViewMode/GetViewmode method to the json interface #15477
this bumps json api version to 10.2.0. For this I need help on how to handle the json api bump.
expose the RenderManager.SetViewMode/GetViewMode method to json
Motivation and Context
This was requested in the forum and is useful for projector users. When having a projector with 16:9 screen and watching 21:9 movies it is good to shift the whole videos own to the bottom of the screen to get a hard cut in contrast (black bars are usually not that black when projected). By exposing ViewMode to json it is now possible to set vertical shift to the liking.
How Has This Been Tested?
Tested via curl:
shift to the bottom ( vertical shift 1.0 means shift down as far as possible without cut):
back to normal view mode
query current viewmode
Types of change
@Memphiz thanks for doing some JSON.
I don't think there is a wiki page for v10 JSON schema yet. One was started for v9 by mistake (the odd versions are interim during dev phase) and some things edited but most not. I think that that a partially updated and inaccurate page is worse than none at all, so unless someone volunteers to write a complete and accurate wiki for v10 I suggest it better to not have one. The schema is self documenting (description method) so it is not as if there is nothing for clients to look at.
But I do have some questions about the method
Thanks for this @Memphiz definitely better, and sorry for delay getting back to you (been busy in real life). But I think it could be improved further. Those using the API should not have to look at C++ to know what the viewmode codes mean, the API should fully document and validate all parameters. Yes this means keeping the JSON schema upto date with any enum changes in core code, but that is how API consumers know something has changed.
Also looking deeper only some parameter combinations are valid. Calls to SetRenderViewMode either set viewmode to one of the mode presets e.g. Normal, Zoom, Stretch4x3 etc. or set view mode to Custom and set one or more of zoom, pixelratio, verticalshift or nonlinearstretch. This can be implemented in JSON too.
using new types added to https://github.com/xbmc/xbmc/blob/master/xbmc/interfaces/json-rpc/schema/types.json with
Example valid calls then look like
I pulled the max/min values for zoom, pixelratio and verticalshift from https://github.com/xbmc/xbmc/blob/master/xbmc/video/PlayerController.cpp, it makes sense to me they should be the same (assuming they exist for a reason?). I can let you have a patch file for this if that helps.
So is our JSON API in that shape you suggest here everywhere else? This will take me a while to do it. I considered this an advanced feature but I guess everything in that API needs to be bullet proof.
Yeap, needs to be bullet proof even if the internal function it exposes does not have the cleanest interface. Understand the time limits etc. @Memphiz, and sorry for any frustration. This can still be a quickish win. I have a patch file that implements what I'm suggesting, shall I push it to your repo (if I can)? Work all done, just a matter of getting into into this PR :)
@DaveTBlake i have added your commit to this PR and added my refactoring proposal. Main goal was to reduce the code duplication, early returns and if nesting. Also we have the string to enum mapping in a single place now which makes it easier to add new values later on. Once you are ok with this (and maybe you even have some time to test it) I will squash this into a single commit.
@Memphiz I'm fine in principle with the refactoring, I obviously don't have as much aversion to early returns as you do and tend to copy existing code style :)
Only thought looking at the code is that