初步完成Windows下的移植

This commit is contained in:
xiongziliang
2017-08-09 18:39:30 +08:00
parent a8b7d53f87
commit a769d6c284
42 changed files with 160 additions and 121 deletions

View File

@@ -57,20 +57,20 @@ Vui参数集视频可用性信息视频标准化选项
int i_sar_height;
int i_sar_width; 设置长宽比
int i_overscan; 0=undef, 1=no overscan, 2=overscan 过扫描线,默认"undef"(不设置),可选项show(观看)/crop(去除)
int i_overscan; 0=undef, 1=no overscan, 2=overscan 过扫描线,默认"undef"(不设置),可选项:show(观看)/crop(去除)
见以下的值h264附件E
Int i_vidformat; 视频格式,默认"undef"component/pal/ntsc/secam/mac/undef
int b_fullrange; Specify full range samples setting默认"off",可选项off/on
int i_colorprim; 原始色度格式,默认"undef",可选项undef/bt709/bt470m/bt470bgsmpte170m/smpte240m/film
int i_transfer; 转换方式,默认"undef",可选项undef/bt709/bt470m/bt470bg/linear,log100/log316/smpte170m/smpte240m
int b_fullrange; Specify full range samples setting默认"off",可选项:off/on
int i_colorprim; 原始色度格式,默认"undef",可选项:undef/bt709/bt470m/bt470bgsmpte170m/smpte240m/film
int i_transfer; 转换方式,默认"undef",可选项:undef/bt709/bt470m/bt470bg/linear,log100/log316/smpte170m/smpte240m
int i_colmatrix; 色度矩阵设置,默认"undef",undef/bt709/fcc/bt470bg,smpte170m/smpte240m/GBR/YCgCo
int i_chroma_loc; both top & bottom色度样本指定范围0~5默认0
} vui;
int i_fps_num;
int i_fps_den;
这两个参数是由fps帧率确定的赋值的过程见下
这两个参数是由fps帧率确定的赋值的过程见下:
{ float fps;
if( sscanf( value, "%d/%d", &p->i_fps_num, &p->i_fps_den ) == 2 )
;
@@ -137,7 +137,7 @@ Value的值就是fps。
int i_subpel_refine; 亚像素运动估计质量
int b_chroma_me; 亚像素色度运动估计和P帧的模式选择
int b_mixed_references; 允许每个宏块的分区在P帧有它自己的参考号
int i_trellis; Trellis量化对每个8x8的块寻找合适的量化值需要CABAC默认0 0关闭1只在最后编码时使用2一直使用
int i_trellis; Trellis量化对每个8x8的块寻找合适的量化值需要CABAC默认0 0:关闭1:只在最后编码时使用2:一直使用
int b_fast_pskip; 快速P帧跳过检测
int b_dct_decimate; 在P-frames转换参数域
int i_noise_reduction; 自适应伪盲区
@@ -249,13 +249,13 @@ bool H264Encoder::init(int iWidth, int iHeight, int iFps) {
这个GOP就称为open-GOP。
有些解码器不能完全支持open-GOP码流
例如蓝光解码器因此在x264里面open-GOP是默认关闭的。
对于解码端,接收到的码流如果如下I0 B0 B1 P0 B2 B3...这就是一个open-GOP码流I帧后面紧跟B帧
对于解码端,接收到的码流如果如下:I0 B0 B1 P0 B2 B3...这就是一个open-GOP码流I帧后面紧跟B帧
因此B0 B1的解码需要用到I0前面一个GOP的数据B0 B1的dts是小于I0的。
如果码流如下 I0 P0 B0 B1 P1 B2 B3...这就是一个close-GOP码流
如果码流如下: I0 P0 B0 B1 P1 B2 B3...这就是一个close-GOP码流
I0后面所有帧的解码不依赖于I0前面的帧I0后面所有帧的dts都比I0的大。
如果码流是IDR0 B0 B1 P0 B2 B3...那个这个GOP是close-GOPB0,B1虽然dst比IDR0小
但编解码端都刷新了参考缓冲B0,B1参考不到前向GOP帧。
对于编码端,如果编码帧类型决定如下 ...P0 B1 B2 P3 B4 B5 I6这就会输出open-Gop码流 P0 P3 B1 B2 I6 B4 B5...
对于编码端,如果编码帧类型决定如下: ...P0 B1 B2 P3 B4 B5 I6这就会输出open-Gop码流 P0 P3 B1 B2 I6 B4 B5...
B4 B5的解码依赖P3。
如果编码帧类型决定如下...P0 B1 B2 P3 B4 P5 I6这样就不会输出open-GOP码流P0 P3 B1 B2 P5 B4 I6...)。
两者区别在于I6前面的第5帧是设置为B帧还是P帧

View File

@@ -9,6 +9,17 @@
using namespace ZL::Network;
#if defined(_WIN32)
static onceToken g_token([]() {
WORD wVersionRequested = MAKEWORD(2, 2);
WSADATA wsaData;
WSAStartup(wVersionRequested, &wsaData);
}, []() {
WSACleanup();
});
#endif // defined(_WIN32)
namespace Config {
void loaIniConfig(){

View File

@@ -8,7 +8,6 @@
#ifndef DEVICE_DEVICE_H_
#define DEVICE_DEVICE_H_
#include <sys/time.h>
#include <memory>
#include <string>
#include <functional>

View File

@@ -2,8 +2,6 @@
#include <stdlib.h>
#include <string.h>
#include <stdint.h> /* for uint32_t, etc */
#include <pthread.h>
#include "SPSParser.h"
/********************************************

View File

@@ -173,7 +173,7 @@ return kInvalidStream; \
start += subsamples[i].clear_bytes;
const uint8_t* end =
std::min(start + subsamples[i].cypher_bytes, stream_end);
min(start + subsamples[i].cypher_bytes, stream_end);
encrypted_ranges_.Add(start, end);
start = end;
}
@@ -311,7 +311,7 @@ return kInvalidStream; \
// The start code is inside an encrypted section so we need to scan
// for another start code.
*start_code_size = 0;
start += std::min(*offset + 1, bytes_left);
start += min(*offset + 1, bytes_left);
}
} while (*start_code_size == 0);

View File

@@ -113,7 +113,7 @@ namespace media {
// (assuming no interlacing).
int32_t top_foc = pic_order_cnt_msb + slice_hdr.pic_order_cnt_lsb;
int32_t bottom_foc = top_foc + slice_hdr.delta_pic_order_cnt_bottom;
*pic_order_cnt = std::min(top_foc, bottom_foc);
*pic_order_cnt = min(top_foc, bottom_foc);
// Store state.
prev_frame_num_ = slice_hdr.frame_num;
@@ -182,7 +182,7 @@ namespace media {
int32_t top_foc = expected_pic_order_cnt + slice_hdr.delta_pic_order_cnt0;
int32_t bottom_foc = top_foc + sps->offset_for_top_to_bottom_field +
slice_hdr.delta_pic_order_cnt1;
*pic_order_cnt = std::min(top_foc, bottom_foc);
*pic_order_cnt = min(top_foc, bottom_foc);
// Store state.
prev_frame_num_ = slice_hdr.frame_num;

View File

@@ -27,7 +27,7 @@ void HttpClient::sendRequest(const string &strUrl){
defaultPort = 443;
isHttps = true;
}else{
auto strErr = StrPrinter << "非法的协议" << protocol << endl;
auto strErr = StrPrinter << "非法的协议:" << protocol << endl;
throw std::invalid_argument(strErr);
}

View File

@@ -8,7 +8,6 @@
#include <stdio.h>
#include <sys/stat.h>
#include <algorithm>
#include <dirent.h>
#include "Common/config.h"
#include "strCoding.h"
@@ -146,7 +145,7 @@ void HttpSession::onManager() {
static uint32_t keepAliveSec = mINI::Instance()[Config::Http::kKeepAliveSecond].as<uint32_t>();
if(m_ticker.elapsedTime() > keepAliveSec * 1000){
//1分钟超时
WarnL<<"HttpSession超时断开!";
WarnL<<"HttpSession timeouted!";
shutdown();
}
}
@@ -226,7 +225,7 @@ inline HttpSession::HttpCode HttpSession::Handle_Req_GET() {
int64_t iReq = MIN(sendBufSize,*piLeft);
int64_t iRead = fread(pacSendBuf.get(), 1, iReq, pFilePtr.get());
*piLeft -= iRead;
//InfoL << "Send file " << iReq << " " << *piLeft;
//InfoL << "Send file :" << iReq << " " << *piLeft;
if (iRead < iReq || !*piLeft) {
//send completed!
//FatalL << "send completed!";
@@ -280,13 +279,13 @@ inline bool HttpSession::makeMeun(const string &strFullPath, string &strRet) {
strRet += "<li><a href=\"";
strRet += "/";
strRet += "\">";
strRet += "根目录";
strRet += "root directory";
strRet += "</a></li>\r\n";
strRet += "<li><a href=\"";
strRet += "../";
strRet += "\">";
strRet += "上一级目录";
strRet += "parent directory";
strRet += "</a></li>\r\n";
}

View File

@@ -6,7 +6,10 @@
*/
#include "HLSMaker.h"
#include <sys/time.h>
#include "Util/File.h"
#include "Util/uv_errno.h"
using namespace ZL::Util;
namespace ZL {
namespace MediaFile {
@@ -126,7 +129,7 @@ void HLSMaker::inputH264(void *data, uint32_t length, uint32_t timeStamp,
m_Timer.resetTime();
removets();
if (write_index_file(m_ui64TsCnt - m_ui32NumSegments, m_ui64TsCnt, 0) == -1) {
WarnL << "write_index_file error :" << strerror(errno);
WarnL << "write_index_file error :" << get_uv_errmsg();
}
}
case 1: //P

View File

@@ -23,7 +23,7 @@ MediaReader::MediaReader(const string &strApp, const string &strId) {
m_hMP4File = MP4Read(strFileName.data());
if(m_hMP4File == MP4_INVALID_FILE_HANDLE){
throw runtime_error(StrPrinter << "打开MP4文件失败" << strFileName << endl);
throw runtime_error(StrPrinter << "打开MP4文件失败:" << strFileName << endl);
}
m_video_trId = MP4FindTrackId(m_hMP4File, 0, MP4_VIDEO_TRACK_TYPE, 0);
if(m_video_trId != MP4_INVALID_TRACK_ID){
@@ -106,7 +106,7 @@ MediaReader::MediaReader(const string &strApp, const string &strId) {
if(m_audio_trId == MP4_INVALID_TRACK_ID && m_video_trId == MP4_INVALID_TRACK_ID){
MP4Close(m_hMP4File);
m_hMP4File = MP4_INVALID_FILE_HANDLE;
throw runtime_error(StrPrinter << "该MP4文件音视频格式不支持" << strFileName << endl);
throw runtime_error(StrPrinter << "该MP4文件音视频格式不支持:" << strFileName << endl);
}
m_iDuration = MAX(m_video_ms,m_audio_ms);

View File

@@ -6,7 +6,6 @@
*/
#include "TSMaker.h"
#include <sys/time.h>
#include "Util/logger.h"
using namespace ZL::Util;

View File

@@ -5,7 +5,6 @@
* Author: xzl
*/
#include <netinet/in.h>
#include "Common/config.h"
#include "RtpMakerAAC.h"
#include "Util/mini.h"

View File

@@ -5,7 +5,6 @@
* Author: xzl
*/
#include <netinet/in.h>
#include "Common/config.h"
#include "RtpMakerH264.h"
#include "Util/mini.h"

View File

@@ -1,7 +1,6 @@
#ifndef __rtmp_h
#define __rtmp_h
#include <netinet/in.h>
#include <memory>
#include <string>
#include "Util/util.h"
@@ -12,7 +11,14 @@ using namespace ZL::Util;
#define PORT 1935
#define DEFAULT_CHUNK_LEN 128
#if !defined(_WIN32)
#define PACKED __attribute__((packed))
#else
#define PACKED
#endif //!defined(_WIN32)
#define HANDSHAKE_PLAINTEXT 0x03
#define RANDOM_LEN (1536 - 8)
@@ -52,6 +58,11 @@ using namespace ZL::Util;
#define FLV_KEY_FRAME 1
#define FLV_INTER_FRAME 2
#if defined(_WIN32)
#pragma pack(push, 1)
#endif // defined(_WIN32)
class RtmpHandshake {
public:
RtmpHandshake(uint32_t _time, uint8_t *_random = nullptr) {
@@ -87,6 +98,9 @@ public:
uint8_t streamId[4]; /* Note, this is little-endian while others are BE */
}PACKED;
#if defined(_WIN32)
#pragma pack(pop)
#endif // defined(_WIN32)
class RtmpPacket {
public:

View File

@@ -8,7 +8,6 @@
#ifndef SRC_RTMP_RTMPMEDIASOURCE_H_
#define SRC_RTMP_RTMPMEDIASOURCE_H_
#include <netinet/in.h>
#include <mutex>
#include <memory>
#include <string>

View File

@@ -19,14 +19,14 @@ RtmpParser::RtmpParser(const AMFValue &val) {
//264
m_bHaveVideo = true;
} else {
InfoL << "不支持RTMP视频格式" << videoCodec.as_string();
InfoL << "不支持RTMP视频格式:" << videoCodec.as_string();
}
}else if (videoCodec.type() != AMF_NULL){
if (videoCodec.as_integer() == 7) {
//264
m_bHaveVideo = true;
} else {
InfoL << "不支持RTMP视频格式" << videoCodec.as_integer();
InfoL << "不支持RTMP视频格式:" << videoCodec.as_integer();
}
}
@@ -36,14 +36,14 @@ RtmpParser::RtmpParser(const AMFValue &val) {
//aac
m_bHaveAudio = true;
} else {
InfoL << "不支持RTMP音频格式" << audioCodec.as_string();
InfoL << "不支持RTMP音频格式:" << audioCodec.as_string();
}
}else if (audioCodec.type() != AMF_NULL) {
if (audioCodec.as_integer() == 10) {
//aac
m_bHaveAudio = true;
} else {
InfoL << "不支持RTMP音频格式" << audioCodec.as_integer();
InfoL << "不支持RTMP音频格式:" << audioCodec.as_integer();
}
}

View File

@@ -144,7 +144,7 @@ inline void RtmpPlayer::send_connect() {
auto level = val["level"].as_string();
auto code = val["code"].as_string();
if(level != "status"){
throw std::runtime_error(StrPrinter <<"connect 失败" << level << " " << code << endl);
throw std::runtime_error(StrPrinter <<"connect 失败:" << level << " " << code << endl);
}
send_createStream();
});
@@ -170,7 +170,7 @@ inline void RtmpPlayer::send_play() {
auto level = val["level"].as_string();
auto code = val["code"].as_string();
if(level != "status"){
throw std::runtime_error(StrPrinter <<"play 失败" << level << " " << code << endl);
throw std::runtime_error(StrPrinter <<"play 失败:" << level << " " << code << endl);
}
};
addOnStatusCB(fun);
@@ -187,7 +187,7 @@ inline void RtmpPlayer::send_pause(bool bPause) {
auto code = val["code"].as_string();
if(level != "status") {
if(!bPause){
throw std::runtime_error(StrPrinter <<"pause 恢复播放失败" << level << " " << code << endl);
throw std::runtime_error(StrPrinter <<"pause 恢复播放失败:" << level << " " << code << endl);
}
}else{
m_bPaused = bPause;
@@ -236,7 +236,7 @@ void RtmpPlayer::onCmd_onStatus(AMFDecoder &dec) {
}
}
if(val.type() != AMF_OBJECT){
throw std::runtime_error("onStatus: 未找到结果对象");
throw std::runtime_error("onStatus:the result object was not found");
}
lock_guard<recursive_mutex> lck(m_mtxOnStatusCB);

View File

@@ -8,7 +8,6 @@
#ifndef SRC_RTMP_RtmpPlayer2_H_
#define SRC_RTMP_RtmpPlayer2_H_
#include <netinet/in.h>
#include <memory>
#include <string>
#include <functional>

View File

@@ -14,17 +14,29 @@
using namespace ZL::Util;
#ifdef ENABLE_OPENSSL
#include "Util/SSLBox.h"
#include <openssl/hmac.h>
static string openssl_HMACsha256(const void *key,unsigned int key_len,
const void *data,unsigned int data_len){
std::shared_ptr<char> out(new char[32],[](char *ptr){delete [] ptr;});
unsigned int out_len;
#if defined(WIN32)
HMAC_CTX *ctx = HMAC_CTX_new();
HMAC_CTX_reset(ctx);
HMAC_Init_ex(ctx, key, key_len, EVP_sha256(), NULL);
HMAC_Update(ctx, (unsigned char*)data, data_len);
HMAC_Final(ctx, (unsigned char *)out.get(), &out_len);
HMAC_CTX_reset(ctx);
HMAC_CTX_free(ctx);
#else
HMAC_CTX ctx;
HMAC_CTX_init(&ctx);
HMAC_Init_ex(&ctx, key, key_len, EVP_sha256(), NULL);
HMAC_Update(&ctx, (unsigned char*)data, data_len);
HMAC_Final(&ctx, (unsigned char *)out.get(), &out_len);
HMAC_CTX_cleanup(&ctx);
#endif // defined(WIN32)
return string(out.get(),out_len);
}
#endif //ENABLE_OPENSSL
@@ -159,7 +171,7 @@ void RtmpProtocol::sendRequest(int iCmd, const string& str) {
void RtmpProtocol::sendRtmp(uint8_t ui8Type, uint32_t ui32StreamId,
const std::string& strBuf, uint32_t ui32TimeStamp, int iChunkId) {
if (iChunkId < 2 || iChunkId > 63) {
auto strErr = StrPrinter << "不支持发送该类型的块流 ID" << iChunkId << endl;
auto strErr = StrPrinter << "不支持发送该类型的块流 ID:" << iChunkId << endl;
throw std::runtime_error(strErr);
}
@@ -275,7 +287,7 @@ void RtmpProtocol::handle_C1_simple(){
}
#ifdef ENABLE_OPENSSL
void RtmpProtocol::handle_C1_complex(){
//参考自http://blog.csdn.net/win_lin/article/details/13006803
//参考自:http://blog.csdn.net/win_lin/article/details/13006803
//skip c0,time,version
const char *c1_start = m_strRcvBuf.data() + 1;
const char *schema_start = c1_start + 8;
@@ -318,6 +330,9 @@ void RtmpProtocol::handle_C1_complex(){
}
}
#if !defined(u_int8_t)
#define u_int8_t unsigned char
#endif // !defined(u_int8_t)
static u_int8_t FMSKey[] = {
0x47, 0x65, 0x6e, 0x75, 0x69, 0x6e, 0x65, 0x20,
@@ -344,7 +359,7 @@ static u_int8_t FPKey[] = {
void RtmpProtocol::check_C1_Digest(const string &digest,const string &data){
auto sha256 = openssl_HMACsha256(FPKey,C1_FPKEY_SIZE,data.data(),data.size());
if(sha256 != digest){
throw std::runtime_error("digest不匹配");
throw std::runtime_error("digest mismatched");
}else{
InfoL << "check rtmp complex handshark success!";
}
@@ -383,7 +398,7 @@ string RtmpProtocol::get_C1_key(const uint8_t *ptr){
return key;
}
void RtmpProtocol::send_complex_S0S1S2(int schemeType,const string &digest){
//S1S2计算参考自https://github.com/hitYangfei/golang/blob/master/rtmpserver.go
//S1S2计算参考自:https://github.com/hitYangfei/golang/blob/master/rtmpserver.go
//发送S0
char handshake_head = HANDSHAKE_PLAINTEXT;
onSendRawData(&handshake_head, 1);

View File

@@ -8,7 +8,6 @@
#ifndef SRC_RTMP_RTMPPROTOCOL_H_
#define SRC_RTMP_RTMPPROTOCOL_H_
#include <netinet/in.h>
#include <memory>
#include <string>
#include <functional>

View File

@@ -26,7 +26,7 @@ RtmpPusher::RtmpPusher(const char *strApp,const char *strStream) {
}, []() {});
auto src = RtmpMediaSource::find(strApp,strStream);
if (!src) {
auto strErr = StrPrinter << "媒体源:" << strApp << "/" << strStream << "不存在" << endl;
auto strErr = StrPrinter << "media source:" << strApp << "/" << strStream << "not found!" << endl;
throw std::runtime_error(strErr);
}
m_pMediaSrc = src;
@@ -132,7 +132,7 @@ inline void RtmpPusher::send_connect() {
auto level = val["level"].as_string();
auto code = val["code"].as_string();
if(level != "status"){
throw std::runtime_error(StrPrinter <<"connect 失败" << level << " " << code << endl);
throw std::runtime_error(StrPrinter <<"connect 失败:" << level << " " << code << endl);
}
send_createStream();
});
@@ -157,7 +157,7 @@ inline void RtmpPusher::send_publish() {
auto level = val["level"].as_string();
auto code = val["code"].as_string();
if(level != "status") {
throw std::runtime_error(StrPrinter <<"publish 失败" << level << " " << code << endl);
throw std::runtime_error(StrPrinter <<"publish 失败:" << level << " " << code << endl);
}
//start send media
send_metaData();
@@ -167,10 +167,10 @@ inline void RtmpPusher::send_publish() {
inline void RtmpPusher::send_metaData(){
auto src = m_pMediaSrc.lock();
if (!src) {
throw std::runtime_error("媒体源已被释放");
throw std::runtime_error("the media source was released");
}
if (!src->ready()) {
throw std::runtime_error("媒体源尚未准备就绪");
throw std::runtime_error("the media source is not ready");
}
AMFEncoder enc;
@@ -219,7 +219,7 @@ void RtmpPusher::onCmd_onStatus(AMFDecoder &dec) {
}
}
if(val.type() != AMF_OBJECT){
throw std::runtime_error("onStatus: 未找到结果对象");
throw std::runtime_error("onStatus:the result object was not found");
}
lock_guard<recursive_mutex> lck(m_mtxOnStatusCB);

View File

@@ -8,7 +8,6 @@
#ifndef SRC_RTMP_RTMPSESSION_H_
#define SRC_RTMP_RTMPSESSION_H_
#include <netinet/in.h>
#include <unordered_map>
#include "amf.h"
#include "Rtmp.h"

View File

@@ -1,6 +1,5 @@
#include <string.h>
#include <stdexcept>
#include <arpa/inet.h>
#include "amf.h"
#include "utils.h"
#include "Util/logger.h"

View File

@@ -3,7 +3,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <arpa/inet.h>
#include "Util/util.h"
using namespace ZL::Util;
/*
* Used to do unaligned loads on archs that don't support them. GCC can mostly

View File

@@ -5,7 +5,6 @@
* Author: xzl
*/
#include <arpa/inet.h>
#include <list>
#include "RtpBroadCaster.h"
#include "Util/util.h"
@@ -65,7 +64,7 @@ RtpBroadCaster::~RtpBroadCaster() {
RtpBroadCaster::RtpBroadCaster(const string &strLocalIp,const string &strApp,const string &strStream) {
auto src = RtspMediaSource::find(strApp, strStream);
if(!src){
auto strErr = StrPrinter << "未找到媒体源" << strApp << " " << strStream << endl;
auto strErr = StrPrinter << "未找到媒体源:" << strApp << " " << strStream << endl;
throw std::runtime_error(strErr);
}
m_multiAddr = MultiCastAddressMaker::Instance().obtain();

View File

@@ -8,8 +8,7 @@
#ifndef SRC_RTSP_RTPBROADCASTER_H_
#define SRC_RTSP_RTPBROADCASTER_H_
#include <arpa/inet.h>
#include <netinet/in.h>
#include <mutex>
#include <memory>
#include <unordered_set>

View File

@@ -35,7 +35,7 @@ RtpParser::RtpParser(const string& sdp) {
RtspTrack tmp[2];
int cnt = parserSDP(sdp, tmp);
if (0 == cnt) {
throw std::runtime_error("解析SDP失败");
throw std::runtime_error("parse sdp failed");
}
for (int i = 0; i < cnt; i++) {
@@ -129,7 +129,7 @@ inline bool RtpParser::inputVideo(const RtpPacket& rtppack,
if (rtppack.sequence != (uint16_t)(m_h264frame.sequence + 1)) {
m_h264frame.data.clear();
WarnL << "丢包,帧废弃" << rtppack.sequence << "," << m_h264frame.sequence;
WarnL << "丢包,帧废弃:" << rtppack.sequence << "," << m_h264frame.sequence;
return false;
}
m_h264frame.sequence = rtppack.sequence;
@@ -204,7 +204,7 @@ inline void RtpParser::onGetVideoTrack(const RtspTrack& video) {
string strTmp((char *)SPS_BUF, SPS_LEN);
if (!getAVCInfo(strTmp, m_iVideoWidth, m_iVideoHeight, m_fVideoFps)) {
throw std::runtime_error("解析SPS失败");
throw std::runtime_error("parse sdp failed");
}
}

View File

@@ -2,13 +2,13 @@
#include <cmath>
#include <stdarg.h>
#include <algorithm>
#include <arpa/inet.h>
#include "Common/config.h"
#include "RtspPlayer.h"
#include "Device/base64.h"
#include "H264/SPSParser.h"
#include "Util/mini.h"
#include "Util/util.h"
#include "Network/sockutil.h"
using namespace ZL::Util;
@@ -127,7 +127,7 @@ void RtspPlayer::onConnect(const SockException &err){
teardown();
return;
}
//发送DESCRIBE命令后处理函数HandleResDESCRIBE
//发送DESCRIBE命令后处理函数:HandleResDESCRIBE
m_onHandshake = std::bind(&RtspPlayer::HandleResDESCRIBE,this, placeholders::_1);
write("DESCRIBE %s RTSP/1.0\r\n"
"CSeq: %d\r\n"
@@ -345,9 +345,7 @@ void RtspPlayer::HandleResSETUP(const Parser& parser, unsigned int uiTrackIndex)
return;
}
if(((struct sockaddr_in *)addr)->sin_addr.s_addr != srcIP) {
char strAddr[32] = {0};
inet_ntop(addr->sa_family,(&((struct sockaddr_in *) addr)->sin_addr),strAddr,sizeof(strAddr));
WarnL << "收到请他地址的UDP数据:" << strAddr;
WarnL << "收到请他地址的UDP数据:" << inet_ntoa(((struct sockaddr_in *) addr)->sin_addr);
return;
}
strongSelf->HandleOneRtp(i,(unsigned char *)buf->data(),buf->size());
@@ -404,7 +402,7 @@ void RtspPlayer::pause(bool bPause) {
sendPause(bPause,getProgressTime());
}
//注意当字符串为空时,也会返回一个空字符串
//注意:当字符串为空时,也会返回一个空字符串
static void split(const string& s, const char *delim, vector<string> &ret) {
size_t last = 0;
size_t index = s.find_first_of(delim, last);
@@ -573,7 +571,7 @@ inline bool RtspPlayer::HandleOneRtp(int iTrackidx, unsigned char *pucData, unsi
WarnL << "ssrc错误";
if (m_aui32SsrcErrorCnt[iTrackidx]++ > 10) {
track.ssrc = rtppt.ssrc;
WarnL << "ssrc更换";
WarnL << "ssrc更换!";
}
return false;
}

View File

@@ -8,7 +8,6 @@
#ifndef SRC_RTSPPLAYER_RTSPPLAYER_H_TXT_
#define SRC_RTSPPLAYER_RTSPPLAYER_H_TXT_
#include <netinet/in.h>
#include <string>
#include <memory>
#include "Rtsp.h"
@@ -37,7 +36,7 @@ class RtspPlayer: public PlayerBase,public TcpClient {
public:
typedef std::shared_ptr<RtspPlayer> Ptr;
//设置rtp传输类型可选项有0(tcp默认)、1(udp)、2(组播)
//设置方法player[RtspPlayer::kRtpType] = 0/1/2;
//设置方法:player[RtspPlayer::kRtpType] = 0/1/2;
static const char kRtpType[];
RtspPlayer();

View File

@@ -4,8 +4,7 @@
* Created on: 2016年8月12日
* Author: xzl
*/
#include <arpa/inet.h>
#include <netinet/in.h>
#include <atomic>
#include "Common/config.h"
#include "UDPServer.h"
@@ -106,7 +105,7 @@ void RtspSession::onError(const SockException& err) {
lock_guard<recursive_mutex> lock(g_mtxPostter);
//为了保证脱离TCPServer后还能正常运作,需要保持本对象的强引用
g_mapPostter.emplace(this, dynamic_pointer_cast<RtspSession>(shared_from_this()));
TraceL << "quickTime已经不再发送请求";
TraceL << "quickTime will not send request any more!";
}
}

View File

@@ -8,7 +8,6 @@
#ifndef SESSION_RTSPSESSION_H_
#define SESSION_RTSPSESSION_H_
#include <netinet/in.h>
#include <set>
#include <vector>
#include <unordered_map>

View File

@@ -5,13 +5,7 @@
* Author: xzl
*/
#include <unistd.h>
#include <string.h>
#include <net/if.h>
#include <arpa/inet.h>
#include <sys/ioctl.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include "Common/config.h"
#include "Rtmp/Rtmp.h"
#include "RtspToRtmpMediaSource.h"

View File

@@ -5,7 +5,7 @@
* Author: xzl
*/
#include <arpa/inet.h>
#include "UDPServer.h"
#include "Util/TimeTicker.h"

View File

@@ -8,7 +8,6 @@
#ifndef SRC_SHELL_CMD_H_
#define SRC_SHELL_CMD_H_
#include <getopt.h>
#include <string>
#include <vector>
#include <iostream>
@@ -69,7 +68,7 @@ public:
typedef function< void(OutStream *stream, const unordered_multimap<char, string> &)> OptionCompleted;
OptionParser(const OptionCompleted &_cb) {
onCompleted = _cb;
helper = Option('h', "help", Option::ArgNone, "获取此帮助", [this](OutStream *stream,const char *arg)->bool {
helper = Option('h', "help", Option::ArgNone, "print this help", [this](OutStream *stream,const char *arg)->bool {
_StrPrinter printer;
for (auto &pr : options) {
printer<<"\t-"<<pr.first<<"\t--"<<pr.second.longOpt<<"\t"<<pr.second.des<<"\r\n";