Commit 43164d36 by ziyue

Merge remote-tracking branch 'origin/master'

parents 68926b4a b90ebf65
......@@ -20,6 +20,7 @@ HttpTSPlayer::HttpTSPlayer(const EventPoller::Ptr &poller, bool split_ts){
HttpTSPlayer::~HttpTSPlayer() {}
int64_t HttpTSPlayer::onResponseHeader(const string &status, const HttpClient::HttpHeader &headers) {
_status = status;
if (status != "200" && status != "206") {
//http状态码不符合预期
shutdown(SockException(Err_other, StrPrinter << "bad http status code:" + status));
......@@ -35,6 +36,9 @@ int64_t HttpTSPlayer::onResponseHeader(const string &status, const HttpClient::H
}
void HttpTSPlayer::onResponseBody(const char *buf, int64_t size, int64_t recvedSize, int64_t totalSize) {
if (_status != "200" && _status != "206") {
return;
}
if (recvedSize == size) {
//开始接收数据
if (buf[0] == TS_SYNC_BYTE) {
......@@ -78,4 +82,4 @@ void HttpTSPlayer::setOnPacket(const TSSegment::onSegment &cb) {
_on_segment = cb;
}
}//namespace mediakit
\ No newline at end of file
}//namespace mediakit
......@@ -48,6 +48,7 @@ private:
bool _is_first_packet_ts = false;
//是否判断是否是ts并split
bool _split_ts;
string _status;
TSSegment _segment;
onShutdown _on_disconnect;
TSSegment::onSegment _on_segment;
......
......@@ -11,6 +11,7 @@
#ifdef ENABLE_MP4
#include <ctime>
#include <sys/stat.h>
#include "Util/File.h"
#include "Common/config.h"
#include "MP4Recorder.h"
#include "Thread/WorkThreadPool.h"
......@@ -77,12 +78,19 @@ void MP4Recorder::asyncClose() {
const_cast<RecordInfo&>(info).time_len = ::time(NULL) - info.start_time;
//关闭mp4非常耗时,所以要放在后台线程执行
muxer->closeMP4();
//临时文件名改成正式文件名,防止mp4未完成时被访问
rename(strFileTmp.data(),strFile.data());
//获取文件大小
struct stat fileData;
stat(strFile.data(), &fileData);
const_cast<RecordInfo&>(info).file_size = fileData.st_size;
stat(strFileTmp.data(), &fileData);
const_cast<RecordInfo &>(info).file_size = fileData.st_size;
if (fileData.st_size < 1024) {
//录像文件太小,删除之
File::delete_file(strFileTmp.data());
return;
}
//临时文件名改成正式文件名,防止mp4未完成时被访问
rename(strFileTmp.data(),strFile.data());
/////record 业务逻辑//////
NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastRecordMP4,info);
});
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论