1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

for #316, add codec info to stream.

This commit is contained in:
winlin 2015-03-08 15:33:08 +08:00
parent 8bf60895a9
commit 04f3f2a8f8
8 changed files with 286 additions and 50 deletions

View file

@ -32,6 +32,80 @@ using namespace std;
#include <srs_kernel_stream.hpp>
#include <srs_kernel_utility.hpp>
string srs_codec_video2str(SrsCodecVideo codec)
{
switch (codec) {
case SrsCodecVideoAVC:
return "H264";
case SrsCodecVideoOn2VP6:
case SrsCodecVideoOn2VP6WithAlphaChannel:
return "H264";
case SrsCodecVideoReserved:
case SrsCodecVideoReserved1:
case SrsCodecVideoReserved2:
case SrsCodecVideoDisabled:
case SrsCodecVideoSorensonH263:
case SrsCodecVideoScreenVideo:
case SrsCodecVideoScreenVideoVersion2:
default:
return "Other";
}
}
string srs_codec_audio2str(SrsCodecAudio codec)
{
switch (codec) {
case SrsCodecAudioAAC:
return "AAC";
case SrsCodecAudioMP3:
return "MP3";
case SrsCodecAudioReserved1:
case SrsCodecAudioLinearPCMPlatformEndian:
case SrsCodecAudioADPCM:
case SrsCodecAudioLinearPCMLittleEndian:
case SrsCodecAudioNellymoser16kHzMono:
case SrsCodecAudioNellymoser8kHzMono:
case SrsCodecAudioNellymoser:
case SrsCodecAudioReservedG711AlawLogarithmicPCM:
case SrsCodecAudioReservedG711MuLawLogarithmicPCM:
case SrsCodecAudioReserved:
case SrsCodecAudioSpeex:
case SrsCodecAudioReservedMP3_8kHz:
case SrsCodecAudioReservedDeviceSpecificSound:
default:
return "Other";
}
}
string srs_codec_aac_profile2str(u_int8_t aac_profile)
{
switch (aac_profile) {
case 1: return "Main";
case 2: return "LC";
case 3: return "SSR";
default: return "Other";
}
}
/**
* the public data, event HLS disable, others can use it.
*/
// 0 = 5.5 kHz = 5512 Hz
// 1 = 11 kHz = 11025 Hz
// 2 = 22 kHz = 22050 Hz
// 3 = 44 kHz = 44100 Hz
int flv_sample_rates[] = {5512, 11025, 22050, 44100};
// the sample rates in the codec,
// in the sequence header.
int aac_sample_rates[] =
{
96000, 88200, 64000, 48000,
44100, 32000, 24000, 22050,
16000, 12000, 11025, 8000,
7350, 0, 0, 0
};
SrsFlvCodec::SrsFlvCodec()
{
}

View file

@ -110,6 +110,7 @@ enum SrsCodecVideo
SrsCodecVideoScreenVideoVersion2 = 6,
SrsCodecVideoAVC = 7,
};
std::string srs_codec_video2str(SrsCodecVideo codec);
// SoundFormat UB [4]
// Format of SoundData. The following values are defined:
@ -150,6 +151,7 @@ enum SrsCodecAudio
SrsCodecAudioReservedMP3_8kHz = 14,
SrsCodecAudioReservedDeviceSpecificSound = 15,
};
std::string srs_codec_audio2str(SrsCodecAudio codec);
/**
* the FLV/RTMP supported audio sample rate.
@ -373,6 +375,21 @@ enum SrsAvcPayloadFormat
SrsAvcPayloadFormatIbmf,
};
// the profile = object_id + 1
// @see aac-mp4a-format-ISO_IEC_14496-3+2001.pdf, page 78,
// Table 1. A.9 C MPEG-2 Audio profiles and MPEG-4 Audio object types
// the valid object type:
// AAC Main(ID == 0)
// AAC LC(ID == 1)
// AAC SSR(ID == 2)
// AAC LTP(ID == 3)
// the valid aac profile:
// Main profile (ID == 1)
// Low Complexity profile (LC) (ID == 2)
// Scalable Sampling Rate profile (SSR) (ID == 3)
// (reserved) (ID == 4)
std::string srs_codec_aac_profile2str(u_int8_t aac_profile);
/**
* the h264/avc and aac codec, for media stream.
*

View file

@ -56,25 +56,6 @@ using namespace std;
#define TS_AUDIO_AAC_PID 0x102
#define TS_AUDIO_MP3_PID 0x103
/**
* the public data, event HLS disable, others can use it.
*/
// 0 = 5.5 kHz = 5512 Hz
// 1 = 11 kHz = 11025 Hz
// 2 = 22 kHz = 22050 Hz
// 3 = 44 kHz = 44100 Hz
int flv_sample_rates[] = {5512, 11025, 22050, 44100};
// the sample rates in the codec,
// in the sequence header.
int aac_sample_rates[] =
{
96000, 88200, 64000, 48000,
44100, 32000, 24000, 22050,
16000, 12000, 11025, 8000,
7350, 0, 0, 0
};
string srs_ts_stream2string(SrsTsStream stream)
{
switch (stream) {