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

for #299, refine the codec object name

This commit is contained in:
winlin 2017-02-12 20:38:39 +08:00
parent d7458c4e72
commit caf69f193d
29 changed files with 731 additions and 699 deletions

View file

@ -454,9 +454,9 @@ int SrsDvrFlvSegmenter::encode_video(SrsSharedPtrMessage* video)
char* payload = video->payload;
int size = video->size;
bool sh = SrsFlvCodec::video_is_sequence_header(payload, size);
bool keyframe = SrsFlvCodec::video_is_h264(payload, size)
&& SrsFlvCodec::video_is_keyframe(payload, size) && !sh;
bool sh = SrsFlvVideo::sh(payload, size);
bool keyframe = SrsFlvVideo::h264(payload, size)
&& SrsFlvVideo::keyframe(payload, size) && !sh;
if (keyframe) {
has_keyframe = true;
@ -534,23 +534,23 @@ int SrsDvrMp4Segmenter::encode_audio(SrsSharedPtrMessage* audio)
return ret;
}
uint8_t v = buffer->read_1bytes();
SrsCodecAudio sound_format = (SrsCodecAudio)((v >> 4) & 0x0f);
SrsCodecAudioSampleRate sound_rate = (SrsCodecAudioSampleRate)((v >> 2) & 0x03);
SrsCodecAudioSampleSize sound_size = (SrsCodecAudioSampleSize)((v >> 1) & 0x01);
SrsCodecAudioSoundType channels = (SrsCodecAudioSoundType)(v&0x01);
SrsAudioCodecId sound_format = (SrsAudioCodecId)((v >> 4) & 0x0f);
SrsAudioSampleRate sound_rate = (SrsAudioSampleRate)((v >> 2) & 0x03);
SrsAudioSampleSize sound_size = (SrsAudioSampleSize)((v >> 1) & 0x01);
SrsAudioSoundType channels = (SrsAudioSoundType)(v&0x01);
uint16_t ct = 0x00;
if (sound_format == SrsCodecAudioAAC) {
if (sound_format == SrsAudioCodecIdAAC) {
if (!buffer->require(1)) {
ret = ERROR_FLV_REQUIRE_SPACE;
srs_error("DVR require flva 1 byte space, format=%d. ret=%d", sound_format, ret);
return ret;
}
v = buffer->read_1bytes();
ct = (v == 0? SrsCodecAudioTypeSequenceHeader:SrsCodecAudioTypeRawData);
ct = (v == 0? SrsAudioAacFrameTraitSequenceHeader:SrsAudioAacFrameTraitRawData);
}
if (ct == SrsCodecAudioTypeSequenceHeader) {
if (ct == SrsAudioAacFrameTraitSequenceHeader) {
enc->acodec = sound_format;
enc->sample_rate = sound_rate;
enc->sound_bits = sound_size;
@ -579,18 +579,18 @@ int SrsDvrMp4Segmenter::encode_video(SrsSharedPtrMessage* video)
return ret;
}
uint8_t v = buffer->read_1bytes();
SrsCodecVideoAVCFrame frame_type = (SrsCodecVideoAVCFrame)((v>>4)&0x0f);
SrsCodecVideo codec_id = (SrsCodecVideo)(v&0x0f);
SrsVideoAvcFrameType frame_type = (SrsVideoAvcFrameType)((v>>4)&0x0f);
SrsVideoCodecId codec_id = (SrsVideoCodecId)(v&0x0f);
if (!buffer->require(4)) {
ret = ERROR_FLV_REQUIRE_SPACE;
srs_error("DVR require flvv 4 bytes space, codec=%d. ret=%d", codec_id, ret);
return ret;
}
SrsCodecVideoAVCType ct = (SrsCodecVideoAVCType)buffer->read_1bytes();
SrsVideoAvcFrameTrait ct = (SrsVideoAvcFrameTrait)buffer->read_1bytes();
uint32_t cts = (uint32_t)buffer->read_3bytes();
if (ct == SrsCodecVideoAVCTypeSequenceHeader) {
if (ct == SrsVideoAvcFrameTraitSequenceHeader) {
enc->vcodec = codec_id;
}
@ -929,9 +929,9 @@ int SrsDvrSegmentPlan::update_duration(SrsSharedPtrMessage* msg)
char* payload = msg->payload;
int size = msg->size;
bool is_key_frame = SrsFlvCodec::video_is_h264(payload, size)
&& SrsFlvCodec::video_is_keyframe(payload, size)
&& !SrsFlvCodec::video_is_sequence_header(payload, size);
bool is_key_frame = SrsFlvVideo::h264(payload, size)
&& SrsFlvVideo::keyframe(payload, size)
&& !SrsFlvVideo::sh(payload, size);
if (!is_key_frame) {
return ret;
}

View file

@ -184,7 +184,7 @@ int SrsForwarder::on_audio(SrsSharedPtrMessage* shared_audio)
return ret;
}
if (SrsFlvCodec::audio_is_sequence_header(msg->payload, msg->size)) {
if (SrsFlvAudio::sh(msg->payload, msg->size)) {
srs_freep(sh_audio);
sh_audio = msg->copy();
}
@ -208,7 +208,7 @@ int SrsForwarder::on_video(SrsSharedPtrMessage* shared_video)
return ret;
}
if (SrsFlvCodec::video_is_sequence_header(msg->payload, msg->size)) {
if (SrsFlvVideo::sh(msg->payload, msg->size)) {
srs_freep(sh_video);
sh_video = msg->copy();
}

View file

@ -331,7 +331,7 @@ int SrsHds::on_video(SrsSharedPtrMessage* msg)
return ret;
}
if (SrsFlvCodec::video_is_sequence_header(msg->payload, msg->size)) {
if (SrsFlvVideo::sh(msg->payload, msg->size)) {
srs_freep(video_sh);
video_sh = msg->copy();
}
@ -383,7 +383,7 @@ int SrsHds::on_audio(SrsSharedPtrMessage* msg)
return ret;
}
if (SrsFlvCodec::audio_is_sequence_header(msg->payload, msg->size)) {
if (SrsFlvAudio::sh(msg->payload, msg->size)) {
srs_freep(audio_sh);
audio_sh = msg->copy();
}

View file

@ -62,7 +62,7 @@ using namespace std;
// reset the piece id when deviation overflow this.
#define SRS_JUMP_WHEN_PIECE_DEVIATION 20
SrsHlsSegment::SrsHlsSegment(SrsTsContext* c, SrsCodecAudio ac, SrsCodecVideo vc)
SrsHlsSegment::SrsHlsSegment(SrsTsContext* c, SrsAudioCodecId ac, SrsVideoCodecId vc)
{
duration = 0;
sequence_no = 0;
@ -223,7 +223,7 @@ SrsHlsMuxer::SrsHlsMuxer()
max_td = 0;
_sequence_no = 0;
current = NULL;
acodec = SrsCodecAudioReserved1;
acodec = SrsAudioCodecIdReserved1;
async = new SrsAsyncCallWorker();
context = new SrsTsContext();
}
@ -361,17 +361,17 @@ int SrsHlsMuxer::segment_open(int64_t segment_start_dts)
srs_assert(!current);
// load the default acodec from config.
SrsCodecAudio default_acodec = SrsCodecAudioAAC;
SrsAudioCodecId default_acodec = SrsAudioCodecIdAAC;
if (true) {
std::string default_acodec_str = _srs_config->get_hls_acodec(req->vhost);
if (default_acodec_str == "mp3") {
default_acodec = SrsCodecAudioMP3;
default_acodec = SrsAudioCodecIdMP3;
srs_info("hls: use default mp3 acodec");
} else if (default_acodec_str == "aac") {
default_acodec = SrsCodecAudioAAC;
default_acodec = SrsAudioCodecIdAAC;
srs_info("hls: use default aac acodec");
} else if (default_acodec_str == "an") {
default_acodec = SrsCodecAudioDisabled;
default_acodec = SrsAudioCodecIdDisabled;
srs_info("hls: use default an acodec for pure video");
} else {
srs_warn("hls: use aac for other codec=%s", default_acodec_str.c_str());
@ -379,14 +379,14 @@ int SrsHlsMuxer::segment_open(int64_t segment_start_dts)
}
// load the default vcodec from config.
SrsCodecVideo default_vcodec = SrsCodecVideoAVC;
SrsVideoCodecId default_vcodec = SrsVideoCodecIdAVC;
if (true) {
std::string default_vcodec_str = _srs_config->get_hls_vcodec(req->vhost);
if (default_vcodec_str == "h264") {
default_vcodec = SrsCodecVideoAVC;
default_vcodec = SrsVideoCodecIdAVC;
srs_info("hls: use default h264 vcodec");
} else if (default_vcodec_str == "vn") {
default_vcodec = SrsCodecVideoDisabled;
default_vcodec = SrsVideoCodecIdDisabled;
srs_info("hls: use default vn vcodec for pure audio");
} else {
srs_warn("hls: use h264 for other codec=%s", default_vcodec_str.c_str());
@ -483,7 +483,7 @@ int SrsHlsMuxer::segment_open(int64_t segment_start_dts)
// set the segment muxer audio codec.
// TODO: FIXME: refine code, use event instead.
if (acodec != SrsCodecAudioReserved1) {
if (acodec != SrsAudioCodecIdReserved1) {
current->muxer->update_acodec(acodec);
}
@ -543,7 +543,7 @@ bool SrsHlsMuxer::is_segment_absolutely_overflow()
return current->duration >= hls_aof_ratio * hls_fragment + deviation;
}
int SrsHlsMuxer::update_acodec(SrsCodecAudio ac)
int SrsHlsMuxer::update_acodec(SrsAudioCodecId ac)
{
srs_assert(current);
srs_assert(current->muxer);
@ -553,7 +553,7 @@ int SrsHlsMuxer::update_acodec(SrsCodecAudio ac)
bool SrsHlsMuxer::pure_audio()
{
return current && current->muxer && current->muxer->video_codec() == SrsCodecVideoDisabled;
return current && current->muxer && current->muxer->video_codec() == SrsVideoCodecIdDisabled;
}
int SrsHlsMuxer::flush_audio(SrsTsCache* cache)
@ -863,7 +863,7 @@ void SrsHlsController::dispose()
muxer->dispose();
}
int SrsHlsController::update_acodec(SrsCodecAudio ac)
int SrsHlsController::update_acodec(SrsAudioCodecId ac)
{
return muxer->update_acodec(ac);
}
@ -1020,7 +1020,7 @@ int SrsHlsController::write_video(SrsVideoFrame* frame, int64_t dts)
// do reap ts if any of:
// a. wait keyframe and got keyframe.
// b. always reap when not wait keyframe.
if (!muxer->wait_keyframe() || frame->frame_type == SrsCodecVideoAVCFrameKeyFrame) {
if (!muxer->wait_keyframe() || frame->frame_type == SrsVideoAvcFrameTypeKeyFrame) {
// reap the segment, which will also flush the video.
if ((ret = reap_segment("video", ts->video->dts)) != ERROR_SUCCESS) {
return ret;
@ -1216,8 +1216,8 @@ int SrsHls::on_audio(SrsSharedPtrMessage* shared_audio, SrsFormat* format)
// ts support audio codec: aac/mp3
srs_assert(format->acodec);
SrsCodecAudio acodec = format->acodec->id;
if (acodec != SrsCodecAudioAAC && acodec != SrsCodecAudioMP3) {
SrsAudioCodecId acodec = format->acodec->id;
if (acodec != SrsAudioCodecIdAAC && acodec != SrsAudioCodecIdMP3) {
return ret;
}
@ -1229,7 +1229,7 @@ int SrsHls::on_audio(SrsSharedPtrMessage* shared_audio, SrsFormat* format)
// ignore sequence header
srs_assert(format->audio);
if (acodec == SrsCodecAudioAAC && format->audio->aac_packet_type == SrsCodecAudioTypeSequenceHeader) {
if (acodec == SrsAudioCodecIdAAC && format->audio->aac_packet_type == SrsAudioAacFrameTraitSequenceHeader) {
return controller->on_sequence_header();
}
@ -1270,17 +1270,17 @@ int SrsHls::on_video(SrsSharedPtrMessage* shared_video, SrsFormat* format)
// ignore info frame,
// @see https://github.com/ossrs/srs/issues/288#issuecomment-69863909
srs_assert(format->video);
if (format->video->frame_type == SrsCodecVideoAVCFrameVideoInfoFrame) {
if (format->video->frame_type == SrsVideoAvcFrameTypeVideoInfoFrame) {
return ret;
}
srs_assert(format->vcodec);
if (format->vcodec->id != SrsCodecVideoAVC) {
if (format->vcodec->id != SrsVideoCodecIdAVC) {
return ret;
}
// ignore sequence header
if (format->video->avc_packet_type == SrsCodecVideoAVCTypeSequenceHeader) {
if (format->video->avc_packet_type == SrsVideoAvcFrameTraitSequenceHeader) {
return controller->on_sequence_header();
}

View file

@ -78,7 +78,7 @@ public:
// whether current segement is sequence header.
bool is_sequence_header;
public:
SrsHlsSegment(SrsTsContext* c, SrsCodecAudio ac, SrsCodecVideo vc);
SrsHlsSegment(SrsTsContext* c, SrsAudioCodecId ac, SrsVideoCodecId vc);
virtual ~SrsHlsSegment();
public:
/**
@ -179,7 +179,7 @@ private:
* set the muxer audio codec.
* @see https://github.com/ossrs/srs/issues/301
*/
SrsCodecAudio acodec;
SrsAudioCodecId acodec;
/**
* the ts context, to keep cc continous between ts.
* @see https://github.com/ossrs/srs/issues/375
@ -230,7 +230,7 @@ public:
*/
virtual bool is_segment_absolutely_overflow();
public:
virtual int update_acodec(SrsCodecAudio ac);
virtual int update_acodec(SrsAudioCodecId ac);
/**
* whether current hls muxer is pure audio mode.
*/
@ -278,7 +278,7 @@ public:
public:
virtual int initialize();
virtual void dispose();
virtual int update_acodec(SrsCodecAudio ac);
virtual int update_acodec(SrsAudioCodecId ac);
virtual int sequence_no();
virtual std::string ts_url();
virtual double duration();

View file

@ -266,7 +266,7 @@ int SrsFlvStreamEncoder::write_video(int64_t timestamp, char* data, int size)
int SrsFlvStreamEncoder::write_metadata(int64_t timestamp, char* data, int size)
{
return enc->write_metadata(SrsCodecFlvTagScript, data, size);
return enc->write_metadata(SrsFrameTypeScript, data, size);
}
bool SrsFlvStreamEncoder::has_cache()

View file

@ -438,8 +438,8 @@ int SrsMpegtsOverUdp::write_h264_sps_pps(uint32_t dts, uint32_t pts)
}
// h264 packet to flv packet.
int8_t frame_type = SrsCodecVideoAVCFrameKeyFrame;
int8_t avc_packet_type = SrsCodecVideoAVCTypeSequenceHeader;
int8_t frame_type = SrsVideoAvcFrameTypeKeyFrame;
int8_t avc_packet_type = SrsVideoAvcFrameTraitSequenceHeader;
char* flv = NULL;
int nb_flv = 0;
if ((ret = avc->mux_avc2flv(sh, frame_type, avc_packet_type, dts, pts, &flv, &nb_flv)) != ERROR_SUCCESS) {
@ -448,7 +448,7 @@ int SrsMpegtsOverUdp::write_h264_sps_pps(uint32_t dts, uint32_t pts)
// the timestamp in rtmp message header is dts.
uint32_t timestamp = dts;
if ((ret = rtmp_write_packet(SrsCodecFlvTagVideo, timestamp, flv, nb_flv)) != ERROR_SUCCESS) {
if ((ret = rtmp_write_packet(SrsFrameTypeVideo, timestamp, flv, nb_flv)) != ERROR_SUCCESS) {
return ret;
}
@ -476,9 +476,9 @@ int SrsMpegtsOverUdp::write_h264_ipb_frame(char* frame, int frame_size, uint32_t
SrsAvcNaluType nal_unit_type = (SrsAvcNaluType)(frame[0] & 0x1f);
// for IDR frame, the frame is keyframe.
SrsCodecVideoAVCFrame frame_type = SrsCodecVideoAVCFrameInterFrame;
SrsVideoAvcFrameType frame_type = SrsVideoAvcFrameTypeInterFrame;
if (nal_unit_type == SrsAvcNaluTypeIDR) {
frame_type = SrsCodecVideoAVCFrameKeyFrame;
frame_type = SrsVideoAvcFrameTypeKeyFrame;
}
std::string ibp;
@ -486,7 +486,7 @@ int SrsMpegtsOverUdp::write_h264_ipb_frame(char* frame, int frame_size, uint32_t
return ret;
}
int8_t avc_packet_type = SrsCodecVideoAVCTypeNALU;
int8_t avc_packet_type = SrsVideoAvcFrameTraitNALU;
char* flv = NULL;
int nb_flv = 0;
if ((ret = avc->mux_avc2flv(ibp, frame_type, avc_packet_type, dts, pts, &flv, &nb_flv)) != ERROR_SUCCESS) {
@ -495,7 +495,7 @@ int SrsMpegtsOverUdp::write_h264_ipb_frame(char* frame, int frame_size, uint32_t
// the timestamp in rtmp message header is dts.
uint32_t timestamp = dts;
return rtmp_write_packet(SrsCodecFlvTagVideo, timestamp, flv, nb_flv);
return rtmp_write_packet(SrsFrameTypeVideo, timestamp, flv, nb_flv);
}
int SrsMpegtsOverUdp::on_ts_audio(SrsTsMessage* msg, SrsBuffer* avs)
@ -561,7 +561,7 @@ int SrsMpegtsOverUdp::write_audio_raw_frame(char* frame, int frame_size, SrsRawA
return ret;
}
return rtmp_write_packet(SrsCodecFlvTagAudio, dts, data, size);
return rtmp_write_packet(SrsFrameTypeAudio, dts, data, size);
}
int SrsMpegtsOverUdp::rtmp_write_packet(char type, uint32_t timestamp, char* data, int size)

View file

@ -518,28 +518,28 @@ int SrsRtspConn::write_sequence_header()
return ret;
}
SrsAudioCodec* dec = format->acodec;
SrsAudioCodecConfig* dec = format->acodec;
acodec->sound_format = SrsCodecAudioAAC;
acodec->sound_type = (dec->aac_channels == 2)? SrsCodecAudioSoundTypeStereo : SrsCodecAudioSoundTypeMono;
acodec->sound_size = SrsCodecAudioSampleSize16bit;
acodec->sound_format = SrsAudioCodecIdAAC;
acodec->sound_type = (dec->aac_channels == 2)? SrsAudioSoundTypeStereo : SrsAudioSoundTypeMono;
acodec->sound_size = SrsAudioSampleSize16bit;
acodec->aac_packet_type = 0;
static int aac_sample_rates[] = {
static int srs_aac_srates[] = {
96000, 88200, 64000, 48000,
44100, 32000, 24000, 22050,
16000, 12000, 11025, 8000,
7350, 0, 0, 0
};
switch (aac_sample_rates[dec->aac_sample_rate]) {
switch (srs_aac_srates[dec->aac_sample_rate]) {
case 11025:
acodec->sound_rate = SrsCodecAudioSampleRate11025;
acodec->sound_rate = SrsAudioSampleRate11025;
break;
case 22050:
acodec->sound_rate = SrsCodecAudioSampleRate22050;
acodec->sound_rate = SrsAudioSampleRate22050;
break;
case 44100:
acodec->sound_rate = SrsCodecAudioSampleRate44100;
acodec->sound_rate = SrsAudioSampleRate44100;
break;
default:
break;
@ -564,8 +564,8 @@ int SrsRtspConn::write_h264_sps_pps(uint32_t dts, uint32_t pts)
}
// h264 packet to flv packet.
int8_t frame_type = SrsCodecVideoAVCFrameKeyFrame;
int8_t avc_packet_type = SrsCodecVideoAVCTypeSequenceHeader;
int8_t frame_type = SrsVideoAvcFrameTypeKeyFrame;
int8_t avc_packet_type = SrsVideoAvcFrameTraitSequenceHeader;
char* flv = NULL;
int nb_flv = 0;
if ((ret = avc->mux_avc2flv(sh, frame_type, avc_packet_type, dts, pts, &flv, &nb_flv)) != ERROR_SUCCESS) {
@ -574,7 +574,7 @@ int SrsRtspConn::write_h264_sps_pps(uint32_t dts, uint32_t pts)
// the timestamp in rtmp message header is dts.
uint32_t timestamp = dts;
if ((ret = rtmp_write_packet(SrsCodecFlvTagVideo, timestamp, flv, nb_flv)) != ERROR_SUCCESS) {
if ((ret = rtmp_write_packet(SrsFrameTypeVideo, timestamp, flv, nb_flv)) != ERROR_SUCCESS) {
return ret;
}
@ -591,9 +591,9 @@ int SrsRtspConn::write_h264_ipb_frame(char* frame, int frame_size, uint32_t dts,
SrsAvcNaluType nal_unit_type = (SrsAvcNaluType)(frame[0] & 0x1f);
// for IDR frame, the frame is keyframe.
SrsCodecVideoAVCFrame frame_type = SrsCodecVideoAVCFrameInterFrame;
SrsVideoAvcFrameType frame_type = SrsVideoAvcFrameTypeInterFrame;
if (nal_unit_type == SrsAvcNaluTypeIDR) {
frame_type = SrsCodecVideoAVCFrameKeyFrame;
frame_type = SrsVideoAvcFrameTypeKeyFrame;
}
std::string ibp;
@ -601,7 +601,7 @@ int SrsRtspConn::write_h264_ipb_frame(char* frame, int frame_size, uint32_t dts,
return ret;
}
int8_t avc_packet_type = SrsCodecVideoAVCTypeNALU;
int8_t avc_packet_type = SrsVideoAvcFrameTraitNALU;
char* flv = NULL;
int nb_flv = 0;
if ((ret = avc->mux_avc2flv(ibp, frame_type, avc_packet_type, dts, pts, &flv, &nb_flv)) != ERROR_SUCCESS) {
@ -610,7 +610,7 @@ int SrsRtspConn::write_h264_ipb_frame(char* frame, int frame_size, uint32_t dts,
// the timestamp in rtmp message header is dts.
uint32_t timestamp = dts;
return rtmp_write_packet(SrsCodecFlvTagVideo, timestamp, flv, nb_flv);
return rtmp_write_packet(SrsFrameTypeVideo, timestamp, flv, nb_flv);
}
int SrsRtspConn::write_audio_raw_frame(char* frame, int frame_size, SrsRawAacStreamCodec* codec, uint32_t dts)
@ -623,7 +623,7 @@ int SrsRtspConn::write_audio_raw_frame(char* frame, int frame_size, SrsRawAacStr
return ret;
}
return rtmp_write_packet(SrsCodecFlvTagAudio, dts, data, size);
return rtmp_write_packet(SrsFrameTypeAudio, dts, data, size);
}
int SrsRtspConn::rtmp_write_packet(char type, uint32_t timestamp, char* data, int size)

View file

@ -362,12 +362,12 @@ void SrsMessageQueue::shrink()
for (int i = 0; i < (int)msgs.size(); i++) {
SrsSharedPtrMessage* msg = msgs.at(i);
if (msg->is_video() && SrsFlvCodec::video_is_sequence_header(msg->payload, msg->size)) {
if (msg->is_video() && SrsFlvVideo::sh(msg->payload, msg->size)) {
srs_freep(video_sh);
video_sh = msg;
continue;
}
else if (msg->is_audio() && SrsFlvCodec::audio_is_sequence_header(msg->payload, msg->size)) {
else if (msg->is_audio() && SrsFlvAudio::sh(msg->payload, msg->size)) {
srs_freep(audio_sh);
audio_sh = msg;
continue;
@ -643,7 +643,7 @@ int SrsGopCache::cache(SrsSharedPtrMessage* shared_msg)
// got video, update the video count if acceptable
if (msg->is_video()) {
// drop video when not h.264
if (!SrsFlvCodec::video_is_h264(msg->payload, msg->size)) {
if (!SrsFlvVideo::h264(msg->payload, msg->size)) {
srs_info("gop cache drop video for none h.264");
return ret;
}
@ -671,7 +671,7 @@ int SrsGopCache::cache(SrsSharedPtrMessage* shared_msg)
}
// clear gop cache when got key frame
if (msg->is_video() && SrsFlvCodec::video_is_keyframe(msg->payload, msg->size)) {
if (msg->is_video() && SrsFlvVideo::keyframe(msg->payload, msg->size)) {
srs_info("clear gop cache when got keyframe. vcount=%d, count=%d",
cached_video_count, (int)gop_cache.size());
@ -975,22 +975,22 @@ int SrsOriginHub::on_audio(SrsSharedPtrMessage* shared_audio)
// donot cache the sequence header to gop_cache, return here.
if (format->is_aac_sequence_header()) {
srs_assert(format->acodec);
SrsAudioCodec* c = format->acodec;
SrsAudioCodecConfig* c = format->acodec;
static int flv_sample_sizes[] = {8, 16, 0};
static int flv_sound_types[] = {1, 2, 0};
// when got audio stream info.
SrsStatistic* stat = SrsStatistic::instance();
if ((ret = stat->on_audio_info(req, SrsCodecAudioAAC, c->sound_rate, c->sound_type, c->aac_object)) != ERROR_SUCCESS) {
if ((ret = stat->on_audio_info(req, SrsAudioCodecIdAAC, c->sound_rate, c->sound_type, c->aac_object)) != ERROR_SUCCESS) {
return ret;
}
srs_trace("%dB audio sh, codec(%d, profile=%s, %dchannels, %dkbps, %dHZ), flv(%dbits, %dchannels, %dHZ)",
msg->size, c->id, srs_codec_aac_object2str(c->aac_object).c_str(), c->aac_channels,
c->audio_data_rate / 1000, aac_sample_rates[c->aac_sample_rate],
msg->size, c->id, srs_aac_object2str(c->aac_object).c_str(), c->aac_channels,
c->audio_data_rate / 1000, srs_aac_srates[c->aac_sample_rate],
flv_sample_sizes[c->sound_size], flv_sound_types[c->sound_type],
flv_sample_rates[c->sound_rate]);
srs_flv_srates[c->sound_rate]);
}
if ((ret = hls->on_audio(msg, format)) != ERROR_SUCCESS) {
@ -1080,18 +1080,18 @@ int SrsOriginHub::on_video(SrsSharedPtrMessage* shared_video, bool is_sequence_h
// cache the sequence header if h264
// donot cache the sequence header to gop_cache, return here.
if (format->is_avc_sequence_header()) {
SrsVideoCodec* c = format->vcodec;
SrsVideoCodecConfig* c = format->vcodec;
srs_assert(c);
// when got video stream info.
SrsStatistic* stat = SrsStatistic::instance();
if ((ret = stat->on_video_info(req, SrsCodecVideoAVC, c->avc_profile, c->avc_level, c->width, c->height)) != ERROR_SUCCESS) {
if ((ret = stat->on_video_info(req, SrsVideoCodecIdAVC, c->avc_profile, c->avc_level, c->width, c->height)) != ERROR_SUCCESS) {
return ret;
}
srs_trace("%dB video sh, codec(%d, profile=%s, level=%s, %dx%d, %dkbps, %.1ffps, %.1fs)",
msg->size, c->id, srs_codec_avc_profile2str(c->avc_profile).c_str(),
srs_codec_avc_level2str(c->avc_level).c_str(), c->width, c->height,
msg->size, c->id, srs_avc_profile2str(c->avc_profile).c_str(),
srs_avc_level2str(c->avc_level).c_str(), c->width, c->height,
c->video_data_rate / 1000, c->frame_rate, c->duration);
}
@ -2171,7 +2171,7 @@ int SrsSource::on_audio_imp(SrsSharedPtrMessage* msg)
int ret = ERROR_SUCCESS;
srs_info("Audio dts=%"PRId64", size=%d", msg->timestamp, msg->size);
bool is_aac_sequence_header = SrsFlvCodec::audio_is_sequence_header(msg->payload, msg->size);
bool is_aac_sequence_header = SrsFlvAudio::sh(msg->payload, msg->size);
bool is_sequence_header = is_aac_sequence_header;
// whether consumer should drop for the duplicated sequence header.
@ -2247,7 +2247,7 @@ int SrsSource::on_video(SrsCommonMessage* shared_video)
// drop any unknown header video.
// @see https://github.com/ossrs/srs/issues/421
if (!SrsFlvCodec::video_is_acceptable(shared_video->payload, shared_video->size)) {
if (!SrsFlvVideo::acceptable(shared_video->payload, shared_video->size)) {
char b0 = 0x00;
if (shared_video->size > 0) {
b0 = shared_video->payload[0];
@ -2298,7 +2298,7 @@ int SrsSource::on_video_imp(SrsSharedPtrMessage* msg)
srs_info("Video dts=%"PRId64", size=%d", msg->timestamp, msg->size);
bool is_sequence_header = SrsFlvCodec::video_is_sequence_header(msg->payload, msg->size);
bool is_sequence_header = SrsFlvVideo::sh(msg->payload, msg->size);
// whether consumer should drop for the duplicated sequence header.
bool drop_for_reduce = false;

View file

@ -99,14 +99,14 @@ SrsStatisticStream::SrsStatisticStream()
connection_cid = -1;
has_video = false;
vcodec = SrsCodecVideoReserved;
vcodec = SrsVideoCodecIdReserved;
avc_profile = SrsAvcProfileReserved;
avc_level = SrsAvcLevelReserved;
has_audio = false;
acodec = SrsCodecAudioReserved1;
asample_rate = SrsCodecAudioSampleRateReserved;
asound_type = SrsCodecAudioSoundTypeReserved;
acodec = SrsAudioCodecIdReserved1;
asample_rate = SrsAudioSampleRateReserved;
asound_type = SrsAudioSoundTypeReserved;
aac_object = SrsAacObjectTypeReserved;
width = 0;
height = 0;
@ -153,9 +153,9 @@ int SrsStatisticStream::dumps(SrsJsonObject* obj)
SrsJsonObject* video = SrsJsonAny::object();
obj->set("video", video);
video->set("codec", SrsJsonAny::str(srs_codec_video2str(vcodec).c_str()));
video->set("profile", SrsJsonAny::str(srs_codec_avc_profile2str(avc_profile).c_str()));
video->set("level", SrsJsonAny::str(srs_codec_avc_level2str(avc_level).c_str()));
video->set("codec", SrsJsonAny::str(srs_video_codec_id2str(vcodec).c_str()));
video->set("profile", SrsJsonAny::str(srs_avc_profile2str(avc_profile).c_str()));
video->set("level", SrsJsonAny::str(srs_avc_level2str(avc_level).c_str()));
video->set("width", SrsJsonAny::integer(width));
video->set("height", SrsJsonAny::integer(height));
}
@ -166,10 +166,10 @@ int SrsStatisticStream::dumps(SrsJsonObject* obj)
SrsJsonObject* audio = SrsJsonAny::object();
obj->set("audio", audio);
audio->set("codec", SrsJsonAny::str(srs_codec_audio2str(acodec).c_str()));
audio->set("sample_rate", SrsJsonAny::integer(flv_sample_rates[asample_rate]));
audio->set("codec", SrsJsonAny::str(srs_audio_codec_id2str(acodec).c_str()));
audio->set("sample_rate", SrsJsonAny::integer(srs_flv_srates[asample_rate]));
audio->set("channel", SrsJsonAny::integer(asound_type + 1));
audio->set("profile", SrsJsonAny::str(srs_codec_aac_object2str(aac_object).c_str()));
audio->set("profile", SrsJsonAny::str(srs_aac_object2str(aac_object).c_str()));
}
return ret;
@ -309,7 +309,7 @@ SrsStatisticClient* SrsStatistic::find_client(int cid)
}
int SrsStatistic::on_video_info(SrsRequest* req,
SrsCodecVideo vcodec, SrsAvcProfile avc_profile, SrsAvcLevel avc_level,
SrsVideoCodecId vcodec, SrsAvcProfile avc_profile, SrsAvcLevel avc_level,
int width, int height
) {
int ret = ERROR_SUCCESS;
@ -329,7 +329,7 @@ int SrsStatistic::on_video_info(SrsRequest* req,
}
int SrsStatistic::on_audio_info(SrsRequest* req,
SrsCodecAudio acodec, SrsCodecAudioSampleRate asample_rate, SrsCodecAudioSoundType asound_type,
SrsAudioCodecId acodec, SrsAudioSampleRate asample_rate, SrsAudioSoundType asound_type,
SrsAacObjectType aac_object
) {
int ret = ERROR_SUCCESS;

View file

@ -80,7 +80,7 @@ public:
SrsKbps* kbps;
public:
bool has_video;
SrsCodecVideo vcodec;
SrsVideoCodecId vcodec;
// profile_idc, ISO_IEC_14496-10-AVC-2003.pdf, page 45.
SrsAvcProfile avc_profile;
// level_idc, ISO_IEC_14496-10-AVC-2003.pdf, page 45.
@ -90,9 +90,9 @@ public:
int height;
public:
bool has_audio;
SrsCodecAudio acodec;
SrsCodecAudioSampleRate asample_rate;
SrsCodecAudioSoundType asound_type;
SrsAudioCodecId acodec;
SrsAudioSampleRate asample_rate;
SrsAudioSoundType asound_type;
/**
* audio specified
* audioObjectType, in 1.6.2.1 AudioSpecificConfig, page 33,
@ -170,14 +170,14 @@ public:
* when got video info for stream.
*/
virtual int on_video_info(SrsRequest* req,
SrsCodecVideo vcodec, SrsAvcProfile avc_profile, SrsAvcLevel avc_level,
SrsVideoCodecId vcodec, SrsAvcProfile avc_profile, SrsAvcLevel avc_level,
int width, int height
);
/**
* when got audio info for stream.
*/
virtual int on_audio_info(SrsRequest* req,
SrsCodecAudio acodec, SrsCodecAudioSampleRate asample_rate, SrsCodecAudioSoundType asound_type,
SrsAudioCodecId acodec, SrsAudioSampleRate asample_rate, SrsAudioSoundType asound_type,
SrsAacObjectType aac_object
);
/**