mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +08:00
更新ZLToolKit并适配代码
This commit is contained in:
parent
14b318525e
commit
80bcf53ccf
@ -1 +1 @@
|
|||||||
Subproject commit 147332ed51c8da49764e6d227034340d86cf7800
|
Subproject commit 7138d3263d4c409fae0f2ae3164612c2e5ea92a0
|
@ -254,7 +254,8 @@ API_EXPORT void API_CALL mk_tcp_client_send_safe(mk_tcp_client ctx, const char *
|
|||||||
assert(ctx && data);
|
assert(ctx && data);
|
||||||
TcpClientForC::Ptr *client = (TcpClientForC::Ptr *)ctx;
|
TcpClientForC::Ptr *client = (TcpClientForC::Ptr *)ctx;
|
||||||
weak_ptr<TcpClient> weakClient = *client;
|
weak_ptr<TcpClient> weakClient = *client;
|
||||||
Buffer::Ptr buf = (*client)->obtainBuffer(data,len);
|
auto buf = BufferRaw::create();
|
||||||
|
buf->assign(data,len);
|
||||||
(*client)->async([weakClient,buf](){
|
(*client)->async([weakClient,buf](){
|
||||||
auto strongClient = weakClient.lock();
|
auto strongClient = weakClient.lock();
|
||||||
if(strongClient){
|
if(strongClient){
|
||||||
|
@ -67,6 +67,12 @@ void FlvMuxer::start(const EventPoller::Ptr &poller,const RtmpMediaSource::Ptr &
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BufferRaw::Ptr FlvMuxer::obtainBuffer(const void *data, size_t len) {
|
||||||
|
auto buffer = BufferRaw::create();
|
||||||
|
buffer->assign((const char *) data, len);
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
void FlvMuxer::onWriteFlvHeader(const RtmpMediaSource::Ptr &mediaSrc) {
|
void FlvMuxer::onWriteFlvHeader(const RtmpMediaSource::Ptr &mediaSrc) {
|
||||||
//发送flv文件头
|
//发送flv文件头
|
||||||
char flv_file_header[] = "FLV\x1\x5\x0\x0\x0\x9"; // have audio and have video
|
char flv_file_header[] = "FLV\x1\x5\x0\x0\x0\x9"; // have audio and have video
|
||||||
@ -92,11 +98,11 @@ void FlvMuxer::onWriteFlvHeader(const RtmpMediaSource::Ptr &mediaSrc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//flv header
|
//flv header
|
||||||
onWrite(std::make_shared<BufferRaw>(flv_file_header, sizeof(flv_file_header) - 1), false);
|
onWrite(obtainBuffer(flv_file_header, sizeof(flv_file_header) - 1), false);
|
||||||
|
|
||||||
auto size = htonl(0);
|
auto size = htonl(0);
|
||||||
//PreviousTagSize0 Always 0
|
//PreviousTagSize0 Always 0
|
||||||
onWrite(std::make_shared<BufferRaw>((char *)&size,4), false);
|
onWrite(obtainBuffer((char *)&size,4), false);
|
||||||
|
|
||||||
|
|
||||||
auto &metadata = mediaSrc->getMetaData();
|
auto &metadata = mediaSrc->getMetaData();
|
||||||
@ -144,12 +150,12 @@ void FlvMuxer::onWriteFlvTag(uint8_t type, const Buffer::Ptr &buffer, uint32_t t
|
|||||||
header.timestamp_ex = (uint8_t) ((time_stamp >> 24) & 0xff);
|
header.timestamp_ex = (uint8_t) ((time_stamp >> 24) & 0xff);
|
||||||
set_be24(header.timestamp, time_stamp & 0xFFFFFF);
|
set_be24(header.timestamp, time_stamp & 0xFFFFFF);
|
||||||
//tag header
|
//tag header
|
||||||
onWrite(std::make_shared<BufferRaw>((char *)&header, sizeof(header)), false);
|
onWrite(obtainBuffer((char *)&header, sizeof(header)), false);
|
||||||
//tag data
|
//tag data
|
||||||
onWrite(buffer, false);
|
onWrite(buffer, false);
|
||||||
uint32_t size = htonl((uint32_t)(buffer->size() + sizeof(header)));
|
uint32_t size = htonl((uint32_t)(buffer->size() + sizeof(header)));
|
||||||
//PreviousTagSize
|
//PreviousTagSize
|
||||||
onWrite(std::make_shared<BufferRaw>((char *)&size,4), flush);
|
onWrite(obtainBuffer((char *)&size,4), flush);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlvMuxer::onWriteRtmp(const RtmpPacket::Ptr &pkt,bool flush) {
|
void FlvMuxer::onWriteRtmp(const RtmpPacket::Ptr &pkt,bool flush) {
|
||||||
|
@ -37,6 +37,7 @@ private:
|
|||||||
void onWriteRtmp(const RtmpPacket::Ptr &pkt, bool flush);
|
void onWriteRtmp(const RtmpPacket::Ptr &pkt, bool flush);
|
||||||
void onWriteFlvTag(const RtmpPacket::Ptr &pkt, uint32_t time_stamp, bool flush);
|
void onWriteFlvTag(const RtmpPacket::Ptr &pkt, uint32_t time_stamp, bool flush);
|
||||||
void onWriteFlvTag(uint8_t type, const Buffer::Ptr &buffer, uint32_t time_stamp, bool flush);
|
void onWriteFlvTag(uint8_t type, const Buffer::Ptr &buffer, uint32_t time_stamp, bool flush);
|
||||||
|
BufferRaw::Ptr obtainBuffer(const void *data, size_t len);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//时间戳修整器
|
//时间戳修整器
|
||||||
|
@ -10,9 +10,6 @@
|
|||||||
|
|
||||||
#include "RtmpProtocol.h"
|
#include "RtmpProtocol.h"
|
||||||
#include "Rtmp/utils.h"
|
#include "Rtmp/utils.h"
|
||||||
#include "Util/util.h"
|
|
||||||
#include "Util/onceToken.h"
|
|
||||||
#include "Thread/ThreadPool.h"
|
|
||||||
#include "RtmpMediaSource.h"
|
#include "RtmpMediaSource.h"
|
||||||
using namespace toolkit;
|
using namespace toolkit;
|
||||||
|
|
||||||
@ -760,13 +757,11 @@ void RtmpProtocol::handle_chunk(RtmpPacket::Ptr packet) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferRaw::Ptr RtmpProtocol::obtainBuffer() {
|
|
||||||
return std::make_shared<BufferRaw>() ;//_bufferPool.obtain();
|
|
||||||
}
|
|
||||||
|
|
||||||
BufferRaw::Ptr RtmpProtocol::obtainBuffer(const void *data, size_t len) {
|
BufferRaw::Ptr RtmpProtocol::obtainBuffer(const void *data, size_t len) {
|
||||||
auto buffer = obtainBuffer();
|
auto buffer = BufferRaw::create();
|
||||||
buffer->assign((const char *) data, len);
|
if (data && len) {
|
||||||
|
buffer->assign((const char *) data, len);
|
||||||
|
}
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,9 +53,6 @@ protected:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void reset();
|
void reset();
|
||||||
BufferRaw::Ptr obtainBuffer();
|
|
||||||
BufferRaw::Ptr obtainBuffer(const void *data, size_t len);
|
|
||||||
|
|
||||||
void sendAcknowledgement(uint32_t size);
|
void sendAcknowledgement(uint32_t size);
|
||||||
void sendAcknowledgementSize(uint32_t size);
|
void sendAcknowledgementSize(uint32_t size);
|
||||||
void sendPeerBandwidth(uint32_t size);
|
void sendPeerBandwidth(uint32_t size);
|
||||||
@ -70,6 +67,7 @@ protected:
|
|||||||
void sendResponse(int type, const string &str);
|
void sendResponse(int type, const string &str);
|
||||||
void sendRtmp(uint8_t type, uint32_t stream_index, const std::string &buffer, uint32_t stamp, int chunk_id);
|
void sendRtmp(uint8_t type, uint32_t stream_index, const std::string &buffer, uint32_t stamp, int chunk_id);
|
||||||
void sendRtmp(uint8_t type, uint32_t stream_index, const Buffer::Ptr &buffer, uint32_t stamp, int chunk_id);
|
void sendRtmp(uint8_t type, uint32_t stream_index, const Buffer::Ptr &buffer, uint32_t stamp, int chunk_id);
|
||||||
|
BufferRaw::Ptr obtainBuffer(const void *data = nullptr, size_t len = 0);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void handle_C1_simple(const char *data);
|
void handle_C1_simple(const char *data);
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
namespace mediakit{
|
namespace mediakit{
|
||||||
|
|
||||||
PSEncoder::PSEncoder() {
|
PSEncoder::PSEncoder() {
|
||||||
_buffer = std::make_shared<BufferRaw>();
|
_buffer = BufferRaw::create();
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -415,7 +415,8 @@ string printSSRC(uint32_t ui32Ssrc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Buffer::Ptr makeRtpOverTcpPrefix(uint16_t size, uint8_t interleaved){
|
Buffer::Ptr makeRtpOverTcpPrefix(uint16_t size, uint8_t interleaved){
|
||||||
auto rtp_tcp = std::make_shared<BufferRaw>(RtpPacket::kRtpTcpHeaderSize);
|
auto rtp_tcp = BufferRaw::create();
|
||||||
|
rtp_tcp->setCapacity(RtpPacket::kRtpTcpHeaderSize);
|
||||||
rtp_tcp->setSize(RtpPacket::kRtpTcpHeaderSize);
|
rtp_tcp->setSize(RtpPacket::kRtpTcpHeaderSize);
|
||||||
auto ptr = rtp_tcp->data();
|
auto ptr = rtp_tcp->data();
|
||||||
ptr[0] = '$';
|
ptr[0] = '$';
|
||||||
|
Loading…
Reference in New Issue
Block a user