-
Notifications
You must be signed in to change notification settings - Fork 6
/
ijkplayer.h
225 lines (188 loc) · 7.98 KB
/
ijkplayer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
/*
* ijkplayer.h
*
* Copyright (c) 2013 Bilibili
* Copyright (c) 2013 Zhang Rui <[email protected]>
*
* This file is part of ijkPlayer.
*
* ijkPlayer is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* ijkPlayer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with ijkPlayer; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef IJKPLAYER_ANDROID__IJKPLAYER_H
#define IJKPLAYER_ANDROID__IJKPLAYER_H
#include <stdbool.h>
#include "ff_ffmsg_queue.h"
#include "ijkmeta.h"
#ifndef MPTRACE
#define MPTRACE ALOGD
#endif
typedef struct IjkMediaPlayer IjkMediaPlayer;
struct FFPlayer;
struct SDL_Vout;
/*-
MPST_CHECK_NOT_RET(mp->mp_state, MP_STATE_IDLE);
MPST_CHECK_NOT_RET(mp->mp_state, MP_STATE_INITIALIZED);
MPST_CHECK_NOT_RET(mp->mp_state, MP_STATE_ASYNC_PREPARING);
MPST_CHECK_NOT_RET(mp->mp_state, MP_STATE_PREPARED);
MPST_CHECK_NOT_RET(mp->mp_state, MP_STATE_STARTED);
MPST_CHECK_NOT_RET(mp->mp_state, MP_STATE_PAUSED);
MPST_CHECK_NOT_RET(mp->mp_state, MP_STATE_COMPLETED);
MPST_CHECK_NOT_RET(mp->mp_state, MP_STATE_STOPPED);
MPST_CHECK_NOT_RET(mp->mp_state, MP_STATE_ERROR);
MPST_CHECK_NOT_RET(mp->mp_state, MP_STATE_END);
*/
/*-
* ijkmp_set_data_source() -> MP_STATE_INITIALIZED
*
* ijkmp_reset -> self
* ijkmp_release -> MP_STATE_END
*/
#define MP_STATE_IDLE 0
/*-
* ijkmp_prepare_async() -> MP_STATE_ASYNC_PREPARING
*
* ijkmp_reset -> MP_STATE_IDLE
* ijkmp_release -> MP_STATE_END
*/
#define MP_STATE_INITIALIZED 1
/*-
* ... -> MP_STATE_PREPARED
* ... -> MP_STATE_ERROR
*
* ijkmp_reset -> MP_STATE_IDLE
* ijkmp_release -> MP_STATE_END
*/
#define MP_STATE_ASYNC_PREPARING 2
/*-
* ijkmp_seek_to() -> self
* ijkmp_start() -> MP_STATE_STARTED
*
* ijkmp_reset -> MP_STATE_IDLE
* ijkmp_release -> MP_STATE_END
*/
#define MP_STATE_PREPARED 3
/*-
* ijkmp_seek_to() -> self
* ijkmp_start() -> self
* ijkmp_pause() -> MP_STATE_PAUSED
* ijkmp_stop() -> MP_STATE_STOPPED
* ... -> MP_STATE_COMPLETED
* ... -> MP_STATE_ERROR
*
* ijkmp_reset -> MP_STATE_IDLE
* ijkmp_release -> MP_STATE_END
*/
#define MP_STATE_STARTED 4
/*-
* ijkmp_seek_to() -> self
* ijkmp_start() -> MP_STATE_STARTED
* ijkmp_pause() -> self
* ijkmp_stop() -> MP_STATE_STOPPED
*
* ijkmp_reset -> MP_STATE_IDLE
* ijkmp_release -> MP_STATE_END
*/
#define MP_STATE_PAUSED 5
/*-
* ijkmp_seek_to() -> self
* ijkmp_start() -> MP_STATE_STARTED (from beginning)
* ijkmp_pause() -> self
* ijkmp_stop() -> MP_STATE_STOPPED
*
* ijkmp_reset -> MP_STATE_IDLE
* ijkmp_release -> MP_STATE_END
*/
#define MP_STATE_COMPLETED 6
/*-
* ijkmp_stop() -> self
* ijkmp_prepare_async() -> MP_STATE_ASYNC_PREPARING
*
* ijkmp_reset -> MP_STATE_IDLE
* ijkmp_release -> MP_STATE_END
*/
#define MP_STATE_STOPPED 7
/*-
* ijkmp_reset -> MP_STATE_IDLE
* ijkmp_release -> MP_STATE_END
*/
#define MP_STATE_ERROR 8
/*-
* ijkmp_release -> self
*/
#define MP_STATE_END 9
#define IJKMP_IO_STAT_READ 1
#define IJKMP_OPT_CATEGORY_FORMAT FFP_OPT_CATEGORY_FORMAT
#define IJKMP_OPT_CATEGORY_CODEC FFP_OPT_CATEGORY_CODEC
#define IJKMP_OPT_CATEGORY_SWS FFP_OPT_CATEGORY_SWS
#define IJKMP_OPT_CATEGORY_PLAYER FFP_OPT_CATEGORY_PLAYER
#define IJKMP_OPT_CATEGORY_SWR FFP_OPT_CATEGORY_SWR
void ijkmp_global_init();
void ijkmp_global_uninit();
void ijkmp_global_set_log_report(int use_report);
void ijkmp_global_set_log_level(int log_level); // log_level = AV_LOG_xxx
void ijkmp_global_set_inject_callback(ijk_inject_callback cb);
const char *ijkmp_version();
void ijkmp_io_stat_register(void (*cb)(const char *url, int type, int bytes));
void ijkmp_io_stat_complete_register(void (*cb)(const char *url,
int64_t read_bytes, int64_t total_size,
int64_t elpased_time, int64_t total_duration));
// ref_count is 1 after open
IjkMediaPlayer *ijkmp_create(int (*msg_loop)(void*));
void* ijkmp_set_inject_opaque(IjkMediaPlayer *mp, void *opaque);
void* ijkmp_set_ijkio_inject_opaque(IjkMediaPlayer *mp, void *opaque);
void ijkmp_set_option(IjkMediaPlayer *mp, int opt_category, const char *name, const char *value);
void ijkmp_set_option_int(IjkMediaPlayer *mp, int opt_category, const char *name, int64_t value);
int ijkmp_get_video_codec_info(IjkMediaPlayer *mp, char **codec_info);
int ijkmp_get_audio_codec_info(IjkMediaPlayer *mp, char **codec_info);
void ijkmp_set_playback_rate(IjkMediaPlayer *mp, float rate);
void ijkmp_set_playback_volume(IjkMediaPlayer *mp, float rate);
int ijkmp_set_stream_selected(IjkMediaPlayer *mp, int stream, int selected);
float ijkmp_get_property_float(IjkMediaPlayer *mp, int id, float default_value);
void ijkmp_set_property_float(IjkMediaPlayer *mp, int id, float value);
int64_t ijkmp_get_property_int64(IjkMediaPlayer *mp, int id, int64_t default_value);
void ijkmp_set_property_int64(IjkMediaPlayer *mp, int id, int64_t value);
// must be freed with free();
IjkMediaMeta *ijkmp_get_meta_l(IjkMediaPlayer *mp);
// preferred to be called explicity, can be called multiple times
// NOTE: ijkmp_shutdown may block thread
void ijkmp_shutdown(IjkMediaPlayer *mp);
void ijkmp_inc_ref(IjkMediaPlayer *mp);
// call close at last release, also free memory
// NOTE: ijkmp_dec_ref may block thread
void ijkmp_dec_ref(IjkMediaPlayer *mp);
void ijkmp_dec_ref_p(IjkMediaPlayer **pmp);
int ijkmp_set_data_source(IjkMediaPlayer *mp, const char *url);
int ijkmp_prepare_async(IjkMediaPlayer *mp);
int ijkmp_start(IjkMediaPlayer *mp);
int ijkmp_pause(IjkMediaPlayer *mp);
int ijkmp_stop(IjkMediaPlayer *mp);
int ijkmp_seek_to(IjkMediaPlayer *mp, long msec);
int ijkmp_get_state(IjkMediaPlayer *mp);
bool ijkmp_is_playing(IjkMediaPlayer *mp);
long ijkmp_get_current_position(IjkMediaPlayer *mp);
long ijkmp_get_duration(IjkMediaPlayer *mp);
long ijkmp_get_playable_duration(IjkMediaPlayer *mp);
void ijkmp_set_loop(IjkMediaPlayer *mp, int loop);
int ijkmp_get_loop(IjkMediaPlayer *mp);
void *ijkmp_get_weak_thiz(IjkMediaPlayer *mp);
void *ijkmp_set_weak_thiz(IjkMediaPlayer *mp, void *weak_thiz);
/* return < 0 if aborted, 0 if no packet and > 0 if packet. */
/* need to call msg_free_res for freeing the resouce obtained in msg */
int ijkmp_get_msg(IjkMediaPlayer *mp, AVMessage *msg, int block);
void ijkmp_set_frame_at_time(IjkMediaPlayer *mp, const char *path, int64_t start_time, int64_t end_time, int num, int definition);
/* 获取音轨信息 */
int ijkmp_get_audio_track(IjkMediaPlayer *mp);
void ijkmp_switch_audio_track(IjkMediaPlayer *mp, int tracksNum, int index);
#endif