Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
srs
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
winlin
2014-11-21 17:09:52 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d3c770d252ad43e1d40c44a457e87d44e329df2a
d3c770d2
1 parent
d80b580c
refine librtmp, add audio video detail.
显示空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
327 行增加
和
4 行删除
trunk/src/libs/srs_librtmp.cpp
trunk/src/libs/srs_librtmp.hpp
trunk/src/libs/srs_librtmp.cpp
查看文件 @
d3c770d
...
...
@@ -1823,6 +1823,85 @@ char srs_utils_flv_video_frame_type(char* data, int size)
return
frame_type
;
}
char
srs_utils_flv_audio_sound_format
(
char
*
data
,
int
size
)
{
if
(
size
<
1
)
{
return
-
1
;
}
u_int8_t
sound_format
=
data
[
0
];
sound_format
=
(
sound_format
>>
4
)
&
0x0f
;
if
(
sound_format
>
15
||
sound_format
==
12
||
sound_format
==
13
)
{
return
-
1
;
}
return
sound_format
;
}
char
srs_utils_flv_audio_sound_rate
(
char
*
data
,
int
size
)
{
if
(
size
<
1
)
{
return
-
1
;
}
u_int8_t
sound_rate
=
data
[
0
];
sound_rate
=
(
sound_rate
>>
2
)
&
0x03
;
if
(
sound_rate
>
3
)
{
return
-
1
;
}
return
sound_rate
;
}
char
srs_utils_flv_audio_sound_size
(
char
*
data
,
int
size
)
{
if
(
size
<
1
)
{
return
-
1
;
}
u_int8_t
sound_size
=
data
[
0
];
sound_size
=
(
sound_size
>>
1
)
&
0x01
;
if
(
sound_size
>
1
)
{
return
-
1
;
}
return
sound_size
;
}
char
srs_utils_flv_audio_sound_type
(
char
*
data
,
int
size
)
{
if
(
size
<
1
)
{
return
-
1
;
}
u_int8_t
sound_type
=
data
[
0
];
sound_type
=
sound_type
&
0x01
;
if
(
sound_type
>
1
)
{
return
-
1
;
}
return
sound_type
;
}
char
srs_utils_flv_audio_aac_packet_type
(
char
*
data
,
int
size
)
{
if
(
size
<
2
)
{
return
-
1
;
}
if
(
srs_utils_flv_audio_sound_format
(
data
,
size
)
!=
10
)
{
return
-
1
;
}
u_int8_t
aac_packet_type
=
data
[
1
];
aac_packet_type
=
aac_packet_type
;
if
(
aac_packet_type
>
1
)
{
return
-
1
;
}
return
aac_packet_type
;
}
char
*
srs_human_amf0_print
(
srs_amf0_t
amf0
,
char
**
pdata
,
int
*
psize
)
{
if
(
!
amf0
)
{
...
...
@@ -1876,7 +1955,7 @@ const char* srs_human_flv_video_codec_id2string(char codec_id)
const
char
*
srs_human_flv_video_avc_packet_type2string
(
char
avc_packet_type
)
{
static
const
char
*
sps_pps
=
"S
psPps
"
;
static
const
char
*
sps_pps
=
"S
H
"
;
static
const
char
*
nalu
=
"Nalu"
;
static
const
char
*
sps_pps_end
=
"SpsPpsEnd"
;
static
const
char
*
unknown
=
"Unknown"
;
...
...
@@ -1912,6 +1991,109 @@ const char* srs_human_flv_video_frame_type2string(char frame_type)
return
unknown
;
}
const
char
*
srs_human_flv_audio_sound_format2string
(
char
sound_format
)
{
static
const
char
*
linear_pcm
=
"LinearPCM"
;
static
const
char
*
ad_pcm
=
"ADPCM"
;
static
const
char
*
mp3
=
"MP3"
;
static
const
char
*
linear_pcm_le
=
"LinearPCMLe"
;
static
const
char
*
nellymoser_16khz
=
"NellymoserKHz16"
;
static
const
char
*
nellymoser_8khz
=
"NellymoserKHz8"
;
static
const
char
*
nellymoser
=
"Nellymoser"
;
static
const
char
*
g711_a_pcm
=
"G711APCM"
;
static
const
char
*
g711_mu_pcm
=
"G711MuPCM"
;
static
const
char
*
reserved
=
"Reserved"
;
static
const
char
*
aac
=
"AAC"
;
static
const
char
*
speex
=
"Speex"
;
static
const
char
*
mp3_8khz
=
"MP3KHz8"
;
static
const
char
*
device_specific
=
"DeviceSpecific"
;
static
const
char
*
unknown
=
"Unknown"
;
switch
(
sound_format
)
{
case
0
:
return
linear_pcm
;
case
1
:
return
ad_pcm
;
case
2
:
return
mp3
;
case
3
:
return
linear_pcm_le
;
case
4
:
return
nellymoser_16khz
;
case
5
:
return
nellymoser_8khz
;
case
6
:
return
nellymoser
;
case
7
:
return
g711_a_pcm
;
case
8
:
return
g711_mu_pcm
;
case
9
:
return
reserved
;
case
10
:
return
aac
;
case
11
:
return
speex
;
case
14
:
return
mp3_8khz
;
case
15
:
return
device_specific
;
default:
return
unknown
;
}
return
unknown
;
}
const
char
*
srs_human_flv_audio_sound_rate2string
(
char
sound_rate
)
{
static
const
char
*
khz_5_5
=
"5.5KHz"
;
static
const
char
*
khz_11
=
"11KHz"
;
static
const
char
*
khz_22
=
"22KHz"
;
static
const
char
*
khz_44
=
"44KHz"
;
static
const
char
*
unknown
=
"Unknown"
;
switch
(
sound_rate
)
{
case
0
:
return
khz_5_5
;
case
1
:
return
khz_11
;
case
2
:
return
khz_22
;
case
3
:
return
khz_44
;
default:
return
unknown
;
}
return
unknown
;
}
const
char
*
srs_human_flv_audio_sound_size2string
(
char
sound_size
)
{
static
const
char
*
bit_8
=
"8bit"
;
static
const
char
*
bit_16
=
"16bit"
;
static
const
char
*
unknown
=
"Unknown"
;
switch
(
sound_size
)
{
case
0
:
return
bit_8
;
case
1
:
return
bit_16
;
default:
return
unknown
;
}
return
unknown
;
}
const
char
*
srs_human_flv_audio_sound_type2string
(
char
sound_type
)
{
static
const
char
*
mono
=
"Mono"
;
static
const
char
*
stereo
=
"Stereo"
;
static
const
char
*
unknown
=
"Unknown"
;
switch
(
sound_type
)
{
case
0
:
return
mono
;
case
1
:
return
stereo
;
default:
return
unknown
;
}
return
unknown
;
}
const
char
*
srs_human_flv_audio_aac_packet_type2string
(
char
aac_packet_type
)
{
static
const
char
*
sps_pps
=
"SH"
;
static
const
char
*
raw
=
"Raw"
;
static
const
char
*
unknown
=
"Unknown"
;
switch
(
aac_packet_type
)
{
case
0
:
return
sps_pps
;
case
1
:
return
raw
;
default:
return
unknown
;
}
return
unknown
;
}
int
srs_human_print_rtmp_packet
(
char
type
,
u_int32_t
timestamp
,
char
*
data
,
int
size
)
{
int
ret
=
ERROR_SUCCESS
;
...
...
@@ -1929,8 +2111,14 @@ int srs_human_print_rtmp_packet(char type, u_int32_t timestamp, char* data, int
srs_human_flv_video_frame_type2string
(
srs_utils_flv_video_frame_type
(
data
,
size
))
);
}
else
if
(
type
==
SRS_RTMP_TYPE_AUDIO
)
{
srs_human_trace
(
"Audio packet type=%s, dts=%d, pts=%d, size=%d"
,
srs_human_flv_tag_type2string
(
type
),
timestamp
,
pts
,
size
);
srs_human_trace
(
"Audio packet type=%s, dts=%d, pts=%d, size=%d, %s(%s,%s,%s,%s)"
,
srs_human_flv_tag_type2string
(
type
),
timestamp
,
pts
,
size
,
srs_human_flv_audio_sound_format2string
(
srs_utils_flv_audio_sound_format
(
data
,
size
)),
srs_human_flv_audio_sound_rate2string
(
srs_utils_flv_audio_sound_rate
(
data
,
size
)),
srs_human_flv_audio_sound_size2string
(
srs_utils_flv_audio_sound_size
(
data
,
size
)),
srs_human_flv_audio_sound_type2string
(
srs_utils_flv_audio_sound_type
(
data
,
size
)),
srs_human_flv_audio_aac_packet_type2string
(
srs_utils_flv_audio_aac_packet_type
(
data
,
size
))
);
}
else
if
(
type
==
SRS_RTMP_TYPE_SCRIPT
)
{
srs_human_verbose
(
"Data packet type=%s, time=%d, size=%d"
,
srs_human_flv_tag_type2string
(
type
),
timestamp
,
size
);
...
...
trunk/src/libs/srs_librtmp.hpp
查看文件 @
d3c770d
...
...
@@ -660,6 +660,70 @@ extern char srs_utils_flv_video_avc_packet_type(char* data, int size);
*/
extern
char
srs_utils_flv_video_frame_type
(
char
*
data
,
int
size
);
/**
* get the SoundFormat of audio tag.
* Format of SoundData. The following values are defined:
* 0 = Linear PCM, platform endian
* 1 = ADPCM
* 2 = MP3
* 3 = Linear PCM, little endian
* 4 = Nellymoser 16 kHz mono
* 5 = Nellymoser 8 kHz mono
* 6 = Nellymoser
* 7 = G.711 A-law logarithmic PCM
* 8 = G.711 mu-law logarithmic PCM
* 9 = reserved
* 10 = AAC
* 11 = Speex
* 14 = MP3 8 kHz
* 15 = Device-specific sound
* Formats 7, 8, 14, and 15 are reserved.
* AAC is supported in Flash Player 9,0,115,0 and higher.
* Speex is supported in Flash Player 10 and higher.
* @return the sound format. -1(0xff) for error.
*/
extern
char
srs_utils_flv_audio_sound_format
(
char
*
data
,
int
size
);
/**
* get the SoundRate of audio tag.
* Sampling rate. The following values are defined:
* 0 = 5.5 kHz
* 1 = 11 kHz
* 2 = 22 kHz
* 3 = 44 kHz
* @return the sound rate. -1(0xff) for error.
*/
extern
char
srs_utils_flv_audio_sound_rate
(
char
*
data
,
int
size
);
/**
* get the SoundSize of audio tag.
* Size of each audio sample. This parameter only pertains to
* uncompressed formats. Compressed formats always decode
* to 16 bits internally.
* 0 = 8-bit samples
* 1 = 16-bit samples
* @return the sound size. -1(0xff) for error.
*/
extern
char
srs_utils_flv_audio_sound_size
(
char
*
data
,
int
size
);
/**
* get the SoundType of audio tag.
* Mono or stereo sound
* 0 = Mono sound
* 1 = Stereo sound
* @return the sound type. -1(0xff) for error.
*/
extern
char
srs_utils_flv_audio_sound_type
(
char
*
data
,
int
size
);
/**
* get the AACPacketType of audio tag.
* The following values are defined:
* 0 = AAC sequence header
* 1 = AAC raw
* @return the aac packet type. -1(0xff) for error.
*/
extern
char
srs_utils_flv_audio_aac_packet_type
(
char
*
data
,
int
size
);
/*************************************************************
**************************************************************
* human readable print.
...
...
@@ -699,7 +763,7 @@ extern const char* srs_human_flv_video_codec_id2string(char codec_id);
/**
* get the avc packet type string.
* S
psPps
= AVC sequence header
* S
H
= AVC sequence header
* Nalu = AVC NALU
* SpsPpsEnd = AVC end of sequence
* otherwise, "Unknown"
...
...
@@ -722,6 +786,77 @@ extern const char* srs_human_flv_video_avc_packet_type2string(char avc_packet_ty
extern
const
char
*
srs_human_flv_video_frame_type2string
(
char
frame_type
);
/**
* get the SoundFormat string.
* Format of SoundData. The following values are defined:
* LinearPCM = Linear PCM, platform endian
* ADPCM = ADPCM
* MP3 = MP3
* LinearPCMLe = Linear PCM, little endian
* NellymoserKHz16 = Nellymoser 16 kHz mono
* NellymoserKHz8 = Nellymoser 8 kHz mono
* Nellymoser = Nellymoser
* G711APCM = G.711 A-law logarithmic PCM
* G711MuPCM = G.711 mu-law logarithmic PCM
* Reserved = reserved
* AAC = AAC
* Speex = Speex
* MP3KHz8 = MP3 8 kHz
* DeviceSpecific = Device-specific sound
* otherwise, "Unknown"
* @remark user never free the return char*,
* it's static shared const string.
*/
extern
const
char
*
srs_human_flv_audio_sound_format2string
(
char
sound_format
);
/**
* get the SoundRate of audio tag.
* Sampling rate. The following values are defined:
* 5.5KHz = 5.5 kHz
* 11KHz = 11 kHz
* 22KHz = 22 kHz
* 44KHz = 44 kHz
* otherwise, "Unknown"
* @remark user never free the return char*,
* it's static shared const string.
*/
extern
const
char
*
srs_human_flv_audio_sound_rate2string
(
char
sound_rate
);
/**
* get the SoundSize of audio tag.
* Size of each audio sample. This parameter only pertains to
* uncompressed formats. Compressed formats always decode
* to 16 bits internally.
* 8bit = 8-bit samples
* 16bit = 16-bit samples
* otherwise, "Unknown"
* @remark user never free the return char*,
* it's static shared const string.
*/
extern
const
char
*
srs_human_flv_audio_sound_size2string
(
char
sound_size
);
/**
* get the SoundType of audio tag.
* Mono or stereo sound
* Mono = Mono sound
* Stereo = Stereo sound
* otherwise, "Unknown"
* @remark user never free the return char*,
* it's static shared const string.
*/
extern
const
char
*
srs_human_flv_audio_sound_type2string
(
char
sound_type
);
/**
* get the AACPacketType of audio tag.
* The following values are defined:
* SH = AAC sequence header
* Raw = AAC raw
* otherwise, "Unknown"
* @remark user never free the return char*,
* it's static shared const string.
*/
extern
const
char
*
srs_human_flv_audio_aac_packet_type2string
(
char
aac_packet_type
);
/**
* print the rtmp packet, use srs_human_trace/srs_human_verbose for packet,
* and use srs_human_raw for script data body.
* @return an error code for parse the timetstamp to dts and pts.
...
...
请
注册
或
登录
后发表评论