mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-26 12:37:09 +08:00
获取MediaSource信息相关接口返回帧数相关字段:#1570
This commit is contained in:
parent
a0955d956a
commit
6eb36ec883
@ -365,6 +365,7 @@ Value makeMediaSourceJson(MediaSource &media){
|
|||||||
}
|
}
|
||||||
obj["loss"] = loss;
|
obj["loss"] = loss;
|
||||||
}
|
}
|
||||||
|
obj["frames"] = track->getFrames();
|
||||||
switch(codec_type){
|
switch(codec_type){
|
||||||
case TrackAudio : {
|
case TrackAudio : {
|
||||||
auto audio_track = dynamic_pointer_cast<AudioTrack>(track);
|
auto audio_track = dynamic_pointer_cast<AudioTrack>(track);
|
||||||
@ -378,6 +379,7 @@ Value makeMediaSourceJson(MediaSource &media){
|
|||||||
obj["width"] = video_track->getVideoWidth();
|
obj["width"] = video_track->getVideoWidth();
|
||||||
obj["height"] = video_track->getVideoHeight();
|
obj["height"] = video_track->getVideoHeight();
|
||||||
obj["fps"] = round(video_track->getVideoFps());
|
obj["fps"] = round(video_track->getVideoFps());
|
||||||
|
obj["key_frames"] = video_track->getVideoKeyFrames();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -311,6 +311,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool inputFrame(const Frame::Ptr &frame) override {
|
bool inputFrame(const Frame::Ptr &frame) override {
|
||||||
std::lock_guard<std::mutex> lck(_mtx);
|
std::lock_guard<std::mutex> lck(_mtx);
|
||||||
|
++_frames;
|
||||||
|
if (frame->keyFrame() && frame->getTrackType() == TrackVideo) {
|
||||||
|
++_video_key_frames;
|
||||||
|
}
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
for (auto &pr : _delegates) {
|
for (auto &pr : _delegates) {
|
||||||
if (pr.second->inputFrame(frame)) {
|
if (pr.second->inputFrame(frame)) {
|
||||||
@ -333,7 +337,25 @@ public:
|
|||||||
_delegates.clear();
|
_delegates.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取累计关键帧数
|
||||||
|
*/
|
||||||
|
uint64_t getVideoKeyFrames() const {
|
||||||
|
std::lock_guard<std::mutex> lck(_mtx);
|
||||||
|
return _video_key_frames;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取帧数
|
||||||
|
*/
|
||||||
|
uint64_t getFrames() const {
|
||||||
|
std::lock_guard<std::mutex> lck(_mtx);
|
||||||
|
return _frames;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
uint64_t _frames = 0;
|
||||||
|
uint64_t _video_key_frames = 0;
|
||||||
mutable std::mutex _mtx;
|
mutable std::mutex _mtx;
|
||||||
std::map<void *, FrameWriterInterface::Ptr> _delegates;
|
std::map<void *, FrameWriterInterface::Ptr> _delegates;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user