Make inner classes public

pull/506/head
Mattia Iavarone 6 years ago
parent 17d7e03d14
commit 0fd0fad4b4
  1. 8
      cameraview/src/main/java/com/otaliastudios/cameraview/video/encoding/AudioMediaEncoder.java
  2. 15
      cameraview/src/main/java/com/otaliastudios/cameraview/video/encoding/InputBuffer.java
  3. 15
      cameraview/src/main/java/com/otaliastudios/cameraview/video/encoding/MediaEncoder.java
  4. 17
      cameraview/src/main/java/com/otaliastudios/cameraview/video/encoding/MediaEncoderEngine.java
  5. 9
      cameraview/src/main/java/com/otaliastudios/cameraview/video/encoding/OutputBuffer.java
  6. 4
      cameraview/src/main/java/com/otaliastudios/cameraview/video/encoding/TextureMediaEncoder.java
  7. 8
      cameraview/src/main/java/com/otaliastudios/cameraview/video/encoding/VideoMediaEncoder.java

@ -88,7 +88,7 @@ public class AudioMediaEncoder extends MediaEncoder {
@EncoderThread
@Override
void onPrepare(@NonNull MediaEncoderEngine.Controller controller, long maxLengthMillis) {
protected void onPrepare(@NonNull MediaEncoderEngine.Controller controller, long maxLengthMillis) {
final MediaFormat audioFormat = MediaFormat.createAudioFormat(MIME_TYPE, SAMPLING_FREQUENCY, CHANNELS_COUNT);
audioFormat.setInteger(MediaFormat.KEY_AAC_PROFILE, MediaCodecInfo.CodecProfileLevel.AACObjectLC);
audioFormat.setInteger(MediaFormat.KEY_CHANNEL_MASK, CHANNELS);
@ -106,14 +106,14 @@ public class AudioMediaEncoder extends MediaEncoder {
@EncoderThread
@Override
void onStart() {
protected void onStart() {
mRequestStop = false;
mRecorder.start();
}
@EncoderThread
@Override
void onStop() {
protected void onStop() {
mRequestStop = true;
}
@ -130,7 +130,7 @@ public class AudioMediaEncoder extends MediaEncoder {
}
@Override
int getEncodedBitRate() {
protected int getEncodedBitRate() {
return mConfig.bitRate;
}

@ -6,11 +6,12 @@ import java.nio.ByteBuffer;
* Represents an input buffer, which means,
* raw data that should be encoded by MediaCodec.
*/
class InputBuffer {
ByteBuffer data;
ByteBuffer source;
int index;
int length;
long timestamp;
boolean isEndOfStream;
@SuppressWarnings("WeakerAccess")
public class InputBuffer {
public ByteBuffer data;
public ByteBuffer source;
public int index;
public int length;
public long timestamp;
public boolean isEndOfStream;
}

@ -75,7 +75,7 @@ import java.nio.ByteBuffer;
*/
// https://github.com/saki4510t/AudioVideoRecordingSample/blob/master/app/src/main/java/com/serenegiant/encoder/MediaEncoder.java
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
abstract class MediaEncoder {
public abstract class MediaEncoder {
private final static String TAG = MediaEncoder.class.getSimpleName();
private final static CameraLogger LOG = CameraLogger.create(TAG);
@ -129,7 +129,8 @@ abstract class MediaEncoder {
* Needs a readable name for the thread and for logging.
* @param name a name
*/
MediaEncoder(@NonNull String name) {
@SuppressWarnings("WeakerAccess")
protected MediaEncoder(@NonNull String name) {
mName = name;
}
@ -261,7 +262,7 @@ abstract class MediaEncoder {
* @param maxLengthMillis the maxLength in millis
*/
@EncoderThread
abstract void onPrepare(@NonNull final MediaEncoderEngine.Controller controller, final long maxLengthMillis);
protected abstract void onPrepare(@NonNull final MediaEncoderEngine.Controller controller, final long maxLengthMillis);
/**
* Start recording. This might be a lightweight operation
@ -269,7 +270,7 @@ abstract class MediaEncoder {
* like a "frame available".
*/
@EncoderThread
abstract void onStart();
protected abstract void onStart();
/**
* The caller notifying of a certain event occurring.
@ -278,14 +279,14 @@ abstract class MediaEncoder {
* @param data object
*/
@EncoderThread
void onEvent(@NonNull String event, @Nullable Object data) {}
protected void onEvent(@NonNull String event, @Nullable Object data) {}
/**
* Stop recording. This involves signaling the end of stream and draining
* all output left.
*/
@EncoderThread
abstract void onStop();
protected abstract void onStop();
/**
* Called by {@link #drainOutput(boolean)} when we get an EOS signal (not necessarily in the
@ -461,7 +462,7 @@ abstract class MediaEncoder {
}
}
abstract int getEncodedBitRate();
protected abstract int getEncodedBitRate();
/**
* Returns the max length setting, in milliseconds, which can be used

@ -246,7 +246,8 @@ public class MediaEncoderEngine {
* A handle for {@link MediaEncoder}s to pass information to this engine.
* All methods here can be called for multiple threads.
*/
class Controller {
@SuppressWarnings("WeakerAccess")
public class Controller {
/**
* Request that the muxer should start. This is not guaranteed to be executed:
@ -254,7 +255,7 @@ public class MediaEncoderEngine {
* @param format the media format
* @return the encoder track index
*/
int notifyStarted(@NonNull MediaFormat format) {
public int notifyStarted(@NonNull MediaFormat format) {
synchronized (mControllerLock) {
if (mMediaMuxerStarted) {
throw new IllegalStateException("Trying to start but muxer started already");
@ -274,10 +275,12 @@ public class MediaEncoderEngine {
}
/**
* Whether the muxer is started.
* Whether the muxer is started. MediaEncoders are required to avoid
* calling {@link #write(OutputBufferPool, OutputBuffer)} until this method returns true.
*
* @return true if muxer was started
*/
boolean isStarted() {
public boolean isStarted() {
synchronized (mControllerLock) {
return mMediaMuxerStarted;
}
@ -287,7 +290,7 @@ public class MediaEncoderEngine {
* Writes the given data to the muxer. Should be called after {@link #isStarted()}
* returns true. Note: this seems to be thread safe, no lock.
*/
void write(@NonNull OutputBufferPool pool, @NonNull OutputBuffer buffer) {
public void write(@NonNull OutputBufferPool pool, @NonNull OutputBuffer buffer) {
if (!mMediaMuxerStarted) {
throw new IllegalStateException("Trying to write before muxer started");
}
@ -303,7 +306,7 @@ public class MediaEncoderEngine {
*
* When this succeeds, {@link MediaEncoder#stop()} is called.
*/
void requestStop(int track) {
public void requestStop(int track) {
synchronized (mControllerLock) {
LOG.w("requestStop:", "Called for track", track);
if (--mStartedEncodersCount == 0) {
@ -318,7 +321,7 @@ public class MediaEncoderEngine {
* Notifies that the encoder was stopped. After this is called by all encoders,
* we will actually stop the muxer.
*/
void notifyStopped(int track) {
public void notifyStopped(int track) {
synchronized (mControllerLock) {
LOG.w("notifyStopped:", "Called for track", track);
if (++mReleasedEncodersCount == mEncoders.size()) {

@ -9,8 +9,9 @@ import java.nio.ByteBuffer;
* an encoded buffer of data that should be passed
* to the muxer.
*/
class OutputBuffer {
MediaCodec.BufferInfo info;
int trackIndex;
ByteBuffer data;
@SuppressWarnings("WeakerAccess")
public class OutputBuffer {
public MediaCodec.BufferInfo info;
public int trackIndex;
public ByteBuffer data;
}

@ -110,7 +110,7 @@ public class TextureMediaEncoder extends VideoMediaEncoder<TextureMediaEncoder.C
@EncoderThread
@Override
void onPrepare(@NonNull MediaEncoderEngine.Controller controller, long maxLengthMillis) {
protected void onPrepare(@NonNull MediaEncoderEngine.Controller controller, long maxLengthMillis) {
// We rotate the texture using transformRotation. Pass rotation=0 to super so that
// no rotation metadata is written into the output file.
mTransformRotation = mConfig.rotation;
@ -125,7 +125,7 @@ public class TextureMediaEncoder extends VideoMediaEncoder<TextureMediaEncoder.C
@EncoderThread
@Override
void onEvent(@NonNull String event, @Nullable Object data) {
protected void onEvent(@NonNull String event, @Nullable Object data) {
if (!event.equals(FRAME_EVENT)) return;
Frame frame = (Frame) data;
if (frame == null) {

@ -68,7 +68,7 @@ abstract class VideoMediaEncoder<C extends VideoMediaEncoder.Config> extends Med
@EncoderThread
@Override
void onPrepare(@NonNull MediaEncoderEngine.Controller controller, long maxLengthMillis) {
protected void onPrepare(@NonNull MediaEncoderEngine.Controller controller, long maxLengthMillis) {
MediaFormat format = MediaFormat.createVideoFormat(mConfig.mimeType, mConfig.width, mConfig.height);
// Set some properties. Failing to specify some of these can cause the MediaCodec
@ -93,14 +93,14 @@ abstract class VideoMediaEncoder<C extends VideoMediaEncoder.Config> extends Med
@EncoderThread
@Override
void onStart() {
protected void onStart() {
// Nothing to do here. Waiting for the first frame.
mFrameNumber = 0;
}
@EncoderThread
@Override
void onStop() {
protected void onStop() {
LOG.i("onStop", "setting mFrameNumber to 1 and signaling the end of input stream.");
mFrameNumber = -1;
// Signals the end of input stream. This is a Video only API, as in the normal case,
@ -111,7 +111,7 @@ abstract class VideoMediaEncoder<C extends VideoMediaEncoder.Config> extends Med
}
@Override
int getEncodedBitRate() {
protected int getEncodedBitRate() {
return mConfig.bitRate;
}
}

Loading…
Cancel
Save