1 Star 3 Fork 4

周新童/LibRtmpPusher

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
rtmppusher.h 2.12 KB
一键复制 编辑 原始数据 按行查看 历史
周新童 提交于 2023-06-14 09:49 . 版本1.0发布
#ifndef RTMPPUSHER_H
#define RTMPPUSHER_H
#include <QThread>
#include <QDebug>
#include <QMutexLocker>
#include "ffmpegheader.h"
#include "librtmp/rtmp.h"
#include "rtmpmsg.h"
enum AVPacketType
{
TypeAudio = 0,
TypeVideo
};
enum
{
FLV_CODECID_H264 = 7,
FLV_CODECID_AAC = 10,
};
struct ReadyPacket
{
//AVpacket数据、类型、以及时间戳ms
AVPacketType type;
AVPacket *packet;
uint32_t ptsTime;
uint32_t dtsTime;
};
class RtmpPusher : public QThread
{
Q_OBJECT
public:
RtmpPusher();
~RtmpPusher();
void setRunState(bool start);
//测试推送本地flv文件
void testPushFlvFile();
//初始化发送队列
void initSender();
//释放队列
void release();
//音视频包的写入
void writePacket(ReadyPacket *packet);
//音视频头信息
void setMetaMsg(FLVMetadataMsg *metaMsg);
void setAudioSeqHeader(char *aacSeqHeader, int aacSeqHeaderLen);
void setVideoSeqHeader(char *avcSeqHeader, int avcSeqHeaderLen);
//解析AVPacket数据
void parseVideoAVPacket(char *packetData, int packetSize, uint32_t ptsTime, uint32_t dtsTime);
void parseAudioAVPacket(char *packetData, int packetSize, uint32_t ptsTime);
//构造rtmp消息
bool sendMetadata(FLVMetadataMsg *metadata);
bool sendAACSpecificConfig();
bool sendH264SequenceHeader();
bool sendAACRawData(char *rawData, int size, uint32_t ptsTime);
bool sendH264RawData(char *rawData, int size, uint32_t ptsTime, uint32_t dtsTime);
//实际发送函数 内部分解rtmp消息chunk发送
int sendRtmpPacket(int packetType, uint8_t *data, int size, uint32_t timeStamp);
protected:
void run();
public:
volatile bool isRun;
QString filePath;
uint32_t pushStartTime;
RTMP *rtmp;
bool hasAudio;
bool hasVideo;
QMutex mutex;
//meta记录
FLVMetadataMsg *metaMsg;
//音频 AAC Sequence header
char *aacSeqHeader;
int aacSeqHeaderLen;
//视频 AVC Sequence header
char *avcSeqHeader;
int avcSeqHeaderLen;
//音视频包队列
QList<ReadyPacket *> packetList;
};
#endif // RTMPPUSHER_H
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/zhou_xintong/lib-rtmp-pusher.git
[email protected]:zhou_xintong/lib-rtmp-pusher.git
zhou_xintong
lib-rtmp-pusher
LibRtmpPusher
master

搜索帮助