|
|
@ -52,6 +52,7 @@ public class SrsEncoder {
|
|
|
|
private boolean networkWeakTriggered = false;
|
|
|
|
private boolean networkWeakTriggered = false;
|
|
|
|
private boolean mCameraFaceFront = true;
|
|
|
|
private boolean mCameraFaceFront = true;
|
|
|
|
private boolean useSoftEncoder = false;
|
|
|
|
private boolean useSoftEncoder = false;
|
|
|
|
|
|
|
|
private boolean canSoftEncoder = false;
|
|
|
|
|
|
|
|
|
|
|
|
private long mPresentTimeUs;
|
|
|
|
private long mPresentTimeUs;
|
|
|
|
|
|
|
|
|
|
|
@ -113,8 +114,11 @@ public class SrsEncoder {
|
|
|
|
setEncoderBitrate(vBitrate);
|
|
|
|
setEncoderBitrate(vBitrate);
|
|
|
|
setEncoderPreset(x264Preset);
|
|
|
|
setEncoderPreset(x264Preset);
|
|
|
|
|
|
|
|
|
|
|
|
if (useSoftEncoder && !openSoftEncoder()) {
|
|
|
|
if (useSoftEncoder) {
|
|
|
|
return false;
|
|
|
|
canSoftEncode = openSoftEncoder();
|
|
|
|
|
|
|
|
if (!canSoftEncode) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// aencoder pcm to aac raw stream.
|
|
|
|
// aencoder pcm to aac raw stream.
|
|
|
@ -170,6 +174,7 @@ public class SrsEncoder {
|
|
|
|
public void stop() {
|
|
|
|
public void stop() {
|
|
|
|
if (useSoftEncoder) {
|
|
|
|
if (useSoftEncoder) {
|
|
|
|
closeSoftEncoder();
|
|
|
|
closeSoftEncoder();
|
|
|
|
|
|
|
|
canSoftEncode = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (aencoder != null) {
|
|
|
|
if (aencoder != null) {
|
|
|
@ -195,11 +200,11 @@ public class SrsEncoder {
|
|
|
|
mCameraFaceFront = false;
|
|
|
|
mCameraFaceFront = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void swithToSoftEncoder() {
|
|
|
|
public void switchToSoftEncoder() {
|
|
|
|
useSoftEncoder = true;
|
|
|
|
useSoftEncoder = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void swithToHardEncoder() {
|
|
|
|
public void switchToHardEncoder() {
|
|
|
|
useSoftEncoder = false;
|
|
|
|
useSoftEncoder = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -207,6 +212,18 @@ public class SrsEncoder {
|
|
|
|
return useSoftEncoder;
|
|
|
|
return useSoftEncoder;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public boolean canHardEncode() {
|
|
|
|
|
|
|
|
return vencoder != null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public boolean canSoftEncode() {
|
|
|
|
|
|
|
|
return canSoftEncode;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public boolean isEnabled() {
|
|
|
|
|
|
|
|
return canHardEncode() || canSoftEncode();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void setPreviewResolution(int width, int height) {
|
|
|
|
public void setPreviewResolution(int width, int height) {
|
|
|
|
vPrevWidth = width;
|
|
|
|
vPrevWidth = width;
|
|
|
|
vPrevHeight = height;
|
|
|
|
vPrevHeight = height;
|
|
|
|