-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
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
Encoding options #1296
Encoding options #1296
Conversation
(cherry picked from commit fa56950) (cherry picked from commit c12306a6c2c15c9368feab25f298e97015ee07eb)
1b12204
to
e5d861c
Compare
e5d861c
to
fb7b2ae
Compare
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.
My idea in #1226 (comment) was to support any key, not a predefined set of keys.
In other words, scrcpy would just delegate the key and the value to:
format.setInteger(key, value);
(in the case of integers)
Without any "understanding" of what the key or the value is.
Sorry, I probably should have been more explicit :/
What do you think of just forwarding key/value pairs?
(Also, please update your dev
branch)
import java.util.LinkedHashMap; | ||
import java.util.Map; | ||
|
||
public class CodecOptions { |
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.
(so this class would not be needed at all)
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 think its a smart idea to let the user pass down any key=value pair he wants...
He can totally mess up and give random values and things that might even break the encoding and he won't be aware that he was giving something wrong.
I don't know about the other options but in case of profile and level it is suggested that if you provide a profile, you will also set a level, this is why when only profile (without level) is provided by the user, there is a calculation based on the screen size that should decide the level.
My goal was not to allow the user to pass down any key=value pair he wants, but to allow you or whoever wants to, to expand on the current CodecOptions and easily add new options that he can choose how they will be parsed and what will happen with them and where in the code.
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 think its a smart idea to let the user pass down any key=value pair he wants...
It would allow to configure the codec generically, without having to build the app.
For advanced options, I would prefer a generic way.
He can totally mess up and give random values and things that might even break the encoding and he won't be aware that he was giving something wrong.
At least, we can warn if the provided key is not supported: (EDIT: in fact, it just tells whether we set a key for the format)containsKey()
.
User can already pass random values (a bitrate of 1Mbps for instance), which is "ignored" by the codec without warnings.
I don't know about the other options but in case of profile and level it is suggested that if you provide a profile, you will also set a level, this is why when only profile (without level) is provided by the user, there is a calculation based on the screen size that should decide the level.
Isn't it done automatically if you don't provide the level? #1226 (comment)
Btw, contrary to what I said here, there is no need to specify the type in the string, it can be requested: getValueTypeForKey
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.
OK, it will be done your way :)
Thanks for the good lesson.
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.
@rom1v
Just a quick question, what if the key is supported but value is not supported by the device?
If we are assuming the codec ignores bad values shouldn't the user know about it somehow?
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.
getValueTypeForKey is API29+ ...
What do you suggest?
We can go back to what you said, assuming int unless specified key:type=value
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.
@rom1v Ping
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 if the key is supported but value is not supported by the device?
The device will just ignore it I guess. Like if for now you pass --max-fps
but the encoder does not support it.
getValueTypeForKey is API29+
:(
We can go back to what you said, assuming int unless specified key:type=value
Hmm, yes... I have no better solution then :(
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.
OK, so I've made the changes on our side, ill need to update my dev branch and make a new PR.
@rom1v
Just to make things clear before i make a new PR, the expected value types are
Integer/int - String/str - Float/float - Long/long
Yes?
(I applied this quick-change from your PR: 125c556) |
Introduced options arguments for the Android MediaCodec library.
There are some decoders like Broadway that can accept only H.264 Baseline profile streams.
This profile is considered the most generic and is available on most Android devices.
To allow selecting a profile new option has been added to client and server.