ZLMediaKit/api/include/mk_player.h

175 lines
4.8 KiB
C++
Raw Normal View History

2019-12-18 11:47:49 +08:00
/*
2020-04-04 20:30:09 +08:00
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
2019-12-18 11:45:33 +08:00
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
*
2020-04-04 20:30:09 +08:00
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors
* may be found in the AUTHORS file in the root of the source tree.
2019-12-18 11:45:33 +08:00
*/
#ifndef MK_PLAYER_H_
#define MK_PLAYER_H_
#include "mk_common.h"
2019-12-18 11:45:33 +08:00
#ifdef __cplusplus
extern "C" {
#endif
typedef void* mk_player;
/**
*
* @param user_data
* @param err_code 0
* @param err_msg
*/
typedef void(API_CALL *on_mk_play_event)(void *user_data,int err_code,const char *err_msg);
/**
*
* @param user_data
* @param track_type 01
2020-04-18 18:46:20 +08:00
* @param codec_id 0H2641H2652AAC 3.G711A 4.G711U
2019-12-18 11:45:33 +08:00
* @param data
* @param len
* @param dts
* @param pts
*/
typedef void(API_CALL *on_mk_play_data)(void *user_data,int track_type,int codec_id,void *data,int len,uint32_t dts,uint32_t pts);
/**
2019-12-18 14:43:32 +08:00
* ,rtmp[s]/rtsp[s]
2019-12-18 11:45:33 +08:00
* @return
*/
API_EXPORT mk_player API_CALL mk_player_create();
/**
*
* @param ctx
*/
API_EXPORT void API_CALL mk_player_release(mk_player ctx);
/**
*
* @param ctx
* @param key , net_adapter/rtp_type/rtsp_user/rtsp_pwd/protocol_timeout_ms/media_timeout_ms/beat_interval_ms/max_analysis_ms
* @param val ,string
*/
API_EXPORT void API_CALL mk_player_set_option(mk_player ctx, const char *key, const char *val);
/**
* url
* @param ctx
2019-12-18 14:43:32 +08:00
* @param url rtsp[s]/rtmp[s] url
2019-12-18 11:45:33 +08:00
*/
API_EXPORT void API_CALL mk_player_play(mk_player ctx, const char *url);
/**
*
* @param ctx
* @param pause 1:0
*/
API_EXPORT void API_CALL mk_player_pause(mk_player ctx, int pause);
/**
*
* @param ctx
* @param progress 0.01.0
*/
API_EXPORT void API_CALL mk_player_seekto(mk_player ctx, float progress);
/**
*
* @param ctx
2019-12-18 14:43:32 +08:00
* @param cb ,null
2019-12-18 11:45:33 +08:00
* @param user_data
*/
API_EXPORT void API_CALL mk_player_set_on_result(mk_player ctx, on_mk_play_event cb, void *user_data);
/**
*
* @param ctx
* @param cb ,null
* @param user_data
*/
API_EXPORT void API_CALL mk_player_set_on_shutdown(mk_player ctx, on_mk_play_event cb, void *user_data);
/**
*
2020-04-18 18:46:20 +08:00
*
2019-12-18 11:45:33 +08:00
* @param ctx
* @param cb ,null
* @param user_data
*/
API_EXPORT void API_CALL mk_player_set_on_data(mk_player ctx, on_mk_play_data cb, void *user_data);
2020-04-18 18:46:20 +08:00
///////////////////////////获取音视频相关信息接口在播放成功回调触发后才有效///////////////////////////////
/**
* codec_id -1 0H2641H2652AAC 3.G711A 4.G711U
* @param ctx
*/
API_EXPORT int API_CALL mk_player_video_codecId(mk_player ctx);
2019-12-18 11:45:33 +08:00
/**
*
*/
API_EXPORT int API_CALL mk_player_video_width(mk_player ctx);
/**
*
*/
API_EXPORT int API_CALL mk_player_video_height(mk_player ctx);
/**
*
*/
API_EXPORT int API_CALL mk_player_video_fps(mk_player ctx);
/**
* codec_id -1 0H2641H2652AAC 3.G711A 4.G711U
* @param ctx
*/
API_EXPORT int API_CALL mk_player_audio_codecId(mk_player ctx);
2019-12-18 11:45:33 +08:00
/**
*
*/
API_EXPORT int API_CALL mk_player_audio_samplerate(mk_player ctx);
/**
* 16
*/
API_EXPORT int API_CALL mk_player_audio_bit(mk_player ctx);
/**
*
*/
API_EXPORT int API_CALL mk_player_audio_channel(mk_player ctx);
/**
* 0
*/
API_EXPORT float API_CALL mk_player_duration(mk_player ctx);
/**
* 0.01.0
*/
API_EXPORT float API_CALL mk_player_progress(mk_player ctx);
/**
* rtsp时有效
* @param ctx
* @param track_type 01
*/
API_EXPORT float API_CALL mk_player_loss_rate(mk_player ctx, int track_type);
#ifdef __cplusplus
}
#endif
#endif /* MK_PLAYER_H_ */