mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-25 20:27:34 +08:00
新增支持mjpeg es rtp流
mpegts/g711 payload改成固定模式
This commit is contained in:
parent
ae950606cb
commit
77e46353ce
@ -293,15 +293,8 @@ h264_pt=98
|
|||||||
h265_pt=99
|
h265_pt=99
|
||||||
#rtp ps 负载的pt
|
#rtp ps 负载的pt
|
||||||
ps_pt=96
|
ps_pt=96
|
||||||
#rtp ts 负载的pt
|
|
||||||
ts_pt=33
|
|
||||||
#rtp opus 负载的pt
|
#rtp opus 负载的pt
|
||||||
opus_pt=100
|
opus_pt=100
|
||||||
#rtp g711u 负载的pt
|
|
||||||
g711u_pt=0
|
|
||||||
#rtp g711a 负载的pt
|
|
||||||
g711a_pt=8
|
|
||||||
|
|
||||||
|
|
||||||
[rtc]
|
[rtc]
|
||||||
#rtc播放推流、播放超时时间
|
#rtc播放推流、播放超时时间
|
||||||
|
@ -317,10 +317,7 @@ const string kPortRange = RTP_PROXY_FIELD "port_range";
|
|||||||
const string kH264PT = RTP_PROXY_FIELD "h264_pt";
|
const string kH264PT = RTP_PROXY_FIELD "h264_pt";
|
||||||
const string kH265PT = RTP_PROXY_FIELD "h265_pt";
|
const string kH265PT = RTP_PROXY_FIELD "h265_pt";
|
||||||
const string kPSPT = RTP_PROXY_FIELD "ps_pt";
|
const string kPSPT = RTP_PROXY_FIELD "ps_pt";
|
||||||
const string kTSPT = RTP_PROXY_FIELD "ts_pt";
|
|
||||||
const string kOpusPT = RTP_PROXY_FIELD "opus_pt";
|
const string kOpusPT = RTP_PROXY_FIELD "opus_pt";
|
||||||
const string kG711UPT = RTP_PROXY_FIELD "g711u_pt";
|
|
||||||
const string kG711APT = RTP_PROXY_FIELD "g711a_pt";
|
|
||||||
|
|
||||||
static onceToken token([]() {
|
static onceToken token([]() {
|
||||||
mINI::Instance()[kDumpDir] = "";
|
mINI::Instance()[kDumpDir] = "";
|
||||||
@ -329,10 +326,7 @@ static onceToken token([]() {
|
|||||||
mINI::Instance()[kH264PT] = 98;
|
mINI::Instance()[kH264PT] = 98;
|
||||||
mINI::Instance()[kH265PT] = 99;
|
mINI::Instance()[kH265PT] = 99;
|
||||||
mINI::Instance()[kPSPT] = 96;
|
mINI::Instance()[kPSPT] = 96;
|
||||||
mINI::Instance()[kTSPT] = 33;
|
|
||||||
mINI::Instance()[kOpusPT] = 100;
|
mINI::Instance()[kOpusPT] = 100;
|
||||||
mINI::Instance()[kG711UPT] = 0;
|
|
||||||
mINI::Instance()[kG711APT] = 8;
|
|
||||||
});
|
});
|
||||||
} // namespace RtpProxy
|
} // namespace RtpProxy
|
||||||
|
|
||||||
|
@ -350,14 +350,8 @@ extern const std::string kH264PT;
|
|||||||
extern const std::string kH265PT;
|
extern const std::string kH265PT;
|
||||||
// rtp server ps 的pt
|
// rtp server ps 的pt
|
||||||
extern const std::string kPSPT;
|
extern const std::string kPSPT;
|
||||||
// rtp server ts 的pt
|
|
||||||
extern const std::string kTSPT;
|
|
||||||
// rtp server opus 的pt
|
// rtp server opus 的pt
|
||||||
extern const std::string kOpusPT;
|
extern const std::string kOpusPT;
|
||||||
// rtp server g711u 的pt
|
|
||||||
extern const std::string kG711UPT;
|
|
||||||
// rtp server g711a 的pt
|
|
||||||
extern const std::string kG711APT;
|
|
||||||
} // namespace RtpProxy
|
} // namespace RtpProxy
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13,14 +13,15 @@
|
|||||||
#include "Extension/CommonRtp.h"
|
#include "Extension/CommonRtp.h"
|
||||||
#include "Extension/Factory.h"
|
#include "Extension/Factory.h"
|
||||||
#include "Extension/G711.h"
|
#include "Extension/G711.h"
|
||||||
#include "Extension/H264Rtp.h"
|
#include "Extension/H264.h"
|
||||||
#include "Extension/H265.h"
|
#include "Extension/H265.h"
|
||||||
#include "Extension/Opus.h"
|
#include "Extension/Opus.h"
|
||||||
|
#include "Extension/JPEG.h"
|
||||||
#include "Http/HttpTSPlayer.h"
|
#include "Http/HttpTSPlayer.h"
|
||||||
#include "Util/File.h"
|
#include "Util/File.h"
|
||||||
#include "Common/config.h"
|
#include "Common/config.h"
|
||||||
#include "Rtsp/RtpCodec.h"
|
|
||||||
#include "Rtsp/RtpReceiver.h"
|
#include "Rtsp/RtpReceiver.h"
|
||||||
|
#include "Rtsp/Rtsp.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace toolkit;
|
using namespace toolkit;
|
||||||
@ -76,10 +77,7 @@ bool GB28181Process::inputRtp(bool, const char *data, size_t data_len) {
|
|||||||
GET_CONFIG(uint32_t, h264_pt, RtpProxy::kH264PT);
|
GET_CONFIG(uint32_t, h264_pt, RtpProxy::kH264PT);
|
||||||
GET_CONFIG(uint32_t, h265_pt, RtpProxy::kH265PT);
|
GET_CONFIG(uint32_t, h265_pt, RtpProxy::kH265PT);
|
||||||
GET_CONFIG(uint32_t, ps_pt, RtpProxy::kPSPT);
|
GET_CONFIG(uint32_t, ps_pt, RtpProxy::kPSPT);
|
||||||
GET_CONFIG(uint32_t, ts_pt, RtpProxy::kTSPT);
|
|
||||||
GET_CONFIG(uint32_t, opus_pt, RtpProxy::kOpusPT);
|
GET_CONFIG(uint32_t, opus_pt, RtpProxy::kOpusPT);
|
||||||
GET_CONFIG(uint32_t, g711u_pt, RtpProxy::kG711UPT);
|
|
||||||
GET_CONFIG(uint32_t, g711a_pt, RtpProxy::kG711APT);
|
|
||||||
|
|
||||||
RtpHeader *header = (RtpHeader *)data;
|
RtpHeader *header = (RtpHeader *)data;
|
||||||
auto pt = header->pt;
|
auto pt = header->pt;
|
||||||
@ -89,53 +87,62 @@ bool GB28181Process::inputRtp(bool, const char *data, size_t data_len) {
|
|||||||
// 防止pt类型太多导致内存溢出
|
// 防止pt类型太多导致内存溢出
|
||||||
throw std::invalid_argument("rtp pt类型不得超过2种!");
|
throw std::invalid_argument("rtp pt类型不得超过2种!");
|
||||||
}
|
}
|
||||||
if (pt == opus_pt) {
|
switch (pt) {
|
||||||
// opus负载
|
case Rtsp::PT_PCMA:
|
||||||
ref = std::make_shared<RtpReceiverImp>(48000, [this](RtpPacket::Ptr rtp) { onRtpSorted(std::move(rtp)); });
|
case Rtsp::PT_PCMU: {
|
||||||
|
// CodecG711U or CodecG711A
|
||||||
auto track = std::make_shared<OpusTrack>();
|
ref = std::make_shared<RtpReceiverImp>(8000, [this](RtpPacket::Ptr rtp) { onRtpSorted(std::move(rtp)); });
|
||||||
_interface->addTrack(track);
|
auto track = std::make_shared<G711Track>(pt == Rtsp::PT_PCMU ? CodecG711U : CodecG711A, 8000, 1, 16);
|
||||||
_rtp_decoder[pt] = Factory::getRtpDecoderByTrack(track);
|
_interface->addTrack(track);
|
||||||
} else if (pt == h265_pt) {
|
_rtp_decoder[pt] = Factory::getRtpDecoderByTrack(track);
|
||||||
// H265负载
|
break;
|
||||||
ref = std::make_shared<RtpReceiverImp>(90000, [this](RtpPacket::Ptr rtp) { onRtpSorted(std::move(rtp)); });
|
|
||||||
|
|
||||||
auto track = std::make_shared<H265Track>();
|
|
||||||
_interface->addTrack(track);
|
|
||||||
_rtp_decoder[pt] = Factory::getRtpDecoderByTrack(track);
|
|
||||||
} else if (pt == h264_pt) {
|
|
||||||
// H264负载
|
|
||||||
ref = std::make_shared<RtpReceiverImp>(90000, [this](RtpPacket::Ptr rtp) { onRtpSorted(std::move(rtp)); });
|
|
||||||
|
|
||||||
auto track = std::make_shared<H264Track>();
|
|
||||||
_interface->addTrack(track);
|
|
||||||
_rtp_decoder[pt] = Factory::getRtpDecoderByTrack(track);
|
|
||||||
} else if (pt == g711u_pt || pt == g711a_pt) {
|
|
||||||
// CodecG711U
|
|
||||||
// CodecG711A
|
|
||||||
ref = std::make_shared<RtpReceiverImp>(8000, [this](RtpPacket::Ptr rtp) { onRtpSorted(std::move(rtp)); });
|
|
||||||
|
|
||||||
auto track = std::make_shared<G711Track>(pt == g711u_pt ? CodecG711U : CodecG711A, 8000, 1, 16);
|
|
||||||
_interface->addTrack(track);
|
|
||||||
_rtp_decoder[pt] = Factory::getRtpDecoderByTrack(track);
|
|
||||||
} else {
|
|
||||||
if (pt != ts_pt && pt != ps_pt) {
|
|
||||||
WarnL << "rtp payload type未识别(" << (int)pt << "),已按ts或ps负载处理";
|
|
||||||
}
|
}
|
||||||
|
case Rtsp::PT_JPEG: {
|
||||||
ref = std::make_shared<RtpReceiverImp>(90000, [this](RtpPacket::Ptr rtp) { onRtpSorted(std::move(rtp)); });
|
// mjpeg
|
||||||
|
ref = std::make_shared<RtpReceiverImp>(90000, [this](RtpPacket::Ptr rtp) { onRtpSorted(std::move(rtp)); });
|
||||||
// ts或ps负载
|
auto track = std::make_shared<JPEGTrack>();
|
||||||
_rtp_decoder[pt] = std::make_shared<CommonRtpDecoder>(CodecInvalid, 32 * 1024);
|
_interface->addTrack(track);
|
||||||
// 设置dump目录
|
_rtp_decoder[pt] = Factory::getRtpDecoderByTrack(track);
|
||||||
GET_CONFIG(string, dump_dir, RtpProxy::kDumpDir);
|
break;
|
||||||
if (!dump_dir.empty()) {
|
}
|
||||||
auto save_path = File::absolutePath(_media_info._streamid + ".mp2", dump_dir);
|
default: {
|
||||||
_save_file_ps.reset(File::create_file(save_path.data(), "wb"), [](FILE *fp) {
|
if (pt == opus_pt) {
|
||||||
if (fp) {
|
// opus负载
|
||||||
fclose(fp);
|
ref = std::make_shared<RtpReceiverImp>(48000, [this](RtpPacket::Ptr rtp) { onRtpSorted(std::move(rtp)); });
|
||||||
|
auto track = std::make_shared<OpusTrack>();
|
||||||
|
_interface->addTrack(track);
|
||||||
|
_rtp_decoder[pt] = Factory::getRtpDecoderByTrack(track);
|
||||||
|
} else if (pt == h265_pt) {
|
||||||
|
// H265负载
|
||||||
|
ref = std::make_shared<RtpReceiverImp>(90000, [this](RtpPacket::Ptr rtp) { onRtpSorted(std::move(rtp)); });
|
||||||
|
auto track = std::make_shared<H265Track>();
|
||||||
|
_interface->addTrack(track);
|
||||||
|
_rtp_decoder[pt] = Factory::getRtpDecoderByTrack(track);
|
||||||
|
} else if (pt == h264_pt) {
|
||||||
|
// H264负载
|
||||||
|
ref = std::make_shared<RtpReceiverImp>(90000, [this](RtpPacket::Ptr rtp) { onRtpSorted(std::move(rtp)); });
|
||||||
|
auto track = std::make_shared<H264Track>();
|
||||||
|
_interface->addTrack(track);
|
||||||
|
_rtp_decoder[pt] = Factory::getRtpDecoderByTrack(track);
|
||||||
|
} else {
|
||||||
|
if (pt != Rtsp::PT_MP2T && pt != ps_pt) {
|
||||||
|
WarnL << "rtp payload type未识别(" << (int)pt << "),已按ts或ps负载处理";
|
||||||
}
|
}
|
||||||
});
|
ref = std::make_shared<RtpReceiverImp>(90000, [this](RtpPacket::Ptr rtp) { onRtpSorted(std::move(rtp)); });
|
||||||
|
// ts或ps负载
|
||||||
|
_rtp_decoder[pt] = std::make_shared<CommonRtpDecoder>(CodecInvalid, 32 * 1024);
|
||||||
|
// 设置dump目录
|
||||||
|
GET_CONFIG(string, dump_dir, RtpProxy::kDumpDir);
|
||||||
|
if (!dump_dir.empty()) {
|
||||||
|
auto save_path = File::absolutePath(_media_info._streamid + ".mpeg", dump_dir);
|
||||||
|
_save_file_ps.reset(File::create_file(save_path.data(), "wb"), [](FILE *fp) {
|
||||||
|
if (fp) {
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 设置frame回调
|
// 设置frame回调
|
||||||
|
Loading…
Reference in New Issue
Block a user