Skip to content
Snippets Groups Projects
Commit e5179d4a authored by Leo Ma's avatar Leo Ma
Browse files

Change mime type macro into constant string


For Android API compatibility.

Signed-off-by: default avatarLeo Ma <begeekmyfriend@gmail.com>
parent 2042e333
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -22,10 +22,10 @@ public class SrsEncoder {
public static final String VCODEC = "video/avc";
public static final String ACODEC = "audio/mp4a-latm";
public static final int VPREV_WIDTH = 1280;
public static final int VPREV_HEIGHT = 720;
public static final int VCROP_WIDTH = 32 * 9 * 2;
public static final int VCROP_HEIGHT = 32 * 16 * 2;
public static final int VPREV_WIDTH = 640;
public static final int VPREV_HEIGHT = 480;
public static final int VCROP_WIDTH = 384;
public static final int VCROP_HEIGHT = 640;
public static int vCropWidth = VCROP_WIDTH; // Note: the stride of resolution must be set as 16x for hard encoding with some chip like MTK
public static int vCropHeight = VCROP_HEIGHT; // Since Y component is quadruple size as U and V component, the stride must be set as 32x
public static final int VBITRATE = 500 * 1000; // 500kbps
Loading
Loading
@@ -99,7 +99,7 @@ public class SrsEncoder {
// setup the aencoder.
// @see https://developer.android.com/reference/android/media/MediaCodec.html
int ach = ACHANNEL == AudioFormat.CHANNEL_IN_STEREO ? 2 : 1;
MediaFormat audioFormat = MediaFormat.createAudioFormat(MediaFormat.MIMETYPE_AUDIO_AAC, ASAMPLERATE, ach);
MediaFormat audioFormat = MediaFormat.createAudioFormat(ACODEC, ASAMPLERATE, ach);
audioFormat.setInteger(MediaFormat.KEY_BIT_RATE, ABITRATE);
audioFormat.setInteger(MediaFormat.KEY_MAX_INPUT_SIZE, 0);
aencoder.configure(audioFormat, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
Loading
Loading
@@ -119,7 +119,7 @@ public class SrsEncoder {
// setup the vencoder.
// Note: landscape to portrait, 90 degree rotation, so we need to switch width and height in configuration
MediaFormat videoFormat = MediaFormat.createVideoFormat(MediaFormat.MIMETYPE_VIDEO_AVC, vCropWidth, vCropHeight);
MediaFormat videoFormat = MediaFormat.createVideoFormat(VCODEC, vCropWidth, vCropHeight);
videoFormat.setInteger(MediaFormat.KEY_COLOR_FORMAT, mVideoColorFormat);
videoFormat.setInteger(MediaFormat.KEY_MAX_INPUT_SIZE, 0);
videoFormat.setInteger(MediaFormat.KEY_BIT_RATE, VBITRATE);
Loading
Loading
Loading
Loading
@@ -94,7 +94,7 @@ public class SrsFlvMuxer {
* @return The track index for this newly added track.
*/
public int addTrack(MediaFormat format) {
if (format.getString(MediaFormat.KEY_MIME).equalsTo(MediaFormat.MIMETYPE_VIDEO_AVC)) {
if (format.getString(MediaFormat.KEY_MIME).contentEquals(SrsEncoder.VCODEC)) {
flv.setVideoTrack(format);
return VIDEO_TRACK;
} else {
Loading
Loading
Loading
Loading
@@ -216,7 +216,7 @@ public class SrsMp4Muxer {
* @return The track index for this newly added track.
*/
public int addTrack(MediaFormat format) {
if (format.getString(MediaFormat.KEY_MIME).equalsTo(MediaFormat.MIMETYPE_VIDEO_AVC)) {
if (format.getString(MediaFormat.KEY_MIME).contentEquals(SrsEncoder.VCODEC)) {
videoFormat = format;
return VIDEO_TRACK;
} else {
Loading
Loading
@@ -522,7 +522,7 @@ public class SrsMp4Muxer {
handler = "vide";
headerBox = new VideoMediaHeaderBox();
sampleDescriptionBox = new SampleDescriptionBox();
if (format.getString(MediaFormat.KEY_MIME).equals("video/avc")) {
if (format.getString(MediaFormat.KEY_MIME).contentEquals(SrsEncoder.VCODEC)) {
VisualSampleEntry visualSampleEntry = new VisualSampleEntry("avc1");
visualSampleEntry.setDataReferenceIndex(1);
visualSampleEntry.setDepth(24);
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment