mirror of
https://gitee.com/xia-chu/ZLMediaKit.git
synced 2026-05-23 18:17:49 +08:00
Compare commits
2 Commits
d0eeba544a
...
a59809047c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a59809047c | ||
|
|
48c37d4f46 |
@ -327,6 +327,7 @@ API_EXPORT uint16_t API_CALL mk_ice_server_start(uint16_t port){
|
|||||||
iceServer_udp = std::make_shared<UdpServer>();
|
iceServer_udp = std::make_shared<UdpServer>();
|
||||||
iceServer_udp->start<IceSession>(port);
|
iceServer_udp->start<IceSession>(port);
|
||||||
iceServer_tcp->start<IceSession>(port);
|
iceServer_tcp->start<IceSession>(port);
|
||||||
|
return 0;
|
||||||
} catch (std::exception &ex) {
|
} catch (std::exception &ex) {
|
||||||
iceServer_udp = nullptr;
|
iceServer_udp = nullptr;
|
||||||
iceServer_tcp = nullptr;
|
iceServer_tcp = nullptr;
|
||||||
|
|||||||
@ -57,7 +57,7 @@ public:
|
|||||||
toolkit::Buffer::Ptr getExtraData() const override;
|
toolkit::Buffer::Ptr getExtraData() const override;
|
||||||
void setExtraData(const uint8_t *data, size_t size) override;
|
void setExtraData(const uint8_t *data, size_t size) override;
|
||||||
protected:
|
protected:
|
||||||
aom_av1_t _context = {0};
|
aom_av1_t _context {};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace mediakit
|
} // namespace mediakit
|
||||||
|
|||||||
@ -20,7 +20,7 @@ using namespace toolkit;
|
|||||||
namespace mediakit {
|
namespace mediakit {
|
||||||
|
|
||||||
Buffer::Ptr G711Track::getExtraData() const {
|
Buffer::Ptr G711Track::getExtraData() const {
|
||||||
struct wave_format_t wav = {0};
|
struct wave_format_t wav {};
|
||||||
wav.wFormatTag = getCodecId() == CodecG711A ? WAVE_FORMAT_ALAW : WAVE_FORMAT_MULAW;
|
wav.wFormatTag = getCodecId() == CodecG711A ? WAVE_FORMAT_ALAW : WAVE_FORMAT_MULAW;
|
||||||
wav.nChannels = getAudioChannel();
|
wav.nChannels = getAudioChannel();
|
||||||
wav.nSamplesPerSec = getAudioSampleRate();
|
wav.nSamplesPerSec = getAudioSampleRate();
|
||||||
|
|||||||
@ -28,7 +28,7 @@ void OpusTrack::setExtraData(const uint8_t *data, size_t size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Buffer::Ptr OpusTrack::getExtraData() const {
|
Buffer::Ptr OpusTrack::getExtraData() const {
|
||||||
struct opus_head_t opus = { 0 };
|
struct opus_head_t opus {};
|
||||||
opus.version = 1;
|
opus.version = 1;
|
||||||
opus.channels = getAudioChannel();
|
opus.channels = getAudioChannel();
|
||||||
opus.input_sample_rate = getAudioSampleRate();
|
opus.input_sample_rate = getAudioSampleRate();
|
||||||
|
|||||||
@ -41,7 +41,7 @@ public:
|
|||||||
toolkit::Buffer::Ptr getExtraData() const override;
|
toolkit::Buffer::Ptr getExtraData() const override;
|
||||||
void setExtraData(const uint8_t *data, size_t size) override;
|
void setExtraData(const uint8_t *data, size_t size) override;
|
||||||
private:
|
private:
|
||||||
webm_vpx_t _vpx = {0};
|
webm_vpx_t _vpx {};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace mediakit
|
} // namespace mediakit
|
||||||
|
|||||||
@ -334,7 +334,7 @@ bool VP8RtpEncoder::inputFrame(const Frame::Ptr &frame) {
|
|||||||
bool key = frame->keyFrame();
|
bool key = frame->keyFrame();
|
||||||
bool mark = false;
|
bool mark = false;
|
||||||
for (size_t pos = 0; pos < len; pos += pdu_size) {
|
for (size_t pos = 0; pos < len; pos += pdu_size) {
|
||||||
if (len - pos <= pdu_size) {
|
if (static_cast<int>(len - pos) <= pdu_size) {
|
||||||
pdu_size = len - pos;
|
pdu_size = len - pos;
|
||||||
mark = true;
|
mark = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -56,9 +56,6 @@ public:
|
|||||||
using Ptr = std::shared_ptr<VP8RtpEncoder>;
|
using Ptr = std::shared_ptr<VP8RtpEncoder>;
|
||||||
|
|
||||||
bool inputFrame(const Frame::Ptr &frame) override;
|
bool inputFrame(const Frame::Ptr &frame) override;
|
||||||
|
|
||||||
private:
|
|
||||||
uint16_t _pic_id = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}//namespace mediakit
|
}//namespace mediakit
|
||||||
|
|||||||
@ -41,7 +41,7 @@ public:
|
|||||||
toolkit::Buffer::Ptr getExtraData() const override;
|
toolkit::Buffer::Ptr getExtraData() const override;
|
||||||
void setExtraData(const uint8_t *data, size_t size) override;
|
void setExtraData(const uint8_t *data, size_t size) override;
|
||||||
private:
|
private:
|
||||||
webm_vpx_t _vpx = {0};
|
webm_vpx_t _vpx {};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace mediakit
|
} // namespace mediakit
|
||||||
|
|||||||
@ -297,7 +297,7 @@ bool VP9RtpEncoder::inputFrame(const Frame::Ptr &frame) {
|
|||||||
int pdu_size = getRtpInfo().getMaxSize() - nheader;
|
int pdu_size = getRtpInfo().getMaxSize() - nheader;
|
||||||
|
|
||||||
bool mark = false;
|
bool mark = false;
|
||||||
for (size_t pos = 0; pos < len; pos += pdu_size) {
|
for (int pos = 0; pos < len; pos += pdu_size) {
|
||||||
if (len - pos <= pdu_size) {
|
if (len - pos <= pdu_size) {
|
||||||
pdu_size = len - pos;
|
pdu_size = len - pos;
|
||||||
header[0] |= kEBit;
|
header[0] |= kEBit;
|
||||||
|
|||||||
@ -60,8 +60,8 @@ uint8_t getCodecFlags(CodecId cid) {
|
|||||||
#define XX(a, b, c) case a: return static_cast<uint8_t>(b);
|
#define XX(a, b, c) case a: return static_cast<uint8_t>(b);
|
||||||
RTMP_CODEC_MAP(XX)
|
RTMP_CODEC_MAP(XX)
|
||||||
#undef XX
|
#undef XX
|
||||||
|
default: return 0;
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t getCodecFourCC(CodecId cid) {
|
uint32_t getCodecFourCC(CodecId cid) {
|
||||||
@ -69,8 +69,8 @@ uint32_t getCodecFourCC(CodecId cid) {
|
|||||||
#define XX(a, b, c) case a: return static_cast<uint32_t>(c);
|
#define XX(a, b, c) case a: return static_cast<uint32_t>(c);
|
||||||
RTMP_CODEC_MAP(XX)
|
RTMP_CODEC_MAP(XX)
|
||||||
#undef XX
|
#undef XX
|
||||||
|
default: return 0;
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CodecId getFourccCodec(uint32_t id) {
|
CodecId getFourccCodec(uint32_t id) {
|
||||||
@ -195,12 +195,10 @@ bool RtmpPacket::isConfigFrame() const {
|
|||||||
switch (type_id) {
|
switch (type_id) {
|
||||||
case MSG_AUDIO: {
|
case MSG_AUDIO: {
|
||||||
switch ((RtmpAudioCodec)getRtmpCodecId()) {
|
switch ((RtmpAudioCodec)getRtmpCodecId()) {
|
||||||
case RtmpAudioCodec::aac:
|
case RtmpAudioCodec::aac: return (RtmpAACPacketType)buffer[1] == RtmpAACPacketType::aac_config_header;
|
||||||
return (RtmpAACPacketType)buffer[1] == RtmpAACPacketType::aac_config_header;
|
case RtmpAudioCodec::ex_header: return (RtmpPacketType)(buffer[0] & 0x0f) == RtmpPacketType::PacketTypeSequenceStart;
|
||||||
case RtmpAudioCodec::ex_header:
|
default: return false;
|
||||||
return (RtmpPacketType)(buffer[0] & 0x0f) == RtmpPacketType::PacketTypeSequenceStart;
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
case MSG_VIDEO: {
|
case MSG_VIDEO: {
|
||||||
if (!isVideoKeyFrame()) {
|
if (!isVideoKeyFrame()) {
|
||||||
|
|||||||
@ -446,7 +446,11 @@ void RtspPlayer::sendOptions() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RtspPlayer::sendKeepAlive() {
|
void RtspPlayer::sendKeepAlive() {
|
||||||
_on_response = [](const Parser &parser) {};
|
if (_play_check_timer)
|
||||||
|
{
|
||||||
|
WarnL << "receive RTP packet before handleResPAUSE";
|
||||||
|
}
|
||||||
|
_on_keepalive_reponse = [](const Parser &parser) {};
|
||||||
if (_supported_cmd.find("GET_PARAMETER") != _supported_cmd.end()) {
|
if (_supported_cmd.find("GET_PARAMETER") != _supported_cmd.end()) {
|
||||||
// 支持GET_PARAMETER,用此命令保活 [AUTO-TRANSLATED:b45cd737]
|
// 支持GET_PARAMETER,用此命令保活 [AUTO-TRANSLATED:b45cd737]
|
||||||
// Support GET_PARAMETER, use this command to keep alive
|
// Support GET_PARAMETER, use this command to keep alive
|
||||||
@ -532,6 +536,10 @@ void RtspPlayer::onWholeRtspPacket(Parser &parser) {
|
|||||||
try {
|
try {
|
||||||
decltype(_on_response) func;
|
decltype(_on_response) func;
|
||||||
_on_response.swap(func);
|
_on_response.swap(func);
|
||||||
|
if (!func)
|
||||||
|
{
|
||||||
|
_on_keepalive_reponse.swap(func);
|
||||||
|
}
|
||||||
if (func) {
|
if (func) {
|
||||||
func(parser);
|
func(parser);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -162,6 +162,7 @@ private:
|
|||||||
float _speed = 0.0f;
|
float _speed = 0.0f;
|
||||||
std::vector<SdpTrack::Ptr> _sdp_track;
|
std::vector<SdpTrack::Ptr> _sdp_track;
|
||||||
std::function<void(const Parser&)> _on_response;
|
std::function<void(const Parser&)> _on_response;
|
||||||
|
std::function<void(const Parser&)> _on_keepalive_reponse;
|
||||||
protected:
|
protected:
|
||||||
// RTP端口,trackid idx 为数组下标 [AUTO-TRANSLATED:77c186bb]
|
// RTP端口,trackid idx 为数组下标 [AUTO-TRANSLATED:77c186bb]
|
||||||
// RTP port, trackid idx is the array subscript
|
// RTP port, trackid idx is the array subscript
|
||||||
|
|||||||
@ -64,7 +64,6 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
MultiMediaSourceMuxer::Ptr _muxer;
|
MultiMediaSourceMuxer::Ptr _muxer;
|
||||||
uint64_t timeStamp = 0;
|
|
||||||
uint64_t timeStamp_last = 0;
|
uint64_t timeStamp_last = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -83,6 +83,10 @@ struct sniff_tcp {
|
|||||||
#define TH_URG 0x20
|
#define TH_URG 0x20
|
||||||
#define TH_ECE 0x40
|
#define TH_ECE 0x40
|
||||||
#define TH_CWR 0x80
|
#define TH_CWR 0x80
|
||||||
|
|
||||||
|
#if defined(TH_FLAGS)
|
||||||
|
#undef TH_FLAGS
|
||||||
|
#endif
|
||||||
#define TH_FLAGS (TH_FINTH_SYNTH_RSTTH_ACKTH_URGTH_ECETH_CWR)
|
#define TH_FLAGS (TH_FINTH_SYNTH_RSTTH_ACKTH_URGTH_ECETH_CWR)
|
||||||
u_short th_win; /* TCP滑动窗口 */
|
u_short th_win; /* TCP滑动窗口 */
|
||||||
u_short th_sum; /* 头部校验和 */
|
u_short th_sum; /* 头部校验和 */
|
||||||
@ -154,7 +158,7 @@ static bool loadFile(const char *path, const EventPoller::Ptr &poller) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
auto total_size = std::make_shared<size_t>(0);
|
auto total_size = std::make_shared<size_t>(0);
|
||||||
struct pcap_pkthdr header = {0};
|
struct pcap_pkthdr header {};
|
||||||
while (true) {
|
while (true) {
|
||||||
const u_char *pkt_buff = pcap_next(handle.get(), &header);
|
const u_char *pkt_buff = pcap_next(handle.get(), &header);
|
||||||
if (!pkt_buff) {
|
if (!pkt_buff) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user