统一成员变量命名风格

This commit is contained in:
xiongziliang
2018-10-24 15:43:52 +08:00
parent 97567ec36d
commit 39baaebc55
74 changed files with 2048 additions and 2048 deletions

View File

@@ -36,13 +36,13 @@ RtmpParser::RtmpParser(const AMFValue &val) {
if (videoCodec.type() == AMF_STRING) {
if (videoCodec.as_string() == "avc1") {
//h264
m_iVideoCodecID = H264_CODEC_ID;
_iVideoCodecID = H264_CODEC_ID;
} else {
InfoL << "不支持RTMP视频格式:" << videoCodec.as_string();
}
}else if (videoCodec.type() != AMF_NULL){
m_iVideoCodecID = videoCodec.as_integer();
if (m_iVideoCodecID != H264_CODEC_ID) {
_iVideoCodecID = videoCodec.as_integer();
if (_iVideoCodecID != H264_CODEC_ID) {
InfoL << "不支持RTMP视频格式:" << videoCodec.as_integer();
}
}
@@ -50,13 +50,13 @@ RtmpParser::RtmpParser(const AMFValue &val) {
if (audioCodec.type() == AMF_STRING) {
if (audioCodec.as_string() == "mp4a") {
//aac
m_iAudioCodecID = AAC_CODEC_ID;
_iAudioCodecID = AAC_CODEC_ID;
} else {
InfoL << "不支持RTMP音频格式:" << audioCodec.as_string();
}
}else if (audioCodec.type() != AMF_NULL) {
m_iAudioCodecID = audioCodec.as_integer();
if (m_iAudioCodecID != AAC_CODEC_ID) {
_iAudioCodecID = audioCodec.as_integer();
if (_iAudioCodecID != AAC_CODEC_ID) {
InfoL << "不支持RTMP音频格式:" << audioCodec.as_integer();
}
}
@@ -69,28 +69,28 @@ RtmpParser::~RtmpParser() {
bool RtmpParser::inputRtmp(const RtmpPacket::Ptr &pkt) {
switch (pkt->typeId) {
case MSG_VIDEO:{
if(m_iVideoCodecID == 0){
if(_iVideoCodecID == 0){
//未初始化视频
m_iVideoCodecID = pkt->getMediaType();
if(m_iVideoCodecID != H264_CODEC_ID){
InfoL << "不支持RTMP视频格式:" << m_iVideoCodecID;
_iVideoCodecID = pkt->getMediaType();
if(_iVideoCodecID != H264_CODEC_ID){
InfoL << "不支持RTMP视频格式:" << _iVideoCodecID;
}
}
if(m_iVideoCodecID == H264_CODEC_ID){
if(_iVideoCodecID == H264_CODEC_ID){
return inputVideo(pkt);
}
return false;
}
case MSG_AUDIO: {
if(m_iAudioCodecID == 0){
if(_iAudioCodecID == 0){
//未初始化音频
m_iAudioCodecID = pkt->getMediaType();
if(m_iAudioCodecID != AAC_CODEC_ID){
InfoL << "不支持RTMP音频格式:" << m_iAudioCodecID;
_iAudioCodecID = pkt->getMediaType();
if(_iAudioCodecID != AAC_CODEC_ID){
InfoL << "不支持RTMP音频格式:" << _iAudioCodecID;
}
}
if (m_iAudioCodecID == AAC_CODEC_ID) {
if (_iAudioCodecID == AAC_CODEC_ID) {
return inputAudio(pkt);
}
return false;
@@ -104,20 +104,20 @@ bool RtmpParser::inputRtmp(const RtmpPacket::Ptr &pkt) {
inline bool RtmpParser::inputVideo(const RtmpPacket::Ptr &pkt) {
if (pkt->isCfgFrame()) {
//WarnL << " got h264 cfg";
if (m_strSPS.size()) {
if (_strSPS.size()) {
return false;
}
m_strSPS.assign("\x00\x00\x00\x01", 4);
m_strSPS.append(pkt->getH264SPS());
_strSPS.assign("\x00\x00\x00\x01", 4);
_strSPS.append(pkt->getH264SPS());
m_strPPS.assign("\x00\x00\x00\x01", 4);
m_strPPS.append(pkt->getH264PPS());
_strPPS.assign("\x00\x00\x00\x01", 4);
_strPPS.append(pkt->getH264PPS());
getAVCInfo(pkt->getH264SPS(), m_iVideoWidth, m_iVideoHeight, m_fVideoFps);
getAVCInfo(pkt->getH264SPS(), _iVideoWidth, _iVideoHeight, _fVideoFps);
return false;
}
if (m_strSPS.size()) {
if (_strSPS.size()) {
uint32_t iTotalLen = pkt->strBuf.size();
uint32_t iOffset = 5;
while(iOffset + 4 < iTotalLen){
@@ -137,8 +137,8 @@ inline bool RtmpParser::inputVideo(const RtmpPacket::Ptr &pkt) {
inline void RtmpParser::_onGetH264(const char* pcData, int iLen, uint32_t ui32TimeStamp) {
switch (pcData[0] & 0x1F) {
case 5: {
onGetH264(m_strSPS.data() + 4, m_strSPS.length() - 4, ui32TimeStamp);
onGetH264(m_strPPS.data() + 4, m_strPPS.length() - 4, ui32TimeStamp);
onGetH264(_strSPS.data() + 4, _strSPS.length() - 4, ui32TimeStamp);
onGetH264(_strPPS.data() + 4, _strPPS.length() - 4, ui32TimeStamp);
}
case 1: {
onGetH264(pcData, iLen, ui32TimeStamp);
@@ -150,82 +150,82 @@ inline void RtmpParser::_onGetH264(const char* pcData, int iLen, uint32_t ui32Ti
}
}
inline void RtmpParser::onGetH264(const char* pcData, int iLen, uint32_t ui32TimeStamp) {
m_h264frame.type = pcData[0] & 0x1F;
m_h264frame.timeStamp = ui32TimeStamp;
m_h264frame.buffer.assign("\x0\x0\x0\x1", 4); //添加264头
m_h264frame.buffer.append(pcData, iLen);
_h264frame.type = pcData[0] & 0x1F;
_h264frame.timeStamp = ui32TimeStamp;
_h264frame.buffer.assign("\x0\x0\x0\x1", 4); //添加264头
_h264frame.buffer.append(pcData, iLen);
{
lock_guard<recursive_mutex> lck(m_mtxCB);
lock_guard<recursive_mutex> lck(_mtxCB);
if (onVideo) {
onVideo(m_h264frame);
onVideo(_h264frame);
}
}
m_h264frame.buffer.clear();
_h264frame.buffer.clear();
}
inline bool RtmpParser::inputAudio(const RtmpPacket::Ptr &pkt) {
if (pkt->isCfgFrame()) {
if (m_strAudioCfg.size()) {
if (_strAudioCfg.size()) {
return false;
}
m_strAudioCfg = pkt->getAacCfg();
m_iSampleBit = pkt->getAudioSampleBit();
makeAdtsHeader(m_strAudioCfg,m_adts);
getAACInfo(m_adts, m_iSampleRate, m_iChannel);
_strAudioCfg = pkt->getAacCfg();
_iSampleBit = pkt->getAudioSampleBit();
makeAdtsHeader(_strAudioCfg,_adts);
getAACInfo(_adts, _iSampleRate, _iChannel);
return false;
}
if (m_strAudioCfg.size()) {
if (_strAudioCfg.size()) {
onGetAAC(pkt->strBuf.data() + 2, pkt->strBuf.size() - 2, pkt->timeStamp);
}
return false;
}
inline void RtmpParser::onGetAAC(const char* pcData, int iLen, uint32_t ui32TimeStamp) {
if(iLen + 7 > sizeof(m_adts.buffer)){
if(iLen + 7 > sizeof(_adts.buffer)){
WarnL << "Illegal adts data, exceeding the length limit.";
return;
}
//添加adts头
memcpy(m_adts.buffer + 7, pcData, iLen);
m_adts.aac_frame_length = 7 + iLen;
m_adts.timeStamp = ui32TimeStamp;
writeAdtsHeader(m_adts, m_adts.buffer);
memcpy(_adts.buffer + 7, pcData, iLen);
_adts.aac_frame_length = 7 + iLen;
_adts.timeStamp = ui32TimeStamp;
writeAdtsHeader(_adts, _adts.buffer);
{
lock_guard<recursive_mutex> lck(m_mtxCB);
lock_guard<recursive_mutex> lck(_mtxCB);
if (onAudio) {
onAudio(m_adts);
onAudio(_adts);
}
}
m_adts.aac_frame_length = 7;
_adts.aac_frame_length = 7;
}
inline void RtmpParser::onCheckMedia(const AMFValue& obj) {
obj.object_for_each([&](const string &key ,const AMFValue& val) {
if(key == "duration") {
m_fDuration = val.as_number();
_fDuration = val.as_number();
return;
}
if(key == "width") {
m_iVideoWidth = val.as_number();
_iVideoWidth = val.as_number();
return;
}
if(key == "height") {
m_iVideoHeight = val.as_number();
_iVideoHeight = val.as_number();
return;
}
if(key == "framerate") {
m_fVideoFps = val.as_number();
_fVideoFps = val.as_number();
return;
}
if(key == "audiosamplerate") {
m_iSampleRate = val.as_number();
_iSampleRate = val.as_number();
return;
}
if(key == "audiosamplesize") {
m_iSampleBit = val.as_number();
_iSampleBit = val.as_number();
return;
}
if(key == "stereo") {
m_iChannel = val.as_boolean() ? 2 :1;
_iChannel = val.as_boolean() ? 2 :1;
return;
}
});