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

Refactor MediaCodecBridge.queueSecureInputBuffer() #3854

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

osagie98
Copy link
Contributor

Modifies the body of MediaCodecBridge.queueSecureInputBuffer() to more closely resemble the Chromium version.

b/352387646

Modifies the body of MediaCodecBridge.queueSecureInputBuffer() to more
closely resemble the Chromium version.

b/352387646
Comment on lines 973 to 980
if (patternEncrypt != 0 && patternSkip != 0) {
if (usesCbcs) {
// Above platform check ensured that setting the pattern is indeed supported.
cryptoInfo.setPattern(new Pattern(patternEncrypt, patternSkip));
} else {
Log.e(TAG, "Pattern encryption only supported for 'cbcs' scheme (CBC mode).");
return MediaCodecStatus.ERROR;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Just wanted to double check that we have verified the new implementation against cbcs and cenc playbacks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, cenc playbacks live on YouTube, cbcs and cenc streams from go/cobalt-media-features#encrypted-content

@osagie98 osagie98 requested a review from xiaomings July 26, 2024 09:07
Log.e(TAG, "Pattern encryption only supported for 'cbcs' scheme (CBC mode).");
return MediaCodecStatus.ERROR;
if (patternEncrypt != 0 || patternSkip != 0) {
if (cipherMode == MediaCodec.CRYPTO_MODE_AES_CBC) {
Copy link
Contributor

Choose a reason for hiding this comment

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

As discussed offline, we are trying to make the implementation as close to the Chromium one as possible, but not apply any functional changes to the existing implementation.

In this particular case, we should add boolean usesCbcs = cipherMode == MediaCodec.CRYPTO_MODE_AES_CBC; in front of CryptoInfo cryptoInfo = new CryptoInfo(); and use usesCbcs here.

TAG,
"Failed to queue secure input buffer, CryptoException with error code "
+ e.getErrorCode());
Log.e(TAG, "Failed to queue secure input buffer. Error code %d", errorCode, e);
return MediaCodecStatus.ERROR;
} catch (IllegalArgumentException e) {
Copy link
Contributor

Choose a reason for hiding this comment

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

MediaCodec.CodecException is caught on the upstream, consider catching it here too if it can be thrown by the function.

TAG,
"Failed to queue secure input buffer, CryptoException with error code "
+ e.getErrorCode());
Log.e(TAG, "Failed to queue secure input buffer. Error code %d", errorCode, e);
Copy link
Contributor

Choose a reason for hiding this comment

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

The upstream seems to use a different formatting (which can probably be refined), and the same to line 966. Try to check if the upstream can be updated with an improved formatting (i.e. if its default code formater will generate a better version).

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