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

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

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

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
@@ -117,13 +117,13 @@ private:
void checkTrackIfReady(const Track::Ptr &track);
void checkTrackIfReady_l(const Track::Ptr &track);
private:
bool _all_track_ready = false;
size_t _max_track_size = 2;
mutable recursive_mutex _mtx;
unordered_map<int,Track::Ptr> _track_map;
unordered_map<int,List<Frame::Ptr> > _frame_unread;
unordered_map<int,function<void()> > _track_ready_callback;
bool _all_track_ready = false;
Ticker _ticker;
int _max_track_size = 2;
};

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
@@ -521,7 +521,7 @@ void MediaSourceEvent::onReaderChanged(MediaSource &sender, int size){
bool is_mp4_vod = sender.getApp() == record_app;
weak_ptr<MediaSource> weak_sender = sender.shared_from_this();
_async_close_timer = std::make_shared<Timer>(stream_none_reader_delay / 1000.0, [weak_sender, is_mp4_vod]() {
_async_close_timer = std::make_shared<Timer>(stream_none_reader_delay / 1000.0f, [weak_sender, is_mp4_vod]() {
auto strong_sender = weak_sender.lock();
if (!strong_sender) {
//对象已经销毁
@@ -672,7 +672,7 @@ std::shared_ptr<MediaSourceEvent> MediaSourceEventInterceptor::getDelegate() con
/////////////////////////////////////FlushPolicy//////////////////////////////////////
static bool isFlushAble_default(bool is_video, uint64_t last_stamp, uint64_t new_stamp, int cache_size) {
static bool isFlushAble_default(bool is_video, uint64_t last_stamp, uint64_t new_stamp, size_t cache_size) {
if (new_stamp + 500 < last_stamp) {
//时间戳回退比较大(可能seek中)由于rtp中时间戳是pts是可能存在一定程度的回退的
return true;
@@ -682,7 +682,7 @@ static bool isFlushAble_default(bool is_video, uint64_t last_stamp, uint64_t new
return last_stamp != new_stamp || cache_size >= 1024;
}
static bool isFlushAble_merge(bool is_video, uint64_t last_stamp, uint64_t new_stamp, int cache_size, int merge_ms) {
static bool isFlushAble_merge(bool is_video, uint64_t last_stamp, uint64_t new_stamp, size_t cache_size, int merge_ms) {
if (new_stamp + 500 < last_stamp) {
//时间戳回退比较大(可能seek中)由于rtp中时间戳是pts是可能存在一定程度的回退的
return true;
@@ -698,7 +698,7 @@ static bool isFlushAble_merge(bool is_video, uint64_t last_stamp, uint64_t new_s
return cache_size >= 1024;
}
bool FlushPolicy::isFlushAble(bool is_video, bool is_key, uint64_t new_stamp, int cache_size) {
bool FlushPolicy::isFlushAble(bool is_video, bool is_key, uint64_t new_stamp, size_t cache_size) {
bool flush_flag = false;
if (is_key && is_video) {
//遇到关键帧flush掉前面的数据确保关键帧为该组数据的第一帧确保GOP缓存有效

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
@@ -148,7 +148,7 @@ public:
/**
* 添加统计字节
*/
BytesSpeed& operator += (uint64_t bytes) {
BytesSpeed& operator += (size_t bytes) {
_bytes += bytes;
if (_bytes > 1024 * 1024) {
//数据大于1MB就计算一次网速
@@ -169,12 +169,12 @@ public:
}
private:
uint64_t computeSpeed() {
int computeSpeed() {
auto elapsed = _ticker.elapsedTime();
if (!elapsed) {
return _speed;
}
_speed = _bytes * 1000 / elapsed;
_speed = (int)(_bytes * 1000 / elapsed);
_ticker.resetTime();
_bytes = 0;
return _speed;
@@ -182,7 +182,7 @@ private:
private:
int _speed = 0;
uint64_t _bytes = 0;
size_t _bytes = 0;
Ticker _ticker;
};
@@ -304,7 +304,7 @@ public:
FlushPolicy() = default;
~FlushPolicy() = default;
bool isFlushAble(bool is_video, bool is_key, uint64_t new_stamp, int cache_size);
bool isFlushAble(bool is_video, bool is_key, uint64_t new_stamp, size_t cache_size);
private:
uint64_t _last_stamp[2] = {0, 0};

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
@@ -404,14 +404,14 @@ public:
~FrameModifyStamp() override {}
uint32_t dts() const override{
return _dts;
return (uint32_t)_dts;
}
uint32_t pts() const override{
return _pts;
return (uint32_t)_pts;
}
uint32_t prefixSize() const override {
size_t prefixSize() const override {
return _frame->prefixSize();
}
@@ -431,7 +431,7 @@ public:
return _frame->data();
}
uint32_t size() const override {
size_t size() const override {
return _frame->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

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
@@ -12,12 +12,12 @@
namespace mediakit{
string FindField(const char* buf, const char* start, const char *end ,int bufSize) {
string FindField(const char* buf, const char* start, const char *end ,size_t bufSize) {
if(bufSize <=0 ){
bufSize = strlen(buf);
}
const char *msg_start = buf, *msg_end = buf + bufSize;
int len = 0;
size_t len = 0;
if (start != NULL) {
len = strlen(start);
msg_start = strstr(buf, start);

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
@@ -19,7 +19,7 @@ using namespace toolkit;
namespace mediakit{
string FindField(const char *buf, const char *start, const char *end, int bufSize = 0);
string FindField(const char *buf, const char *start, const char *end, size_t bufSize = 0);
struct StrCaseCompare {
bool operator()(const string &__x, const string &__y) const {

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
@@ -101,7 +101,7 @@ void Stamp::revise_l2(int64_t dts, int64_t pts, int64_t &dts_out, int64_t &pts_o
}
//pts和dts的差值
int pts_dts_diff = pts - dts;
auto pts_dts_diff = pts - dts;
if (_last_dts_in != dts) {
//时间戳发生变更

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
@@ -30,7 +30,7 @@ bool loadIniConfig(const char *ini_path){
mINI::Instance().parseFile(ini);
NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastReloadConfig);
return true;
}catch (std::exception &ex) {
}catch (std::exception &) {
InfoL << "dump ini file to:" << ini;
mINI::Instance().dumpFile(ini);
return false;

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
@@ -15,6 +15,7 @@
namespace mediakit{
#ifndef ENABLE_MP4
unsigned const samplingFrequencyTable[16] = { 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 7350, 0, 0, 0 };
class AdtsHeader{
@@ -91,8 +92,9 @@ static void parseAacConfig(const string &config, AdtsHeader &adts) {
adts.adts_buffer_fullness = 2047;
adts.no_raw_data_blocks_in_frame = 0;
}
#endif// ENABLE_MP4
int getAacFrameLength(const uint8_t *data, int bytes) {
int getAacFrameLength(const uint8_t *data, size_t bytes) {
uint16_t len;
if (bytes < 7) return -1;
if (0xFF != data[0] || 0xF0 != (data[1] & 0xF0)) {
@@ -102,7 +104,7 @@ int getAacFrameLength(const uint8_t *data, int bytes) {
return len;
}
string makeAacConfig(const uint8_t *hex, int length){
string makeAacConfig(const uint8_t *hex, size_t length){
#ifndef ENABLE_MP4
if (!(hex[0] == 0xFF && (hex[1] & 0xF0) == 0xF0)) {
return "";
@@ -140,11 +142,11 @@ string makeAacConfig(const uint8_t *hex, int length){
#endif
}
int dumpAacConfig(const string &config, int length, uint8_t *out, int out_size) {
int dumpAacConfig(const string &config, size_t length, uint8_t *out, size_t out_size) {
#ifndef ENABLE_MP4
AdtsHeader header;
parseAacConfig(config, header);
header.aac_frame_length = ADTS_HEADER_LEN + length;
header.aac_frame_length = (decltype(header.aac_frame_length))(ADTS_HEADER_LEN + length);
dumpAdtsHeader(header, out);
return ADTS_HEADER_LEN;
#else

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
@@ -17,9 +17,9 @@
namespace mediakit{
string makeAacConfig(const uint8_t *hex, int length);
int getAacFrameLength(const uint8_t *hex, int length);
int dumpAacConfig(const string &config, int length, uint8_t *out, int out_size);
string makeAacConfig(const uint8_t *hex, size_t length);
int getAacFrameLength(const uint8_t *hex, size_t length);
int dumpAacConfig(const string &config, size_t length, uint8_t *out, size_t out_size);
bool parseAacConfig(const string &config, int &samplerate, int &channels);
/**

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
@@ -41,7 +41,7 @@ void AACRtmpDecoder::inputRtmp(const RtmpPacket::Ptr &pkt) {
}
}
void AACRtmpDecoder::onGetAAC(const char* data, int len, uint32_t stamp) {
void AACRtmpDecoder::onGetAAC(const char* data, size_t len, uint32_t stamp) {
auto frame = ResourcePoolHelper<FrameImp>::obtainObj();
frame->_codec_id = CodecAAC;

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
@@ -37,7 +37,7 @@ public:
}
private:
void onGetAAC(const char *data, int len, uint32_t stamp);
void onGetAAC(const char *data, size_t len, uint32_t stamp);
private:
string _aac_cfg;

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,22 +31,22 @@ void AACRtpEncoder::inputFrame(const Frame::Ptr &frame) {
auto iLen = frame->size() - frame->prefixSize();
uiStamp %= cycleMS;
char *ptr = (char *) pcData;
int iSize = iLen;
auto *ptr = (char *) pcData;
auto iSize = iLen;
while (iSize > 0) {
if (iSize <= _ui32MtuSize - 20) {
_aucSectionBuf[0] = 0;
_aucSectionBuf[1] = 16;
_aucSectionBuf[2] = iLen >> 5;
_aucSectionBuf[3] = (iLen & 0x1F) << 3;
_aucSectionBuf[2] = (iLen >> 5) & 0xFF;
_aucSectionBuf[3] = ((iLen & 0x1F) << 3) & 0xFF;
memcpy(_aucSectionBuf + 4, ptr, iSize);
makeAACRtp(_aucSectionBuf, iSize + 4, true, uiStamp);
break;
}
_aucSectionBuf[0] = 0;
_aucSectionBuf[1] = 16;
_aucSectionBuf[2] = (iLen) >> 5;
_aucSectionBuf[3] = (iLen & 0x1F) << 3;
_aucSectionBuf[2] = ((iLen) >> 5) & 0xFF;
_aucSectionBuf[3] = ((iLen & 0x1F) << 3) & 0xFF;
memcpy(_aucSectionBuf + 4, ptr, _ui32MtuSize - 20);
makeAACRtp(_aucSectionBuf, _ui32MtuSize - 16, false, uiStamp);
ptr += (_ui32MtuSize - 20);
@@ -54,7 +54,7 @@ void AACRtpEncoder::inputFrame(const Frame::Ptr &frame) {
}
}
void AACRtpEncoder::makeAACRtp(const void *data, unsigned int len, bool mark, uint32_t uiStamp) {
void AACRtpEncoder::makeAACRtp(const void *data, size_t len, bool mark, uint32_t uiStamp) {
RtpCodec::inputRtp(makeRtp(getTrackType(), data, len, mark, uiStamp), false);
}

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
@@ -43,9 +43,9 @@ private:
void flushData();
private:
FrameImp::Ptr _frame;
string _aac_cfg;
uint32_t _last_dts = 0;
string _aac_cfg;
FrameImp::Ptr _frame;
};
@@ -77,7 +77,7 @@ public:
void inputFrame(const Frame::Ptr &frame) override;
private:
void makeAACRtp(const void *pData, unsigned int uiLen, bool bMark, uint32_t uiStamp);
void makeAACRtp(const void *pData, size_t uiLen, bool bMark, uint32_t uiStamp);
private:
unsigned char _aucSectionBuf[1600];

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

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
@@ -58,10 +58,10 @@ public:
}
private:
Frame::Ptr _frame;
BufferRaw::Ptr _buffer;
bool _key;
bool _config;
Frame::Ptr _frame;
BufferRaw::Ptr _buffer;
};
Frame::Ptr Frame::getCacheAbleFrame(const Frame::Ptr &frame){

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
@@ -101,7 +101,7 @@ public:
* 前缀长度譬如264前缀为0x00 00 00 01,那么前缀长度就是4
* aac前缀则为7个字节
*/
virtual uint32_t prefixSize() const = 0;
virtual size_t prefixSize() const = 0;
/**
* 返回是否为关键帧
@@ -132,7 +132,7 @@ public:
return (char *)_buffer.data();
}
uint32_t size() const override {
size_t size() const override {
return _buffer.size();
}
@@ -144,7 +144,7 @@ public:
return _pts ? _pts : _dts;
}
uint32_t prefixSize() const override{
size_t prefixSize() const override{
return _prefix_size;
}
@@ -162,10 +162,10 @@ public:
public:
CodecId _codec_id = CodecInvalid;
BufferLikeString _buffer;
uint32_t _dts = 0;
uint32_t _pts = 0;
uint32_t _prefix_size = 0;
size_t _prefix_size = 0;
BufferLikeString _buffer;
};
/**
@@ -178,7 +178,7 @@ template<typename Parent>
class FrameInternal : public Parent{
public:
typedef std::shared_ptr<FrameInternal> Ptr;
FrameInternal(const Frame::Ptr &parent_frame, char *ptr, uint32_t size, int prefix_size)
FrameInternal(const Frame::Ptr &parent_frame, char *ptr, size_t size, size_t prefix_size)
: Parent(ptr, size, parent_frame->dts(), parent_frame->pts(), prefix_size) {
_parent_frame = parent_frame;
}
@@ -301,7 +301,7 @@ public:
/**
* 返回代理个数
*/
int size() const {
size_t size() const {
return _delegates_write.size();
}
private:
@@ -318,12 +318,12 @@ class FrameFromPtr : public Frame{
public:
typedef std::shared_ptr<FrameFromPtr> Ptr;
FrameFromPtr(CodecId codec_id, char *ptr, uint32_t size, uint32_t dts, uint32_t pts = 0, int prefix_size = 0)
FrameFromPtr(CodecId codec_id, char *ptr, size_t size, uint32_t dts, uint32_t pts = 0, size_t prefix_size = 0)
: FrameFromPtr(ptr, size, dts, pts, prefix_size) {
_codec_id = codec_id;
}
FrameFromPtr(char *ptr, uint32_t size, uint32_t dts, uint32_t pts = 0, int prefix_size = 0){
FrameFromPtr(char *ptr, size_t size, uint32_t dts, uint32_t pts = 0, size_t prefix_size = 0){
_ptr = ptr;
_size = size;
_dts = dts;
@@ -335,7 +335,7 @@ public:
return _ptr;
}
uint32_t size() const override {
size_t size() const override {
return _size;
}
@@ -347,7 +347,7 @@ public:
return _pts ? _pts : dts();
}
uint32_t prefixSize() const override{
size_t prefixSize() const override{
return _prefix_size;
}
@@ -379,10 +379,10 @@ protected:
protected:
char *_ptr;
uint32_t _size;
uint32_t _dts;
uint32_t _pts = 0;
uint32_t _prefix_size;
size_t _size;
size_t _prefix_size;
CodecId _codec_id = CodecInvalid;
};
@@ -402,7 +402,7 @@ public:
* @param prefix 帧前缀长度
* @param offset buffer有效数据偏移量
*/
FrameWrapper(const Buffer::Ptr &buf, int64_t dts, int64_t pts, int prefix, int offset) : Parent(buf->data() + offset, buf->size() - offset, dts, pts, prefix){
FrameWrapper(const Buffer::Ptr &buf, uint32_t dts, uint32_t pts, size_t prefix, size_t offset) : Parent(buf->data() + offset, buf->size() - offset, dts, pts, prefix){
_buf = buf;
}
@@ -415,7 +415,7 @@ public:
* @param offset buffer有效数据偏移量
* @param codec 帧类型
*/
FrameWrapper(const Buffer::Ptr &buf, int64_t dts, int64_t pts, int prefix, int offset, CodecId codec) : Parent(codec, buf->data() + offset, buf->size() - offset, dts, pts, prefix){
FrameWrapper(const Buffer::Ptr &buf, uint32_t dts, uint32_t pts, size_t prefix, size_t offset, CodecId codec) : Parent(codec, buf->data() + offset, buf->size() - offset, dts, pts, prefix){
_buf = buf;
}

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
@@ -15,13 +15,13 @@ using namespace toolkit;
namespace mediakit{
bool getAVCInfo(const char * sps,int sps_len,int &iVideoWidth, int &iVideoHeight, float &iVideoFps){
static bool getAVCInfo(const char * sps,size_t sps_len,int &iVideoWidth, int &iVideoHeight, float &iVideoFps){
T_GetBitContext tGetBitBuf;
T_SPS tH264SpsInfo;
memset(&tGetBitBuf,0,sizeof(tGetBitBuf));
memset(&tH264SpsInfo,0,sizeof(tH264SpsInfo));
tGetBitBuf.pu8Buf = (uint8_t*)sps + 1;
tGetBitBuf.iBufSize = sps_len - 1;
tGetBitBuf.iBufSize = (int)(sps_len - 1);
if(0 != h264DecSeqParameterSet((void *) &tGetBitBuf, &tH264SpsInfo)){
return false;
}
@@ -31,11 +31,11 @@ bool getAVCInfo(const char * sps,int sps_len,int &iVideoWidth, int &iVideoHeight
return true;
}
bool getAVCInfo(const string& strSps,int &iVideoWidth, int &iVideoHeight, float &iVideoFps) {
return getAVCInfo(strSps.data(),strSps.size(),iVideoWidth,iVideoHeight,iVideoFps);
bool getAVCInfo(const string &strSps, int &iVideoWidth, int &iVideoHeight, float &iVideoFps) {
return getAVCInfo(strSps.data(), strSps.size(), iVideoWidth, iVideoHeight, iVideoFps);
}
const char *memfind(const char *buf, int len, const char *subbuf, int sublen) {
static const char *memfind(const char *buf, size_t len, const char *subbuf, size_t sublen) {
for (auto i = 0; i < len - sublen; ++i) {
if (memcmp(buf + i, subbuf, sublen) == 0) {
return buf + i;
@@ -44,10 +44,10 @@ const char *memfind(const char *buf, int len, const char *subbuf, int sublen) {
return NULL;
}
void splitH264(const char *ptr, int len, int prefix, const std::function<void(const char *, int, int)> &cb) {
void splitH264(const char *ptr, size_t len, size_t prefix, const std::function<void(const char *, size_t , size_t)> &cb) {
auto start = ptr + prefix;
auto end = ptr + len;
int next_prefix;
size_t next_prefix;
while (true) {
auto next_start = memfind(start, end - start, "\x00\x00\x01", 3);
if (next_start) {
@@ -74,7 +74,7 @@ void splitH264(const char *ptr, int len, int prefix, const std::function<void(co
}
}
int prefixSize(const char *ptr, int len){
size_t prefixSize(const char *ptr, size_t len){
if (len < 4) {
return 0;
}
@@ -96,28 +96,6 @@ int prefixSize(const char *ptr, int len){
return 0;
}
#if 0
//splitH264函数测试程序
static onceToken s_token([](){
{
char buf[] = "\x00\x00\x00\x01\x12\x23\x34\x45\x56"
"\x00\x00\x00\x01\x23\x34\x45\x56"
"\x00\x00\x00\x01x34\x45\x56"
"\x00\x00\x01\x12\x23\x34\x45\x56";
splitH264(buf, sizeof(buf) - 1, 4, [](const char *ptr, int len, int prefix) {
cout << prefix << " " << hexdump(ptr, len) << endl;
});
}
{
char buf[] = "\x00\x00\x00\x01\x12\x23\x34\x45\x56";
splitH264(buf, sizeof(buf) - 1, 4, [](const char *ptr, int len, int prefix) {
cout << prefix << " " << hexdump(ptr, len) << endl;
});
}
});
#endif //0
Sdp::Ptr H264Track::getSdp() {
if(!ready()){
WarnL << getCodecName() << " Track未准备好";

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
@@ -19,9 +19,9 @@ using namespace toolkit;
namespace mediakit{
bool getAVCInfo(const string &strSps,int &iVideoWidth, int &iVideoHeight, float &iVideoFps);
void splitH264(const char *ptr, int len, int prefix, const std::function<void(const char *, int, int)> &cb);
int prefixSize(const char *ptr, int len);
bool getAVCInfo(const string &strSps,int &iVideoWidth, int &iVideoHeight, float &iVideoFps);
void splitH264(const char *ptr, size_t len, size_t prefix, const std::function<void(const char *, size_t, size_t)> &cb);
size_t prefixSize(const char *ptr, size_t len);
/**
* 264帧类
*/
@@ -64,7 +64,7 @@ class H264FrameNoCacheAble : public FrameFromPtr {
public:
typedef std::shared_ptr<H264FrameNoCacheAble> Ptr;
H264FrameNoCacheAble(char *ptr,uint32_t size,uint32_t dts , uint32_t pts ,int prefix_size = 4){
H264FrameNoCacheAble(char *ptr,size_t size,uint32_t dts , uint32_t pts ,size_t prefix_size = 4){
_ptr = ptr;
_size = size;
_dts = dts;
@@ -183,7 +183,7 @@ public:
int type = H264_TYPE(*((uint8_t *)frame->data() + frame->prefixSize()));
if(type != H264Frame::NAL_B_P && type != H264Frame::NAL_IDR){
//非I/B/P帧情况下split一下防止多个帧粘合在一起
splitH264(frame->data(), frame->size(), frame->prefixSize(), [&](const char *ptr, int len, int prefix) {
splitH264(frame->data(), frame->size(), frame->prefixSize(), [&](const char *ptr, size_t len, size_t prefix) {
H264FrameInternal::Ptr sub_frame = std::make_shared<H264FrameInternal>(frame, (char *)ptr, len, prefix);
inputFrame_l(sub_frame);
});
@@ -310,14 +310,14 @@ public:
(uint8_t(strSPS[3])); // profile_idc|constraint_setN_flag|level_idc
}
memset(strTemp, 0, 100);
sprintf(strTemp, "%06X", profile_level_id);
snprintf(strTemp, sizeof(strTemp), "%06X", profile_level_id);
_printer << strTemp;
_printer << "; sprop-parameter-sets=";
memset(strTemp, 0, 100);
av_base64_encode(strTemp, 100, (uint8_t *) strSPS.data(), strSPS.size());
av_base64_encode(strTemp, 100, (uint8_t *) strSPS.data(), (int)strSPS.size());
_printer << strTemp << ",";
memset(strTemp, 0, 100);
av_base64_encode(strTemp, 100, (uint8_t *) strPPS.data(), strPPS.size());
av_base64_encode(strTemp, 100, (uint8_t *) strPPS.data(), (int)strPPS.size());
_printer << strTemp << "\r\n";
_printer << "a=control:trackID=" << (int)TrackVideo << "\r\n";
}

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
@@ -97,8 +97,8 @@ void H264RtmpDecoder::inputRtmp(const RtmpPacket::Ptr &pkt) {
}
if (pkt->buffer.size() > 9) {
uint32_t iTotalLen = pkt->buffer.size();
uint32_t iOffset = 5;
auto iTotalLen = pkt->buffer.size();
size_t iOffset = 5;
uint8_t *cts_ptr = (uint8_t *) (pkt->buffer.data() + 2);
int32_t cts = (((cts_ptr[0] << 16) | (cts_ptr[1] << 8) | (cts_ptr[2])) + 0xff800000) ^ 0xff800000;
auto pts = pkt->time_stamp + cts;
@@ -117,7 +117,7 @@ void H264RtmpDecoder::inputRtmp(const RtmpPacket::Ptr &pkt) {
}
}
inline void H264RtmpDecoder::onGetH264(const char* pcData, int iLen, uint32_t dts,uint32_t pts) {
inline void H264RtmpDecoder::onGetH264(const char* pcData, size_t iLen, uint32_t dts,uint32_t pts) {
if(iLen == 0){
return;
}
@@ -213,7 +213,7 @@ void H264RtmpEncoder::inputFrame(const Frame::Ptr &frame) {
_lastPacket->type_id = MSG_VIDEO;
}
auto size = htonl(iLen);
uint32_t size = htonl((uint32_t)iLen);
_lastPacket->buffer.append((char *) &size, 4);
_lastPacket->buffer.append(pcData, iLen);
_lastPacket->body_size = _lastPacket->buffer.size();
@@ -238,16 +238,16 @@ void H264RtmpEncoder::makeVideoConfigPkt() {
rtmpPkt->buffer.push_back(_sps[1]); // profile
rtmpPkt->buffer.push_back(_sps[2]); // compat
rtmpPkt->buffer.push_back(_sps[3]); // level
rtmpPkt->buffer.push_back(0xff); // 6 bits reserved + 2 bits nal size length - 1 (11)
rtmpPkt->buffer.push_back(0xe1); // 3 bits reserved + 5 bits number of sps (00001)
rtmpPkt->buffer.push_back((char)0xff); // 6 bits reserved + 2 bits nal size length - 1 (11)
rtmpPkt->buffer.push_back((char)0xe1); // 3 bits reserved + 5 bits number of sps (00001)
//sps
uint16_t size = _sps.size();
uint16_t size = (uint16_t)_sps.size();
size = htons(size);
rtmpPkt->buffer.append((char *) &size, 2);
rtmpPkt->buffer.append(_sps);
//pps
rtmpPkt->buffer.push_back(1); // version
size = _pps.size();
size = (uint16_t)_pps.size();
size = htons(size);
rtmpPkt->buffer.append((char *) &size, 2);
rtmpPkt->buffer.append(_pps);

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
@@ -40,7 +40,7 @@ public:
}
protected:
void onGetH264(const char *pcData, int iLen, uint32_t dts,uint32_t pts);
void onGetH264(const char *pcData, size_t iLen, uint32_t dts,uint32_t pts);
H264Frame::Ptr obtainFrame();
protected:

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
@@ -72,7 +72,7 @@ bool H264RtpDecoder::decodeRtp(const RtpPacket::Ptr &rtppack) {
30-31 undefined -
*/
const uint8_t *frame = (uint8_t *) rtppack->data() + rtppack->offset;
int length = rtppack->size() - rtppack->offset;
auto length = rtppack->size() - rtppack->offset;
int nal_type = *frame & 0x1F;
int nal_suffix = *frame & (~0x1F);
@@ -92,7 +92,7 @@ bool H264RtpDecoder::decodeRtp(const RtpPacket::Ptr &rtppack) {
bool haveIDR = false;
auto ptr = frame + 1;
while (true) {
int off = ptr - frame;
size_t off = ptr - frame;
if (off >= length) {
break;
}
@@ -198,7 +198,7 @@ void H264RtpEncoder::inputFrame(const Frame::Ptr &frame) {
auto len = frame->size() - frame->prefixSize();
auto pts = frame->pts() % cycleMS;
auto nal_type = H264_TYPE(ptr[0]);
auto payload_size = _ui32MtuSize - 2;
size_t payload_size = _ui32MtuSize - 2;
//超过MTU则按照FU-A模式打包
if (len > payload_size + 1) {
@@ -209,7 +209,7 @@ void H264RtpEncoder::inputFrame(const Frame::Ptr &frame) {
unsigned char s_e_r_flags;
bool fu_a_start = true;
bool mark_bit = false;
int offset = 1;
size_t offset = 1;
while (!mark_bit) {
if (len <= offset + payload_size) {
//FU-A end
@@ -247,7 +247,7 @@ void H264RtpEncoder::inputFrame(const Frame::Ptr &frame) {
}
}
void H264RtpEncoder::makeH264Rtp(const void* data, unsigned int len, bool mark, bool gop_pos, uint32_t uiStamp) {
void H264RtpEncoder::makeH264Rtp(const void* data, size_t len, bool mark, bool gop_pos, uint32_t uiStamp) {
RtpCodec::inputRtp(makeRtp(getTrackType(), data, len, mark, uiStamp), gop_pos);
}

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
@@ -41,14 +41,16 @@ public:
CodecId getCodecId() const override{
return CodecH264;
}
private:
bool decodeRtp(const RtpPacket::Ptr &rtp);
void onGetH264(const H264Frame::Ptr &frame);
H264Frame::Ptr obtainFrame();
private:
int _lastSeq = 0;
H264Frame::Ptr _h264frame;
DtsGenerator _dts_generator;
int _lastSeq = 0;
};
/**
@@ -77,8 +79,9 @@ public:
* @param frame 帧数据,必须
*/
void inputFrame(const Frame::Ptr &frame) override;
private:
void makeH264Rtp(const void *pData, unsigned int uiLen, bool bMark, bool gop_pos, uint32_t uiStamp);
void makeH264Rtp(const void *pData, size_t uiLen, bool bMark, bool gop_pos, uint32_t uiStamp);
};
}//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
@@ -14,7 +14,7 @@
namespace mediakit{
bool getHEVCInfo(const char * vps, int vps_len,const char * sps,int sps_len,int &iVideoWidth, int &iVideoHeight, float &iVideoFps){
bool getHEVCInfo(const char * vps, size_t vps_len,const char * sps,size_t sps_len,int &iVideoWidth, int &iVideoHeight, float &iVideoFps){
T_GetBitContext tGetBitBuf;
T_HEVCSPS tH265SpsInfo;
T_HEVCVPS tH265VpsInfo;
@@ -22,7 +22,7 @@ bool getHEVCInfo(const char * vps, int vps_len,const char * sps,int sps_len,int
memset(&tGetBitBuf,0,sizeof(tGetBitBuf));
memset(&tH265VpsInfo,0,sizeof(tH265VpsInfo));
tGetBitBuf.pu8Buf = (uint8_t*)vps+2;
tGetBitBuf.iBufSize = vps_len-2;
tGetBitBuf.iBufSize = (int)(vps_len-2);
if(0 != h265DecVideoParameterSet((void *) &tGetBitBuf, &tH265VpsInfo)){
return false;
}
@@ -32,7 +32,7 @@ bool getHEVCInfo(const char * vps, int vps_len,const char * sps,int sps_len,int
memset(&tGetBitBuf,0,sizeof(tGetBitBuf));
memset(&tH265SpsInfo,0,sizeof(tH265SpsInfo));
tGetBitBuf.pu8Buf = (uint8_t*)sps+2;
tGetBitBuf.iBufSize = sps_len-2;
tGetBitBuf.iBufSize = (int)(sps_len-2);
if(0 != h265DecSeqParameterSet((void *) &tGetBitBuf, &tH265SpsInfo)){
return false;
}
@@ -47,7 +47,7 @@ bool getHEVCInfo(const char * vps, int vps_len,const char * sps,int sps_len,int
}
bool getHEVCInfo(const string &strVps, const string &strSps, int &iVideoWidth, int &iVideoHeight, float &iVideoFps) {
return getHEVCInfo(strVps.data(),strVps.size(),strSps.data(),strSps.size(),iVideoWidth,iVideoHeight,iVideoFps);
return getHEVCInfo(strVps.data(), strVps.size(), strSps.data(), strSps.size(), iVideoWidth, iVideoHeight,iVideoFps);
}
Sdp::Ptr H265Track::getSdp() {

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
@@ -86,7 +86,7 @@ class H265FrameNoCacheAble : public FrameFromPtr {
public:
typedef std::shared_ptr<H265FrameNoCacheAble> Ptr;
H265FrameNoCacheAble(char *ptr, uint32_t size, uint32_t dts,uint32_t pts, int prefix_size = 4) {
H265FrameNoCacheAble(char *ptr, size_t size, uint32_t dts,uint32_t pts, size_t prefix_size = 4) {
_ptr = ptr;
_size = size;
_dts = dts;
@@ -197,7 +197,7 @@ public:
void inputFrame(const Frame::Ptr &frame) override{
int type = H265_TYPE(*((uint8_t *)frame->data() + frame->prefixSize()));
if(frame->configFrame() || type == H265Frame::NAL_SEI_PREFIX){
splitH264(frame->data(), frame->size(), frame->prefixSize(), [&](const char *ptr, int len, int prefix){
splitH264(frame->data(), frame->size(), frame->prefixSize(), [&](const char *ptr, size_t len, size_t prefix){
H265FrameInternal::Ptr sub_frame = std::make_shared<H265FrameInternal>(frame, (char*)ptr, len, prefix);
inputFrame_l(sub_frame);
});

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,8 +75,8 @@ void H265RtmpDecoder::inputRtmp(const RtmpPacket::Ptr &pkt) {
}
if (pkt->buffer.size() > 9) {
uint32_t iTotalLen = pkt->buffer.size();
uint32_t iOffset = 5;
auto iTotalLen = pkt->buffer.size();
size_t iOffset = 5;
uint8_t *cts_ptr = (uint8_t *) (pkt->buffer.data() + 2);
int32_t cts = (((cts_ptr[0] << 16) | (cts_ptr[1] << 8) | (cts_ptr[2])) + 0xff800000) ^ 0xff800000;
auto pts = pkt->time_stamp + cts;
@@ -95,7 +95,7 @@ void H265RtmpDecoder::inputRtmp(const RtmpPacket::Ptr &pkt) {
}
}
inline void H265RtmpDecoder::onGetH265(const char* pcData, int iLen, uint32_t dts,uint32_t pts) {
inline void H265RtmpDecoder::onGetH265(const char* pcData, size_t iLen, uint32_t dts,uint32_t pts) {
if(iLen == 0){
return;
}
@@ -196,7 +196,7 @@ void H265RtmpEncoder::inputFrame(const Frame::Ptr &frame) {
_lastPacket->type_id = MSG_VIDEO;
}
auto size = htonl(iLen);
uint32_t size = htonl((uint32_t)iLen);
_lastPacket->buffer.append((char *) &size, 4);
_lastPacket->buffer.append(pcData, iLen);
_lastPacket->body_size = _lastPacket->buffer.size();
@@ -221,7 +221,7 @@ void H265RtmpEncoder::makeVideoConfigPkt() {
string vps_sps_pps = string("\x00\x00\x00\x01", 4) + _vps +
string("\x00\x00\x00\x01", 4) + _sps +
string("\x00\x00\x00\x01", 4) + _pps;
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));
if (extra_data_size == -1) {

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
@@ -40,7 +40,7 @@ public:
}
protected:
void onGetH265(const char *pcData, int iLen, uint32_t dts,uint32_t pts);
void onGetH265(const char *pcData, size_t iLen, uint32_t dts,uint32_t pts);
H265Frame::Ptr obtainFrame();
protected:
@@ -73,14 +73,16 @@ public:
* 生成config包
*/
void makeConfigPacket() override;
private:
void makeVideoConfigPkt();
private:
bool _gotSpsPps = false;
string _vps;
string _sps;
string _pps;
H265Track::Ptr _track;
bool _gotSpsPps = false;
RtmpPacket::Ptr _lastPacket;
};

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
@@ -64,7 +64,7 @@ bool H265RtpDecoder::inputRtp(const RtpPacket::Ptr &rtp, bool key_pos) {
bool H265RtpDecoder::decodeRtp(const RtpPacket::Ptr &rtppack) {
const uint8_t *frame = (uint8_t *) rtppack->data() + rtppack->offset;
int length = rtppack->size() - rtppack->offset;
auto length = rtppack->size() - rtppack->offset;
int nal = H265_TYPE(frame[0]);
if (nal > 50){
@@ -154,7 +154,7 @@ void H265RtpEncoder::inputFrame(const Frame::Ptr &frame) {
auto len = frame->size() - frame->prefixSize();
auto pts = frame->pts() % cycleMS;
auto nal_type = H265_TYPE(ptr[0]); //获取NALU的5bit 帧类型
auto payload_size = _ui32MtuSize - 3;
size_t payload_size = _ui32MtuSize - 3;
//超过MTU,按照FU方式打包
if (len > payload_size + 2) {
@@ -162,7 +162,7 @@ void H265RtpEncoder::inputFrame(const Frame::Ptr &frame) {
unsigned char s_e_flags;
bool fu_start = true;
bool mark_bit = false;
int offset = 2;
size_t offset = 2;
while (!mark_bit) {
if (len <= offset + payload_size) {
//FU end
@@ -202,7 +202,7 @@ void H265RtpEncoder::inputFrame(const Frame::Ptr &frame) {
}
}
void H265RtpEncoder::makeH265Rtp(int nal_type,const void* data, unsigned int len, bool mark, bool first_packet, uint32_t uiStamp) {
void H265RtpEncoder::makeH265Rtp(int nal_type,const void* data, size_t len, bool mark, bool first_packet, uint32_t uiStamp) {
RtpCodec::inputRtp(makeRtp(getTrackType(),data,len,mark,uiStamp),first_packet && H265Frame::isKeyFrame(nal_type));
}

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
@@ -42,14 +42,16 @@ public:
CodecId getCodecId() const override{
return CodecH265;
}
private:
bool decodeRtp(const RtpPacket::Ptr &rtp);
void onGetH265(const H265Frame::Ptr &frame);
H265Frame::Ptr obtainFrame();
private:
int _lastSeq = 0;
H265Frame::Ptr _h265frame;
DtsGenerator _dts_generator;
int _lastSeq = 0;
};
/**
@@ -79,7 +81,7 @@ public:
*/
void inputFrame(const Frame::Ptr &frame) override;
private:
void makeH265Rtp(int nal_type,const void *pData, unsigned int uiLen, bool bMark, bool first_packet,uint32_t uiStamp);
void makeH265Rtp(int nal_type,const void *pData, size_t uiLen, bool bMark, bool first_packet,uint32_t uiStamp);
};
}//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

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

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) 2020 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
@@ -129,7 +129,7 @@ int HlsParser::getTargetDur() const {
return _target_dur;
}
int HlsParser::getSequence() const {
int64_t HlsParser::getSequence() const {
return _sequence;
}

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2020 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
@@ -68,7 +68,7 @@ public:
/**
* #EXT-X-MEDIA-SEQUENCE字段值该m3u8序号
*/
int getSequence() const;
int64_t getSequence() const;
/**
* 内部是否含有子m3u8

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2020 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
@@ -12,7 +12,7 @@
namespace mediakit {
HlsPlayer::HlsPlayer(const EventPoller::Ptr &poller){
_segment.setOnSegment([this](const char *data, uint64_t len) { onPacket(data, len); });
_segment.setOnSegment([this](const char *data, size_t len) { onPacket(data, len); });
setPoller(poller ? poller : EventPollerPool::Instance().getPoller());
}
@@ -28,7 +28,7 @@ void HlsPlayer::play_l(){
teardown_l(SockException(Err_shutdown, "所有hls url都尝试播放失败!"));
return;
}
float playTimeOutSec = (*this)[Client::kTimeoutMS].as<int>() / 1000.0;
float playTimeOutSec = (*this)[Client::kTimeoutMS].as<int>() / 1000.0f;
setMethod("GET");
if(!(*this)[kNetAdapter].empty()) {
setNetAdapter((*this)[kNetAdapter]);
@@ -83,7 +83,7 @@ void HlsPlayer::playNextTs(bool force){
strongSelf->playNextTs(true);
} else {
//下一个切片慢点播放
strongSelf->_timer_ts.reset(new Timer(delay / 1000.0, [weakSelf, delay]() {
strongSelf->_timer_ts.reset(new Timer(delay / 1000.0f, [weakSelf, delay]() {
auto strongSelf = weakSelf.lock();
if (!strongSelf) {
return false;
@@ -94,7 +94,7 @@ void HlsPlayer::playNextTs(bool force){
}
});
_http_ts_player->setOnPacket([weakSelf](const char *data, uint64_t len) {
_http_ts_player->setOnPacket([weakSelf](const char *data, size_t len) {
auto strongSelf = weakSelf.lock();
if (!strongSelf) {
return;
@@ -153,7 +153,7 @@ void HlsPlayer::onParsed(bool is_m3u8_inner,int64_t sequence,const map<int,ts_se
}
}
int64_t HlsPlayer::onResponseHeader(const string &status, const HttpClient::HttpHeader &headers) {
size_t HlsPlayer::onResponseHeader(const string &status, const HttpClient::HttpHeader &headers) {
if (status != "200" && status != "206") {
//失败
teardown_l(SockException(Err_shutdown, StrPrinter << "bad http status code:" + status));
@@ -164,7 +164,7 @@ int64_t HlsPlayer::onResponseHeader(const string &status, const HttpClient::Http
return -1;
}
void HlsPlayer::onResponseBody(const char *buf, int64_t size, int64_t recvedSize, int64_t totalSize) {
void HlsPlayer::onResponseBody(const char *buf, size_t size, size_t recvedSize, size_t totalSize) {
if (recvedSize == size) {
//刚开始
_m3u8.clear();
@@ -186,9 +186,9 @@ void HlsPlayer::onResponseCompleted() {
float HlsPlayer::delaySecond(){
if (HlsParser::isM3u8() && HlsParser::getTargetDur() > 0) {
return HlsParser::getTargetDur();
return (float)HlsParser::getTargetDur();
}
return 1;
return 1.0f;
}
void HlsPlayer::onDisconnect(const SockException &ex) {
@@ -232,7 +232,7 @@ void HlsPlayer::playDelay(){
}, getPoller()));
}
void HlsPlayer::onPacket_l(const char *data, uint64_t len){
void HlsPlayer::onPacket_l(const char *data, size_t len){
_segment.input(data,len);
}
@@ -246,7 +246,7 @@ void HlsPlayerImp::setOnPacket(const TSSegment::onSegment &cb){
_on_ts = cb;
}
void HlsPlayerImp::onPacket(const char *data,uint64_t len) {
void HlsPlayerImp::onPacket(const char *data,size_t len) {
if (_on_ts) {
_on_ts(data, len);
}
@@ -276,7 +276,7 @@ void HlsPlayerImp::onPlayResult(const SockException &ex) {
weak_ptr<HlsPlayerImp> weakSelf = dynamic_pointer_cast<HlsPlayerImp>(shared_from_this());
//每50毫秒执行一次
_timer = std::make_shared<Timer>(0.05, [weakSelf]() {
_timer = std::make_shared<Timer>(0.05f, [weakSelf]() {
auto strongSelf = weakSelf.lock();
if (!strongSelf) {
return false;

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2020 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
@@ -46,7 +46,7 @@ protected:
* @param data ts数据负载
* @param len ts包长度
*/
virtual void onPacket(const char *data, uint64_t len) = 0;
virtual void onPacket(const char *data, size_t len) = 0;
private:
/**
@@ -63,7 +63,7 @@ private:
* @return 返回后续content的长度-1:后续数据全是content>=0:固定长度content
* 需要指出的是在http头中带有Content-Length字段时该返回值无效
*/
int64_t onResponseHeader(const string &status,const HttpHeader &headers) override;
size_t onResponseHeader(const string &status,const HttpHeader &headers) override;
/**
* 收到http conten数据
* @param buf 数据指针
@@ -71,7 +71,7 @@ private:
* @param recvedSize 已收数据大小(包含本次数据大小),当其等于totalSize时将触发onResponseCompleted回调
* @param totalSize 总数据大小
*/
void onResponseBody(const char *buf,int64_t size,int64_t recvedSize,int64_t totalSize) override;
void onResponseBody(const char *buf,size_t size,size_t recvedSize,size_t totalSize) override;
/**
* 接收http回复完毕,
@@ -98,7 +98,7 @@ private:
void playNextTs(bool force = false);
void teardown_l(const SockException &ex);
void play_l();
void onPacket_l(const char *data, uint64_t len);
void onPacket_l(const char *data, size_t len);
private:
struct UrlComp {
@@ -131,7 +131,7 @@ public:
void setOnPacket(const TSSegment::onSegment &cb);
private:
void onPacket(const char *data, uint64_t len) override;
void onPacket(const char *data, size_t len) override;
void onAllTrackReady() override;
void onPlayResult(const SockException &ex) override;
vector<Track::Ptr> getTracks(bool trackReady = true) const override;

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
@@ -26,11 +26,12 @@ namespace mediakit {
HttpStringBody::HttpStringBody(const string &str){
_str = str;
}
uint64_t HttpStringBody::remainSize() {
size_t HttpStringBody::remainSize() {
return _str.size() - _offset;
}
Buffer::Ptr HttpStringBody::readData(uint32_t size) {
Buffer::Ptr HttpStringBody::readData(size_t size) {
size = MIN(remainSize(),size);
if(!size){
//没有剩余字节了
@@ -55,11 +56,19 @@ HttpFileBody::HttpFileBody(const string &filePath){
}
}
HttpFileBody::HttpFileBody(const std::shared_ptr<FILE> &fp, uint64_t offset, uint64_t max_size) {
HttpFileBody::HttpFileBody(const std::shared_ptr<FILE> &fp, size_t offset, size_t max_size) {
init(fp,offset,max_size);
}
void HttpFileBody::init(const std::shared_ptr<FILE> &fp,uint64_t offset,uint64_t max_size){
#if defined(_WIN32) || defined(_WIN64)
#define fseek64 _fseeki64
#define ftell64 _ftelli64
#else
#define fseek64 fseek
#define ftell64 ftell
#endif
void HttpFileBody::init(const std::shared_ptr<FILE> &fp,size_t offset, size_t max_size){
_fp = fp;
_max_size = max_size;
#ifdef ENABLE_MMAP
@@ -85,7 +94,7 @@ void HttpFileBody::init(const std::shared_ptr<FILE> &fp,uint64_t offset,uint64_t
#endif
if(!_map_addr && offset && fp.get()){
//未映射,那么fseek设置偏移量
fseek(fp.get(), offset, SEEK_SET);
fseek64(fp.get(), offset, SEEK_SET);
}
}
@@ -93,30 +102,30 @@ void HttpFileBody::init(const std::shared_ptr<FILE> &fp,uint64_t offset,uint64_t
class BufferMmap : public Buffer{
public:
typedef std::shared_ptr<BufferMmap> Ptr;
BufferMmap(const std::shared_ptr<char> &map_addr,uint64_t offset,int size){
BufferMmap(const std::shared_ptr<char> &map_addr, size_t offset, size_t size) {
_map_addr = map_addr;
_data = map_addr.get() + offset;
_size = size;
};
virtual ~BufferMmap(){};
}
~BufferMmap() override{};
//返回数据长度
char *data() const override {
return _data;
}
uint32_t size() const override{
size_t size() const override{
return _size;
}
private:
std::shared_ptr<char> _map_addr;
char *_data;
uint32_t _size;
size_t _size;
};
uint64_t HttpFileBody::remainSize() {
size_t HttpFileBody::remainSize() {
return _max_size - _offset;
}
Buffer::Ptr HttpFileBody::readData(uint32_t size) {
Buffer::Ptr HttpFileBody::readData(size_t size) {
size = MIN(remainSize(),size);
if(!size){
//没有剩余字节了
@@ -124,7 +133,7 @@ Buffer::Ptr HttpFileBody::readData(uint32_t size) {
}
if(!_map_addr){
//fread模式
int iRead;
size_t iRead;
auto ret = _pool.obtain();
ret->setCapacity(size + 1);
do{
@@ -171,11 +180,11 @@ HttpMultiFormBody::HttpMultiFormBody(const HttpArgs &args,const string &filePath
_totalSize = _bodyPrefix.size() + _bodySuffix.size() + _fileBody->remainSize();
}
uint64_t HttpMultiFormBody::remainSize() {
size_t HttpMultiFormBody::remainSize() {
return _totalSize - _offset;
}
Buffer::Ptr HttpMultiFormBody::readData(uint32_t size){
Buffer::Ptr HttpMultiFormBody::readData(size_t size){
if(_bodyPrefix.size()){
auto ret = std::make_shared<BufferString>(_bodyPrefix);
_offset += _bodyPrefix.size();
@@ -212,11 +221,11 @@ string HttpMultiFormBody::multiFormBodySuffix(const string &boundary){
return body;
}
uint64_t HttpMultiFormBody::fileSize(FILE *fp) {
auto current = ftell(fp);
fseek(fp,0L,SEEK_END); /* 定位到文件末尾 */
auto end = ftell(fp); /* 得到文件大小 */
fseek(fp,current,SEEK_SET);
size_t HttpMultiFormBody::fileSize(FILE *fp) {
auto current = ftell64(fp);
fseek64(fp, 0L, SEEK_END); /* 定位到文件末尾 */
auto end = ftell64(fp); /* 得到文件大小 */
fseek64(fp, current, SEEK_SET);
return end - current;
}

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
@@ -33,52 +33,33 @@ namespace mediakit {
class HttpBody : public std::enable_shared_from_this<HttpBody>{
public:
typedef std::shared_ptr<HttpBody> Ptr;
HttpBody(){
// _async_read_thread = WorkThreadPool::Instance().getPoller();
}
HttpBody(){}
virtual ~HttpBody(){}
/**
* 剩余数据大小,如果返回>=INT64_MAX, 那么就不设置content-length
* 剩余数据大小,如果返回-1, 那么就不设置content-length
*/
virtual uint64_t remainSize() { return 0;};
virtual size_t remainSize() { return 0;};
/**
* 读取一定字节数返回大小可能小于size
* @param size 请求大小
* @return 字节对象,如果读完了那么请返回nullptr
*/
virtual Buffer::Ptr readData(uint32_t size) { return nullptr;};
virtual Buffer::Ptr readData(size_t size) { return nullptr;};
/**
* 异步请求读取一定字节数返回大小可能小于size
* @param size 请求大小
* @param cb 回调函数
*/
virtual void readDataAsync(uint32_t size,const function<void(const Buffer::Ptr &buf)> &cb){
#if 0
if(size >= remainSize()){
//假如剩余数据很小,那么同步获取(为了优化性能)
cb(readData(size));
return;
}
//如果是大文件,那么后台读取
weak_ptr<HttpBody> weakSelf = shared_from_this();
_async_read_thread->async([cb,size,weakSelf](){
auto strongSelf = weakSelf.lock();
if(strongSelf){
cb(strongSelf->readData(size));
}
});
#else
virtual void readDataAsync(size_t size,const function<void(const Buffer::Ptr &buf)> &cb){
//由于unix和linux是通过mmap的方式读取文件所以把读文件操作放在后台线程并不能提高性能
//反而会由于频繁的线程切换导致性能降低以及延时增加,所以我们默认同步获取文件内容
//(其实并没有读,拷贝文件数据时在内核态完成文件读)
cb(readData(size));
#endif
}
private:
// EventPoller::Ptr _async_read_thread;
};
/**
@@ -89,11 +70,12 @@ public:
typedef std::shared_ptr<HttpStringBody> Ptr;
HttpStringBody(const string &str);
virtual ~HttpStringBody(){}
uint64_t remainSize() override ;
Buffer::Ptr readData(uint32_t size) override ;
size_t remainSize() override;
Buffer::Ptr readData(size_t size) override ;
private:
size_t _offset = 0;
mutable string _str;
uint64_t _offset = 0;
};
/**
@@ -109,18 +91,20 @@ public:
* @param offset 相对文件头的偏移量
* @param max_size 最大读取字节数,未判断是否大于文件真实大小
*/
HttpFileBody(const std::shared_ptr<FILE> &fp,uint64_t offset,uint64_t max_size);
HttpFileBody(const std::shared_ptr<FILE> &fp,size_t offset,size_t max_size);
HttpFileBody(const string &file_path);
~HttpFileBody(){};
uint64_t remainSize() override ;
Buffer::Ptr readData(uint32_t size) override;
size_t remainSize() override ;
Buffer::Ptr readData(size_t size) override;
private:
void init(const std::shared_ptr<FILE> &fp,uint64_t offset,uint64_t max_size);
void init(const std::shared_ptr<FILE> &fp,size_t offset,size_t max_size);
private:
size_t _max_size;
size_t _offset = 0;
std::shared_ptr<FILE> _fp;
uint64_t _max_size;
uint64_t _offset = 0;
std::shared_ptr<char> _map_addr;
ResourcePool<BufferRaw> _pool;
};
@@ -142,18 +126,20 @@ public:
*/
HttpMultiFormBody(const HttpArgs &args,const string &filePath,const string &boundary = "0xKhTmLbOuNdArY");
virtual ~HttpMultiFormBody(){}
uint64_t remainSize() override ;
Buffer::Ptr readData(uint32_t size) override;
size_t remainSize() override ;
Buffer::Ptr readData(size_t size) override;
public:
static string multiFormBodyPrefix(const HttpArgs &args,const string &boundary,const string &fileName);
static string multiFormBodySuffix(const string &boundary);
static uint64_t fileSize(FILE *fp);
static size_t fileSize(FILE *fp);
static string multiFormContentType(const string &boundary);
private:
size_t _offset = 0;
size_t _totalSize;
string _bodyPrefix;
string _bodySuffix;
uint64_t _offset = 0;
uint64_t _totalSize;
HttpFileBody::Ptr _fileBody;
};

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
@@ -13,7 +13,7 @@
namespace mediakit{
const char *HttpChunkedSplitter::onSearchPacketTail(const char *data, uint64_t len) {
const char *HttpChunkedSplitter::onSearchPacketTail(const char *data, size_t len) {
auto pos = strstr(data,"\r\n");
if(!pos){
return nullptr;
@@ -21,11 +21,11 @@ const char *HttpChunkedSplitter::onSearchPacketTail(const char *data, uint64_t l
return pos + 2;
}
void HttpChunkedSplitter::onRecvContent(const char *data, uint64_t len) {
void HttpChunkedSplitter::onRecvContent(const char *data, size_t len) {
onRecvChunk(data,len - 2);
}
int64_t HttpChunkedSplitter::onRecvHeader(const char *data, uint64_t len) {
size_t HttpChunkedSplitter::onRecvHeader(const char *data, size_t len) {
string str(data,len - 2);
int ret;
sscanf(str.data(),"%X",&ret);

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,22 +21,25 @@ public:
/**
* len == 0时代表结束
*/
typedef std::function<void (const char *data,uint64_t len)> onChunkData;
typedef std::function<void (const char *data,size_t len)> onChunkData;
HttpChunkedSplitter(const onChunkData &cb){
_onChunkData = cb;
};
~HttpChunkedSplitter() override {} ;
protected:
int64_t onRecvHeader(const char *data,uint64_t len) override;
void onRecvContent(const char *data,uint64_t len) override;
const char *onSearchPacketTail(const char *data,uint64_t len) override;
size_t onRecvHeader(const char *data,size_t len) override;
void onRecvContent(const char *data,size_t len) override;
const char *onSearchPacketTail(const char *data,size_t len) override;
protected:
virtual void onRecvChunk(const char *data,uint64_t len){
virtual void onRecvChunk(const char *data,size_t len){
if(_onChunkData){
_onChunkData(data,len);
}
};
private:
onChunkData _onChunkData;
};

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
@@ -129,7 +129,7 @@ void HttpClient::onErr(const SockException &ex) {
onDisconnect(ex);
}
int64_t HttpClient::onRecvHeader(const char *data, uint64_t len) {
size_t HttpClient::onRecvHeader(const char *data, size_t len) {
_parser.Parse(data);
if(_parser.Url() == "302" || _parser.Url() == "301"){
auto newUrl = _parser["Location"];
@@ -156,7 +156,7 @@ int64_t HttpClient::onRecvHeader(const char *data, uint64_t len) {
if(_parser["Transfer-Encoding"] == "chunked"){
//如果Transfer-Encoding字段等于chunked则认为后续的content是不限制长度的
_totalBodySize = -1;
_chunkedSplitter = std::make_shared<HttpChunkedSplitter>([this](const char *data,uint64_t len){
_chunkedSplitter = std::make_shared<HttpChunkedSplitter>([this](const char *data,size_t len){
if(len > 0){
auto recvedBodySize = _recvedBodySize + len;
onResponseBody(data, len, recvedBodySize, INT64_MAX);
@@ -181,7 +181,7 @@ int64_t HttpClient::onRecvHeader(const char *data, uint64_t len) {
return -1;
}
void HttpClient::onRecvContent(const char *data, uint64_t len) {
void HttpClient::onRecvContent(const char *data, size_t len) {
if(_chunkedSplitter){
_chunkedSplitter->input(data,len);
return;

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
@@ -110,7 +110,7 @@ protected:
* @return 返回后续content的长度-1:后续数据全是content>=0:固定长度content
* 需要指出的是在http头中带有Content-Length字段时该返回值无效
*/
virtual int64_t onResponseHeader(const string &status,const HttpHeader &headers){
virtual size_t onResponseHeader(const string &status,const HttpHeader &headers){
DebugL << status;
//无Content-Length字段时默认后面全是content
return -1;
@@ -123,7 +123,7 @@ protected:
* @param recvedSize 已收数据大小(包含本次数据大小),当其等于totalSize时将触发onResponseCompleted回调
* @param totalSize 总数据大小
*/
virtual void onResponseBody(const char *buf,int64_t size,int64_t recvedSize,int64_t totalSize){
virtual void onResponseBody(const char *buf,size_t size,size_t recvedSize,size_t totalSize){
DebugL << size << " " << recvedSize << " " << totalSize;
};
@@ -149,19 +149,23 @@ protected:
virtual bool onRedirectUrl(const string &url,bool temporary){ return true;};
//HttpRequestSplitter override
int64_t onRecvHeader(const char *data,uint64_t len) override ;
void onRecvContent(const char *data,uint64_t len) override;
size_t onRecvHeader(const char *data,size_t len) override;
void onRecvContent(const char *data,size_t len) override;
protected:
virtual void onConnect(const SockException &ex) override;
virtual void onRecv(const Buffer::Ptr &pBuf) override;
virtual void onErr(const SockException &ex) override;
virtual void onFlush() override;
virtual void onManager() override;
private:
void onResponseCompleted_l();
void checkCookie(HttpHeader &headers );
protected:
bool _isHttps;
private:
string _url;
HttpHeader _header;
@@ -169,8 +173,8 @@ private:
string _method;
string _path;
//recv
int64_t _recvedBodySize;
int64_t _totalBodySize;
size_t _recvedBodySize;
size_t _totalBodySize;
Parser _parser;
string _lastHost;
Ticker _aliveTicker;

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

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
@@ -25,7 +25,7 @@ void HttpCookie::setPath(const string &path){
void HttpCookie::setHost(const string &host){
_host = host;
}
static uint32_t timeStrToInt(const string &date){
static time_t timeStrToInt(const string &date){
struct tm tt;
strptime(date.data(),"%a, %b %d %Y %H:%M:%S %Z",&tt);
return mktime(&tt);
@@ -34,7 +34,6 @@ void HttpCookie::setExpires(const string &expires,const string &server_date){
_expire = timeStrToInt(expires);
if(!server_date.empty()){
_expire = time(NULL) + (_expire - timeStrToInt(server_date));
// DebugL << (timeStrToInt(expires) - timeStrToInt(server_date)) / 60;
}
}
void HttpCookie::setKeyVal(const string &key,const string &val){

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
@@ -42,9 +42,9 @@ public:
private:
string _host;
string _path = "/";
uint32_t _expire = 0;
string _key;
string _val;
time_t _expire = 0;
};

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 @@ INSTANCE_IMP(HttpCookieManager);
HttpCookieManager::HttpCookieManager() {
//定时删除过期的cookie防止内存膨胀
_timer = std::make_shared<Timer>(10,[this](){
_timer = std::make_shared<Timer>(10.0f,[this](){
onManager();
return true;
}, 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
@@ -47,7 +47,7 @@ void HttpDownloader::startDownload(const string& url, const string& filePath,boo
sendRequest(url,timeOutSecond);
}
int64_t HttpDownloader::onResponseHeader(const string& status,const HttpHeader& headers) {
size_t HttpDownloader::onResponseHeader(const string& status,const HttpHeader& headers) {
if(status != "200" && status != "206"){
//失败
shutdown(SockException(Err_shutdown,StrPrinter << "Http Status:" << status));
@@ -56,7 +56,7 @@ int64_t HttpDownloader::onResponseHeader(const string& status,const HttpHeader&
return -1;
}
void HttpDownloader::onResponseBody(const char* buf, int64_t size, int64_t recvedSize, int64_t totalSize) {
void HttpDownloader::onResponseBody(const char* buf, size_t size, size_t recvedSize, size_t totalSize) {
if(_saveFile){
fwrite(buf,size,1,_saveFile);
}

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,11 +31,12 @@ public:
_onResult = cb;
}
private:
int64_t onResponseHeader(const string &status,const HttpHeader &headers) override;
void onResponseBody(const char *buf,int64_t size,int64_t recvedSize,int64_t totalSize) override;
size_t onResponseHeader(const string &status, const HttpHeader &headers) override;
void onResponseBody(const char *buf, size_t size, size_t recvedSize, size_t totalSize) override;
void onResponseCompleted() override;
void onDisconnect(const SockException &ex) override;
void closeFile();
private:
FILE *_saveFile = nullptr;
string _filePath;

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
@@ -564,9 +564,9 @@ void HttpResponseInvokerImp::responseFile(const StrCaseMap &requestHeader,
}
auto &strRange = const_cast<StrCaseMap &>(requestHeader)["Range"];
int64_t iRangeStart = 0;
int64_t iRangeEnd = 0;
int64_t fileSize = HttpMultiFormBody::fileSize(fp.get());
size_t iRangeStart = 0;
size_t iRangeEnd = 0;
size_t fileSize = HttpMultiFormBody::fileSize(fp.get());
int code;
if (strRange.size() == 0) {

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
@@ -15,7 +15,7 @@ using namespace toolkit;
namespace mediakit {
void HttpRequestSplitter::input(const char *data,uint64_t len) {
void HttpRequestSplitter::input(const char *data,size_t len) {
const char *ptr = data;
if(!_remain_data.empty()){
_remain_data.append(data,len);
@@ -44,7 +44,7 @@ void HttpRequestSplitter::input(const char *data,uint64_t len) {
}
//_content_len == 0这是请求头
const char *header_ptr = ptr;
int64_t header_size = index - ptr;
auto header_size = index - ptr;
ptr = index;
_remain_data_size = len - (ptr - data);
_content_len = onRecvHeader(header_ptr, header_size);
@@ -101,7 +101,7 @@ void HttpRequestSplitter::input(const char *data,uint64_t len) {
_remain_data.clear();
}
void HttpRequestSplitter::setContentLen(int64_t content_len) {
void HttpRequestSplitter::setContentLen(size_t content_len) {
_content_len = content_len;
}
@@ -111,7 +111,7 @@ void HttpRequestSplitter::reset() {
_remain_data.clear();
}
const char *HttpRequestSplitter::onSearchPacketTail(const char *data,uint64_t len) {
const char *HttpRequestSplitter::onSearchPacketTail(const char *data,size_t len) {
auto pos = strstr(data,"\r\n\r\n");
if(pos == nullptr){
return nullptr;
@@ -119,7 +119,7 @@ const char *HttpRequestSplitter::onSearchPacketTail(const char *data,uint64_t le
return pos + 4;
}
int64_t HttpRequestSplitter::remainDataSize() {
size_t HttpRequestSplitter::remainDataSize() {
return _remain_data_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
@@ -28,7 +28,8 @@ public:
* @param data 需要添加的数据
* @param len 数据长度
*/
virtual void input(const char *data,uint64_t len);
virtual void input(const char *data,size_t len);
protected:
/**
* 收到请求头
@@ -40,7 +41,7 @@ protected:
* 0 : 代表为后面数据还是请求头,
* >0 : 代表后面数据为固定长度content,此时将缓存content并等到所有content接收完毕一次性通过onRecvContent函数回调出去
*/
virtual int64_t onRecvHeader(const char *data,uint64_t len) = 0;
virtual size_t onRecvHeader(const char *data,size_t len) = 0;
/**
* 收到content分片或全部数据
@@ -48,7 +49,7 @@ protected:
* @param data content分片或全部数据
* @param len 数据长度
*/
virtual void onRecvContent(const char *data,uint64_t len) {};
virtual void onRecvContent(const char *data,size_t len) {};
/**
* 判断数据中是否有包尾
@@ -56,12 +57,12 @@ protected:
* @param len 数据长度
* @return nullptr代表未找到包位否则返回包尾指针
*/
virtual const char *onSearchPacketTail(const char *data, uint64_t len);
virtual const char *onSearchPacketTail(const char *data, size_t len);
/**
* 设置content len
*/
void setContentLen(int64_t content_len);
void setContentLen(size_t content_len);
/**
* 恢复初始设置
@@ -71,11 +72,12 @@ protected:
/**
* 剩余数据大小
*/
int64_t remainDataSize();
size_t remainDataSize();
private:
size_t _content_len = 0;
size_t _remain_data_size = 0;
BufferLikeString _remain_data;
int64_t _content_len = 0;
int64_t _remain_data_size = 0;
};
} /* 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
@@ -19,13 +19,13 @@ HttpRequester::~HttpRequester(){
}
int64_t HttpRequester::onResponseHeader(const string &status,const HttpHeader &headers) {
size_t HttpRequester::onResponseHeader(const string &status,const HttpHeader &headers) {
_strRecvBody.clear();
//无Content-Length字段时默认后面没有content
return 0;
}
void HttpRequester::onResponseBody(const char *buf,int64_t size,int64_t recvedSize,int64_t totalSize) {
void HttpRequester::onResponseBody(const char *buf,size_t size,size_t recvedSize,size_t totalSize) {
_strRecvBody.append(buf,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
@@ -26,8 +26,8 @@ public:
void startRequester(const string &url,const HttpRequesterResult &onResult,float timeOutSecond = 10);
void clear() override ;
private:
int64_t onResponseHeader(const string &status,const HttpHeader &headers) override;
void onResponseBody(const char *buf,int64_t size,int64_t recvedSize,int64_t totalSize) override;
size_t onResponseHeader(const string &status,const HttpHeader &headers) override;
void onResponseBody(const char *buf,size_t size,size_t recvedSize,size_t totalSize) override;
void onResponseCompleted() override;
void onDisconnect(const SockException &ex) override;
private:

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,15 +31,15 @@ HttpSession::~HttpSession() {
TraceP(this);
}
void HttpSession::Handle_Req_HEAD(int64_t &content_len){
void HttpSession::Handle_Req_HEAD(size_t &content_len){
//暂时全部返回200 OK因为HTTP GET存在按需生成流的操作所以不能按照HTTP GET的流程返回
//如果直接返回404那么又会导致按需生成流的逻辑失效所以HTTP HEAD在静态文件或者已存在资源时才有效
//对于按需生成流的直播场景并不适用
sendResponse(200, true);
}
int64_t HttpSession::onRecvHeader(const char *header,uint64_t len) {
typedef void (HttpSession::*HttpCMDHandle)(int64_t &);
size_t HttpSession::onRecvHeader(const char *header,size_t len) {
typedef void (HttpSession::*HttpCMDHandle)(size_t &);
static unordered_map<string, HttpCMDHandle> s_func_map;
static onceToken token([]() {
s_func_map.emplace("GET",&HttpSession::Handle_Req_GET);
@@ -61,7 +61,7 @@ int64_t HttpSession::onRecvHeader(const char *header,uint64_t len) {
_origin = _parser["Origin"];
//默认后面数据不是content而是header
int64_t content_len = 0;
size_t content_len = 0;
auto &fun = it->second;
try {
(this->*fun)(content_len);
@@ -75,7 +75,7 @@ int64_t HttpSession::onRecvHeader(const char *header,uint64_t len) {
return content_len;
}
void HttpSession::onRecvContent(const char *data,uint64_t len) {
void HttpSession::onRecvContent(const char *data,size_t len) {
if(_contentCallBack){
if(!_contentCallBack(data,len)){
_contentCallBack = nullptr;
@@ -271,8 +271,8 @@ bool HttpSession::checkLiveStreamFMP4(const function<void()> &cb){
//本对象已经销毁
return;
}
int i = 0;
int size = fmp4_list->size();
size_t i = 0;
auto size = fmp4_list->size();
fmp4_list->for_each([&](const FMP4Packet::Ptr &ts) {
strong_self->onWrite(ts, ++i == size);
});
@@ -311,8 +311,8 @@ bool HttpSession::checkLiveStreamTS(const function<void()> &cb){
//本对象已经销毁
return;
}
int i = 0;
int size = ts_list->size();
size_t i = 0;
auto size = ts_list->size();
ts_list->for_each([&](const TSPacket::Ptr &ts) {
strong_self->onWrite(ts, ++i == size);
});
@@ -353,15 +353,15 @@ bool HttpSession::checkLiveStreamFlv(const function<void()> &cb){
});
}
void HttpSession::Handle_Req_GET(int64_t &content_len) {
void HttpSession::Handle_Req_GET(size_t &content_len) {
Handle_Req_GET_l(content_len, true);
}
void HttpSession::Handle_Req_GET_l(int64_t &content_len, bool sendBody) {
void HttpSession::Handle_Req_GET_l(size_t &content_len, bool sendBody) {
//先看看是否为WebSocket请求
if (checkWebSocket()) {
content_len = -1;
_contentCallBack = [this](const char *data, uint64_t len) {
_contentCallBack = [this](const char *data, size_t len) {
WebSocketSplitter::decode((uint8_t *) data, len);
//_contentCallBack是可持续的后面还要处理后续数据
return true;
@@ -506,7 +506,7 @@ void HttpSession::sendResponse(int code,
GET_CONFIG(uint32_t,keepAliveSec,Http::kKeepAliveSecond);
//body默认为空
int64_t size = 0;
size_t size = 0;
if (body && body->remainSize()) {
//有body获取body大小
size = body->remainSize();
@@ -515,7 +515,7 @@ void HttpSession::sendResponse(int code,
if(no_content_length){
//http-flv直播是Keep-Alive类型
bClose = false;
}else if(size >= INT64_MAX){
}else if(size >= INT64_MAX || size < 0 ){
//不固定长度的body那么发送完body后应该关闭socket以便浏览器做下载完毕的判断
bClose = true;
}
@@ -642,10 +642,10 @@ bool HttpSession::emitHttpEvent(bool doInvoke){
return consumed;
}
void HttpSession::Handle_Req_POST(int64_t &content_len) {
GET_CONFIG(uint64_t,maxReqSize,Http::kMaxReqSize);
void HttpSession::Handle_Req_POST(size_t &content_len) {
GET_CONFIG(size_t,maxReqSize,Http::kMaxReqSize);
int64_t totalContentLen = _parser["Content-Length"].empty() ? -1 : atoll(_parser["Content-Length"].data());
size_t totalContentLen = _parser["Content-Length"].empty() ? -1 : atoll(_parser["Content-Length"].data());
if(totalContentLen == 0){
//content为空
@@ -658,7 +658,7 @@ void HttpSession::Handle_Req_POST(int64_t &content_len) {
//返回固定长度的content
content_len = totalContentLen;
auto parserCopy = _parser;
_contentCallBack = [this,parserCopy](const char *data,uint64_t len){
_contentCallBack = [this,parserCopy](const char *data,size_t len){
//恢复http头
_parser = parserCopy;
//设置content
@@ -674,10 +674,10 @@ void HttpSession::Handle_Req_POST(int64_t &content_len) {
//返回不固定长度的content
content_len = -1;
auto parserCopy = _parser;
std::shared_ptr<uint64_t> recvedContentLen = std::make_shared<uint64_t>(0);
std::shared_ptr<size_t> recvedContentLen = std::make_shared<uint64_t>(0);
bool bClose = !strcasecmp(_parser["Connection"].data(),"close");
_contentCallBack = [this,parserCopy,totalContentLen,recvedContentLen,bClose](const char *data,uint64_t len){
_contentCallBack = [this,parserCopy,totalContentLen,recvedContentLen,bClose](const char *data,size_t len){
*(recvedContentLen) += len;
onRecvUnlimitedContent(parserCopy,data,len,totalContentLen,*(recvedContentLen));

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
@@ -57,8 +57,8 @@ protected:
std::shared_ptr<FlvMuxer> getSharedPtr() override;
//HttpRequestSplitter override
int64_t onRecvHeader(const char *data,uint64_t len) override;
void onRecvContent(const char *data,uint64_t len) override;
size_t onRecvHeader(const char *data,size_t len) override;
void onRecvContent(const char *data,size_t len) override;
/**
* 重载之用于处理不定长度的content
@@ -71,9 +71,9 @@ protected:
*/
virtual void onRecvUnlimitedContent(const Parser &header,
const char *data,
uint64_t len,
uint64_t totalSize,
uint64_t recvedSize){
size_t len,
size_t totalSize,
size_t recvedSize){
shutdown(SockException(Err_shutdown,"http post content is too huge,default closed"));
}
@@ -101,10 +101,10 @@ protected:
void onWebSocketDecodeComplete(const WebSocketHeader &header_in) override;
private:
void Handle_Req_GET(int64_t &content_len);
void Handle_Req_GET_l(int64_t &content_len, bool sendBody);
void Handle_Req_POST(int64_t &content_len);
void Handle_Req_HEAD(int64_t &content_len);
void Handle_Req_GET(size_t &content_len);
void Handle_Req_GET_l(size_t &content_len, bool sendBody);
void Handle_Req_POST(size_t &content_len);
void Handle_Req_HEAD(size_t &content_len);
bool checkLiveStream(const string &schema, const string &url_suffix, const function<void(const MediaSource::Ptr &src)> &cb);
@@ -135,7 +135,7 @@ private:
TSMediaSource::RingType::RingReader::Ptr _ts_reader;
FMP4MediaSource::RingType::RingReader::Ptr _fmp4_reader;
//处理content数据的callback
function<bool (const char *data,uint64_t len) > _contentCallBack;
function<bool (const char *data,size_t len) > _contentCallBack;
};

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2020 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
@@ -13,13 +13,13 @@ namespace mediakit {
HttpTSPlayer::HttpTSPlayer(const EventPoller::Ptr &poller, bool split_ts){
_split_ts = split_ts;
_segment.setOnSegment([this](const char *data, uint64_t len) { onPacket(data, len); });
_segment.setOnSegment([this](const char *data, size_t len) { onPacket(data, len); });
setPoller(poller ? poller : EventPollerPool::Instance().getPoller());
}
HttpTSPlayer::~HttpTSPlayer() {}
int64_t HttpTSPlayer::onResponseHeader(const string &status, const HttpClient::HttpHeader &headers) {
size_t HttpTSPlayer::onResponseHeader(const string &status, const HttpClient::HttpHeader &headers) {
_status = status;
if (status != "200" && status != "206") {
//http状态码不符合预期
@@ -35,7 +35,7 @@ int64_t HttpTSPlayer::onResponseHeader(const string &status, const HttpClient::H
return -1;
}
void HttpTSPlayer::onResponseBody(const char *buf, int64_t size, int64_t recvedSize, int64_t totalSize) {
void HttpTSPlayer::onResponseBody(const char *buf, size_t size, size_t recvedSize, size_t totalSize) {
if (_status != "200" && _status != "206") {
return;
}
@@ -68,7 +68,7 @@ void HttpTSPlayer::onDisconnect(const SockException &ex) {
}
}
void HttpTSPlayer::onPacket(const char *data, uint64_t len) {
void HttpTSPlayer::onPacket(const char *data, size_t len) {
if (_on_segment) {
_on_segment(data, len);
}

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2020 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
@@ -33,13 +33,13 @@ public:
protected:
///HttpClient override///
int64_t onResponseHeader(const string &status,const HttpHeader &headers) override;
void onResponseBody(const char *buf,int64_t size,int64_t recvedSize,int64_t totalSize) override;
size_t onResponseHeader(const string &status,const HttpHeader &headers) override;
void onResponseBody(const char *buf,size_t size,size_t recvedSize,size_t totalSize) override;
void onResponseCompleted() override;
void onDisconnect(const SockException &ex) override ;
//收到ts包
virtual void onPacket(const char *data, uint64_t len);
virtual void onPacket(const char *data, size_t len);
private:
//是否为mpegts负载

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
@@ -32,7 +32,7 @@ class HttpWsClient;
template <typename ClientType,WebSocketHeader::Type DataType>
class ClientTypeImp : public ClientType {
public:
typedef function<int(const Buffer::Ptr &buf)> onBeforeSendCB;
typedef function<size_t (const Buffer::Ptr &buf)> onBeforeSendCB;
friend class HttpWsClient<ClientType,DataType>;
template<typename ...ArgsType>
@@ -43,7 +43,7 @@ protected:
/**
* 发送前拦截并打包为websocket协议
*/
int send(Buffer::Ptr buf) override{
size_t send(Buffer::Ptr buf) override{
if(_beforeSendCB){
return _beforeSendCB(buf);
}
@@ -120,7 +120,7 @@ protected:
* @return 返回后续content的长度-1:后续数据全是content>=0:固定长度content
* 需要指出的是在http头中带有Content-Length字段时该返回值无效
*/
int64_t onResponseHeader(const string &status,const HttpHeader &headers) override {
size_t onResponseHeader(const string &status,const HttpHeader &headers) override {
if(status == "101"){
auto Sec_WebSocket_Accept = encodeBase64(SHA1::encode_bin(_Sec_WebSocket_Key + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"));
if(Sec_WebSocket_Accept == const_cast<HttpHeader &>(headers)["Sec-WebSocket-Accept"]){
@@ -147,7 +147,7 @@ protected:
/**
* 接收websocket负载数据
*/
void onResponseBody(const char *buf,int64_t size,int64_t recvedSize,int64_t totalSize) override{
void onResponseBody(const char *buf,size_t size,size_t recvedSize,size_t totalSize) override{
if(_onRecv){
//完成websocket握手后拦截websocket数据并解析
_onRecv(buf, size);
@@ -220,7 +220,7 @@ protected:
* @param len 负载数据长度
* @param recved 已接收数据长度(包含本次数据长度)等于header._payload_len时则接受完毕
*/
void onWebSocketDecodePayload(const WebSocketHeader &header, const uint8_t *ptr, uint64_t len, uint64_t recved) override{
void onWebSocketDecodePayload(const WebSocketHeader &header, const uint8_t *ptr, size_t len, size_t recved) override{
_payload_section.append((char *)ptr,len);
}
@@ -316,7 +316,7 @@ private:
//触发连接成功事件
_delegate.onConnect(ex);
//拦截websocket数据接收
_onRecv = [this](const char *data, int len){
_onRecv = [this](const char *data, size_t len){
//解析websocket数据包
this->WebSocketSplitter::decode((uint8_t *)data, len);
};
@@ -337,7 +337,7 @@ private:
private:
string _Sec_WebSocket_Key;
function<void(const char *data, int len)> _onRecv;
function<void(const char *data, size_t len)> _onRecv;
ClientTypeImp<ClientType,DataType> &_delegate;
string _payload_section;
string _payload_cache;

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
@@ -19,7 +19,7 @@
*/
class SendInterceptor{
public:
typedef function<int(const Buffer::Ptr &buf)> onBeforeSendCB;
typedef function<size_t (const Buffer::Ptr &buf)> onBeforeSendCB;
SendInterceptor() = default;
virtual ~SendInterceptor() = default;
virtual void setOnBeforeSendCB(const onBeforeSendCB &cb) = 0;
@@ -35,7 +35,7 @@ public:
typedef std::shared_ptr<TcpSessionTypeImp> Ptr;
TcpSessionTypeImp(const Parser &header, const HttpSession &parent, const Socket::Ptr &pSock) :
_identifier(parent.getIdentifier()), TcpSessionType(pSock) {}
TcpSessionType(pSock), _identifier(parent.getIdentifier()) {}
~TcpSessionTypeImp() {}
@@ -53,7 +53,7 @@ protected:
* @param buf 需要截取的数据
* @return 数据字节数
*/
int send(Buffer::Ptr buf) override {
size_t send(Buffer::Ptr buf) override {
if (_beforeSendCB) {
return _beforeSendCB(buf);
}
@@ -65,8 +65,8 @@ protected:
}
private:
onBeforeSendCB _beforeSendCB;
string _identifier;
onBeforeSendCB _beforeSendCB;
};
template <typename TcpSessionType>
@@ -157,7 +157,7 @@ protected:
/**
* 收到websocket数据包负载
*/
void onWebSocketDecodePayload(const WebSocketHeader &packet,const uint8_t *ptr,uint64_t len,uint64_t recved) override {
void onWebSocketDecodePayload(const WebSocketHeader &packet,const uint8_t *ptr,size_t len,size_t recved) override {
_payload_section.append((char *)ptr,len);
}

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
@@ -53,7 +53,7 @@ do{ \
} \
}while(0) \
void WebSocketSplitter::decode(uint8_t *data,uint64_t len) {
void WebSocketSplitter::decode(uint8_t *data,size_t len) {
uint8_t *ptr = data;
if(!_got_header) {
//还没有获取数据头
@@ -107,9 +107,9 @@ begin_decode:
//进入后面逻辑代表已经获取到了webSocket协议头
uint64_t remain = len - (ptr - data);
auto remain = len - (ptr - data);
if(remain > 0){
uint64_t payload_slice_len = remain;
auto payload_slice_len = remain;
if(payload_slice_len + _payload_offset > _payload_len){
payload_slice_len = _payload_len - _payload_offset;
}
@@ -138,7 +138,7 @@ begin_decode:
_remain_data.clear();
}
void WebSocketSplitter::onPayloadData(uint8_t *data, uint64_t len) {
void WebSocketSplitter::onPayloadData(uint8_t *data, size_t len) {
if(_mask_flag){
for(int i = 0; i < len ; ++i,++data){
*(data) ^= _mask[(i + _mask_offset) % 4];
@@ -150,7 +150,7 @@ void WebSocketSplitter::onPayloadData(uint8_t *data, uint64_t len) {
void WebSocketSplitter::encode(const WebSocketHeader &header,const Buffer::Ptr &buffer) {
string ret;
uint64_t len = buffer ? buffer->size() : 0;
auto len = buffer ? buffer->size() : 0;
uint8_t byte = header._fin << 7 | ((header._reserved & 0x07) << 4) | (header._opcode & 0x0F) ;
ret.push_back(byte);
@@ -164,7 +164,7 @@ void WebSocketSplitter::encode(const WebSocketHeader &header,const Buffer::Ptr &
byte |= 126;
ret.push_back(byte);
auto len_low = htons(len);
uint16_t len_low = htons((uint16_t)len);
ret.append((char *)&len_low,2);
}else{
byte |= 127;

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
@@ -60,7 +60,7 @@ public:
uint8_t _reserved;
Type _opcode;
bool _mask_flag;
uint64_t _payload_len;
size_t _payload_len;
vector<uint8_t > _mask;
};
@@ -71,7 +71,7 @@ public:
template<typename ...ARGS>
WebSocketBuffer(WebSocketHeader::Type headType, bool fin, ARGS &&...args)
: _head_type(headType), _fin(fin), BufferString(std::forward<ARGS>(args)...) {}
: BufferString(std::forward<ARGS>(args)...), _fin(fin), _head_type(headType){}
~WebSocketBuffer() override {}
@@ -80,8 +80,8 @@ public:
bool isFinished() const { return _fin; };
private:
WebSocketHeader::Type _head_type;
bool _fin;
WebSocketHeader::Type _head_type;
};
class WebSocketSplitter : public WebSocketHeader{

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
@@ -70,7 +70,7 @@ string strCoding::UrlEncode(const string &str) {
string strCoding::UrlDecode(const string &str) {
string output = "";
char tmp[2];
int i = 0, len = str.length();
size_t i = 0, len = str.length();
while (i < len) {
if (str[i] == '%') {
if(i > len - 3){
@@ -138,10 +138,10 @@ string strCoding::GB2312ToUTF8(const string &str) {
auto len = str.size();
auto pText = str.data();
char buf[4] = { 0 };
int nLength = len * 3;
auto nLength = len * 3;
char* pOut = new char[nLength];
memset(pOut, 0, nLength);
int i = 0, j = 0;
size_t i = 0, j = 0;
while (i < len)
{
//如果是英文直接复制就可以

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

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

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
@@ -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

Some files were not shown because too many files have changed in this diff Show More