mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
for #316, add stream codec info. 2.0.135
This commit is contained in:
parent
885b9af122
commit
2e9f2753c9
6 changed files with 109 additions and 17 deletions
|
@ -1531,9 +1531,10 @@ int SrsSource::on_video(SrsCommonMessage* __video)
|
|||
}
|
||||
|
||||
srs_trace("%dB video sh, "
|
||||
"codec(%d, profile=%d, level=%d, %dx%d, %dkbps, %dfps, %ds)",
|
||||
"codec(%d, profile=%s, level=%s, %dx%d, %dkbps, %dfps, %ds)",
|
||||
msg.size, codec.video_codec_id,
|
||||
codec.avc_profile, codec.avc_level, codec.width, codec.height,
|
||||
srs_codec_avc_profile2str(codec.avc_profile).c_str(),
|
||||
srs_codec_avc_level2str(codec.avc_level).c_str(), codec.width, codec.height,
|
||||
codec.video_data_rate / 1000, codec.frame_rate, codec.duration);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -53,8 +53,8 @@ SrsStatisticStream::SrsStatisticStream()
|
|||
|
||||
has_video = false;
|
||||
vcodec = SrsCodecVideoReserved;
|
||||
avc_profile = 0;
|
||||
avc_level = 0;
|
||||
avc_profile = SrsAvcProfileReserved;
|
||||
avc_level = SrsAvcLevelReserved;
|
||||
|
||||
has_audio = false;
|
||||
acodec = SrsCodecAudioReserved1;
|
||||
|
@ -111,7 +111,7 @@ SrsStatistic* SrsStatistic::instance()
|
|||
}
|
||||
|
||||
int SrsStatistic::on_video_info(SrsRequest* req,
|
||||
SrsCodecVideo vcodec, u_int8_t avc_profile, u_int8_t avc_level
|
||||
SrsCodecVideo vcodec, SrsAvcProfile avc_profile, SrsAvcLevel avc_level
|
||||
) {
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
|
@ -243,8 +243,8 @@ int SrsStatistic::dumps_streams(stringstream& ss)
|
|||
ss << __SRS_JFIELD_NAME("video")
|
||||
<< __SRS_JOBJECT_START
|
||||
<< __SRS_JFIELD_STR("codec", srs_codec_video2str(stream->vcodec)) << __SRS_JFIELD_CONT
|
||||
<< __SRS_JFIELD_ORG("profile", (int)stream->avc_profile) << __SRS_JFIELD_CONT
|
||||
<< __SRS_JFIELD_ORG("level", (int)stream->avc_level)
|
||||
<< __SRS_JFIELD_STR("profile", srs_codec_avc_profile2str(stream->avc_profile)) << __SRS_JFIELD_CONT
|
||||
<< __SRS_JFIELD_ORG("level", srs_codec_avc_level2str(stream->avc_level))
|
||||
<< __SRS_JOBJECT_END
|
||||
<< __SRS_JFIELD_CONT;
|
||||
}
|
||||
|
|
|
@ -59,9 +59,9 @@ public:
|
|||
bool has_video;
|
||||
SrsCodecVideo vcodec;
|
||||
// profile_idc, H.264-AVC-ISO_IEC_14496-10.pdf, page 45.
|
||||
u_int8_t avc_profile;
|
||||
SrsAvcProfile avc_profile;
|
||||
// level_idc, H.264-AVC-ISO_IEC_14496-10.pdf, page 45.
|
||||
u_int8_t avc_level;
|
||||
SrsAvcLevel avc_level;
|
||||
public:
|
||||
bool has_audio;
|
||||
SrsCodecAudio acodec;
|
||||
|
@ -113,7 +113,7 @@ public:
|
|||
* when got video info for stream.
|
||||
*/
|
||||
virtual int on_video_info(SrsRequest* req,
|
||||
SrsCodecVideo vcodec, u_int8_t avc_profile, u_int8_t avc_level
|
||||
SrsCodecVideo vcodec, SrsAvcProfile avc_profile, SrsAvcLevel avc_level
|
||||
);
|
||||
/**
|
||||
* when got audio info for stream.
|
||||
|
|
|
@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
// current release version
|
||||
#define VERSION_MAJOR 2
|
||||
#define VERSION_MINOR 0
|
||||
#define VERSION_REVISION 134
|
||||
#define VERSION_REVISION 135
|
||||
|
||||
// server info.
|
||||
#define RTMP_SIG_SRS_KEY "SRS"
|
||||
|
|
|
@ -121,6 +121,46 @@ SrsAacProfile srs_codec_aac_rtmp2ts(SrsAacObjectType object_type)
|
|||
}
|
||||
}
|
||||
|
||||
string srs_codec_avc_profile2str(SrsAvcProfile profile)
|
||||
{
|
||||
switch (profile) {
|
||||
case SrsAvcProfileBaseline: return "Baseline";
|
||||
case SrsAvcProfileConstrainedBaseline: return "Baseline(Constrained)";
|
||||
case SrsAvcProfileMain: return "Main";
|
||||
case SrsAvcProfileExtended: return "Extended";
|
||||
case SrsAvcProfileHigh: return "High";
|
||||
case SrsAvcProfileHigh10: return "High(10)";
|
||||
case SrsAvcProfileHigh10Intra: return "High(10+Intra)";
|
||||
case SrsAvcProfileHigh422: return "High(422)";
|
||||
case SrsAvcProfileHigh422Intra: return "High(422+Intra)";
|
||||
case SrsAvcProfileHigh444: return "High(444)";
|
||||
case SrsAvcProfileHigh444Predictive: return "High(444+Predictive)";
|
||||
case SrsAvcProfileHigh444Intra: return "High(444+Intra)";
|
||||
default: return "Other";
|
||||
}
|
||||
}
|
||||
|
||||
string srs_codec_avc_level2str(SrsAvcLevel level)
|
||||
{
|
||||
switch (level) {
|
||||
case SrsAvcLevel_1: return "1";
|
||||
case SrsAvcLevel_11: return "1.1";
|
||||
case SrsAvcLevel_12: return "1.2";
|
||||
case SrsAvcLevel_13: return "1.3";
|
||||
case SrsAvcLevel_2: return "2";
|
||||
case SrsAvcLevel_21: return "2.1";
|
||||
case SrsAvcLevel_22: return "2.2";
|
||||
case SrsAvcLevel_3: return "3";
|
||||
case SrsAvcLevel_31: return "3.1";
|
||||
case SrsAvcLevel_32: return "3.2";
|
||||
case SrsAvcLevel_4: return "4";
|
||||
case SrsAvcLevel_41: return "4.1";
|
||||
case SrsAvcLevel_5: return "5";
|
||||
case SrsAvcLevel_51: return "5.1";
|
||||
default: return "Other";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* the public data, event HLS disable, others can use it.
|
||||
*/
|
||||
|
@ -292,8 +332,8 @@ SrsAvcAacCodec::SrsAvcAacCodec()
|
|||
audio_data_rate = 0;
|
||||
audio_codec_id = 0;
|
||||
|
||||
avc_profile = 0;
|
||||
avc_level = 0;
|
||||
avc_profile = SrsAvcProfileReserved;
|
||||
avc_level = SrsAvcLevelReserved;
|
||||
aac_object = SrsAacObjectTypeReserved;
|
||||
aac_sample_rate = __SRS_AAC_SAMPLE_RATE_UNSET; // sample rate ignored
|
||||
aac_channels = 0;
|
||||
|
@ -651,11 +691,11 @@ int SrsAvcAacCodec::avc_demux_sps_pps(SrsStream* stream)
|
|||
//int8_t configurationVersion = stream->read_1bytes();
|
||||
stream->read_1bytes();
|
||||
//int8_t AVCProfileIndication = stream->read_1bytes();
|
||||
avc_profile = stream->read_1bytes();
|
||||
avc_profile = (SrsAvcProfile)stream->read_1bytes();
|
||||
//int8_t profile_compatibility = stream->read_1bytes();
|
||||
stream->read_1bytes();
|
||||
//int8_t AVCLevelIndication = stream->read_1bytes();
|
||||
avc_level = stream->read_1bytes();
|
||||
avc_level = (SrsAvcLevel)stream->read_1bytes();
|
||||
|
||||
// parse the NALU size.
|
||||
int8_t lengthSizeMinusOne = stream->read_1bytes();
|
||||
|
|
|
@ -416,6 +416,57 @@ SrsAacObjectType srs_codec_aac_ts2rtmp(SrsAacProfile profile);
|
|||
// RTMP sequence header object type to ts/hls/adts audio header profile.
|
||||
SrsAacProfile srs_codec_aac_rtmp2ts(SrsAacObjectType object_type);
|
||||
|
||||
/**
|
||||
* the profile for avc/h.264.
|
||||
* @see Annex A Profiles and levels, H.264-AVC-ISO_IEC_14496-10.pdf, page 205.
|
||||
*/
|
||||
enum SrsAvcProfile
|
||||
{
|
||||
SrsAvcProfileReserved = 0,
|
||||
|
||||
// @see ffmpeg, libavcodec/avcodec.h:2713
|
||||
SrsAvcProfileBaseline = 66,
|
||||
// FF_PROFILE_H264_CONSTRAINED (1<<9) // 8+1; constraint_set1_flag
|
||||
// FF_PROFILE_H264_CONSTRAINED_BASELINE (66|FF_PROFILE_H264_CONSTRAINED)
|
||||
SrsAvcProfileConstrainedBaseline = 578,
|
||||
SrsAvcProfileMain = 77,
|
||||
SrsAvcProfileExtended = 88,
|
||||
SrsAvcProfileHigh = 100,
|
||||
SrsAvcProfileHigh10 = 110,
|
||||
SrsAvcProfileHigh10Intra = 2158,
|
||||
SrsAvcProfileHigh422 = 122,
|
||||
SrsAvcProfileHigh422Intra = 2170,
|
||||
SrsAvcProfileHigh444 = 144,
|
||||
SrsAvcProfileHigh444Predictive = 244,
|
||||
SrsAvcProfileHigh444Intra = 2192,
|
||||
};
|
||||
std::string srs_codec_avc_profile2str(SrsAvcProfile profile);
|
||||
|
||||
/**
|
||||
* the level for avc/h.264.
|
||||
* @see Annex A Profiles and levels, H.264-AVC-ISO_IEC_14496-10.pdf, page 207.
|
||||
*/
|
||||
enum SrsAvcLevel
|
||||
{
|
||||
SrsAvcLevelReserved = 0,
|
||||
|
||||
SrsAvcLevel_1 = 10,
|
||||
SrsAvcLevel_11 = 11,
|
||||
SrsAvcLevel_12 = 12,
|
||||
SrsAvcLevel_13 = 13,
|
||||
SrsAvcLevel_2 = 20,
|
||||
SrsAvcLevel_21 = 21,
|
||||
SrsAvcLevel_22 = 22,
|
||||
SrsAvcLevel_3 = 30,
|
||||
SrsAvcLevel_31 = 31,
|
||||
SrsAvcLevel_32 = 32,
|
||||
SrsAvcLevel_4 = 40,
|
||||
SrsAvcLevel_41 = 41,
|
||||
SrsAvcLevel_5 = 50,
|
||||
SrsAvcLevel_51 = 51,
|
||||
};
|
||||
std::string srs_codec_avc_level2str(SrsAvcLevel level);
|
||||
|
||||
/**
|
||||
* the h264/avc and aac codec, for media stream.
|
||||
*
|
||||
|
@ -453,9 +504,9 @@ public:
|
|||
* video specified
|
||||
*/
|
||||
// profile_idc, H.264-AVC-ISO_IEC_14496-10.pdf, page 45.
|
||||
u_int8_t avc_profile;
|
||||
SrsAvcProfile avc_profile;
|
||||
// level_idc, H.264-AVC-ISO_IEC_14496-10.pdf, page 45.
|
||||
u_int8_t avc_level;
|
||||
SrsAvcLevel avc_level;
|
||||
// lengthSizeMinusOne, H.264-AVC-ISO_IEC_14496-15.pdf, page 16
|
||||
int8_t NAL_unit_length;
|
||||
u_int16_t sequenceParameterSetLength;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue