mirror of
https://gitee.com/xia-chu/ZLMediaKit.git
synced 2026-05-25 11:07:50 +08:00
Compare commits
No commits in common. "fd34b5526b84c44705ea6f65e3f2b2a86d9846ad" and "f0bc7a75aad217234954335ed6481e514dca9645" have entirely different histories.
fd34b5526b
...
f0bc7a75aa
@ -264,7 +264,7 @@ ssize_t HttpClient::onRecvHeader(const char *data, size_t len) {
|
|||||||
_total_body_size = -1;
|
_total_body_size = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_total_body_size == 0 || _method == "HEAD") {
|
if (_total_body_size == 0) {
|
||||||
// 后续没content,本次http请求结束 [AUTO-TRANSLATED:8532172f]
|
// 后续没content,本次http请求结束 [AUTO-TRANSLATED:8532172f]
|
||||||
// There is no content afterwards, this http request ends
|
// There is no content afterwards, this http request ends
|
||||||
onResponseCompleted_l(SockException(Err_success, "The request is successful but has no body"));
|
onResponseCompleted_l(SockException(Err_success, "The request is successful but has no body"));
|
||||||
|
|||||||
@ -117,19 +117,33 @@ void MP4Recorder::flush() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool MP4Recorder::inputFrame(const Frame::Ptr &frame) {
|
bool MP4Recorder::inputFrame(const Frame::Ptr &frame) {
|
||||||
auto stamp_inc = _delta_stamp[frame->getTrackType()].relativeStamp(frame->pts(), false);
|
if (!(_have_video && frame->getTrackType() == TrackAudio)) {
|
||||||
if (!_muxer || (stamp_inc > int64_t(_max_second) * 1000 && (!_have_video || frame->keyFrame()))) {
|
// 如果有视频且输入的是音频,那么应该忽略切片逻辑 [AUTO-TRANSLATED:fbb15d93]
|
||||||
// 成立条件 [AUTO-TRANSLATED:8c9c6083]
|
// If there is video and the input is audio, then the slice logic should be ignored
|
||||||
// Conditions for establishment
|
if (_last_dts == 0) {
|
||||||
// 1、_muxer为空 [AUTO-TRANSLATED:fa236097]
|
// first frame assign dts
|
||||||
// 1. _muxer is empty
|
_last_dts = frame->dts();
|
||||||
// 2、到了切片时间,并且只有音频 [AUTO-TRANSLATED:212e9d23]
|
} else if (_last_dts > frame->dts()) {
|
||||||
// 2. It's time to slice, and there is only audio
|
// b帧情况下dts时间戳可能回退 [AUTO-TRANSLATED:1de38f77]
|
||||||
// 3、到了切片时间,有视频并且遇到视频的关键帧 [AUTO-TRANSLATED:fa4a71ad]
|
// In the case of b-frames, the dts timestamp may regress
|
||||||
// 3. It's time to slice, there is video and a video keyframe is encountered
|
_last_dts = MIN(frame->dts(), _last_dts);
|
||||||
createFile();
|
}
|
||||||
for (auto &ref : _delta_stamp) {
|
|
||||||
ref.reset();
|
auto duration = 5u; // 默认至少一帧5ms
|
||||||
|
if (frame->dts() > 0 && frame->dts() > _last_dts) {
|
||||||
|
duration = MAX(duration, frame->dts() - _last_dts);
|
||||||
|
}
|
||||||
|
if (!_muxer || ((duration > _max_second * 1000) && (!_have_video || (_have_video && frame->keyFrame())))) {
|
||||||
|
// 成立条件 [AUTO-TRANSLATED:8c9c6083]
|
||||||
|
// Conditions for establishment
|
||||||
|
// 1、_muxer为空 [AUTO-TRANSLATED:fa236097]
|
||||||
|
// 1. _muxer is empty
|
||||||
|
// 2、到了切片时间,并且只有音频 [AUTO-TRANSLATED:212e9d23]
|
||||||
|
// 2. It's time to slice, and there is only audio
|
||||||
|
// 3、到了切片时间,有视频并且遇到视频的关键帧 [AUTO-TRANSLATED:fa4a71ad]
|
||||||
|
// 3. It's time to slice, there is video and a video keyframe is encountered
|
||||||
|
_last_dts = 0;
|
||||||
|
createFile();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -70,7 +70,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
bool _have_video = false;
|
bool _have_video = false;
|
||||||
size_t _max_second;
|
size_t _max_second;
|
||||||
DeltaStamp _delta_stamp[TrackMax];
|
uint64_t _last_dts = 0;
|
||||||
std::atomic<uint64_t> _file_index { 0 };
|
std::atomic<uint64_t> _file_index { 0 };
|
||||||
std::string _full_path_tmp;
|
std::string _full_path_tmp;
|
||||||
RecordInfo _info;
|
RecordInfo _info;
|
||||||
|
|||||||
@ -1,27 +0,0 @@
|
|||||||
#include "Http/HttpRequester.h"
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
auto requester = std::make_shared<mediakit::HttpRequester>();
|
|
||||||
requester->setMethod("HEAD");
|
|
||||||
|
|
||||||
requester->startRequester(
|
|
||||||
"http://baidu.com",
|
|
||||||
|
|
||||||
[](const toolkit::SockException &ex, const mediakit::Parser &parser) {
|
|
||||||
if (ex) {
|
|
||||||
PrintI("HEAD请求失败: %s", ex.what());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检查HTTP状态码
|
|
||||||
if (parser.status() != "200") {
|
|
||||||
PrintI("HEAD请求返回错误状态: %s", parser.status().c_str());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (auto &header : parser.getHeader()) {
|
|
||||||
PrintI("key=%s, val=%s", header.first.c_str(), header.second.c_str());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
getchar();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue
Block a user