msmediaplayer.h 4.39 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/*
mediastreamer2 library - modular sound and video processing and streaming
Copyright (C) 2010  Belledonne Communications SARL (simon.morlat@linphone.org)

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program 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 General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

#ifndef MS_MEDIA_PLAYER_H
#define MS_MEDIA_PLAYER_H
François Grisez's avatar
François Grisez committed
22

23 24 25
#include <mediastreamer2/mssndcard.h>
#include <mediastreamer2/msinterfaces.h>
#include <mediastreamer2/msvideo.h>
François Grisez's avatar
François Grisez committed
26

27 28 29
/**
 * @brief Media file player
 */
30
typedef struct _MSMediaPlayer MSMediaPlayer;
François Grisez's avatar
François Grisez committed
31

32
/**
33 34
 * Callbacks definitions */
typedef void (*MSMediaPlayerEofCallback)(void *user_data);
François Grisez's avatar
François Grisez committed
35

36 37 38 39 40 41
typedef enum {
	MS_FILE_FORMAT_UNKNOWN,
	MS_FILE_FORMAT_WAVE,
	MS_FILE_FORMAT_MATROSKA
} MSFileFormat;

42 43 44 45 46

#ifdef __cplusplus
extern "C"{
#endif

47
/**
48
 * @brief Instanciate a media player
49 50
 * @param snd_card Playback sound card
 * @param video_display_name Video out
51
 * @param window_id Pointer on the drawing window
52
 * @return A pointer on the created MSMediaPlayer
53
 */
54
MS2_PUBLIC MSMediaPlayer *ms_media_player_new(MSSndCard *snd_card, const char *video_display_name, unsigned long window_id);
55 56

/**
57 58
 * @brief Free a media player
 * @param obj Pointer on the MSMediaPlayer to free
59
 */
60
MS2_PUBLIC void ms_media_player_free(MSMediaPlayer *obj);
61

62 63 64 65 66
/**
 * @brief Get the window ID
 * @param obj The player
 * @return The window ID
 */
67
MS2_PUBLIC unsigned long ms_media_player_get_window_id(const MSMediaPlayer *obj);
68

69 70
/**
 * @brief Set the "End of File" callback
71
 * @param obj The player
72 73 74
 * @param cb Function to call
 * @param user_data Data which will be passed to the function
 */
75
MS2_PUBLIC void ms_media_player_set_eof_callback(MSMediaPlayer *obj, MSMediaPlayerEofCallback cb, void *user_data);
76 77 78

/**
 * @brief Open a media file
79
 * @param obj The player
80 81 82
 * @param filepath Path of the file to open
 * @return TRUE if the file could be opened
 */
83
MS2_PUBLIC bool_t ms_media_player_open(MSMediaPlayer *obj, const char *filepath);
84 85 86 87

/**
 * @brief Close a media file
 * That function can be safly call even if no file has been opend
88
 * @param obj The player
89
 */
90
MS2_PUBLIC void ms_media_player_close(MSMediaPlayer *obj);
91 92 93

/**
 * @brief Start playback
94
 * @param obj The player
95 96
 * @return TRUE if playback has been successfuly started
 */
97
MS2_PUBLIC bool_t ms_media_player_start(MSMediaPlayer *obj);
98 99 100 101 102

/**
 * @brief Stop a playback
 * When a playback is stoped, the player automatically seek at
 * the begining of the file.
103
 * @param obj The player
104
 */
105
MS2_PUBLIC void ms_media_player_stop(MSMediaPlayer *obj);
106 107 108

/**
 * @brief Turn playback to paused.
109
 * @param obj The player
110
 */
111
MS2_PUBLIC void ms_media_player_pause(MSMediaPlayer *obj);
112 113 114 115

/**
 * @brief Seek into the opened file
 * Can be safly call when playback is runing
116
 * @param obj The player
117 118 119
 * @param seek_pos_ms Position where to seek on (in milliseconds)
 * @return
 */
120
MS2_PUBLIC bool_t ms_media_player_seek(MSMediaPlayer *obj, int seek_pos_ms);
121 122 123

/**
 * @brief Get the state of the player
124
 * @param obj The player
125 126
 * @return An MSPLayerSate enum
 */
127
MS2_PUBLIC MSPlayerState ms_media_player_get_state(MSMediaPlayer *obj);
François Grisez's avatar
François Grisez committed
128

129 130
/**
 * @brief Get the duration of the opened media
131
 * @param obj The player
132 133
 * @return The duration in milliseconds. -1 if failure
 */
134
MS2_PUBLIC int ms_media_player_get_duration(MSMediaPlayer *obj);
135 136 137 138 139 140

/**
 * @brief Get the position of the playback
 * @param obj The player
 * @return The position in milliseconds. -1 if failure
 */
141
MS2_PUBLIC int ms_media_player_get_current_position(MSMediaPlayer *obj);
142

143 144 145 146
/**
 * @brief Check whether Matroska format is supported by the player
 * @return TRUE if supported
 */
147
MS2_PUBLIC bool_t ms_media_player_matroska_supported(void);
148

149 150 151 152 153 154 155
/**
 * @brief Return format of the current opened file
 * @param obj Player
 * @return Format of the file. UNKNOWN_FORMAT when no file is opened
 */
MS2_PUBLIC MSFileFormat ms_media_player_get_file_format(const MSMediaPlayer *obj);

156 157 158 159 160
#ifdef __cplusplus
}
#endif


François Grisez's avatar
François Grisez committed
161
#endif