mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-07-04 01:37:33 +08:00
完成DevChannel类的视频
This commit is contained in:
@@ -31,10 +31,8 @@
|
||||
#include <string>
|
||||
#include <functional>
|
||||
#include "Util/util.h"
|
||||
#include "Player/Player.h"
|
||||
#include "Rtsp/RtspToRtmpMediaSource.h"
|
||||
#include "RtspMuxer/RtspSdp.h"
|
||||
#include "Util/TimeTicker.h"
|
||||
#include "Player/Player.h"
|
||||
#include "Common/MultiMediaSourceMuxer.h"
|
||||
|
||||
using namespace std;
|
||||
@@ -52,7 +50,6 @@ using namespace toolkit;
|
||||
|
||||
namespace mediakit {
|
||||
|
||||
#if 0
|
||||
class VideoInfo {
|
||||
public:
|
||||
int iWidth;
|
||||
@@ -67,37 +64,85 @@ public:
|
||||
int iProfile;
|
||||
};
|
||||
|
||||
class DevChannel : public RtspToRtmpMediaSource{
|
||||
/**
|
||||
* 该类已经废弃,保留只为兼容旧代码,请直接使用MultiMediaSourceMuxer类!
|
||||
*/
|
||||
class DevChannel : public MultiMediaSourceMuxer{
|
||||
public:
|
||||
typedef std::shared_ptr<DevChannel> Ptr;
|
||||
//fDuration<=0为直播,否则为点播
|
||||
DevChannel(const char *strVhost,
|
||||
DevChannel(const char *strVhost,
|
||||
const char *strApp,
|
||||
const char *strId,
|
||||
float fDuration = 0,
|
||||
bool bEanbleHls = true,
|
||||
bool bEnableMp4 = false);
|
||||
|
||||
virtual ~DevChannel();
|
||||
|
||||
void initVideo(const VideoInfo &info);
|
||||
/**
|
||||
* 初始化h264视频Track
|
||||
* 相当于MultiMediaSourceMuxer::addTrack(H264Track::Ptr );
|
||||
* @param info
|
||||
*/
|
||||
void initVideo(const VideoInfo &info);
|
||||
|
||||
/**
|
||||
* 初始化aac音频Track
|
||||
* 相当于MultiMediaSourceMuxer::addTrack(AACTrack::Ptr );
|
||||
* @param info
|
||||
*/
|
||||
void initAudio(const AudioInfo &info);
|
||||
|
||||
void inputH264(const char *pcData, int iDataLen, uint32_t uiStamp);
|
||||
/**
|
||||
* 输入264帧
|
||||
* @param pcData 264单帧数据指针
|
||||
* @param iDataLen 数据指针长度
|
||||
* @param uiStamp 时间戳,单位毫秒
|
||||
* @param prefixSize 264 其实头字节数,起始头可以是0x00 00 00 01 或 0x 00 00 01 或者没有起始头
|
||||
*/
|
||||
void inputH264(const char *pcData, int iDataLen, uint32_t uiStamp,int prefixSize = 4);
|
||||
|
||||
/**
|
||||
* 输入可能带adts头的aac帧
|
||||
* @param pcDataWithAdts 可能带adts头的aac帧
|
||||
* @param iDataLen 帧数据长度
|
||||
* @param uiStamp 时间戳,单位毫秒
|
||||
* @param withAdtsHeader 是否带adts头
|
||||
*/
|
||||
void inputAAC(const char *pcDataWithAdts, int iDataLen, uint32_t uiStamp, bool withAdtsHeader = true);
|
||||
|
||||
/**
|
||||
* 输入不带adts头的aac帧
|
||||
* @param pcDataWithoutAdts 不带adts头的aac帧
|
||||
* @param iDataLen 帧数据长度
|
||||
* @param uiStamp 时间戳,单位毫秒
|
||||
* @param pcAdtsHeader adts头
|
||||
*/
|
||||
void inputAAC(const char *pcDataWithoutAdts,int iDataLen, uint32_t uiStamp,const char *pcAdtsHeader);
|
||||
|
||||
#ifdef ENABLE_X264
|
||||
void inputYUV(char *apcYuv[3], int aiYuvLen[3], uint32_t uiStamp);
|
||||
/**
|
||||
* 输入yuv420p视频帧,内部会完成编码并调用inputH264方法
|
||||
* @param apcYuv
|
||||
* @param aiYuvLen
|
||||
* @param uiStamp
|
||||
*/
|
||||
void inputYUV(char *apcYuv[3], int aiYuvLen[3], uint32_t uiStamp);
|
||||
#endif //ENABLE_X264
|
||||
|
||||
#ifdef ENABLE_FAAC
|
||||
void inputPCM(char *pcData, int iDataLen, uint32_t uiStamp);
|
||||
|
||||
/**
|
||||
* 输入pcm数据,内部会完成编码并调用inputAAC方法
|
||||
* @param pcData
|
||||
* @param iDataLen
|
||||
* @param uiStamp
|
||||
*/
|
||||
void inputPCM(char *pcData, int iDataLen, uint32_t uiStamp);
|
||||
#endif //ENABLE_FAAC
|
||||
|
||||
private:
|
||||
inline void makeSDP_264(unsigned char *pucData, int iDataLen);
|
||||
inline void makeSDP_AAC(unsigned char *pucData);
|
||||
inline void makeSDP(const string& strSdp);
|
||||
#ifdef ENABLE_X264
|
||||
std::shared_ptr<H264Encoder> _pH264Enc;
|
||||
#endif //ENABLE_X264
|
||||
@@ -105,25 +150,13 @@ private:
|
||||
#ifdef ENABLE_FAAC
|
||||
std::shared_ptr<AACEncoder> _pAacEnc;
|
||||
#endif //ENABLE_FAAC
|
||||
RtpMaker_AAC::Ptr _pRtpMaker_aac;
|
||||
RtpMaker_H264::Ptr _pRtpMaker_h264;
|
||||
bool _bSdp_gotH264 = false;
|
||||
bool _bSdp_gotAAC = false;
|
||||
std::shared_ptr<VideoInfo> _video;
|
||||
std::shared_ptr<AudioInfo> _audio;
|
||||
|
||||
unsigned char _aucSPS[256];
|
||||
unsigned int _uiSPSLen = 0;
|
||||
unsigned char _aucPPS[256];
|
||||
unsigned int _uiPPSLen = 0;
|
||||
std::shared_ptr<VideoInfo> _video;
|
||||
std::shared_ptr<AudioInfo> _audio;
|
||||
SmoothTicker _aTicker[2];
|
||||
std::shared_ptr<AACFrame> _pAdtsHeader;
|
||||
uint8_t _adtsHeader[7];
|
||||
};
|
||||
|
||||
#endif //0
|
||||
|
||||
typedef MultiMediaSourceMuxer DevChannel;
|
||||
|
||||
} /* namespace mediakit */
|
||||
|
||||
#endif /* DEVICE_DEVICE_H_ */
|
||||
|
||||
Reference in New Issue
Block a user