diff --git a/haishinkit/src/main/java/com/haishinkit/codec/VideoCodec.kt b/haishinkit/src/main/java/com/haishinkit/codec/VideoCodec.kt index 1885e58c..15c1d254 100644 --- a/haishinkit/src/main/java/com/haishinkit/codec/VideoCodec.kt +++ b/haishinkit/src/main/java/com/haishinkit/codec/VideoCodec.kt @@ -29,8 +29,7 @@ class VideoCodec(applicationContext: Context) : Codec() { throw IllegalArgumentException("Unsupported mime type for ${newValue.mime}.") } codec?.outputMimeType = newValue.mime - codec?.profile = newValue.profile - codec?.level = newValue.level + codec?.profileLevel = newValue } /** @@ -130,12 +129,7 @@ class VideoCodec(applicationContext: Context) : Codec() { /** * Specifies the profile for a video output. */ - var profile = DEFAULT_PROFILE_LEVEL.profile - - /** - * Specifies the profile-level for a video outout. - */ - var level = DEFAULT_PROFILE_LEVEL.level + var profileLevel: VideoCodecProfileLevel = VideoCodecProfileLevel.H264_BASELINE_3_2 /** * The pixel transform instance. @@ -174,11 +168,11 @@ class VideoCodec(applicationContext: Context) : Codec() { setInteger(MediaFormat.KEY_CHANNEL_COUNT, 1) setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, IFrameInterval) setInteger(MediaFormat.KEY_COLOR_FORMAT, colorFormat) - setInteger(MediaFormat.KEY_PROFILE, profile) + setInteger(MediaFormat.KEY_PROFILE, profileLevel.profile) if (Build.VERSION_CODES.M <= Build.VERSION.SDK_INT) { - setInteger(MediaFormat.KEY_LEVEL, level) + setInteger(MediaFormat.KEY_LEVEL, profileLevel.level) } else { - setInteger("level", level) + setInteger("level", profileLevel.level) } } else { if (Build.VERSION_CODES.R <= Build.VERSION.SDK_INT) { diff --git a/haishinkit/src/main/java/com/haishinkit/rtmp/RtmpStream.kt b/haishinkit/src/main/java/com/haishinkit/rtmp/RtmpStream.kt index 3d82d0a6..e6a3eab8 100644 --- a/haishinkit/src/main/java/com/haishinkit/rtmp/RtmpStream.kt +++ b/haishinkit/src/main/java/com/haishinkit/rtmp/RtmpStream.kt @@ -1,6 +1,7 @@ package com.haishinkit.rtmp import android.content.Context +import android.media.MediaFormat import android.util.Log import com.haishinkit.codec.Codec import com.haishinkit.event.Event @@ -415,7 +416,18 @@ class RtmpStream(context: Context, internal var connection: RtmpConnection) : metadata["width"] = videoCodec.width metadata["height"] = videoCodec.height metadata["framerate"] = videoCodec.frameRate - metadata["videocodecid"] = RtmpMuxer.FLV_VIDEO_CODEC_AVC.toInt() + when (videoCodec.profileLevel.mime) { + MediaFormat.MIMETYPE_VIDEO_HEVC -> + metadata["videocodecid"] = RtmpMuxer.FLV_VIDEO_FOUR_CC_HEVC + + MediaFormat.MIMETYPE_VIDEO_AVC -> { + metadata["videocodecid"] = RtmpMuxer.FLV_VIDEO_CODEC_AVC.toInt() + } + + else -> { + Log.w(TAG, "not set a videocodecid for ${videoCodec.profileLevel.mime}") + } + } metadata["videodatarate"] = videoCodec.bitRate / 1000 } audioSource?.let {