mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-10-31 00:37:39 +08:00
Track可以不设置视频宽高、音频采样率等信息
This commit is contained in:
parent
8154170515
commit
949640d493
@ -1 +1 @@
|
||||
Subproject commit 4a8615d63ac1c2b910cb016e6462635d375b6497
|
||||
Subproject commit b92dd89e81146312b7a0c96071ceb0c394b7c4d6
|
@ -173,7 +173,6 @@ public:
|
||||
_vps = vps.substr(vps_prefix_len);
|
||||
_sps = sps.substr(sps_prefix_len);
|
||||
_pps = pps.substr(pps_prefix_len);
|
||||
onReady();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -204,30 +203,6 @@ public:
|
||||
return CodecH265;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回视频高度
|
||||
* @return
|
||||
*/
|
||||
int getVideoHeight() const override {
|
||||
return _width;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回视频宽度
|
||||
* @return
|
||||
*/
|
||||
int getVideoWidth() const override {
|
||||
return _height;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回视频fps
|
||||
* @return
|
||||
*/
|
||||
float getVideoFps() const override {
|
||||
return _fps;
|
||||
}
|
||||
|
||||
bool ready() override {
|
||||
return !_vps.empty() && !_sps.empty() && !_pps.empty();
|
||||
}
|
||||
@ -313,20 +288,8 @@ public:
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if(_width == 0 && ready() ){
|
||||
onReady();
|
||||
}
|
||||
}
|
||||
private:
|
||||
/**
|
||||
* 解析sps获取宽高fps
|
||||
* @param sps sps不含头数据
|
||||
*/
|
||||
void onReady() {
|
||||
// getAVCInfo(sps,_width,_height,_fps);
|
||||
}
|
||||
|
||||
Track::Ptr clone() override {
|
||||
return std::make_shared<std::remove_reference<decltype(*this)>::type>(*this);
|
||||
}
|
||||
@ -335,9 +298,6 @@ private:
|
||||
string _vps;
|
||||
string _sps;
|
||||
string _pps;
|
||||
int _width = 0;
|
||||
int _height = 0;
|
||||
float _fps = 0;
|
||||
|
||||
H265Frame::Ptr _vpsFrame;
|
||||
H265Frame::Ptr _spsFrame;
|
||||
|
@ -81,19 +81,19 @@ public:
|
||||
* 返回视频高度
|
||||
* @return
|
||||
*/
|
||||
virtual int getVideoHeight() const = 0;
|
||||
virtual int getVideoHeight() const {return 0;};
|
||||
|
||||
/**
|
||||
* 返回视频宽度
|
||||
* @return
|
||||
*/
|
||||
virtual int getVideoWidth() const = 0;
|
||||
virtual int getVideoWidth() const {return 0;};
|
||||
|
||||
/**
|
||||
* 返回视频fps
|
||||
* @return
|
||||
*/
|
||||
virtual float getVideoFps() const = 0;
|
||||
virtual float getVideoFps() const {return 0;};
|
||||
};
|
||||
|
||||
/**
|
||||
@ -109,19 +109,19 @@ public:
|
||||
* 返回音频采样率
|
||||
* @return
|
||||
*/
|
||||
virtual int getAudioSampleRate() const = 0;
|
||||
virtual int getAudioSampleRate() const {return 0;};
|
||||
|
||||
/**
|
||||
* 返回音频采样位数,一般为16或8
|
||||
* @return
|
||||
*/
|
||||
virtual int getAudioSampleBit() const = 0;
|
||||
virtual int getAudioSampleBit() const {return 0;};
|
||||
|
||||
/**
|
||||
* 返回音频通道数
|
||||
* @return
|
||||
*/
|
||||
virtual int getAudioChannel() const = 0;
|
||||
virtual int getAudioChannel() const {return 0;};
|
||||
};
|
||||
|
||||
|
||||
|
@ -92,10 +92,16 @@ public:
|
||||
typedef std::shared_ptr<VideoMete> Ptr;
|
||||
|
||||
VideoMete(const VideoTrack::Ptr &video,int datarate = 5000){
|
||||
_metedata.set("width", video->getVideoWidth());
|
||||
_metedata.set("height", video->getVideoHeight());
|
||||
if(video->getVideoWidth() > 0 ){
|
||||
_metedata.set("width", video->getVideoWidth());
|
||||
}
|
||||
if(video->getVideoHeight() > 0 ){
|
||||
_metedata.set("height", video->getVideoHeight());
|
||||
}
|
||||
if(video->getVideoFps() > 0 ){
|
||||
_metedata.set("framerate", video->getVideoFps());
|
||||
}
|
||||
_metedata.set("videodatarate", datarate);
|
||||
_metedata.set("framerate", video->getVideoFps());
|
||||
_codecId = video->getCodecId();
|
||||
_metedata.set("videocodecid", Factory::getAmfByCodecId(_codecId));
|
||||
}
|
||||
@ -127,10 +133,16 @@ public:
|
||||
|
||||
AudioMete(const AudioTrack::Ptr &audio,int datarate = 160){
|
||||
_metedata.set("audiodatarate", datarate);
|
||||
_metedata.set("audiosamplerate", audio->getAudioSampleRate());
|
||||
_metedata.set("audiosamplesize", audio->getAudioSampleBit());
|
||||
_metedata.set("audiochannels", audio->getAudioChannel());
|
||||
_metedata.set("stereo", audio->getAudioChannel() > 1);
|
||||
if(audio->getAudioSampleRate() > 0){
|
||||
_metedata.set("audiosamplerate", audio->getAudioSampleRate());
|
||||
}
|
||||
if(audio->getAudioSampleBit() > 0){
|
||||
_metedata.set("audiosamplesize", audio->getAudioSampleBit());
|
||||
}
|
||||
if(audio->getAudioChannel() > 0){
|
||||
_metedata.set("audiochannels", audio->getAudioChannel());
|
||||
_metedata.set("stereo", audio->getAudioChannel() > 1);
|
||||
}
|
||||
_codecId = audio->getCodecId();
|
||||
_metedata.set("audiocodecid", Factory::getAmfByCodecId(_codecId));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user