正在显示
6 个修改的文件
包含
109 行增加
和
17 行删除
| @@ -1531,9 +1531,10 @@ int SrsSource::on_video(SrsCommonMessage* __video) | @@ -1531,9 +1531,10 @@ int SrsSource::on_video(SrsCommonMessage* __video) | ||
| 1531 | } | 1531 | } |
| 1532 | 1532 | ||
| 1533 | srs_trace("%dB video sh, " | 1533 | srs_trace("%dB video sh, " |
| 1534 | - "codec(%d, profile=%d, level=%d, %dx%d, %dkbps, %dfps, %ds)", | 1534 | + "codec(%d, profile=%s, level=%s, %dx%d, %dkbps, %dfps, %ds)", |
| 1535 | msg.size, codec.video_codec_id, | 1535 | msg.size, codec.video_codec_id, |
| 1536 | - codec.avc_profile, codec.avc_level, codec.width, codec.height, | 1536 | + srs_codec_avc_profile2str(codec.avc_profile).c_str(), |
| 1537 | + srs_codec_avc_level2str(codec.avc_level).c_str(), codec.width, codec.height, | ||
| 1537 | codec.video_data_rate / 1000, codec.frame_rate, codec.duration); | 1538 | codec.video_data_rate / 1000, codec.frame_rate, codec.duration); |
| 1538 | return ret; | 1539 | return ret; |
| 1539 | } | 1540 | } |
| @@ -53,8 +53,8 @@ SrsStatisticStream::SrsStatisticStream() | @@ -53,8 +53,8 @@ SrsStatisticStream::SrsStatisticStream() | ||
| 53 | 53 | ||
| 54 | has_video = false; | 54 | has_video = false; |
| 55 | vcodec = SrsCodecVideoReserved; | 55 | vcodec = SrsCodecVideoReserved; |
| 56 | - avc_profile = 0; | ||
| 57 | - avc_level = 0; | 56 | + avc_profile = SrsAvcProfileReserved; |
| 57 | + avc_level = SrsAvcLevelReserved; | ||
| 58 | 58 | ||
| 59 | has_audio = false; | 59 | has_audio = false; |
| 60 | acodec = SrsCodecAudioReserved1; | 60 | acodec = SrsCodecAudioReserved1; |
| @@ -111,7 +111,7 @@ SrsStatistic* SrsStatistic::instance() | @@ -111,7 +111,7 @@ SrsStatistic* SrsStatistic::instance() | ||
| 111 | } | 111 | } |
| 112 | 112 | ||
| 113 | int SrsStatistic::on_video_info(SrsRequest* req, | 113 | int SrsStatistic::on_video_info(SrsRequest* req, |
| 114 | - SrsCodecVideo vcodec, u_int8_t avc_profile, u_int8_t avc_level | 114 | + SrsCodecVideo vcodec, SrsAvcProfile avc_profile, SrsAvcLevel avc_level |
| 115 | ) { | 115 | ) { |
| 116 | int ret = ERROR_SUCCESS; | 116 | int ret = ERROR_SUCCESS; |
| 117 | 117 | ||
| @@ -243,8 +243,8 @@ int SrsStatistic::dumps_streams(stringstream& ss) | @@ -243,8 +243,8 @@ int SrsStatistic::dumps_streams(stringstream& ss) | ||
| 243 | ss << __SRS_JFIELD_NAME("video") | 243 | ss << __SRS_JFIELD_NAME("video") |
| 244 | << __SRS_JOBJECT_START | 244 | << __SRS_JOBJECT_START |
| 245 | << __SRS_JFIELD_STR("codec", srs_codec_video2str(stream->vcodec)) << __SRS_JFIELD_CONT | 245 | << __SRS_JFIELD_STR("codec", srs_codec_video2str(stream->vcodec)) << __SRS_JFIELD_CONT |
| 246 | - << __SRS_JFIELD_ORG("profile", (int)stream->avc_profile) << __SRS_JFIELD_CONT | ||
| 247 | - << __SRS_JFIELD_ORG("level", (int)stream->avc_level) | 246 | + << __SRS_JFIELD_STR("profile", srs_codec_avc_profile2str(stream->avc_profile)) << __SRS_JFIELD_CONT |
| 247 | + << __SRS_JFIELD_ORG("level", srs_codec_avc_level2str(stream->avc_level)) | ||
| 248 | << __SRS_JOBJECT_END | 248 | << __SRS_JOBJECT_END |
| 249 | << __SRS_JFIELD_CONT; | 249 | << __SRS_JFIELD_CONT; |
| 250 | } | 250 | } |
| @@ -59,9 +59,9 @@ public: | @@ -59,9 +59,9 @@ public: | ||
| 59 | bool has_video; | 59 | bool has_video; |
| 60 | SrsCodecVideo vcodec; | 60 | SrsCodecVideo vcodec; |
| 61 | // profile_idc, H.264-AVC-ISO_IEC_14496-10.pdf, page 45. | 61 | // profile_idc, H.264-AVC-ISO_IEC_14496-10.pdf, page 45. |
| 62 | - u_int8_t avc_profile; | 62 | + SrsAvcProfile avc_profile; |
| 63 | // level_idc, H.264-AVC-ISO_IEC_14496-10.pdf, page 45. | 63 | // level_idc, H.264-AVC-ISO_IEC_14496-10.pdf, page 45. |
| 64 | - u_int8_t avc_level; | 64 | + SrsAvcLevel avc_level; |
| 65 | public: | 65 | public: |
| 66 | bool has_audio; | 66 | bool has_audio; |
| 67 | SrsCodecAudio acodec; | 67 | SrsCodecAudio acodec; |
| @@ -113,7 +113,7 @@ public: | @@ -113,7 +113,7 @@ public: | ||
| 113 | * when got video info for stream. | 113 | * when got video info for stream. |
| 114 | */ | 114 | */ |
| 115 | virtual int on_video_info(SrsRequest* req, | 115 | virtual int on_video_info(SrsRequest* req, |
| 116 | - SrsCodecVideo vcodec, u_int8_t avc_profile, u_int8_t avc_level | 116 | + SrsCodecVideo vcodec, SrsAvcProfile avc_profile, SrsAvcLevel avc_level |
| 117 | ); | 117 | ); |
| 118 | /** | 118 | /** |
| 119 | * when got audio info for stream. | 119 | * when got audio info for stream. |
| @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 31 | // current release version | 31 | // current release version |
| 32 | #define VERSION_MAJOR 2 | 32 | #define VERSION_MAJOR 2 |
| 33 | #define VERSION_MINOR 0 | 33 | #define VERSION_MINOR 0 |
| 34 | -#define VERSION_REVISION 134 | 34 | +#define VERSION_REVISION 135 |
| 35 | 35 | ||
| 36 | // server info. | 36 | // server info. |
| 37 | #define RTMP_SIG_SRS_KEY "SRS" | 37 | #define RTMP_SIG_SRS_KEY "SRS" |
| @@ -121,6 +121,46 @@ SrsAacProfile srs_codec_aac_rtmp2ts(SrsAacObjectType object_type) | @@ -121,6 +121,46 @@ SrsAacProfile srs_codec_aac_rtmp2ts(SrsAacObjectType object_type) | ||
| 121 | } | 121 | } |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | +string srs_codec_avc_profile2str(SrsAvcProfile profile) | ||
| 125 | +{ | ||
| 126 | + switch (profile) { | ||
| 127 | + case SrsAvcProfileBaseline: return "Baseline"; | ||
| 128 | + case SrsAvcProfileConstrainedBaseline: return "Baseline(Constrained)"; | ||
| 129 | + case SrsAvcProfileMain: return "Main"; | ||
| 130 | + case SrsAvcProfileExtended: return "Extended"; | ||
| 131 | + case SrsAvcProfileHigh: return "High"; | ||
| 132 | + case SrsAvcProfileHigh10: return "High(10)"; | ||
| 133 | + case SrsAvcProfileHigh10Intra: return "High(10+Intra)"; | ||
| 134 | + case SrsAvcProfileHigh422: return "High(422)"; | ||
| 135 | + case SrsAvcProfileHigh422Intra: return "High(422+Intra)"; | ||
| 136 | + case SrsAvcProfileHigh444: return "High(444)"; | ||
| 137 | + case SrsAvcProfileHigh444Predictive: return "High(444+Predictive)"; | ||
| 138 | + case SrsAvcProfileHigh444Intra: return "High(444+Intra)"; | ||
| 139 | + default: return "Other"; | ||
| 140 | + } | ||
| 141 | +} | ||
| 142 | + | ||
| 143 | +string srs_codec_avc_level2str(SrsAvcLevel level) | ||
| 144 | +{ | ||
| 145 | + switch (level) { | ||
| 146 | + case SrsAvcLevel_1: return "1"; | ||
| 147 | + case SrsAvcLevel_11: return "1.1"; | ||
| 148 | + case SrsAvcLevel_12: return "1.2"; | ||
| 149 | + case SrsAvcLevel_13: return "1.3"; | ||
| 150 | + case SrsAvcLevel_2: return "2"; | ||
| 151 | + case SrsAvcLevel_21: return "2.1"; | ||
| 152 | + case SrsAvcLevel_22: return "2.2"; | ||
| 153 | + case SrsAvcLevel_3: return "3"; | ||
| 154 | + case SrsAvcLevel_31: return "3.1"; | ||
| 155 | + case SrsAvcLevel_32: return "3.2"; | ||
| 156 | + case SrsAvcLevel_4: return "4"; | ||
| 157 | + case SrsAvcLevel_41: return "4.1"; | ||
| 158 | + case SrsAvcLevel_5: return "5"; | ||
| 159 | + case SrsAvcLevel_51: return "5.1"; | ||
| 160 | + default: return "Other"; | ||
| 161 | + } | ||
| 162 | +} | ||
| 163 | + | ||
| 124 | /** | 164 | /** |
| 125 | * the public data, event HLS disable, others can use it. | 165 | * the public data, event HLS disable, others can use it. |
| 126 | */ | 166 | */ |
| @@ -292,8 +332,8 @@ SrsAvcAacCodec::SrsAvcAacCodec() | @@ -292,8 +332,8 @@ SrsAvcAacCodec::SrsAvcAacCodec() | ||
| 292 | audio_data_rate = 0; | 332 | audio_data_rate = 0; |
| 293 | audio_codec_id = 0; | 333 | audio_codec_id = 0; |
| 294 | 334 | ||
| 295 | - avc_profile = 0; | ||
| 296 | - avc_level = 0; | 335 | + avc_profile = SrsAvcProfileReserved; |
| 336 | + avc_level = SrsAvcLevelReserved; | ||
| 297 | aac_object = SrsAacObjectTypeReserved; | 337 | aac_object = SrsAacObjectTypeReserved; |
| 298 | aac_sample_rate = __SRS_AAC_SAMPLE_RATE_UNSET; // sample rate ignored | 338 | aac_sample_rate = __SRS_AAC_SAMPLE_RATE_UNSET; // sample rate ignored |
| 299 | aac_channels = 0; | 339 | aac_channels = 0; |
| @@ -651,11 +691,11 @@ int SrsAvcAacCodec::avc_demux_sps_pps(SrsStream* stream) | @@ -651,11 +691,11 @@ int SrsAvcAacCodec::avc_demux_sps_pps(SrsStream* stream) | ||
| 651 | //int8_t configurationVersion = stream->read_1bytes(); | 691 | //int8_t configurationVersion = stream->read_1bytes(); |
| 652 | stream->read_1bytes(); | 692 | stream->read_1bytes(); |
| 653 | //int8_t AVCProfileIndication = stream->read_1bytes(); | 693 | //int8_t AVCProfileIndication = stream->read_1bytes(); |
| 654 | - avc_profile = stream->read_1bytes(); | 694 | + avc_profile = (SrsAvcProfile)stream->read_1bytes(); |
| 655 | //int8_t profile_compatibility = stream->read_1bytes(); | 695 | //int8_t profile_compatibility = stream->read_1bytes(); |
| 656 | stream->read_1bytes(); | 696 | stream->read_1bytes(); |
| 657 | //int8_t AVCLevelIndication = stream->read_1bytes(); | 697 | //int8_t AVCLevelIndication = stream->read_1bytes(); |
| 658 | - avc_level = stream->read_1bytes(); | 698 | + avc_level = (SrsAvcLevel)stream->read_1bytes(); |
| 659 | 699 | ||
| 660 | // parse the NALU size. | 700 | // parse the NALU size. |
| 661 | int8_t lengthSizeMinusOne = stream->read_1bytes(); | 701 | int8_t lengthSizeMinusOne = stream->read_1bytes(); |
| @@ -417,6 +417,57 @@ SrsAacObjectType srs_codec_aac_ts2rtmp(SrsAacProfile profile); | @@ -417,6 +417,57 @@ SrsAacObjectType srs_codec_aac_ts2rtmp(SrsAacProfile profile); | ||
| 417 | SrsAacProfile srs_codec_aac_rtmp2ts(SrsAacObjectType object_type); | 417 | SrsAacProfile srs_codec_aac_rtmp2ts(SrsAacObjectType object_type); |
| 418 | 418 | ||
| 419 | /** | 419 | /** |
| 420 | +* the profile for avc/h.264. | ||
| 421 | +* @see Annex A Profiles and levels, H.264-AVC-ISO_IEC_14496-10.pdf, page 205. | ||
| 422 | +*/ | ||
| 423 | +enum SrsAvcProfile | ||
| 424 | +{ | ||
| 425 | + SrsAvcProfileReserved = 0, | ||
| 426 | + | ||
| 427 | + // @see ffmpeg, libavcodec/avcodec.h:2713 | ||
| 428 | + SrsAvcProfileBaseline = 66, | ||
| 429 | + // FF_PROFILE_H264_CONSTRAINED (1<<9) // 8+1; constraint_set1_flag | ||
| 430 | + // FF_PROFILE_H264_CONSTRAINED_BASELINE (66|FF_PROFILE_H264_CONSTRAINED) | ||
| 431 | + SrsAvcProfileConstrainedBaseline = 578, | ||
| 432 | + SrsAvcProfileMain = 77, | ||
| 433 | + SrsAvcProfileExtended = 88, | ||
| 434 | + SrsAvcProfileHigh = 100, | ||
| 435 | + SrsAvcProfileHigh10 = 110, | ||
| 436 | + SrsAvcProfileHigh10Intra = 2158, | ||
| 437 | + SrsAvcProfileHigh422 = 122, | ||
| 438 | + SrsAvcProfileHigh422Intra = 2170, | ||
| 439 | + SrsAvcProfileHigh444 = 144, | ||
| 440 | + SrsAvcProfileHigh444Predictive = 244, | ||
| 441 | + SrsAvcProfileHigh444Intra = 2192, | ||
| 442 | +}; | ||
| 443 | +std::string srs_codec_avc_profile2str(SrsAvcProfile profile); | ||
| 444 | + | ||
| 445 | +/** | ||
| 446 | +* the level for avc/h.264. | ||
| 447 | +* @see Annex A Profiles and levels, H.264-AVC-ISO_IEC_14496-10.pdf, page 207. | ||
| 448 | +*/ | ||
| 449 | +enum SrsAvcLevel | ||
| 450 | +{ | ||
| 451 | + SrsAvcLevelReserved = 0, | ||
| 452 | + | ||
| 453 | + SrsAvcLevel_1 = 10, | ||
| 454 | + SrsAvcLevel_11 = 11, | ||
| 455 | + SrsAvcLevel_12 = 12, | ||
| 456 | + SrsAvcLevel_13 = 13, | ||
| 457 | + SrsAvcLevel_2 = 20, | ||
| 458 | + SrsAvcLevel_21 = 21, | ||
| 459 | + SrsAvcLevel_22 = 22, | ||
| 460 | + SrsAvcLevel_3 = 30, | ||
| 461 | + SrsAvcLevel_31 = 31, | ||
| 462 | + SrsAvcLevel_32 = 32, | ||
| 463 | + SrsAvcLevel_4 = 40, | ||
| 464 | + SrsAvcLevel_41 = 41, | ||
| 465 | + SrsAvcLevel_5 = 50, | ||
| 466 | + SrsAvcLevel_51 = 51, | ||
| 467 | +}; | ||
| 468 | +std::string srs_codec_avc_level2str(SrsAvcLevel level); | ||
| 469 | + | ||
| 470 | +/** | ||
| 420 | * the h264/avc and aac codec, for media stream. | 471 | * the h264/avc and aac codec, for media stream. |
| 421 | * | 472 | * |
| 422 | * to demux the FLV/RTMP video/audio packet to sample, | 473 | * to demux the FLV/RTMP video/audio packet to sample, |
| @@ -453,9 +504,9 @@ public: | @@ -453,9 +504,9 @@ public: | ||
| 453 | * video specified | 504 | * video specified |
| 454 | */ | 505 | */ |
| 455 | // profile_idc, H.264-AVC-ISO_IEC_14496-10.pdf, page 45. | 506 | // profile_idc, H.264-AVC-ISO_IEC_14496-10.pdf, page 45. |
| 456 | - u_int8_t avc_profile; | 507 | + SrsAvcProfile avc_profile; |
| 457 | // level_idc, H.264-AVC-ISO_IEC_14496-10.pdf, page 45. | 508 | // level_idc, H.264-AVC-ISO_IEC_14496-10.pdf, page 45. |
| 458 | - u_int8_t avc_level; | 509 | + SrsAvcLevel avc_level; |
| 459 | // lengthSizeMinusOne, H.264-AVC-ISO_IEC_14496-15.pdf, page 16 | 510 | // lengthSizeMinusOne, H.264-AVC-ISO_IEC_14496-15.pdf, page 16 |
| 460 | int8_t NAL_unit_length; | 511 | int8_t NAL_unit_length; |
| 461 | u_int16_t sequenceParameterSetLength; | 512 | u_int16_t sequenceParameterSetLength; |
-
请 注册 或 登录 后发表评论