You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

209 lines
6.8 KiB
C

12 months ago
/*
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
*
* Use of this source code is governed by MIT-like 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.
*/
#ifndef MK_PLAYER_H_
#define MK_PLAYER_H_
#include "mk_common.h"
#include "mk_frame.h"
#include "mk_track.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct mk_player_t *mk_player;
/**
*
* @param user_data
* @param err_code 0
* @param err_msg
* @param tracks track
* @param track_count track
7 months ago
* Callback for playback result or playback interruption event
* @param user_data User data pointer
* @param err_code Error code, 0 for success
* @param err_msg Error message
* @param tracks Track list
* @param track_count Number of tracks
* [AUTO-TRANSLATED:38d4c546]
12 months ago
*/
typedef void(API_CALL *on_mk_play_event)(void *user_data, int err_code, const char *err_msg, mk_track tracks[],
int track_count);
/**
* ,rtmp[s]/rtsp[s]
* @return
7 months ago
* Create a player that supports rtmp[s]/rtsp[s]
* @return Player pointer
* [AUTO-TRANSLATED:509f9a50]
12 months ago
*/
API_EXPORT mk_player API_CALL mk_player_create();
/**
*
* @param ctx
7 months ago
* Destroy the player
* @param ctx Player pointer
* [AUTO-TRANSLATED:2448eb93]
12 months ago
*/
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/wait_track_ready
* @param val ,string
7 months ago
* Set player configuration options
* @param ctx Player pointer
* @param key Configuration key, supports net_adapter/rtp_type/rtsp_user/rtsp_pwd/protocol_timeout_ms/media_timeout_ms/beat_interval_ms/wait_track_ready
* @param val Configuration value, if it is an integer, it needs to be converted to a string
* [AUTO-TRANSLATED:12650e9f]
12 months ago
*/
API_EXPORT void API_CALL mk_player_set_option(mk_player ctx, const char *key, const char *val);
/**
* url
* @param ctx
* @param url rtsp[s]/rtmp[s] url
7 months ago
* Start playing the url
* @param ctx Player pointer
* @param url rtsp[s]/rtmp[s] url
* [AUTO-TRANSLATED:dbec813f]
12 months ago
*/
API_EXPORT void API_CALL mk_player_play(mk_player ctx, const char *url);
/**
*
* @param ctx
* @param pause 1:0
7 months ago
* Pause or resume playback, only useful for on-demand
* @param ctx Player pointer
* @param pause 1: Pause playback, 0: Resume playback
* [AUTO-TRANSLATED:28eee990]
12 months ago
*/
API_EXPORT void API_CALL mk_player_pause(mk_player ctx, int pause);
/**
*
* @param ctx
* @param speed 0.5 1.0 2.0
7 months ago
* Playback at a multiple, only useful for on-demand
* @param ctx Player pointer
* @param speed 0.5 1.0 2.0
* [AUTO-TRANSLATED:95249ade]
12 months ago
*/
API_EXPORT void API_CALL mk_player_speed(mk_player ctx, float speed);
/**
*
* @param ctx
* @param progress 0.01.0
7 months ago
* Set the on-demand progress bar
* @param ctx Object pointer
* @param progress Value range is 0.01.0
* [AUTO-TRANSLATED:cede3a8f]
12 months ago
*/
API_EXPORT void API_CALL mk_player_seekto(mk_player ctx, float progress);
/**
*
* @param ctx
* @param seek_pos
7 months ago
* Set the on-demand progress bar
* @param ctx Object pointer
* @param seek_pos Value range is the increment relative to the start time, unit is seconds
* [AUTO-TRANSLATED:cddea627]
12 months ago
*/
API_EXPORT void API_CALL mk_player_seekto_pos(mk_player ctx, int seek_pos);
/**
*
* @param ctx
* @param cb ,null
* @param user_data
7 months ago
* Set the player to enable playback result callback function
* @param ctx Player pointer
* @param cb Callback function pointer, set null to immediately cancel the callback
* @param user_data User data pointer
* [AUTO-TRANSLATED:1c2daeaf]
12 months ago
*/
API_EXPORT void API_CALL mk_player_set_on_result(mk_player ctx, on_mk_play_event cb, void *user_data);
API_EXPORT void API_CALL mk_player_set_on_result2(mk_player ctx, on_mk_play_event cb, void *user_data, on_user_data_free user_data_free);
/**
*
* @param ctx
* @param cb ,null
* @param user_data
7 months ago
* Set the callback for playback being abnormally interrupted
* @param ctx Player pointer
* @param cb Callback function pointer, set null to immediately cancel the callback
* @param user_data User data pointer
///////////////////////////Audio and video related information interfaces are only valid after the playback success callback is triggered///////////////////////////////
* [AUTO-TRANSLATED:18f58697]
12 months ago
*/
API_EXPORT void API_CALL mk_player_set_on_shutdown(mk_player ctx, on_mk_play_event cb, void *user_data);
API_EXPORT void API_CALL mk_player_set_on_shutdown2(mk_player ctx, on_mk_play_event cb, void *user_data, on_user_data_free user_data_free);
7 months ago
// /////////////////////////获取音视频相关信息接口在播放成功回调触发后才有效/////////////////////////////// [AUTO-TRANSLATED:4b53d8ff]
// * Get the duration of the on-demand program, if it is live, return 0, otherwise return the number of seconds
12 months ago
/**
* 0
7 months ago
* Get the on-demand playback progress, value range is 0.01.0
* [AUTO-TRANSLATED:522140b7]
12 months ago
*/
API_EXPORT float API_CALL mk_player_duration(mk_player ctx);
/**
* 0.01.0
7 months ago
* Get the on-demand playback progress position, value range is the increment relative to the start time, unit is seconds
* [AUTO-TRANSLATED:921795a0]
12 months ago
*/
API_EXPORT float API_CALL mk_player_progress(mk_player ctx);
/**
*
7 months ago
* Get the packet loss rate, valid for rtsp
* @param ctx Object pointer
* @param track_type 0: Video, 1: Audio
* [AUTO-TRANSLATED:058e5089]
12 months ago
*/
API_EXPORT int API_CALL mk_player_progress_pos(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_ */