added H264 profile & level parsers

This commit is contained in:
Roman Arutyunyan 2012-06-14 17:44:30 +04:00
parent bf04e66862
commit 1da4bb923e
4 changed files with 43 additions and 4 deletions

View file

@ -250,6 +250,8 @@ ngx_rtmp_codec_meta_data(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
double audio_data_rate;
double audio_codec_id_n;
u_char audio_codec_id_s[32];
u_char profile[32];
u_char level[32];
} v;
static ngx_rtmp_amf_elt_t in_video_codec_id[] = {
@ -311,6 +313,14 @@ ngx_rtmp_codec_meta_data(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
{ NGX_RTMP_AMF_VARIANT,
ngx_string("audiocodecid"),
in_audio_codec_id, sizeof(in_audio_codec_id) },
{ NGX_RTMP_AMF_STRING,
ngx_string("profile"),
&v.profile, sizeof(v.profile) },
{ NGX_RTMP_AMF_STRING,
ngx_string("level"),
&v.level, sizeof(v.level) },
};
static ngx_rtmp_amf_elt_t in_elts[] = {
@ -357,6 +367,8 @@ ngx_rtmp_codec_meta_data(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
ctx->audio_codec_id = (v.audio_codec_id_n == -1
? 0 : v.audio_codec_id_n == 0
? NGX_RTMP_AUDIO_UNCOMPRESSED : v.audio_codec_id_n);
ngx_memcpy(ctx->profile, v.profile, sizeof(v.profile));
ngx_memcpy(ctx->level, v.level, sizeof(v.level));
ngx_log_debug8(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
"codec: data frame: "

View file

@ -55,6 +55,8 @@ typedef struct {
ngx_uint_t video_codec_id;
ngx_uint_t audio_data_rate;
ngx_uint_t audio_codec_id;
u_char profile[32];
u_char level[32];
ngx_uint_t avc_version;
ngx_uint_t aac_version;

View file

@ -347,17 +347,30 @@ ngx_rtmp_stat_live(ngx_http_request_t *r, ngx_chain_t ***lll,
NGX_RTMP_STAT_L("</height><framerate>");
NGX_RTMP_STAT(buf, ngx_snprintf(buf, sizeof(buf),
"%ui", codec->frame_rate) - buf);
NGX_RTMP_STAT_L("</framerate><video>");
NGX_RTMP_STAT_L("</framerate>");
cname = ngx_rtmp_get_video_codec_name(codec->video_codec_id);
if (*cname) {
NGX_RTMP_STAT_L("<video>");
NGX_RTMP_STAT_ECS(cname);
NGX_RTMP_STAT_L("</video>");
}
NGX_RTMP_STAT_L("</video><audio>");
cname = ngx_rtmp_get_audio_codec_name(codec->audio_codec_id);
if (*cname) {
NGX_RTMP_STAT_L("<audio>");
NGX_RTMP_STAT_ECS(cname);
NGX_RTMP_STAT_L("</audio>");
}
NGX_RTMP_STAT_L("</audio></meta>\r\n");
if (*codec->profile) {
NGX_RTMP_STAT_L("<profile>");
NGX_RTMP_STAT_ECS(codec->profile);
NGX_RTMP_STAT_L("</profile>");
}
if (*codec->level) {
NGX_RTMP_STAT_L("<level>");
NGX_RTMP_STAT_ECS(codec->level);
NGX_RTMP_STAT_L("</level>");
}
NGX_RTMP_STAT_L("</meta>\r\n");
}
NGX_RTMP_STAT_L("<nclients>");

View file

@ -92,7 +92,11 @@
<td><xsl:value-of select="round(bwout div 1024)"/></td>
<td><xsl:value-of select="meta/width"/>x<xsl:value-of select="meta/height"/></td>
<td align="middle"><xsl:value-of select="meta/framerate"/></td>
<td><xsl:value-of select="meta/video"/></td>
<td>
<xsl:value-of select="meta/video"/>
<xsl:apply-templates select="meta/profile"/>
<xsl:apply-templates select="meta/level"/>
</td>
<td><xsl:value-of select="meta/audio"/></td>
<td> <xsl:apply-templates select="publishing"/> </td>
<td>
@ -172,4 +176,12 @@
publishing
</xsl:template>
<xsl:template match="profile">
/<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="level">
/<xsl:value-of select="."/>
</xsl:template>
</xsl:stylesheet>