全面整理代码,去除编译警告

This commit is contained in:
xia-chu
2021-01-17 18:31:50 +08:00
parent fb1e35a39a
commit b6cbc87712
272 changed files with 936 additions and 933 deletions

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors
@@ -59,7 +59,7 @@ void HlsMaker::makeIndexFile(bool eof) {
}
void HlsMaker::inputData(void *data, uint32_t len, uint32_t timestamp, bool is_idr_fast_packet) {
void HlsMaker::inputData(void *data, size_t len, uint32_t timestamp, bool is_idr_fast_packet) {
if (data && len) {
if (is_idr_fast_packet) {
//尝试切片ts

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors
@@ -38,7 +38,7 @@ public:
* @param timestamp 毫秒时间戳
* @param is_idr_fast_packet 是否为关键帧第一个包
*/
void inputData(void *data, uint32_t len, uint32_t timestamp, bool is_idr_fast_packet);
void inputData(void *data, size_t len, uint32_t timestamp, bool is_idr_fast_packet);
/**
* 是否为直播
@@ -56,27 +56,27 @@ protected:
* @param index
* @return
*/
virtual string onOpenSegment(int index) = 0;
virtual string onOpenSegment(uint64_t index) = 0;
/**
* 删除ts切片文件回调
* @param index
*/
virtual void onDelSegment(int index) = 0;
virtual void onDelSegment(uint64_t index) = 0;
/**
* 写ts切片文件回调
* @param data
* @param len
*/
virtual void onWriteSegment(const char *data, int len) = 0;
virtual void onWriteSegment(const char *data, size_t len) = 0;
/**
* 写m3u8文件回调
* @param data
* @param len
*/
virtual void onWriteHls(const char *data, int len) = 0;
virtual void onWriteHls(const char *data, size_t len) = 0;
/**
* 上一个 ts 切片写入完成, 可在这里进行通知处理

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors
@@ -50,7 +50,7 @@ void HlsMakerImp::clearCache() {
}
}
string HlsMakerImp::onOpenSegment(int index) {
string HlsMakerImp::onOpenSegment(uint64_t index) {
string segment_name, segment_path;
{
auto strDate = getTimeStr("%Y-%m-%d");
@@ -79,7 +79,7 @@ string HlsMakerImp::onOpenSegment(int index) {
return segment_name + "?" + _params;
}
void HlsMakerImp::onDelSegment(int index) {
void HlsMakerImp::onDelSegment(uint64_t index) {
auto it = _segment_file_paths.find(index);
if (it == _segment_file_paths.end()) {
return;
@@ -88,7 +88,7 @@ void HlsMakerImp::onDelSegment(int index) {
_segment_file_paths.erase(it);
}
void HlsMakerImp::onWriteSegment(const char *data, int len) {
void HlsMakerImp::onWriteSegment(const char *data, size_t len) {
if (_file) {
fwrite(data, len, 1, _file.get());
}
@@ -97,7 +97,7 @@ void HlsMakerImp::onWriteSegment(const char *data, int len) {
}
}
void HlsMakerImp::onWriteHls(const char *data, int len) {
void HlsMakerImp::onWriteHls(const char *data, size_t len) {
auto hls = makeFile(_path_hls);
if (hls) {
fwrite(data, len, 1, hls.get());
@@ -116,7 +116,7 @@ void HlsMakerImp::onFlushLastSegment(uint32_t duration_ms) {
if (broadcastRecordTs) {
//关闭ts文件以便获取正确的文件大小
_file = nullptr;
_info.time_len = duration_ms / 1000.0;
_info.time_len = duration_ms / 1000.0f;
struct stat fileData;
stat(_info.file_path.data(), &fileData);
_info.file_size = fileData.st_size;

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors
@@ -51,10 +51,10 @@ public:
void clearCache();
protected:
string onOpenSegment(int index) override ;
void onDelSegment(int index) override;
void onWriteSegment(const char *data, int len) override;
void onWriteHls(const char *data, int len) override;
string onOpenSegment(uint64_t index) override ;
void onDelSegment(uint64_t index) override;
void onWriteSegment(const char *data, size_t len) override;
void onWriteHls(const char *data, size_t len) override;
void onFlushLastSegment(uint32_t duration_ms) override;
private:
@@ -69,7 +69,7 @@ private:
std::shared_ptr<FILE> _file;
std::shared_ptr<char> _file_buf;
HlsMediaSource::Ptr _media_src;
map<int /*index*/,string/*file_path*/> _segment_file_paths;
map<uint64_t/*index*/,string/*file_path*/> _segment_file_paths;
};
}//namespace mediakit

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors
@@ -49,7 +49,7 @@ HlsCookieData::~HlsCookieData() {
}
}
void HlsCookieData::addByteUsage(uint64_t bytes) {
void HlsCookieData::addByteUsage(size_t bytes) {
addReaderCount();
_bytes += bytes;
_ticker.resetTime();

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors
@@ -79,7 +79,7 @@ public:
_list_cb.emplace_back(std::move(cb));
}
void onSegmentSize(uint64_t bytes) {
void onSegmentSize(size_t bytes) {
_speed[TrackVideo] += bytes;
}
@@ -95,7 +95,7 @@ public:
typedef std::shared_ptr<HlsCookieData> Ptr;
HlsCookieData(const MediaInfo &info, const std::shared_ptr<SockInfo> &sock_info);
~HlsCookieData();
void addByteUsage(uint64_t bytes);
void addByteUsage(size_t bytes);
private:
void addReaderCount();

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors
@@ -21,7 +21,7 @@ public:
HlsRecorder(const string &m3u8_file, const string &params){
GET_CONFIG(uint32_t, hlsNum, Hls::kSegmentNum);
GET_CONFIG(uint32_t, hlsBufSize, Hls::kFileBufSize);
GET_CONFIG(uint32_t, hlsDuration, Hls::kSegmentDuration);
GET_CONFIG(float, hlsDuration, Hls::kSegmentDuration);
_hls = std::make_shared<HlsMakerImp>(m3u8_file, params, hlsBufSize, hlsDuration, hlsNum);
//清空上次的残余文件
_hls->clearCache();
@@ -73,7 +73,7 @@ public:
}
private:
void onTs(const void *packet, int bytes, uint32_t timestamp, bool is_idr_fast_packet) override {
void onTs(const void *packet, size_t bytes, uint32_t timestamp, bool is_idr_fast_packet) override {
_hls->inputData((char *) packet, bytes, timestamp, is_idr_fast_packet);
}

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors
@@ -197,22 +197,22 @@ void MP4FileDisk::closeFile() {
_file = nullptr;
}
int MP4FileDisk::onRead(void *data, uint64_t bytes) {
int MP4FileDisk::onRead(void *data, size_t bytes) {
if (bytes == fread(data, 1, bytes, _file.get())){
return 0;
}
return 0 != ferror(_file.get()) ? ferror(_file.get()) : -1 /*EOF*/;
}
int MP4FileDisk::onWrite(const void *data, uint64_t bytes) {
int MP4FileDisk::onWrite(const void *data, size_t bytes) {
return bytes == fwrite(data, 1, bytes, _file.get()) ? 0 : ferror(_file.get());
}
int MP4FileDisk::onSeek(uint64_t offset) {
int MP4FileDisk::onSeek(size_t offset) {
return fseek64(_file.get(), offset, SEEK_SET);
}
uint64_t MP4FileDisk::onTell() {
size_t MP4FileDisk::onTell() {
return ftell64(_file.get());
}
@@ -225,15 +225,15 @@ string MP4FileMemory::getAndClearMemory(){
return ret;
}
uint64_t MP4FileMemory::fileSize() const{
size_t MP4FileMemory::fileSize() const{
return _memory.size();
}
uint64_t MP4FileMemory::onTell(){
size_t MP4FileMemory::onTell(){
return _offset;
}
int MP4FileMemory::onSeek(uint64_t offset){
int MP4FileMemory::onSeek(size_t offset){
if (offset > _memory.size()) {
return -1;
}
@@ -241,7 +241,7 @@ int MP4FileMemory::onSeek(uint64_t offset){
return 0;
}
int MP4FileMemory::onRead(void *data, uint64_t bytes){
int MP4FileMemory::onRead(void *data, size_t bytes){
if (_offset >= _memory.size()) {
//EOF
return -1;
@@ -252,7 +252,7 @@ int MP4FileMemory::onRead(void *data, uint64_t bytes){
return 0;
}
int MP4FileMemory::onWrite(const void *data, uint64_t bytes){
int MP4FileMemory::onWrite(const void *data, size_t bytes){
if (_offset + bytes > _memory.size()) {
//需要扩容
_memory.resize(_offset + bytes);

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors
@@ -62,14 +62,14 @@ public:
/**
* 获取文件读写位置
*/
virtual uint64_t onTell() = 0;
virtual size_t onTell() = 0;
/**
* seek至文件某处
* @param offset 文件偏移量
* @return 是否成功(0成功)
*/
virtual int onSeek(uint64_t offset) = 0;
virtual int onSeek(size_t offset) = 0;
/**
* 从文件读取一定数据
@@ -77,7 +77,7 @@ public:
* @param bytes 指针长度
* @return 是否成功(0成功)
*/
virtual int onRead(void *data, uint64_t bytes) = 0;
virtual int onRead(void *data, size_t bytes) = 0;
/**
* 写入文件一定数据
@@ -85,7 +85,7 @@ public:
* @param bytes 数据长度
* @return 是否成功(0成功)
*/
virtual int onWrite(const void *data, uint64_t bytes) = 0;
virtual int onWrite(const void *data, size_t bytes) = 0;
};
//磁盘MP4文件类
@@ -108,10 +108,10 @@ public:
void closeFile();
protected:
uint64_t onTell() override;
int onSeek(uint64_t offset) override;
int onRead(void *data, uint64_t bytes) override;
int onWrite(const void *data, uint64_t bytes) override;
size_t onTell() override;
int onSeek(size_t offset) override;
int onRead(void *data, size_t bytes) override;
int onWrite(const void *data, size_t bytes) override;
private:
std::shared_ptr<FILE> _file;
@@ -126,7 +126,7 @@ public:
/**
* 获取文件大小
*/
uint64_t fileSize() const;
size_t fileSize() const;
/**
* 获取并清空文件缓存
@@ -134,13 +134,13 @@ public:
string getAndClearMemory();
protected:
uint64_t onTell() override;
int onSeek(uint64_t offset) override;
int onRead(void *data, uint64_t bytes) override;
int onWrite(const void *data, uint64_t bytes) override;
size_t onTell() override;
int onSeek(size_t offset) override;
int onRead(void *data, size_t bytes) override;
int onWrite(const void *data, size_t bytes) override;
private:
uint64_t _offset = 0;
size_t _offset = 0;
string _memory;
};

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors
@@ -225,9 +225,9 @@ Frame::Ptr MP4Demuxer::makeFrame(uint32_t track_id, const Buffer::Ptr &buf, int6
offset += (frame_len + 4);
}
if (codec == CodecH264) {
return std::make_shared<FrameWrapper<H264FrameNoCacheAble> >(buf, dts, pts, 4, DATA_OFFSET);
return std::make_shared<FrameWrapper<H264FrameNoCacheAble> >(buf, (uint32_t)dts, (uint32_t)pts, 4, DATA_OFFSET);
}
return std::make_shared<FrameWrapper<H265FrameNoCacheAble> >(buf, dts, pts, 4, DATA_OFFSET);
return std::make_shared<FrameWrapper<H265FrameNoCacheAble> >(buf, (uint32_t)dts, (uint32_t)pts, 4, DATA_OFFSET);
}
case CodecAAC: {
@@ -235,13 +235,13 @@ Frame::Ptr MP4Demuxer::makeFrame(uint32_t track_id, const Buffer::Ptr &buf, int6
assert(track);
//加上adts头
dumpAacConfig(track->getAacCfg(), buf->size() - DATA_OFFSET, (uint8_t *) buf->data() + (DATA_OFFSET - ADTS_HEADER_LEN), ADTS_HEADER_LEN);
return std::make_shared<FrameWrapper<FrameFromPtr> >(buf, dts, pts, ADTS_HEADER_LEN, DATA_OFFSET - ADTS_HEADER_LEN, codec);
return std::make_shared<FrameWrapper<FrameFromPtr> >(buf, (uint32_t)dts, (uint32_t)pts, ADTS_HEADER_LEN, DATA_OFFSET - ADTS_HEADER_LEN, codec);
}
case CodecOpus:
case CodecG711A:
case CodecG711U: {
return std::make_shared<FrameWrapper<FrameFromPtr> >(buf, dts, pts, 0, DATA_OFFSET, codec);
return std::make_shared<FrameWrapper<FrameFromPtr> >(buf, (uint32_t)dts, (uint32_t)pts, 0, DATA_OFFSET, codec);
}
default: return nullptr;

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors
@@ -104,7 +104,7 @@ void MP4MuxerInterface::inputFrame(const Frame::Ptr &frame) {
BufferLikeString merged;
merged.reserve(back->size() + 1024);
_frameCached.for_each([&](const Frame::Ptr &frame) {
uint32_t nalu_size = frame->size() - frame->prefixSize();
uint32_t nalu_size = (uint32_t)(frame->size() - frame->prefixSize());
nalu_size = htonl(nalu_size);
merged.append((char *) &nalu_size, 4);
merged.append(frame->data() + frame->prefixSize(), frame->size() - frame->prefixSize());
@@ -249,7 +249,7 @@ void MP4MuxerInterface::addTrack(const Track::Ptr &track) {
struct mpeg4_avc_t avc = {0};
string sps_pps = string("\x00\x00\x00\x01", 4) + h264_track->getSps() +
string("\x00\x00\x00\x01", 4) + h264_track->getPps();
h264_annexbtomp4(&avc, sps_pps.data(), sps_pps.size(), NULL, 0, NULL, NULL);
h264_annexbtomp4(&avc, sps_pps.data(), (int)sps_pps.size(), NULL, 0, NULL, NULL);
uint8_t extra_data[1024];
int extra_data_size = mpeg4_avc_decoder_configuration_record_save(&avc, extra_data, sizeof(extra_data));
@@ -284,7 +284,7 @@ void MP4MuxerInterface::addTrack(const Track::Ptr &track) {
string vps_sps_pps = string("\x00\x00\x00\x01", 4) + h265_track->getVps() +
string("\x00\x00\x00\x01", 4) + h265_track->getSps() +
string("\x00\x00\x00\x01", 4) + h265_track->getPps();
h265_annexbtomp4(&hevc, vps_sps_pps.data(), vps_sps_pps.size(), NULL, 0, NULL, NULL);
h265_annexbtomp4(&hevc, vps_sps_pps.data(), (int)vps_sps_pps.size(), NULL, 0, NULL, NULL);
uint8_t extra_data[1024];
int extra_data_size = mpeg4_hevc_decoder_configuration_record_save(&hevc, extra_data, sizeof(extra_data));

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors
@@ -31,7 +31,7 @@ MP4Reader::MP4Reader(const string &strVhost,const string &strApp, const string &
_demuxer = std::make_shared<MP4Demuxer>();
_demuxer->openMP4(_file_path);
_mediaMuxer.reset(new MultiMediaSourceMuxer(strVhost, strApp, strId, _demuxer->getDurationMS() / 1000.0, true, true, false, false));
_mediaMuxer.reset(new MultiMediaSourceMuxer(strVhost, strApp, strId, _demuxer->getDurationMS() / 1000.0f, true, true, false, false));
auto tracks = _demuxer->getTracks(false);
if(tracks.empty()){
throw std::runtime_error(StrPrinter << "该mp4文件没有有效的track:" << _file_path);
@@ -89,7 +89,7 @@ void MP4Reader::startReadMP4() {
}
uint32_t MP4Reader::getCurrentStamp() {
return _seek_to + _seek_ticker.elapsedTime();
return (uint32_t)(_seek_to + _seek_ticker.elapsedTime());
}
void MP4Reader::setCurrentStamp(uint32_t ui32Stamp){
@@ -117,7 +117,7 @@ bool MP4Reader::seekTo(uint32_t ui32Stamp){
if(!_have_video){
//没有视频,不需要搜索关键帧
//设置当前时间戳
setCurrentStamp(stamp);
setCurrentStamp((uint32_t)stamp);
return true;
}
//搜索到下一帧关键帧

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors
@@ -75,7 +75,7 @@ void MP4Recorder::asyncClose() {
auto info = _info;
WorkThreadPool::Instance().getExecutor()->async([muxer,strFileTmp,strFile,info]() {
//获取文件录制时间放在关闭mp4之前是为了忽略关闭mp4执行时间
const_cast<RecordInfo&>(info).time_len = ::time(NULL) - info.start_time;
const_cast<RecordInfo&>(info).time_len = (float)(::time(NULL) - info.start_time);
//关闭mp4非常耗时所以要放在后台线程执行
muxer->closeMP4();

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors
@@ -124,7 +124,7 @@ void TsMuxer::inputFrame(const Frame::Ptr &frame) {
}
track_info.stamp.revise(back->dts(), back->pts(), dts_out, pts_out);
//取视频时间戳为TS的时间戳
_timestamp = dts_out;
_timestamp = (uint32_t)dts_out;
mpeg_ts_write(_context, track_info.track_id, back->keyFrame() ? 0x0001 : 0, pts_out * 90LL,dts_out * 90LL, merged_frame->data(), merged_frame->size());
_frameCached.clear();
}
@@ -143,7 +143,7 @@ void TsMuxer::inputFrame(const Frame::Ptr &frame) {
track_info.stamp.revise(frame->dts(), frame->pts(), dts_out, pts_out);
if(!_have_video){
//没有视频时才以音频时间戳为TS的时间戳
_timestamp = dts_out;
_timestamp = (uint32_t)dts_out;
}
mpeg_ts_write(_context, track_info.track_id, frame->keyFrame() ? 0x0001 : 0, pts_out * 90LL, dts_out * 90LL, frame->data(), frame->size());
break;

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors
@@ -50,7 +50,7 @@ protected:
* @param timestamp 时间戳,单位毫秒
* @param is_idr_fast_packet 是否为关键帧的第一个TS包用于确保ts切片第一帧为关键帧
*/
virtual void onTs(const void *packet, int bytes,uint32_t timestamp,bool is_idr_fast_packet) = 0;
virtual void onTs(const void *packet, size_t bytes,uint32_t timestamp,bool is_idr_fast_packet) = 0;
private:
void init();
@@ -88,7 +88,7 @@ public:
void inputFrame(const Frame::Ptr &frame) override {}
protected:
virtual void onTs(const void *packet, int bytes,uint32_t timestamp,bool is_idr_fast_packet) = 0;
virtual void onTs(const void *packet, size_t bytes,uint32_t timestamp,bool is_idr_fast_packet) = 0;
};
}//namespace mediakit