-
Notifications
You must be signed in to change notification settings - Fork 6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add SurfaceCapturer base class, and provide the first implementation
Use PixelCopy API for the first SurfaceCapturer implementation. This supports devices from API 24+. Github: #3609. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=197732711
- Loading branch information
1 parent
a98d8fe
commit 0cb34dc
Showing
5 changed files
with
127 additions
and
5 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
84 changes: 84 additions & 0 deletions
84
...ary/core/src/main/java/com/google/android/exoplayer2/surfacecapturer/SurfaceCapturer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* Copyright (C) 2018 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.google.android.exoplayer2.surfacecapturer; | ||
|
||
import android.graphics.Bitmap; | ||
import android.view.Surface; | ||
|
||
/** | ||
* A surface capturer, which captures image drawn into its surface as bitmaps. | ||
* | ||
* <p>It constructs a {@link Surface}, which can be used as the output surface for an image producer | ||
* to draw images to. As images are being drawn into this surface, this capturer will capture these | ||
* images, and return them via {@link Callback}. The output images will have a fixed frame size of | ||
* (width, height), and any image drawn into the surface will be stretched to fit this frame size. | ||
*/ | ||
public abstract class SurfaceCapturer { | ||
|
||
/** The callback to be notified of the image capturing result. */ | ||
public interface Callback { | ||
|
||
/** | ||
* Called when the surface capturer has been able to capture its surface into a {@link Bitmap}. | ||
* This will happen whenever the producer updates the image on the wrapped surface. | ||
*/ | ||
void onSurfaceCaptured(Bitmap bitmap); | ||
|
||
/** Called when the surface capturer couldn't capture its surface due to an error. */ | ||
void onSurfaceCaptureError(Exception e); | ||
} | ||
|
||
/** The callback to be notified of the image capturing result. */ | ||
private final Callback callback; | ||
/** The width of the output images. */ | ||
private final int outputWidth; | ||
/** The height of the output images. */ | ||
private final int outputHeight; | ||
|
||
/** | ||
* Constructs a new instance. | ||
* | ||
* @param callback See {@link #callback}. | ||
* @param outputWidth See {@link #outputWidth}. | ||
* @param outputHeight See {@link #outputHeight}. | ||
*/ | ||
protected SurfaceCapturer(Callback callback, int outputWidth, int outputHeight) { | ||
this.callback = callback; | ||
this.outputWidth = outputWidth; | ||
this.outputHeight = outputHeight; | ||
} | ||
|
||
/** Returns the callback to be notified of the image capturing result. */ | ||
protected Callback getCallback() { | ||
return callback; | ||
} | ||
|
||
/** Returns the width of the output images. */ | ||
public int getOutputWidth() { | ||
return outputWidth; | ||
} | ||
|
||
/** Returns the height of the output images. */ | ||
public int getOutputHeight() { | ||
return outputHeight; | ||
} | ||
|
||
/** Returns a {@link Surface} that image producers (camera, video codec etc...) can draw to. */ | ||
public abstract Surface getSurface(); | ||
|
||
/** Releases all kept resources. This instance cannot be used after this call. */ | ||
public abstract void release(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.