Skip to content

Commit

Permalink
moving encoder java files to kotlin and fix srtsender discard frames
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroSG94 committed Sep 19, 2023
1 parent bc51ca4 commit 0005d02
Show file tree
Hide file tree
Showing 32 changed files with 346 additions and 433 deletions.
35 changes: 0 additions & 35 deletions encoder/src/main/java/com/pedro/encoder/EncoderCallback.java

This file was deleted.

32 changes: 32 additions & 0 deletions encoder/src/main/java/com/pedro/encoder/EncoderCallback.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (C) 2021 pedroSG94.
*
* 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.pedro.encoder

import android.media.MediaCodec
import android.media.MediaFormat

/**
* Created by pedro on 18/09/19.
*/
interface EncoderCallback {
@Throws(IllegalStateException::class)
fun inputAvailable(mediaCodec: MediaCodec, inBufferIndex: Int)

@Throws(IllegalStateException::class)
fun outputAvailable(mediaCodec: MediaCodec, outBufferIndex: Int, bufferInfo: MediaCodec.BufferInfo)

fun formatChanged(mediaCodec: MediaCodec, mediaFormat: MediaFormat)
}
102 changes: 0 additions & 102 deletions encoder/src/main/java/com/pedro/encoder/Frame.java

This file was deleted.

54 changes: 54 additions & 0 deletions encoder/src/main/java/com/pedro/encoder/Frame.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright (C) 2021 pedroSG94.
*
* 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.pedro.encoder

import android.graphics.ImageFormat

/**
* Created by pedro on 17/02/18.
*/
class Frame {
var buffer: ByteArray
var offset: Int
var size: Int
var orientation = 0
var isFlip = false
var format = ImageFormat.NV21 //nv21 or yv12 supported
var timeStamp: Long

/**
* Used with video frame
*/
constructor(buffer: ByteArray, orientation: Int, flip: Boolean, format: Int, timeStamp: Long) {
this.buffer = buffer
this.orientation = orientation
isFlip = flip
this.format = format
offset = 0
size = buffer.size
this.timeStamp = timeStamp
}

/**
* Used with audio frame
*/
constructor(buffer: ByteArray, offset: Int, size: Int, timeStamp: Long) {
this.buffer = buffer
this.offset = offset
this.size = size
this.timeStamp = timeStamp
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.pedro.encoder

package com.pedro.encoder;

public interface GetFrame {
Frame getInputFrame();
}
interface GetFrame {
fun getInputFrame(): Frame
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ protected long calculatePts(Frame frame, long presentTimeUs) {
pts = 1000000 * bytesRead / 2 / channels / sampleRate;
bytesRead += frame.getSize();
} else {
pts = System.nanoTime() / 1000 - presentTimeUs;
pts = Math.max(0, frame.getTimeStamp() - presentTimeUs);
}
return pts;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.pedro.encoder.audio

package com.pedro.encoder.audio;

import android.media.MediaCodec;
import android.media.MediaFormat;

import java.nio.ByteBuffer;
import android.media.MediaCodec
import android.media.MediaFormat
import java.nio.ByteBuffer

/**
* Created by pedro on 19/01/17.
*/

public interface GetAacData {

void getAacData(ByteBuffer aacBuffer, MediaCodec.BufferInfo info);

void onAudioFormat(MediaFormat mediaFormat);
}
interface GetAacData {
fun getAacData(aacBuffer: ByteBuffer, info: MediaCodec.BufferInfo)
fun onAudioFormat(mediaFormat: MediaFormat)
}

This file was deleted.

Loading

0 comments on commit 0005d02

Please sign in to comment.