資源簡介
通過ffmpeg把分出264的包,在通過jrtplib庫分成rtp包發(fā)送出去,供學(xué)習(xí)用
代碼片段和文件信息
/*
*?Copyright?(c)?2013?Stefano?Sabatini
*
*?Permission?is?hereby?granted?free?of?charge?to?any?person?obtaining?a?copy
*?of?this?software?and?associated?documentation?files?(the?“Software“)?to?deal
*?in?the?Software?without?restriction?including?without?limitation?the?rights
*?to?use?copy?modify?merge?publish?distribute?sublicense?and/or?sell
*?copies?of?the?Software?and?to?permit?persons?to?whom?the?Software?is
*?furnished?to?do?so?subject?to?the?following?conditions:
*
*?The?above?copyright?notice?and?this?permission?notice?shall?be?included?in
*?all?copies?or?substantial?portions?of?the?Software.
*
*?THE?SOFTWARE?IS?PROVIDED?“AS?IS“?WITHOUT?WARRANTY?OF?ANY?KIND?EXPRESS?OR
*?IMPLIED?INCLUDING?BUT?NOT?LIMITED?TO?THE?WARRANTIES?OF?MERCHANTABILITY
*?FITNESS?FOR?A?PARTICULAR?PURPOSE?AND?NONINFRINGEMENT.?IN?NO?EVENT?SHALL
*?THE?AUTHORS?OR?COPYRIGHT?HOLDERS?BE?LIABLE?FOR?ANY?CLAIM?DAMAGES?OR?OTHER
*?LIABILITY?WHETHER?IN?AN?ACTION?OF?CONTRACT?TORT?OR?OTHERWISE?ARISING?FROM
*?OUT?OF?OR?IN?CONNECTION?WITH?THE?SOFTWARE?OR?THE?USE?OR?OTHER?DEALINGS?IN
*?THE?SOFTWARE.
*/
/**
*?@file
*?libavformat/libavcodec?demuxing?and?muxing?API?example.
*
*?Remux?streams?from?one?container?format?to?another.
*?@example?remuxing.c
*/
#include?
#include?
#include?
#include?
#include?
extern?“C“
{
#include?
#include?
#include?
}
#define?SSRC???????????100
#define?DEST_IP_STR???“127.0.0.1“
#define?DEST_PORT?????1234
#define?base_PORT?????2222
#define?MAX_RTP_PKT_LENGTH?1360
#define?H264???????????????96
using?namespace?jrtplib;
using?namespace?std;
bool?CheckError(int?rtperr);
class?CRTPSender?:
public?RTPSession
{
public:
CRTPSender(void);
~CRTPSender(void);
protected:
void?OnAPPPacket(RTCPAPPPacket?*apppacket?const?RTPTime?&receivetime?const?RTPAddress?*senderaddress);
void?OnBYEPacket(RTPSourceData?*srcdat);
void?OnBYETimeout(RTPSourceData?*srcdat);
public:
void?SendH264Nalu(unsigned?char*?m_h264Buf?int?buflen);
void?SetParamsForSendingH264();
};
bool?CheckError(int?rtperr)
{
if?(rtperr?0)
{
std::cout?<“ERROR:?“?< return?false;
}
return?true;
}
CRTPSender::CRTPSender(void)
{
}
CRTPSender::~CRTPSender(void)
{
}
void?CRTPSender::SendH264Nalu(unsigned?char*?m_h264Buf?int?buflen)
{
unsigned?char?*pSendbuf;?//發(fā)送數(shù)據(jù)指針
pSendbuf?=?m_h264Buf;
cout?<“1111\n“;
//去除起始碼0x000001?或者0x00000001
if(?0x01?==?m_h264Buf[2]?)
{
pSendbuf?=?&m_h264Buf[3];
buflen?-=?3;
}
else
{
pSendbuf?=?&m_h264Buf[4];
buflen?-=?4;
}
char?sendbuf[1430];???//發(fā)送的數(shù)據(jù)緩沖
memset(sendbuf?0?1430);
int?status;
printf(“send?packet?length?%d?\n“?buflen);
if?(buflen?<=?MAX_RTP_PKT_LENGTH)
{
memcpy(se
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2019-07-23?20:49??rtp\
?????目錄???????????0??2019-07-23?20:53??rtp\build\
?????目錄???????????0??2019-07-23?22:53??rtp\build\rtp\
?????目錄???????????0??2019-07-23?20:54??rtp\build\rtp\.vs\
?????目錄???????????0??2019-07-23?20:54??rtp\build\rtp\.vs\rtp\
?????目錄???????????0??2019-07-23?20:54??rtp\build\rtp\.vs\rtp\v14\
?????文件???????35840??2019-07-23?22:53??rtp\build\rtp\.vs\rtp\v14\.suo
?????目錄???????????0??2019-07-23?22:52??rtp\build\rtp\Debug\
?????文件??????903674??2019-07-23?22:52??rtp\build\rtp\Debug\main.obj
?????文件?????????657??2019-07-23?21:37??rtp\build\rtp\Debug\rtp.Build.CppClean.log
?????文件??????705536??2019-07-23?22:52??rtp\build\rtp\Debug\rtp.exe
?????文件?????2814772??2019-07-23?22:52??rtp\build\rtp\Debug\rtp.ilk
?????文件?????????488??2019-07-23?22:52??rtp\build\rtp\Debug\rtp.log
?????文件?????6344704??2019-07-23?22:52??rtp\build\rtp\Debug\rtp.pdb
?????目錄???????????0??2019-07-23?22:52??rtp\build\rtp\Debug\rtp.tlog\
?????文件?????????546??2019-07-23?22:52??rtp\build\rtp\Debug\rtp.tlog\CL.command.1.tlog
?????文件???????38696??2019-07-23?22:52??rtp\build\rtp\Debug\rtp.tlog\CL.read.1.tlog
?????文件?????????260??2019-07-23?22:52??rtp\build\rtp\Debug\rtp.tlog\CL.write.1.tlog
?????文件????????2194??2019-07-23?22:52??rtp\build\rtp\Debug\rtp.tlog\li
?????文件????????3880??2019-07-23?22:52??rtp\build\rtp\Debug\rtp.tlog\li
?????文件?????????742??2019-07-23?22:52??rtp\build\rtp\Debug\rtp.tlog\li
?????文件?????????183??2019-07-23?22:52??rtp\build\rtp\Debug\rtp.tlog\rtp.lastbuildstate
?????文件?????1117184??2019-07-23?22:52??rtp\build\rtp\Debug\vc140.idb
?????文件??????970752??2019-07-23?22:52??rtp\build\rtp\Debug\vc140.pdb
?????文件???????17448??2019-07-23?22:52??rtp\build\rtp\main.cpp
?????文件????39313408??2019-07-23?22:53??rtp\build\rtp\rtp.VC.db
?????文件????????1287??2019-07-23?20:54??rtp\build\rtp\rtp.sln
?????文件???????20064??2019-07-23?21:40??rtp\build\rtp\rtp.vcxproj
?????文件???????22292??2019-07-23?21:36??rtp\build\rtp\rtp.vcxproj.filters
?????文件?????????165??2019-07-23?20:54??rtp\build\rtp\rtp.vcxproj.user
?????目錄???????????0??2019-07-23?21:40??rtp\include\
............此處省略197個(gè)文件信息
評論
共有 條評論