本文档提供了使用 C++SDK 的操作步骤及代码示例,通过本文您可以快速了解如何使用 SDK 提供的功能。您也可以通过 Demo 中的示例进行了解和自有业务开发。
std::count << "the log file result:" << ret << std::endl;
std::string viewerId = "业务id";
std::string viewerName = "业务nick";
std::string viewerAvatar= "业务Avatar";
std::cout << "init sdk result:" << ret << std::endl;
std::cout<< "the error info: << desc << std::endl;
PLAYERSDK_API int PLAYERSDK_CALL PLVSetSdkKeepLastFrame(bool enable)
设置是否播放结束保持在最后一帧画面上.
PLAYERSDK_API int PLAYERSDK_CALL PLVSetSdkLogLevel(LOG_FILTER_TYPE level)
设置 SDK 的日志过滤等级.
PLAYERSDK_API int PLAYERSDK_CALL PLVSetSdkSeed(const char *seed)
设置解密 seed.
PLAYERSDK_API int PLAYERSDK_CALL PLVSetSdkLogMessageCallback(bool enable, OnLogMessageHandler handler, void *data)
设置日志信息回调.
PLAYERSDK_API int PLAYERSDK_CALL PLVSetSdkRetryAttempts(int attempts, int milliseconds, int millisecondsMax)
设置下载的重试次数, 每次重试的间隔时间会递增. 默认是无限重试(-1).
PLAYERSDK_API void PLAYERSDK_CALL PLVReleaseSdkLibrary(void)
析构 SDK, 停止使用后要调用此接口.
PLAYERSDK_API int PLAYERSDK_CALL PLVInitSdkLibrary(const PLVAccountInfo *info)
初始化 SDK , 在使用 SDK 前一定要调用此接口.
PLAYERSDK_API const char *PLAYERSDK_CALL PLVGetSdkVersion(void)
获取 SDK 版本号.
PLAYERSDK_API const char *PLAYERSDK_CALL PLVGetSdkErrorDescription(int err)
根据错误码获取错误描述.
PLAYERSDK_API int PLAYERSDK_CALL PLVSetSdkVideoOutputDevice(VIDEO_OUTPUT_DEVICE type, const char *context=NULL)
设置视频输出驱动类型.
PLAYERSDK_API int PLAYERSDK_CALL PLVSetSdkLocalRememberPlay(bool enable)
本地记忆续播放功能.
PLAYERSDK_API int PLAYERSDK_CALL PLVSetSdkLogFile(const char *fileName)
设置 SDK 的日志文件位置, 文件名带路径.
PLAYERSDK_API int PLAYERSDK_CALL PLVSetSdkHwdecEnable(bool enable)
设置是否使用硬件加速.
PLAYERSDK_API int PLAYERSDK_CALL PLVSetSdkViewerInfo(const char *viewerId, const char *viewerName, const char *viewerAvatar, const char *viewerExtraInfo1=NULL, const char *viewerExtraInfo2=NULL, const char *viewerExtraInfo3=NULL)
设置 qos 的信息追踪, 建议设置.
const char * userId
主帐号的userId, 请向 SDK 供应商获取.
class Record{
public:
Record(void){
}, userdata);
}, userdata);
}
int SetPreventSoftwareRecording(void* window, bool enable){
}
int GetPreventSoftwareRecording(void* window, bool* enable){
}
};
PLAYERSDK_API int PLAYERSDK_CALL PLVSetDetectHardwareRecordingHandler(bool enable, OnDetectHardwareRecordingHandler handler, void *data)
设置设备插拔变动的回调通知.
PLAYERSDK_API int PLAYERSDK_CALL PLVSetPreventSoftwareRecording(void *window, bool enable)
设置播放窗口的软件防录制, 用于防止屏幕录制或屏幕截图.
PLAYERSDK_API int PLAYERSDK_CALL PLVSetDetectSoftwareRecordingHandler(bool enable, OnDetectSoftwareRecordingHandler handler, void *data)
设置软件录制的回调通知.
PLAYERSDK_API int PLAYERSDK_CALL PLVGetPreventSoftwareRecording(void *window, bool *enable)
获取播放窗口是否开启软件防录制.
class Download{
private:
public:
Download(void){
}, userdata);
}, userdata);
}, userdata);
}
~Download(void){
downolader = nullptr;
}
int SetInfo(const char* vid, const char* path, int rate){
}
int Start(const char* token, bool autoDownRate){
}
int Stop(void){
}
int Pause(bool pause){
}
int Delete(void){
}
int Reset(void){
}
};
PLAYERSDK_API PLVDownloadPtr PLAYERSDK_CALL PLVDownloadCreate()
创建下载对象并返回对象指针. 在使用下载接口对象前, 必须先调用此接口创建对象.
PLAYERSDK_API int PLAYERSDK_CALL PLVDownloadDelete(PLVDownloadPtr download)
删除视频文件. 如果视频正在下载中时, 会中断下载, 并删除所有临时文件, 并退出线程.
void * PLVDownloadPtr
下载对象, 每一个下载任务对应一个下载对象, 可以创建多个下载对象.
PLAYERSDK_API int PLAYERSDK_CALL PLVDownloadResetHandler(PLVDownloadPtr download)
重置所有回调通知, 会请空所有的回调函数地址.
PLAYERSDK_API int PLAYERSDK_CALL PLVDownloadStart(PLVDownloadPtr download, const char *token, bool autoDownRate)
开始下载.
PLAYERSDK_API int PLAYERSDK_CALL PLVDownloadSetInfo(PLVDownloadPtr download, const char *vid, const char *path, int rate)
设置视频信息. 在调用下载前, 必须先设置视频的相关信息, 否则会报错.
PLAYERSDK_API int PLAYERSDK_CALL PLVDownloadSetErrorHandler(PLVDownloadPtr download, OnDownloadErrorHandler handler, void *data)
设置下载错误的回调通知.
PLAYERSDK_API int PLAYERSDK_CALL PLVDownloadPause(PLVDownloadPtr download, bool pause)
暂停下载, 此时线程进入休眠, 不会退出, 区别于停止下载. 再开始下载时会更快些.
PLAYERSDK_API int PLAYERSDK_CALL PLVDownloadSetResultHandler(PLVDownloadPtr download, OnDownloadResultHandler handler, void *data)
设置下载结果的回调通知.
PLAYERSDK_API int PLAYERSDK_CALL PLVDownloadStop(PLVDownloadPtr download)
停止下载, 此时线程会回收退出, 区别于暂停下载. 再开始下载时会慢些.
PLAYERSDK_API void PLAYERSDK_CALL PLVDownloadDestroy(PLVDownloadPtr download)
销毁下载对象. 不再使用创建的对象后, 必须调用此接口回收.
PLAYERSDK_API int PLAYERSDK_CALL PLVDownloadSetProgressHandler(PLVDownloadPtr download, OnDownloadProgressHandler handler, void *data)
设置下载进度的回调通知.
class Player{
private:
PLVPlayer mediaPlayer = nullptr;
public:
Player((void*)window){
}, userdata);
}, userdata);
}, userdata);
}, userdata);
}, userdata);
}
~Player(void){
mediaPlayer = nullptr;
}
}
}
int SetCache(bool enable, int maxCacheBytes, int maxCacheSeconds);
int GetCache(int* maxCacheBytes, int* maxCacheSeconds);
int SetInfo(const char* vid, const char* path, int rate);
int Play(const char* token, int seekMillisecond, bool autoDownRate, bool playWithToken, bool sync);
int PlayLocal(int seekMillisecond, bool autoDownRate);
int LoadLocal(int seekMillisecond, bool autoDownRate);
int Pause(bool pause);
int Stop(void);
int SetMute(bool mute);
int SetSeek(int millisecond);
int SeekToEnd(void);
int SetVolume(int volume);
int SetVolumeMax(int volume);
int SetSpeed(double speed);
int Screenshot(const char* filename);
int GetAudioDeviceCount();
};
PLAYERSDK_API int PLAYERSDK_CALL PLVPlayerSetPropertyHandler(PLVPlayerPtr player, OnPlayerPropertyHandler handler, void *data)
设置播放属性值的回调通知.
PLAYERSDK_API PLVPlayerPtr PLAYERSDK_CALL PLVPlayerCreate(void *window)
创建播放对象并返回对象指针. 在使用播放接口对象前, 必须先调用此接口创建对象.
PLAYERSDK_API int PLAYERSDK_CALL PLVPlayerSetProgressHandler(PLVPlayerPtr player, OnPlayerProgressHandler handler, void *data)
设置播放进度的回调通知.
PLAYERSDK_API int PLAYERSDK_CALL PLVPlayerSetOSDConfig(PLVPlayerPtr player, bool enable, const PLVOsdConfigInfo *config)
设置跑马灯信息
PLAYERSDK_API int PLAYERSDK_CALL PLVPlayerGetOSDConfig(PLVPlayerPtr player, PLVOsdConfigInfo &config)
获取跑马灯信息.
PLAYERSDK_API void PLAYERSDK_CALL PLVPlayerDestroy(PLVPlayerPtr player)
销毁播放对象. 不再使用创建的对象后, 必须调用此接口回收.
PLAYERSDK_API int PLAYERSDK_CALL PLVPlayerSetStateHandler(PLVPlayerPtr player, OnPlayerStateHandler handler, void *data)
设置播放状态的回调通知.
PLAYERSDK_API int PLAYERSDK_CALL PLVPlayerSetAudioDeviceHandler(PLVPlayerPtr player, OnPlayerAudioDeviceHandler handler, void *data)
设置扬声器热插拔的回调通知.
PLAYERSDK_API int PLAYERSDK_CALL PLVPlayerSetRateChangeHandler(PLVPlayerPtr player, OnPlayerRateChangeHandler handler, void *data)
设置清晰度变化的回调通知. 只有输入清度为 VIDEO_RATE_AUTO 才会触发此回调.
const int PLV_MAX_DEVICE_ID_LENGTH