ZLMediaKit/c_wrapper/src/player.h

236 lines
7.1 KiB
C
Raw Normal View History

2017-12-13 18:15:22 +08:00
/*
* MIT License
*
* Copyright (c) 2016 xiongziliang <771730766@qq.com>
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
*
* 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.
*/
#ifndef SRC_PLAYER_H_
#define SRC_PLAYER_H_
#include "common.h"
#ifdef __cplusplus
extern "C" {
#endif
////////////////////////////////////////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);
/*
* :Rtsp播放器
* :
* :Rtsp播放器句柄
*/
API_EXPORT PlayerContext CALLTYPE createPlayer();
/*
* :
* :ctx:
* :
*/
API_EXPORT void CALLTYPE releasePlayer(PlayerContext ctx);
/*
* :
* : ctx:
* key:, rtp_type
* 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);
/*
* :rtsp链接H264与AAC负载
* : ctx:
* url:rtsp链接
* :
*/
API_EXPORT void CALLTYPE player_play(PlayerContext ctx,const char* url);
/*
* :RTSP
* :ctx:pause:1:0
* :
*/
API_EXPORT void CALLTYPE player_pause(PlayerContext ctx,int pause);
/*
* :
* :ctx:;cb:;userData:
* :
*/
API_EXPORT void CALLTYPE 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);
/*
* :,I帧前为SPSPPS帧00 00 00 01
* :ctx:,cb:;userData:
* :
*/
API_EXPORT void CALLTYPE player_setOnGetVideo(PlayerContext ctx,player_onGetH264 cb,void *userData);
/*
* :,ADTS头
* :ctx:,cb:;userData:
* :
*/
API_EXPORT void CALLTYPE player_setOnGetAudio(PlayerContext ctx,player_onGetAAC cb,void *userData);
/*
* :
* :ctx:
* :
*/
API_EXPORT int CALLTYPE player_getVideoWidth(PlayerContext ctx);
/*
* :
* :ctx:
* :
*/
API_EXPORT int CALLTYPE CALLTYPE player_getVideoHeight(PlayerContext ctx);
/*
* :
* :ctx:
* :
*/
API_EXPORT int CALLTYPE player_getVideoFps(PlayerContext ctx);
/*
* :
* :ctx:
* :
*/
API_EXPORT int CALLTYPE player_getAudioSampleRate(PlayerContext ctx);
/*
* :8bit或16bit
* :ctx:
* :
*/
API_EXPORT int CALLTYPE player_getAudioSampleBit(PlayerContext ctx);
/*
* :12
* :ctx:
* :
*/
API_EXPORT int CALLTYPE player_getAudioChannel(PlayerContext ctx);
/*
* :H264的PPS帧
* :ctx:buf:PPS数据的缓存bufsize
* :
*/
API_EXPORT int CALLTYPE player_getH264PPS(PlayerContext ctx,char *buf,int bufsize);
/*
* :H264的SPS帧
* :ctx:buf:SPS数据的缓存bufsize
* :
*/
API_EXPORT int CALLTYPE player_getH264SPS(PlayerContext ctx,char *buf,int bufsize);
/*
* :AAC编码配置信息
* :ctx:buf:CFG数据的缓存bufsize
* :CFG数据长度
*/
API_EXPORT int CALLTYPE player_getAacCfg(PlayerContext ctx,char *buf,int bufsize);
/*
* :
* :ctx:
* :10
*/
API_EXPORT int CALLTYPE player_containAudio(PlayerContext ctx);
/*
* :
* :ctx:
* :10
*/
API_EXPORT int CALLTYPE player_containVideo(PlayerContext ctx);
/*
* :
* :ctx:
* :10
*/
API_EXPORT int CALLTYPE player_isInited(PlayerContext ctx);
/*
* :0
* :ctx:
* :
*/
API_EXPORT float CALLTYPE player_getDuration(PlayerContext ctx);
/*
* :
* :ctx:
* : 0.01.0
*/
API_EXPORT float CALLTYPE player_getProgress(PlayerContext ctx);
/*
* :
* :ctx:fProgress 0.01.0
* :
*/
API_EXPORT void CALLTYPE player_seekTo(PlayerContext ctx, float fProgress);
/*
* :
* :ctx:trackId:-1,
* :
*/
API_EXPORT float CALLTYPE player_getLossRate(PlayerContext ctx,int trackId);
#ifdef __cplusplus
}
#endif
#endif /* SRC_PLAYER_H_ */