增加adts头相关接口

This commit is contained in:
xiongziliang 2017-12-19 10:34:52 +08:00
parent 68bc9b6a6a
commit 6ff01f55c4
12 changed files with 150 additions and 114 deletions

View File

@ -50,7 +50,7 @@ static TcpServer<HttpSession>::Ptr s_pHttpSrv;
//////////////////////////environment init///////////////////////////
API_EXPORT void CALLTYPE onAppStart(){
API_EXPORT void API_CALL onAppStart(){
static onceToken s_token([](){
Logger::Instance().add(std::make_shared<ConsoleChannel>("stdout", LTrace));
EventPoller::Instance(true);
@ -70,11 +70,13 @@ API_EXPORT void CALLTYPE onAppStart(){
}
API_EXPORT void CALLTYPE onAppExit(){
API_EXPORT void API_CALL onAppExit(){
cleaner::Destory();
}
API_EXPORT int CALLTYPE initHttpServer(unsigned short port){
API_EXPORT void API_CALL setGlobalOptionString(const char *key,const char *val){
mINI::Instance()[key] = val;
}
API_EXPORT int API_CALL initHttpServer(unsigned short port){
s_pHttpSrv.reset(new TcpServer<HttpSession>());
try {
s_pHttpSrv->start(port);
@ -85,7 +87,7 @@ API_EXPORT int CALLTYPE initHttpServer(unsigned short port){
return -1;
}
}
API_EXPORT int CALLTYPE initRtspServer(unsigned short port) {
API_EXPORT int API_CALL initRtspServer(unsigned short port) {
s_pRtspSrv.reset(new TcpServer<RtspSession>());
try {
s_pRtspSrv->start(port);
@ -97,7 +99,7 @@ API_EXPORT int CALLTYPE initRtspServer(unsigned short port) {
}
}
API_EXPORT int CALLTYPE initRtmpServer(unsigned short port) {
API_EXPORT int API_CALL initRtmpServer(unsigned short port) {
s_pRtmpSrv.reset(new TcpServer<RtmpSession>());
try {
s_pRtmpSrv->start(port);
@ -109,7 +111,7 @@ API_EXPORT int CALLTYPE initRtmpServer(unsigned short port) {
}
}
API_EXPORT void CALLTYPE listenEvent_onPlay(onEventPlay cb,void *userData){
API_EXPORT void API_CALL listenEvent_onPlay(onEventPlay cb,void *userData){
NoticeCenter::Instance().addListener((void *)(cb),Config::Broadcast::kBroadcastRtspSessionPlay,
[cb,userData](BroadcastRtspSessionPlayArgs){
static unordered_map<string, void *> s_timerKeyMap;
@ -132,14 +134,14 @@ API_EXPORT void CALLTYPE listenEvent_onPlay(onEventPlay cb,void *userData){
});
}
API_EXPORT void CALLTYPE listenEvent_onRegistRtsp(onEventRegistMediaSrc cb,void *userData){
API_EXPORT void API_CALL listenEvent_onRegistRtsp(onEventRegistMediaSrc cb,void *userData){
NoticeCenter::Instance().addListener((void *)(cb),Config::Broadcast::kBroadcastRtspSrcRegisted,
[cb,userData](BroadcastRtspSrcRegistedArgs){
cb(userData,app,stream);
});
}
API_EXPORT void CALLTYPE listenEvent_onRegistRtmp(onEventRegistMediaSrc cb,void *userData){
API_EXPORT void API_CALL listenEvent_onRegistRtmp(onEventRegistMediaSrc cb,void *userData){
NoticeCenter::Instance().addListener((void *)(cb),Config::Broadcast::kBroadcastRtmpSrcRegisted,
[cb,userData](BroadcastRtmpSrcRegistedArgs){
cb(userData,app,stream);
@ -147,7 +149,7 @@ API_EXPORT void CALLTYPE listenEvent_onRegistRtmp(onEventRegistMediaSrc cb,void
}
API_EXPORT void CALLTYPE log_printf(LogType level,const char* file, const char* function, int line,const char *fmt,...){
API_EXPORT void API_CALL log_printf(LogType level,const char* file, const char* function, int line,const char *fmt,...){
LogInfoMaker info((LogLevel)level,file,function,line);
va_list pArg;
va_start(pArg, fmt);
@ -157,7 +159,7 @@ API_EXPORT void CALLTYPE log_printf(LogType level,const char* file, const char*
va_end(pArg);
info << buf;
}
API_EXPORT void CALLTYPE log_setLevel(LogType level){
API_EXPORT void API_CALL log_setLevel(LogType level){
Logger::Instance().setLevel((LogLevel)level);
}
@ -183,7 +185,7 @@ private:
onLogOut _cb = nullptr;
};
API_EXPORT void CALLTYPE log_setOnLogOut(onLogOut cb){
API_EXPORT void API_CALL log_setOnLogOut(onLogOut cb){
std::shared_ptr<LogoutChannel> chn(new LogoutChannel("LogoutChannel",cb,LTrace));
Logger::Instance().add(chn);
}

View File

@ -36,10 +36,10 @@
#define API_EXPORT __declspec(dllimport)
#endif
#define CALLTYPE __cdecl
#define API_CALL __cdecl
#else
#define API_EXPORT
#define CALLTYPE
#define API_CALL
#endif
@ -50,62 +50,63 @@ extern "C" {
/////////////////////////environment init////////////////////////////////
API_EXPORT void CALLTYPE onAppStart();
API_EXPORT void CALLTYPE onAppExit();
API_EXPORT void API_CALL onAppStart();
API_EXPORT void API_CALL onAppExit();
API_EXPORT void API_CALL setGlobalOptionString(const char *key,const char *val);
/*
* :Http服务器
* :port:htt监听端口80
* :0:;-1:
*/
API_EXPORT int CALLTYPE initHttpServer(unsigned short port);
API_EXPORT int API_CALL initHttpServer(unsigned short port);
/*
* :RTSP服务器
* :port:rtsp监听端口554
* :0:;-1:
*/
API_EXPORT int CALLTYPE initRtspServer(unsigned short port);
API_EXPORT int API_CALL initRtspServer(unsigned short port);
/*
* :RTMP服务器
* :port:rtmp监听端口1935
* :0:;-1:
*/
API_EXPORT int CALLTYPE initRtmpServer(unsigned short port);
API_EXPORT int API_CALL initRtmpServer(unsigned short port);
/*
* :
* :userData:strApp:,strStream:
*/
typedef void (CALLTYPE *onEventPlay)(void *userData,const char *strApp,const char *strStream);
typedef void (API_CALL *onEventPlay)(void *userData,const char *strApp,const char *strStream);
/*
* :
* :cb:,userData:
* :
*/
API_EXPORT void CALLTYPE listenEvent_onPlay(onEventPlay cb,void *userData);
API_EXPORT void API_CALL listenEvent_onPlay(onEventPlay cb,void *userData);
/*
* :RTSP事件
* :userData:strApp:,strStream:
*/
typedef void (CALLTYPE *onEventRegistMediaSrc)(void *userData,const char *strApp,const char *strStream);
typedef void (API_CALL *onEventRegistMediaSrc)(void *userData,const char *strApp,const char *strStream);
/*
* :
* :cb:,userData:
* :
*/
API_EXPORT void CALLTYPE listenEvent_onRegistRtsp(onEventRegistMediaSrc cb,void *userData);
API_EXPORT void API_CALL listenEvent_onRegistRtsp(onEventRegistMediaSrc cb,void *userData);
/*
* :
* :cb:,userData:
* :
*/
API_EXPORT void CALLTYPE listenEvent_onRegistRtmp(onEventRegistMediaSrc cb,void *userData);
API_EXPORT void API_CALL listenEvent_onRegistRtmp(onEventRegistMediaSrc cb,void *userData);
/////////////////////////日志////////////////////////////////
@ -115,28 +116,28 @@ typedef enum {
LogTrace = 0, LogDebug, LogInfo, LogWarn, LogError, LogFatal,
} LogType;
typedef void(CALLTYPE *onLogOut)(const char *strLog, int iLogLen);
typedef void(API_CALL *onLogOut)(const char *strLog, int iLogLen);
/*
* :Log输出回调
* :onLogOut
* :
*/
API_EXPORT void CALLTYPE log_setOnLogOut(onLogOut);
API_EXPORT void API_CALL log_setOnLogOut(onLogOut);
/*
* :
* :level:
* :
*/
API_EXPORT void CALLTYPE log_setLevel(LogType level);
API_EXPORT void API_CALL log_setLevel(LogType level);
/*
* :
* :level:file:,functionlinefmt
* :
*/
API_EXPORT void CALLTYPE log_printf(LogType level, const char* file, const char* function, int line, const char *fmt, ...);
API_EXPORT void API_CALL log_printf(LogType level, const char* file, const char* function, int line, const char *fmt, ...);
#define log_trace(fmt,...) log_printf(LogTrace,__FILE__,__FUNCTION__,__LINE__,fmt,__VA_ARGS__)

View File

@ -50,13 +50,13 @@ static onceToken s_token([](){
API_EXPORT HttpDownloaderContex CALLTYPE createDownloader(){
API_EXPORT HttpDownloaderContex API_CALL createDownloader(){
HttpDownloader::Ptr ret(new HttpDownloader());
lock_guard<recursive_mutex> lck(s_mtxMapDownloader);
s_mapDownloader.emplace(ret.get(),ret);
return ret.get();
}
API_EXPORT void CALLTYPE downloader_startDownload(HttpDownloaderContex ctx,const char *url,downloader_onResult cb,void *userData){
API_EXPORT void API_CALL downloader_startDownload(HttpDownloaderContex ctx,const char *url,downloader_onResult cb,void *userData){
HttpDownloader *ptr = (HttpDownloader *)ctx;
string urlTmp(url);
ptr->startDownload(url, [cb,userData,urlTmp](int code,const char *errMsg,const char *filePath){
@ -66,7 +66,7 @@ API_EXPORT void CALLTYPE downloader_startDownload(HttpDownloaderContex ctx,const
}
});
}
API_EXPORT void CALLTYPE releaseDownloader(HttpDownloaderContex ctx){
API_EXPORT void API_CALL releaseDownloader(HttpDownloaderContex ctx){
lock_guard<recursive_mutex> lck(s_mtxMapDownloader);
s_mapDownloader.erase(ctx);
}

View File

@ -35,11 +35,11 @@ extern "C" {
////////////////////////////////////////Httpdownloader/////////////////////////////////////////////////
typedef void * HttpDownloaderContex;
typedef void(CALLTYPE *downloader_onResult)(void *userData,int code,const char *errMsg,const char *filePath);
typedef void(API_CALL *downloader_onResult)(void *userData,int code,const char *errMsg,const char *filePath);
API_EXPORT HttpDownloaderContex CALLTYPE createDownloader();
API_EXPORT void CALLTYPE downloader_startDownload(HttpDownloaderContex ctx,const char *url,downloader_onResult cb,void *userData);
API_EXPORT void CALLTYPE releaseDownloader(HttpDownloaderContex ctx);
API_EXPORT HttpDownloaderContex API_CALL createDownloader();
API_EXPORT void API_CALL downloader_startDownload(HttpDownloaderContex ctx,const char *url,downloader_onResult cb,void *userData);
API_EXPORT void API_CALL releaseDownloader(HttpDownloaderContex ctx);
#ifdef __cplusplus

View File

@ -49,18 +49,18 @@ static onceToken s_token([](){
//////////////////////////Rtsp media///////////////////////////
API_EXPORT MediaContext CALLTYPE createMedia(const char *appName,const char *mediaName) {
API_EXPORT MediaContext API_CALL createMedia(const char *appName,const char *mediaName) {
DevChannel::Ptr ret(new DevChannel(appName,mediaName));
lock_guard<recursive_mutex> lck(s_mtxMapMedia);
s_mapMedia.emplace((void *) (ret.get()), ret);
return ret.get();
}
API_EXPORT void CALLTYPE releaseMedia(MediaContext ctx) {
API_EXPORT void API_CALL releaseMedia(MediaContext ctx) {
lock_guard<recursive_mutex> lck(s_mtxMapMedia);
s_mapMedia.erase(ctx);
}
API_EXPORT void CALLTYPE media_initVideo(MediaContext ctx, int width, int height, int frameRate) {
API_EXPORT void API_CALL media_initVideo(MediaContext ctx, int width, int height, int frameRate) {
DevChannel *ptr = (DevChannel *) ctx;
VideoInfo info;
info.iFrameRate = frameRate;
@ -68,7 +68,7 @@ API_EXPORT void CALLTYPE media_initVideo(MediaContext ctx, int width, int height
info.iHeight = height;
ptr->initVideo(info);
}
API_EXPORT void CALLTYPE media_initAudio(MediaContext ctx, int channel, int sampleBit, int sampleRate) {
API_EXPORT void API_CALL media_initAudio(MediaContext ctx, int channel, int sampleBit, int sampleRate) {
DevChannel *ptr = (DevChannel *) ctx;
AudioInfo info;
info.iSampleRate = sampleRate;
@ -76,15 +76,30 @@ API_EXPORT void CALLTYPE media_initAudio(MediaContext ctx, int channel, int samp
info.iSampleBit = sampleBit;
ptr->initAudio(info);
}
API_EXPORT void CALLTYPE media_inputH264(MediaContext ctx, void *data, int len, unsigned long stamp) {
API_EXPORT void API_CALL media_inputH264(MediaContext ctx, void *data, int len, unsigned long stamp) {
//TimeTicker();
DevChannel *ptr = (DevChannel *) ctx;
ptr->inputH264((char *) data, len, stamp);
}
API_EXPORT void CALLTYPE media_inputAAC(MediaContext ctx, void *data, int len,unsigned long stamp) {
API_EXPORT void API_CALL media_inputAAC(MediaContext ctx, void *data, int len,unsigned long stamp) {
//TimeTicker();
DevChannel *ptr = (DevChannel *) ctx;
ptr->inputAAC((char *) data, len, stamp);
}
API_EXPORT void API_CALL media_inputAAC1(MediaContext ctx, void *data, int len, unsigned long stamp,void *adts){
DevChannel *ptr = (DevChannel *) ctx;
ptr->inputAAC((char *) data, len, stamp,(char *)adts);
}
API_EXPORT void API_CALL media_inputAAC2(MediaContext ctx, void *data, int len, unsigned long stamp,void *aac_cfg){
DevChannel *ptr = (DevChannel *) ctx;
AdtsFrame frame;
makeAdtsHeader((char*)aac_cfg, frame);
char adts[8];
writeAdtsHeader(frame, (uint8_t*)adts);
ptr->inputAAC((char *) data, len, stamp,(char *)adts);
}

View File

@ -42,42 +42,58 @@ typedef void* MediaContext;
* :mediaName:,url地址的一部分
* :
*/
API_EXPORT MediaContext CALLTYPE createMedia(const char *appName,const char *mediaName);
API_EXPORT MediaContext API_CALL createMedia(const char *appName,const char *mediaName);
/*
* :
* :ctx:
* :
*/
API_EXPORT void CALLTYPE releaseMedia(MediaContext ctx);
API_EXPORT void API_CALL releaseMedia(MediaContext ctx);
/*
* :
* :ctx:;width:;height:;frameRate:fps
* :
*/
API_EXPORT void CALLTYPE media_initVideo(MediaContext ctx, int width, int height, int frameRate);
API_EXPORT void API_CALL media_initVideo(MediaContext ctx, int width, int height, int frameRate);
/*
* :
* :ctx:;channel:;sampleBit:,16bit;sampleRate:
* :
*/
API_EXPORT void CALLTYPE media_initAudio(MediaContext ctx, int channel, int sampleBit, int sampleRate);
API_EXPORT void API_CALL media_initAudio(MediaContext ctx, int channel, int sampleBit, int sampleRate);
/*
* :H264视频SPS和PPS帧,00 00 01,00 00 00 01
* :ctx:;data:H264数据;len:H264数据字节数;stamp:
* :
*/
API_EXPORT void CALLTYPE media_inputH264(MediaContext ctx, void *data, int len, unsigned long stamp);
API_EXPORT void API_CALL media_inputH264(MediaContext ctx, void *data, int len, unsigned long stamp);
/*
* :AAC音频(adts头)
* :ctx:;data:AAC数据;len:AAC数据字节数;stamp:
* :
*/
API_EXPORT void CALLTYPE media_inputAAC(MediaContext ctx, void *data, int len, unsigned long stamp);
API_EXPORT void API_CALL media_inputAAC(MediaContext ctx, void *data, int len, unsigned long stamp);
/*
* :AAC音频(adts头)
* :ctx:;data:AAC数据;len:AAC数据字节数;stamp:;adts:adts头指针
* :
*/
API_EXPORT void API_CALL media_inputAAC1(MediaContext ctx, void *data, int len, unsigned long stamp,void *adts);
/*
* :AAC音频(2aac配置)
* :ctx:;data:AAC数据;len:AAC数据字节数;stamp:;adts:adts头指针;aac_cfg:aac配置
* :
*/
API_EXPORT void API_CALL media_inputAAC2(MediaContext ctx, void *data, int len, unsigned long stamp,void *aac_cfg);
#ifdef __cplusplus

View File

@ -63,7 +63,7 @@ static onceToken s_token([](){
player = it->second;\
}\
}
API_EXPORT PlayerContext CALLTYPE createPlayer() {
API_EXPORT PlayerContext API_CALL createPlayer() {
lock_guard<recursive_mutex> lck(s_mtxMapPlayer);
MediaPlayer::Ptr ret(new MediaPlayer());
s_mapPlayer.emplace(ret.get(), ret);
@ -72,7 +72,7 @@ API_EXPORT PlayerContext CALLTYPE createPlayer() {
}
return ret.get();
}
API_EXPORT void CALLTYPE releasePlayer(PlayerContext ctx) {
API_EXPORT void API_CALL releasePlayer(PlayerContext ctx) {
getPlayer(ctx);
if (!player) {
return;
@ -90,7 +90,7 @@ API_EXPORT void CALLTYPE releasePlayer(PlayerContext ctx) {
});
}
API_EXPORT void CALLTYPE player_setOptionInt(PlayerContext ctx,const char* key,int val){
API_EXPORT void API_CALL player_setOptionInt(PlayerContext ctx,const char* key,int val){
string keyTmp(key);
ASYNC_TRACE([ctx,keyTmp,val](){
getPlayer(ctx);
@ -100,7 +100,7 @@ API_EXPORT void CALLTYPE player_setOptionInt(PlayerContext ctx,const char* key,i
(*player)[keyTmp] = val;
});
}
API_EXPORT void CALLTYPE player_setOptionString(PlayerContext ctx,const char* key,const char *val){
API_EXPORT void API_CALL player_setOptionString(PlayerContext ctx,const char* key,const char *val){
string keyTmp(key);
string valTmp(val);
ASYNC_TRACE([ctx,keyTmp,valTmp](){
@ -111,7 +111,7 @@ API_EXPORT void CALLTYPE player_setOptionString(PlayerContext ctx,const char* ke
(*player)[keyTmp] = valTmp;
});
}
API_EXPORT void CALLTYPE player_play(PlayerContext ctx, const char* url) {
API_EXPORT void API_CALL player_play(PlayerContext ctx, const char* url) {
string urlTmp(url);
ASYNC_TRACE([ctx,urlTmp](){
getPlayer(ctx);
@ -122,7 +122,7 @@ API_EXPORT void CALLTYPE player_play(PlayerContext ctx, const char* url) {
});
}
API_EXPORT void CALLTYPE player_pause(PlayerContext ctx, int pause) {
API_EXPORT void API_CALL player_pause(PlayerContext ctx, int pause) {
ASYNC_TRACE([ctx,pause](){
getPlayer(ctx);
if (!player) {
@ -132,7 +132,7 @@ API_EXPORT void CALLTYPE player_pause(PlayerContext ctx, int pause) {
});
}
API_EXPORT void CALLTYPE player_seekTo(PlayerContext ctx, float fProgress) {
API_EXPORT void API_CALL player_seekTo(PlayerContext ctx, float fProgress) {
ASYNC_TRACE([ctx,fProgress]() {
getPlayer(ctx);
if (!player) {
@ -141,7 +141,7 @@ API_EXPORT void CALLTYPE player_seekTo(PlayerContext ctx, float fProgress) {
return player->seekTo(fProgress);
});
}
API_EXPORT void CALLTYPE player_setOnShutdown(PlayerContext ctx, player_onResult cb, void *userData) {
API_EXPORT void API_CALL player_setOnShutdown(PlayerContext ctx, player_onResult cb, void *userData) {
getPlayer(ctx);
if (!player) {
return;
@ -159,7 +159,7 @@ API_EXPORT void CALLTYPE player_setOnShutdown(PlayerContext ctx, player_onResult
}
}
API_EXPORT void CALLTYPE player_setOnPlayResult(PlayerContext ctx, player_onResult cb, void *userData) {
API_EXPORT void API_CALL player_setOnPlayResult(PlayerContext ctx, player_onResult cb, void *userData) {
getPlayer(ctx);
if (!player) {
return;
@ -177,7 +177,7 @@ API_EXPORT void CALLTYPE player_setOnPlayResult(PlayerContext ctx, player_onResu
}
}
API_EXPORT void CALLTYPE player_setOnGetVideo(PlayerContext ctx, player_onGetH264 cb,
API_EXPORT void API_CALL player_setOnGetVideo(PlayerContext ctx, player_onGetH264 cb,
void *userData) {
getPlayer(ctx);
if (!player) {
@ -198,7 +198,7 @@ API_EXPORT void CALLTYPE player_setOnGetVideo(PlayerContext ctx, player_onGetH26
}
}
API_EXPORT void CALLTYPE player_setOnGetAudio(PlayerContext ctx, player_onGetAAC cb,
API_EXPORT void API_CALL player_setOnGetAudio(PlayerContext ctx, player_onGetAAC cb,
void *userData) {
getPlayer(ctx);
if (!player) {
@ -217,7 +217,7 @@ API_EXPORT void CALLTYPE player_setOnGetAudio(PlayerContext ctx, player_onGetAAC
}
}
API_EXPORT int CALLTYPE player_getVideoWidth(PlayerContext ctx) {
API_EXPORT int API_CALL player_getVideoWidth(PlayerContext ctx) {
getPlayer(ctx);
if (!player) {
return -1;
@ -225,7 +225,7 @@ API_EXPORT int CALLTYPE player_getVideoWidth(PlayerContext ctx) {
return player->getVideoWidth();
}
API_EXPORT int CALLTYPE player_getVideoHeight(PlayerContext ctx) {
API_EXPORT int API_CALL player_getVideoHeight(PlayerContext ctx) {
getPlayer(ctx);
if (!player) {
return -1;
@ -233,7 +233,7 @@ API_EXPORT int CALLTYPE player_getVideoHeight(PlayerContext ctx) {
return player->getVideoHeight();
}
API_EXPORT int CALLTYPE player_getVideoFps(PlayerContext ctx) {
API_EXPORT int API_CALL player_getVideoFps(PlayerContext ctx) {
getPlayer(ctx);
if (!player) {
return -1;
@ -241,7 +241,7 @@ API_EXPORT int CALLTYPE player_getVideoFps(PlayerContext ctx) {
return player->getVideoFps();
}
API_EXPORT int CALLTYPE player_getAudioSampleRate(PlayerContext ctx) {
API_EXPORT int API_CALL player_getAudioSampleRate(PlayerContext ctx) {
getPlayer(ctx);
if (!player) {
return -1;
@ -249,7 +249,7 @@ API_EXPORT int CALLTYPE player_getAudioSampleRate(PlayerContext ctx) {
return player->getAudioSampleRate();
}
API_EXPORT int CALLTYPE player_getAudioSampleBit(PlayerContext ctx) {
API_EXPORT int API_CALL player_getAudioSampleBit(PlayerContext ctx) {
getPlayer(ctx);
if (!player) {
return -1;
@ -257,7 +257,7 @@ API_EXPORT int CALLTYPE player_getAudioSampleBit(PlayerContext ctx) {
return player->getAudioSampleBit();
}
API_EXPORT int CALLTYPE player_getAudioChannel(PlayerContext ctx) {
API_EXPORT int API_CALL player_getAudioChannel(PlayerContext ctx) {
getPlayer(ctx);
if (!player) {
return -1;
@ -265,7 +265,7 @@ API_EXPORT int CALLTYPE player_getAudioChannel(PlayerContext ctx) {
return player->getAudioChannel();
}
API_EXPORT int CALLTYPE player_getH264PPS(PlayerContext ctx, char *buf, int bufsize) {
API_EXPORT int API_CALL player_getH264PPS(PlayerContext ctx, char *buf, int bufsize) {
getPlayer(ctx);
if (!player) {
return -1;
@ -276,7 +276,7 @@ API_EXPORT int CALLTYPE player_getH264PPS(PlayerContext ctx, char *buf, int bufs
memcpy(buf, player->getPps().data(), player->getPps().size());
return player->getPps().size();
}
API_EXPORT int CALLTYPE player_getH264SPS(PlayerContext ctx, char *buf, int bufsize) {
API_EXPORT int API_CALL player_getH264SPS(PlayerContext ctx, char *buf, int bufsize) {
getPlayer(ctx);
if (!player) {
return -1;
@ -288,7 +288,7 @@ API_EXPORT int CALLTYPE player_getH264SPS(PlayerContext ctx, char *buf, int bufs
return player->getSps().size();
}
API_EXPORT int CALLTYPE player_getAacCfg(PlayerContext ctx, char *buf, int bufsize) {
API_EXPORT int API_CALL player_getAacCfg(PlayerContext ctx, char *buf, int bufsize) {
getPlayer(ctx);
if (!player) {
return -1;
@ -300,7 +300,7 @@ API_EXPORT int CALLTYPE player_getAacCfg(PlayerContext ctx, char *buf, int bufsi
return player->getAudioCfg().size();
}
API_EXPORT int CALLTYPE player_containAudio(PlayerContext ctx) {
API_EXPORT int API_CALL player_containAudio(PlayerContext ctx) {
getPlayer(ctx);
if (!player) {
return -1;
@ -308,7 +308,7 @@ API_EXPORT int CALLTYPE player_containAudio(PlayerContext ctx) {
return player->containAudio();
}
API_EXPORT int CALLTYPE player_containVideo(PlayerContext ctx) {
API_EXPORT int API_CALL player_containVideo(PlayerContext ctx) {
getPlayer(ctx);
if (!player) {
return -1;
@ -316,14 +316,14 @@ API_EXPORT int CALLTYPE player_containVideo(PlayerContext ctx) {
return player->containVideo();
}
API_EXPORT int CALLTYPE player_isInited(PlayerContext ctx) {
API_EXPORT int API_CALL player_isInited(PlayerContext ctx) {
getPlayer(ctx);
if (!player) {
return -1;
}
return player->isInited();
}
API_EXPORT float CALLTYPE player_getDuration(PlayerContext ctx) {
API_EXPORT float API_CALL player_getDuration(PlayerContext ctx) {
getPlayer(ctx);
if (!player) {
return -1;
@ -331,7 +331,7 @@ API_EXPORT float CALLTYPE player_getDuration(PlayerContext ctx) {
return player->getDuration();
}
API_EXPORT float CALLTYPE player_getProgress(PlayerContext ctx) {
API_EXPORT float API_CALL player_getProgress(PlayerContext ctx) {
getPlayer(ctx);
if (!player) {
return -1;
@ -339,7 +339,7 @@ API_EXPORT float CALLTYPE player_getProgress(PlayerContext ctx) {
return player->getProgress();
}
API_EXPORT float CALLTYPE player_getLossRate(PlayerContext ctx, int trackId) {
API_EXPORT float API_CALL player_getLossRate(PlayerContext ctx, int trackId) {
getPlayer(ctx);
if (!player) {
return -1;

View File

@ -36,22 +36,22 @@ extern "C" {
////////////////////////////////////////RTSP Player/////////////////////////////////////////////////
typedef void* PlayerContext;
typedef void(CALLTYPE *player_onResult)(void *userData,int errCode,const char *errMsg);
typedef void(CALLTYPE *player_onGetAAC)(void *userData,void *data,int len,unsigned long timeStamp);
typedef void(CALLTYPE *player_onGetH264)(void *userData,void *data,int len,unsigned long dts,unsigned long pts);
typedef void(API_CALL *player_onResult)(void *userData,int errCode,const char *errMsg);
typedef void(API_CALL *player_onGetAAC)(void *userData,void *data,int len,unsigned long timeStamp);
typedef void(API_CALL *player_onGetH264)(void *userData,void *data,int len,unsigned long dts,unsigned long pts);
/*
* :Rtsp播放器
* :
* :Rtsp播放器句柄
*/
API_EXPORT PlayerContext CALLTYPE createPlayer();
API_EXPORT PlayerContext API_CALL createPlayer();
/*
* :
* :ctx:
* :
*/
API_EXPORT void CALLTYPE releasePlayer(PlayerContext ctx);
API_EXPORT void API_CALL releasePlayer(PlayerContext ctx);
/*
@ -61,8 +61,8 @@ API_EXPORT void CALLTYPE releasePlayer(PlayerContext ctx);
* val:, //设置rtp传输类型可选项有0(tcp默认)、1(udp)、2(组播)
* :
*/
API_EXPORT void CALLTYPE player_setOptionInt(PlayerContext ctx,const char* key,int val);
API_EXPORT void CALLTYPE player_setOptionString(PlayerContext ctx,const char* key,const char *val);
API_EXPORT void API_CALL player_setOptionInt(PlayerContext ctx,const char* key,int val);
API_EXPORT void API_CALL player_setOptionString(PlayerContext ctx,const char* key,const char *val);
/*
@ -71,35 +71,35 @@ API_EXPORT void CALLTYPE player_setOptionString(PlayerContext ctx,const char* ke
* url:rtsp链接
* :
*/
API_EXPORT void CALLTYPE player_play(PlayerContext ctx,const char* url);
API_EXPORT void API_CALL player_play(PlayerContext ctx,const char* url);
/*
* :RTSP
* :ctx:pause:1:0
* :
*/
API_EXPORT void CALLTYPE player_pause(PlayerContext ctx,int pause);
API_EXPORT void API_CALL player_pause(PlayerContext ctx,int pause);
/*
* :
* :ctx:;cb:;userData:
* :
*/
API_EXPORT void CALLTYPE player_setOnShutdown(PlayerContext ctx,player_onResult cb,void *userData);
API_EXPORT void API_CALL player_setOnShutdown(PlayerContext ctx,player_onResult cb,void *userData);
/*
* :
* :ctx:,cb:;userData:
* :
*/
API_EXPORT void CALLTYPE player_setOnPlayResult(PlayerContext ctx,player_onResult cb,void *userData);
API_EXPORT void API_CALL player_setOnPlayResult(PlayerContext ctx,player_onResult cb,void *userData);
/*
* :,I帧前为SPSPPS帧00 00 00 01
* :ctx:,cb:;userData:
* :
*/
API_EXPORT void CALLTYPE player_setOnGetVideo(PlayerContext ctx,player_onGetH264 cb,void *userData);
API_EXPORT void API_CALL player_setOnGetVideo(PlayerContext ctx,player_onGetH264 cb,void *userData);
/*
@ -107,49 +107,49 @@ API_EXPORT void CALLTYPE player_setOnGetVideo(PlayerContext ctx,player_onGetH264
* :ctx:,cb:;userData:
* :
*/
API_EXPORT void CALLTYPE player_setOnGetAudio(PlayerContext ctx,player_onGetAAC cb,void *userData);
API_EXPORT void API_CALL player_setOnGetAudio(PlayerContext ctx,player_onGetAAC cb,void *userData);
/*
* :
* :ctx:
* :
*/
API_EXPORT int CALLTYPE player_getVideoWidth(PlayerContext ctx);
API_EXPORT int API_CALL player_getVideoWidth(PlayerContext ctx);
/*
* :
* :ctx:
* :
*/
API_EXPORT int CALLTYPE CALLTYPE player_getVideoHeight(PlayerContext ctx);
API_EXPORT int API_CALL API_CALL player_getVideoHeight(PlayerContext ctx);
/*
* :
* :ctx:
* :
*/
API_EXPORT int CALLTYPE player_getVideoFps(PlayerContext ctx);
API_EXPORT int API_CALL player_getVideoFps(PlayerContext ctx);
/*
* :
* :ctx:
* :
*/
API_EXPORT int CALLTYPE player_getAudioSampleRate(PlayerContext ctx);
API_EXPORT int API_CALL player_getAudioSampleRate(PlayerContext ctx);
/*
* :8bit或16bit
* :ctx:
* :
*/
API_EXPORT int CALLTYPE player_getAudioSampleBit(PlayerContext ctx);
API_EXPORT int API_CALL player_getAudioSampleBit(PlayerContext ctx);
/*
* :12
* :ctx:
* :
*/
API_EXPORT int CALLTYPE player_getAudioChannel(PlayerContext ctx);
API_EXPORT int API_CALL player_getAudioChannel(PlayerContext ctx);
/*
@ -157,7 +157,7 @@ API_EXPORT int CALLTYPE player_getAudioChannel(PlayerContext ctx);
* :ctx:buf:PPS数据的缓存bufsize
* :
*/
API_EXPORT int CALLTYPE player_getH264PPS(PlayerContext ctx,char *buf,int bufsize);
API_EXPORT int API_CALL player_getH264PPS(PlayerContext ctx,char *buf,int bufsize);
/*
@ -165,7 +165,7 @@ API_EXPORT int CALLTYPE player_getH264PPS(PlayerContext ctx,char *buf,int bufsiz
* :ctx:buf:SPS数据的缓存bufsize
* :
*/
API_EXPORT int CALLTYPE player_getH264SPS(PlayerContext ctx,char *buf,int bufsize);
API_EXPORT int API_CALL player_getH264SPS(PlayerContext ctx,char *buf,int bufsize);
/*
@ -173,7 +173,7 @@ API_EXPORT int CALLTYPE player_getH264SPS(PlayerContext ctx,char *buf,int bufsiz
* :ctx:buf:CFG数据的缓存bufsize
* :CFG数据长度
*/
API_EXPORT int CALLTYPE player_getAacCfg(PlayerContext ctx,char *buf,int bufsize);
API_EXPORT int API_CALL player_getAacCfg(PlayerContext ctx,char *buf,int bufsize);
/*
@ -181,7 +181,7 @@ API_EXPORT int CALLTYPE player_getAacCfg(PlayerContext ctx,char *buf,int bufsize
* :ctx:
* :10
*/
API_EXPORT int CALLTYPE player_containAudio(PlayerContext ctx);
API_EXPORT int API_CALL player_containAudio(PlayerContext ctx);
/*
@ -189,7 +189,7 @@ API_EXPORT int CALLTYPE player_containAudio(PlayerContext ctx);
* :ctx:
* :10
*/
API_EXPORT int CALLTYPE player_containVideo(PlayerContext ctx);
API_EXPORT int API_CALL player_containVideo(PlayerContext ctx);
/*
@ -197,35 +197,35 @@ API_EXPORT int CALLTYPE player_containVideo(PlayerContext ctx);
* :ctx:
* :10
*/
API_EXPORT int CALLTYPE player_isInited(PlayerContext ctx);
API_EXPORT int API_CALL player_isInited(PlayerContext ctx);
/*
* :0
* :ctx:
* :
*/
API_EXPORT float CALLTYPE player_getDuration(PlayerContext ctx);
API_EXPORT float API_CALL player_getDuration(PlayerContext ctx);
/*
* :
* :ctx:
* : 0.01.0
*/
API_EXPORT float CALLTYPE player_getProgress(PlayerContext ctx);
API_EXPORT float API_CALL player_getProgress(PlayerContext ctx);
/*
* :
* :ctx:fProgress 0.01.0
* :
*/
API_EXPORT void CALLTYPE player_seekTo(PlayerContext ctx, float fProgress);
API_EXPORT void API_CALL player_seekTo(PlayerContext ctx, float fProgress);
/*
* :
* :ctx:trackId:-1,
* :
*/
API_EXPORT float CALLTYPE player_getLossRate(PlayerContext ctx,int trackId);
API_EXPORT float API_CALL player_getLossRate(PlayerContext ctx,int trackId);
#ifdef __cplusplus

View File

@ -42,7 +42,7 @@ static onceToken s_token([](){
});
},nullptr);
API_EXPORT ProxyPlayerContext CALLTYPE createProxyPlayer(const char *app,const char *stream,int rtp_type){
API_EXPORT ProxyPlayerContext API_CALL createProxyPlayer(const char *app,const char *stream,int rtp_type){
PlayerProxy::Ptr ret(new PlayerProxy(app,stream));
(*ret)[RtspPlayer::kRtpType] = rtp_type;
@ -50,11 +50,11 @@ API_EXPORT ProxyPlayerContext CALLTYPE createProxyPlayer(const char *app,const c
s_mapProxyPlayer.emplace(ret.get(),ret);
return ret.get();
}
API_EXPORT void CALLTYPE releaseProxyPlayer(ProxyPlayerContext ctx){
API_EXPORT void API_CALL releaseProxyPlayer(ProxyPlayerContext ctx){
lock_guard<recursive_mutex> lck(s_mtxMapProxyPlayer);
s_mapProxyPlayer.erase(ctx);
}
API_EXPORT void CALLTYPE proxyPlayer_play(ProxyPlayerContext ctx,const char *url){
API_EXPORT void API_CALL proxyPlayer_play(ProxyPlayerContext ctx,const char *url){
PlayerProxy *ptr = (PlayerProxy *)ctx;
ptr->play(url);
}

View File

@ -42,14 +42,14 @@ typedef void* ProxyPlayerContext;
* rtp_type:rtsp连接则通过该参数配置设置rtp传输方式:RTP_TCP = 0, RTP_UDP = 1, RTP_MULTICAST = 2
* :
*/
API_EXPORT ProxyPlayerContext CALLTYPE createProxyPlayer(const char *app,const char *stream,int rtp_type);
API_EXPORT ProxyPlayerContext API_CALL createProxyPlayer(const char *app,const char *stream,int rtp_type);
/*
* :
* :ctx:
* :
*/
API_EXPORT void CALLTYPE releaseProxyPlayer(ProxyPlayerContext ctx);
API_EXPORT void API_CALL releaseProxyPlayer(ProxyPlayerContext ctx);
/*
@ -57,7 +57,7 @@ API_EXPORT void CALLTYPE releaseProxyPlayer(ProxyPlayerContext ctx);
* :url:rtsp/rtmp连接
* :
*/
API_EXPORT void CALLTYPE proxyPlayer_play(ProxyPlayerContext ctx,const char *url);
API_EXPORT void API_CALL proxyPlayer_play(ProxyPlayerContext ctx,const char *url);
#ifdef __cplusplus

View File

@ -138,11 +138,13 @@ void DevChannel::inputAAC(char *pcDataWithoutAdts,int iDataLen, uint32_t uiStamp
static uint32_t audioMtu = mINI::Instance()[Config::Rtp::kAudioMtuSize].as<uint32_t>();
m_pRtpMaker_aac.reset(new RtpMaker_AAC(lam, ssrc, audioMtu,m_audio->iSampleRate));
}
if (!m_bSdp_gotAAC && m_audio) {
makeSDP_AAC((unsigned char*) pcAdtsHeader, iDataLen);
if (!m_bSdp_gotAAC && m_audio && pcAdtsHeader) {
makeSDP_AAC((unsigned char*) pcAdtsHeader);
}
if(pcDataWithoutAdts && iDataLen){
m_pRtpMaker_aac->makeRtp(pcDataWithoutAdts, iDataLen, uiStamp);
}
}
inline void DevChannel::makeSDP_264(unsigned char *pcData, int iDataLen) {
int offset = 4;
@ -226,7 +228,7 @@ inline void DevChannel::makeSDP_264(unsigned char *pcData, int iDataLen) {
}
}
inline void DevChannel::makeSDP_AAC(unsigned char *fixedHeader, int dataLen) {
inline void DevChannel::makeSDP_AAC(unsigned char *fixedHeader) {
auto audioSpecificConfig = makeAdtsConfig(fixedHeader);
if (audioSpecificConfig.size() != 2) {
return;

View File

@ -96,7 +96,7 @@ public:
}
private:
inline void makeSDP_264(unsigned char *pucData, int iDataLen);
inline void makeSDP_AAC(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> m_pH264Enc;