Signed-off-by: Leo Ma <begeekmyfriend@gmail.com>
camera2
Leo Ma 8 years ago
parent 283d52ef73
commit 4b67a0640f

@ -33,10 +33,10 @@ public class MainActivity extends AppCompatActivity implements RtmpHandler.RtmpL
private static final String TAG = "Yasea"; private static final String TAG = "Yasea";
Button btnPublish = null; private Button btnPublish;
Button btnSwitchCamera = null; private Button btnSwitchCamera;
Button btnRecord = null; private Button btnRecord;
Button btnSwitchEncoder = null; private Button btnSwitchEncoder;
private SharedPreferences sp; private SharedPreferences sp;
private String rtmpUrl = "rtmp://ossrs.net/" + getRandomAlphaString(3) + '/' + getRandomAlphaDigitString(5); private String rtmpUrl = "rtmp://ossrs.net/" + getRandomAlphaString(3) + '/' + getRandomAlphaDigitString(5);

@ -401,7 +401,7 @@ public class SrsEncoder {
throw new UnsupportedOperationException("Not implemented"); throw new UnsupportedOperationException("Not implemented");
//swRgbaFrame(data, width, height, pts); //swRgbaFrame(data, width, height, pts);
} else { } else {
byte[] processedData = hwYUVNV21FrameScale(data, width, height, boundingBox); byte[] processedData = hwYUVNV21FrameScaled(data, width, height, boundingBox);
if (processedData != null) { if (processedData != null) {
onProcessedYuvFrame(processedData, pts); onProcessedYuvFrame(processedData, pts);
} else { } else {
@ -429,7 +429,7 @@ public class SrsEncoder {
throw new UnsupportedOperationException("Not implemented"); throw new UnsupportedOperationException("Not implemented");
//swArgbFrame(data, width, height, pts); //swArgbFrame(data, width, height, pts);
} else { } else {
byte[] processedData = hwArgbaFrameScale(data, width, height, boundingBox); byte[] processedData = hwArgbFrameScaled(data, width, height, boundingBox);
if (processedData != null) { if (processedData != null) {
onProcessedYuvFrame(processedData, pts); onProcessedYuvFrame(processedData, pts);
} else { } else {
@ -457,7 +457,7 @@ public class SrsEncoder {
throw new UnsupportedOperationException("Not implemented"); throw new UnsupportedOperationException("Not implemented");
//swArgbFrame(data, width, height, pts); //swArgbFrame(data, width, height, pts);
} else { } else {
byte[] processedData = hwArgbaFrame(data, width, height); byte[] processedData = hwArgbFrame(data, width, height);
if (processedData != null) { if (processedData != null) {
onProcessedYuvFrame(processedData, pts); onProcessedYuvFrame(processedData, pts);
} else { } else {
@ -486,7 +486,7 @@ public class SrsEncoder {
} }
} }
private byte[] hwYUVNV21FrameScale(byte[] data, int width, int height, Rect boundingBox) { private byte[] hwYUVNV21FrameScaled(byte[] data, int width, int height, Rect boundingBox) {
switch (mVideoColorFormat) { switch (mVideoColorFormat) {
case MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420Planar: case MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420Planar:
return NV21ToI420Scaled(data, width, height, true, 180, boundingBox.left, boundingBox.top, boundingBox.width(), boundingBox.height()); return NV21ToI420Scaled(data, width, height, true, 180, boundingBox.left, boundingBox.top, boundingBox.width(), boundingBox.height());
@ -497,7 +497,7 @@ public class SrsEncoder {
} }
} }
private byte[] hwArgbaFrameScale(int[] data, int width, int height, Rect boundingBox) { private byte[] hwArgbFrameScaled(int[] data, int width, int height, Rect boundingBox) {
switch (mVideoColorFormat) { switch (mVideoColorFormat) {
case MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420Planar: case MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420Planar:
return ARGBToI420Scaled(data, width, height, false, 0, boundingBox.left, boundingBox.top, boundingBox.width(), boundingBox.height()); return ARGBToI420Scaled(data, width, height, false, 0, boundingBox.left, boundingBox.top, boundingBox.width(), boundingBox.height());
@ -508,7 +508,7 @@ public class SrsEncoder {
} }
} }
private byte[] hwArgbaFrame(int[] data, int inputWidth, int inputHeight) { private byte[] hwArgbFrame(int[] data, int inputWidth, int inputHeight) {
switch (mVideoColorFormat) { switch (mVideoColorFormat) {
case MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420Planar: case MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420Planar:
return ARGBToI420(data, inputWidth, inputHeight, false, 0); return ARGBToI420(data, inputWidth, inputHeight, false, 0);

Loading…
Cancel
Save