Skip to content
This repository was archived by the owner on Apr 16, 2025. It is now read-only.

Refactor sample - #9

Open
sdk-banuba wants to merge 8 commits into
masterfrom
feature/add_camera2
Open

Refactor sample#9
sdk-banuba wants to merge 8 commits into
masterfrom
feature/add_camera2

Conversation

@sdk-banuba

Copy link
Copy Markdown
Contributor

No description provided.

@sdk-banuba

Copy link
Copy Markdown
Contributor Author

In last commit the opportunity to disable OEP was created (to disable OEP set mIsOEPEnabled = false;)

@sdk-banuba sdk-banuba changed the title Fix memory leak Refactor sample Aug 17, 2022
Comment thread app/src/main/java/com/banuba/quickstart_c_api/Image.java Outdated
Comment thread app/src/main/java/com/banuba/quickstart_c_api/Image.java Outdated
Comment thread app/src/main/java/com/banuba/quickstart_c_api/Image.java Outdated
Comment thread app/src/main/java/com/banuba/quickstart_c_api/Image.java Outdated
Comment thread app/src/main/java/com/banuba/quickstart_c_api/Image.java Outdated
Comment thread app/src/main/java/com/banuba/quickstart_c_api/rendering/GLRenderer.java Outdated
(image0,image1, image2, width, height) -> {
List<byte[]> planes = Arrays.asList(image0, image1, image2);
renderer.drawImage(planes, width, height);
(offscreenEffectPlayerImage) -> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the name of variable is better to shorten to 'oepImage'

int inputOrientation,
boolean isRequiredMirroring,
int outputOrientation,
int imageFormat) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What does this variable mean ? input/output ?
If this is an output image format, then it's better to name it that 'outputImageFormat'

int inputOrientation,
boolean isRequiredMirroring,
int outputOrientation,
int imageFormat);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

see previous comment

public boolean requireMirroring;
} No newline at end of file

public int getWidth() { return mWidth; }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

reformat this line

OffscreenEffectPlayerImage() {
mImageInfo = new ImageInfo();

OffscreenEffectPlayerImage(ImageProxy imageProxy) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The OffscreenEffectPlayerImage should not depends on ImageProxy. Remove it

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add a method that returns OffscreenEffectPlayerImage from ImageProxy, to the class in which it is used

public ByteBuffer mImageFirst = null;
public ByteBuffer mImageSecond = null;
}
OffscreenEffectPlayerImage(byte[] rgbPlane, int width, int height) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

OffscreenEffectPlayerImage(final byte[] rgbPlane, final int rgbPlaneStride, final int width, final int height)

final private ByteBuffer mPlane0;
final private ByteBuffer mPlane1;
final private ByteBuffer mPlane2;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

add the variable:
final private mNumberOfPlanes;

mPixelFormat = 0;
}

OffscreenEffectPlayerImage(byte[] yPlane, byte[] uvPlane, int width, int height) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

change to:
OffscreenEffectPlayerImage(final byte[] yPlane, final int yPlaneStride, final byte[] uvPlane, final int uvPlaneStride, final int width, final int height)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this constructor will create an Image with nv12 format

}

public ByteBuffer getPlane(int planeNumber) {
switch (planeNumber) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

if (planeNumber >= 0 && planeNumber < mNumberOfPlanes ) {
swich-case for planes 0, 1, 2: ...
} else { throw new ... }

oep.processImageAsync(mImage);
int rotation = getRotation(MainActivity.this);
int imageFormat = mImageFormat.ordinal();
OffscreenEffectPlayerImage image = new OffscreenEffectPlayerImage(proxy);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

for example:
OffscreenEffectPlayerImage image = wrapToOffscreenEffectPlayerImage(proxy);

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants