| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
#include "libvlc_internal.h" |
|---|
| 25 |
#include "libvlc.h" |
|---|
| 26 |
#include <vlc/libvlc.h> |
|---|
| 27 |
#include <vlc_input.h> |
|---|
| 28 |
#include <vlc_meta.h> |
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
#include <vlc_playlist.h> |
|---|
| 32 |
|
|---|
| 33 |
static const vlc_meta_type_t libvlc_to_vlc_meta[] = |
|---|
| 34 |
{ |
|---|
| 35 |
[libvlc_meta_Title] = vlc_meta_Title, |
|---|
| 36 |
[libvlc_meta_Artist] = vlc_meta_Artist, |
|---|
| 37 |
[libvlc_meta_Genre] = vlc_meta_Genre, |
|---|
| 38 |
[libvlc_meta_Copyright] = vlc_meta_Copyright, |
|---|
| 39 |
[libvlc_meta_Album] = vlc_meta_Album, |
|---|
| 40 |
[libvlc_meta_TrackNumber] = vlc_meta_TrackNumber, |
|---|
| 41 |
[libvlc_meta_Description] = vlc_meta_Description, |
|---|
| 42 |
[libvlc_meta_Rating] = vlc_meta_Rating, |
|---|
| 43 |
[libvlc_meta_Date] = vlc_meta_Date, |
|---|
| 44 |
[libvlc_meta_Setting] = vlc_meta_Setting, |
|---|
| 45 |
[libvlc_meta_URL] = vlc_meta_URL, |
|---|
| 46 |
[libvlc_meta_Language] = vlc_meta_Language, |
|---|
| 47 |
[libvlc_meta_NowPlaying] = vlc_meta_NowPlaying, |
|---|
| 48 |
[libvlc_meta_Publisher] = vlc_meta_Publisher, |
|---|
| 49 |
[libvlc_meta_EncodedBy] = vlc_meta_EncodedBy, |
|---|
| 50 |
[libvlc_meta_ArtworkURL] = vlc_meta_ArtworkURL, |
|---|
| 51 |
[libvlc_meta_TrackID] = vlc_meta_TrackID |
|---|
| 52 |
}; |
|---|
| 53 |
|
|---|
| 54 |
static const libvlc_meta_t vlc_to_libvlc_meta[] = |
|---|
| 55 |
{ |
|---|
| 56 |
[vlc_meta_Title] = libvlc_meta_Title, |
|---|
| 57 |
[vlc_meta_Artist] = libvlc_meta_Artist, |
|---|
| 58 |
[vlc_meta_Genre] = libvlc_meta_Genre, |
|---|
| 59 |
[vlc_meta_Copyright] = libvlc_meta_Copyright, |
|---|
| 60 |
[vlc_meta_Album] = libvlc_meta_Album, |
|---|
| 61 |
[vlc_meta_TrackNumber] = libvlc_meta_TrackNumber, |
|---|
| 62 |
[vlc_meta_Description] = libvlc_meta_Description, |
|---|
| 63 |
[vlc_meta_Rating] = libvlc_meta_Rating, |
|---|
| 64 |
[vlc_meta_Date] = libvlc_meta_Date, |
|---|
| 65 |
[vlc_meta_Setting] = libvlc_meta_Setting, |
|---|
| 66 |
[vlc_meta_URL] = libvlc_meta_URL, |
|---|
| 67 |
[vlc_meta_Language] = libvlc_meta_Language, |
|---|
| 68 |
[vlc_meta_NowPlaying] = libvlc_meta_NowPlaying, |
|---|
| 69 |
[vlc_meta_Publisher] = libvlc_meta_Publisher, |
|---|
| 70 |
[vlc_meta_EncodedBy] = libvlc_meta_EncodedBy, |
|---|
| 71 |
[vlc_meta_ArtworkURL] = libvlc_meta_ArtworkURL, |
|---|
| 72 |
[vlc_meta_TrackID] = libvlc_meta_TrackID |
|---|
| 73 |
}; |
|---|
| 74 |
|
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 |
|
|---|
| 78 |
static void input_item_subitem_added( const vlc_event_t *p_event, |
|---|
| 79 |
void * user_data ) |
|---|
| 80 |
{ |
|---|
| 81 |
libvlc_media_t * p_md = user_data; |
|---|
| 82 |
libvlc_media_t * p_md_child; |
|---|
| 83 |
libvlc_event_t event; |
|---|
| 84 |
|
|---|
| 85 |
p_md_child = libvlc_media_new_from_input_item( |
|---|
| 86 |
p_md->p_libvlc_instance, |
|---|
| 87 |
p_event->u.input_item_subitem_added.p_new_child, NULL ); |
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
if( !p_md->p_subitems ) |
|---|
| 91 |
{ |
|---|
| 92 |
p_md->p_subitems = libvlc_media_list_new( p_md->p_libvlc_instance, NULL ); |
|---|
| 93 |
libvlc_media_list_set_media( p_md->p_subitems, p_md, NULL ); |
|---|
| 94 |
} |
|---|
| 95 |
if( p_md->p_subitems ) |
|---|
| 96 |
{ |
|---|
| 97 |
libvlc_media_list_add_media( p_md->p_subitems, p_md_child, NULL ); |
|---|
| 98 |
} |
|---|
| 99 |
|
|---|
| 100 |
|
|---|
| 101 |
event.type = libvlc_MediaSubItemAdded; |
|---|
| 102 |
event.u.media_subitem_added.new_child = p_md_child; |
|---|
| 103 |
|
|---|
| 104 |
|
|---|
| 105 |
libvlc_event_send( p_md->p_event_manager, &event ); |
|---|
| 106 |
libvlc_media_release( p_md_child ); |
|---|
| 107 |
} |
|---|
| 108 |
|
|---|
| 109 |
|
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 |
static void input_item_meta_changed( const vlc_event_t *p_event, |
|---|
| 113 |
void * user_data ) |
|---|
| 114 |
{ |
|---|
| 115 |
libvlc_media_t * p_md = user_data; |
|---|
| 116 |
libvlc_event_t event; |
|---|
| 117 |
|
|---|
| 118 |
|
|---|
| 119 |
event.type = libvlc_MediaMetaChanged; |
|---|
| 120 |
event.u.media_meta_changed.meta_type = |
|---|
| 121 |
vlc_to_libvlc_meta[p_event->u.input_item_meta_changed.meta_type]; |
|---|
| 122 |
|
|---|
| 123 |
|
|---|
| 124 |
libvlc_event_send( p_md->p_event_manager, &event ); |
|---|
| 125 |
} |
|---|
| 126 |
|
|---|
| 127 |
|
|---|
| 128 |
|
|---|
| 129 |
|
|---|
| 130 |
static void input_item_duration_changed( const vlc_event_t *p_event, |
|---|
| 131 |
void * user_data ) |
|---|
| 132 |
{ |
|---|
| 133 |
libvlc_media_t * p_md = user_data; |
|---|
| 134 |
libvlc_event_t event; |
|---|
| 135 |
|
|---|
| 136 |
|
|---|
| 137 |
event.type = libvlc_MediaDurationChanged; |
|---|
| 138 |
event.u.media_duration_changed.new_duration = |
|---|
| 139 |
p_event->u.input_item_duration_changed.new_duration; |
|---|
| 140 |
|
|---|
| 141 |
|
|---|
| 142 |
libvlc_event_send( p_md->p_event_manager, &event ); |
|---|
| 143 |
} |
|---|
| 144 |
|
|---|
| 145 |
|
|---|
| 146 |
|
|---|
| 147 |
|
|---|
| 148 |
static void input_item_preparsed_changed( const vlc_event_t *p_event, |
|---|
| 149 |
void * user_data ) |
|---|
| 150 |
{ |
|---|
| 151 |
libvlc_media_t * p_md = user_data; |
|---|
| 152 |
libvlc_event_t event; |
|---|
| 153 |
|
|---|
| 154 |
|
|---|
| 155 |
event.type = libvlc_MediaPreparsedChanged; |
|---|
| 156 |
event.u.media_preparsed_changed.new_status = |
|---|
| 157 |
p_event->u.input_item_preparsed_changed.new_status; |
|---|
| 158 |
|
|---|
| 159 |
|
|---|
| 160 |
libvlc_event_send( p_md->p_event_manager, &event ); |
|---|
| 161 |
} |
|---|
| 162 |
|
|---|
| 163 |
|
|---|
| 164 |
|
|---|
| 165 |
|
|---|
| 166 |
static void install_input_item_observer( libvlc_media_t *p_md ) |
|---|
| 167 |
{ |
|---|
| 168 |
vlc_event_attach( &p_md->p_input_item->event_manager, |
|---|
| 169 |
vlc_InputItemSubItemAdded, |
|---|
| 170 |
input_item_subitem_added, |
|---|
| 171 |
p_md ); |
|---|
| 172 |
vlc_event_attach( &p_md->p_input_item->event_manager, |
|---|
| 173 |
vlc_InputItemMetaChanged, |
|---|
| 174 |
input_item_meta_changed, |
|---|
| 175 |
p_md ); |
|---|
| 176 |
vlc_event_attach( &p_md->p_input_item->event_manager, |
|---|
| 177 |
vlc_InputItemDurationChanged, |
|---|
| 178 |
input_item_duration_changed, |
|---|
| 179 |
p_md ); |
|---|
| 180 |
vlc_event_attach( &p_md->p_input_item->event_manager, |
|---|
| 181 |
vlc_InputItemPreparsedChanged, |
|---|
| 182 |
input_item_preparsed_changed, |
|---|
| 183 |
p_md ); |
|---|
| 184 |
} |
|---|
| 185 |
|
|---|
| 186 |
|
|---|
| 187 |
|
|---|
| 188 |
|
|---|
| 189 |
static void uninstall_input_item_observer( libvlc_media_t *p_md ) |
|---|
| 190 |
{ |
|---|
| 191 |
vlc_event_detach( &p_md->p_input_item->event_manager, |
|---|
| 192 |
vlc_InputItemSubItemAdded, |
|---|
| 193 |
input_item_subitem_added, |
|---|
| 194 |
p_md ); |
|---|
| 195 |
vlc_event_detach( &p_md->p_input_item->event_manager, |
|---|
| 196 |
vlc_InputItemMetaChanged, |
|---|
| 197 |
input_item_meta_changed, |
|---|
| 198 |
p_md ); |
|---|
| 199 |
vlc_event_detach( &p_md->p_input_item->event_manager, |
|---|
| 200 |
vlc_InputItemDurationChanged, |
|---|
| 201 |
input_item_duration_changed, |
|---|
| 202 |
p_md ); |
|---|
| 203 |
vlc_event_detach( &p_md->p_input_item->event_manager, |
|---|
| 204 |
vlc_InputItemPreparsedChanged, |
|---|
| 205 |
input_item_preparsed_changed, |
|---|
| 206 |
p_md ); |
|---|
| 207 |
} |
|---|
| 208 |
|
|---|
| 209 |
|
|---|
| 210 |
|
|---|
| 211 |
|
|---|
| 212 |
static void preparse_if_needed( libvlc_media_t *p_md ) |
|---|
| 213 |
{ |
|---|
| 214 |
|
|---|
| 215 |
if (!p_md->b_preparsed) |
|---|
| 216 |
{ |
|---|
| 217 |
playlist_PreparseEnqueue( |
|---|
| 218 |
libvlc_priv (p_md->p_libvlc_instance->p_libvlc_int)->p_playlist, |
|---|
| 219 |
p_md->p_input_item ); |
|---|
| 220 |
p_md->b_preparsed = true; |
|---|
| 221 |
} |
|---|
| 222 |
} |
|---|
| 223 |
|
|---|
| 224 |
|
|---|
| 225 |
|
|---|
| 226 |
|
|---|
| 227 |
|
|---|
| 228 |
|
|---|
| 229 |
libvlc_media_t * libvlc_media_new_from_input_item( |
|---|
| 230 |
libvlc_instance_t *p_instance, |
|---|
| 231 |
input_item_t *p_input_item, |
|---|
| 232 |
libvlc_exception_t *p_e ) |
|---|
| 233 |
{ |
|---|
| 234 |
libvlc_media_t * p_md; |
|---|
| 235 |
|
|---|
| 236 |
if (!p_input_item) |
|---|
| 237 |
{ |
|---|
| 238 |
libvlc_exception_raise( p_e, "No input item given" ); |
|---|
| 239 |
return NULL; |
|---|
| 240 |
} |
|---|
| 241 |
|
|---|
| 242 |
p_md = malloc( sizeof(libvlc_media_t) ); |
|---|
| 243 |
if( !p_md ) |
|---|
| 244 |
{ |
|---|
| 245 |
libvlc_exception_raise( p_e, "Not enough memory" ); |
|---|
| 246 |
return NULL; |
|---|
| 247 |
} |
|---|
| 248 |
|
|---|
| 249 |
p_md->p_libvlc_instance = p_instance; |
|---|
| 250 |
p_md->p_input_item = p_input_item; |
|---|
| 251 |
p_md->b_preparsed = false; |
|---|
| 252 |
p_md->i_refcount = 1; |
|---|
| 253 |
p_md->p_user_data = NULL; |
|---|
| 254 |
|
|---|
| 255 |
p_md->state = libvlc_NothingSpecial; |
|---|
| 256 |
|
|---|
| 257 |
|
|---|
| 258 |
|
|---|
| 259 |
p_md->p_subitems = NULL; |
|---|
| 260 |
|
|---|
| 261 |
p_md->p_event_manager = libvlc_event_manager_new( p_md, p_instance, p_e ); |
|---|
| 262 |
libvlc_event_manager_register_event_type( p_md->p_event_manager, |
|---|
| 263 |
libvlc_MediaMetaChanged, p_e ); |
|---|
| 264 |
libvlc_event_manager_register_event_type( p_md->p_event_manager, |
|---|
| 265 |
libvlc_MediaSubItemAdded, p_e ); |
|---|
| 266 |
libvlc_event_manager_register_event_type( p_md->p_event_manager, |
|---|
| 267 |
libvlc_MediaFreed, p_e ); |
|---|
| 268 |
libvlc_event_manager_register_event_type( p_md->p_event_manager, |
|---|
| 269 |
libvlc_MediaDurationChanged, p_e ); |
|---|
| 270 |
libvlc_event_manager_register_event_type( p_md->p_event_manager, |
|---|
| 271 |
libvlc_MediaStateChanged, p_e ); |
|---|
| 272 |
|
|---|
| 273 |
vlc_gc_incref( p_md->p_input_item ); |
|---|
| 274 |
|
|---|
| 275 |
install_input_item_observer( p_md ); |
|---|
| 276 |
|
|---|
| 277 |
return p_md; |
|---|
| 278 |
} |
|---|
| 279 |
|
|---|
| 280 |
|
|---|
| 281 |
|
|---|
| 282 |
|
|---|
| 283 |
libvlc_media_t * libvlc_media_new( |
|---|
| 284 |
libvlc_instance_t *p_instance, |
|---|
| 285 |
const char * psz_mrl, |
|---|
| 286 |
libvlc_exception_t *p_e ) |
|---|
| 287 |
{ |
|---|
| 288 |
input_item_t * p_input_item; |
|---|
| 289 |
libvlc_media_t * p_md; |
|---|
| 290 |
|
|---|
| 291 |
p_input_item = input_item_New( p_instance->p_libvlc_int, psz_mrl, NULL ); |
|---|
| 292 |
|
|---|
| 293 |
if (!p_input_item) |
|---|
| 294 |
{ |
|---|
| 295 |
libvlc_exception_raise( p_e, "Can't create md's input_item" ); |
|---|
| 296 |
return NULL; |
|---|
| 297 |
} |
|---|
| 298 |
|
|---|
| 299 |
p_md = libvlc_media_new_from_input_item( p_instance, |
|---|
| 300 |
p_input_item, p_e ); |
|---|
| 301 |
|
|---|
| 302 |
|
|---|
| 303 |
vlc_gc_decref( p_input_item ); |
|---|
| 304 |
|
|---|
| 305 |
return p_md; |
|---|
| 306 |
} |
|---|
| 307 |
|
|---|
| 308 |
|
|---|
| 309 |
|
|---|
| 310 |
|
|---|
| 311 |
libvlc_media_t * libvlc_media_new_as_node( |
|---|
| 312 |
libvlc_instance_t *p_instance, |
|---|
| 313 |
const char * psz_name, |
|---|
| 314 |
libvlc_exception_t *p_e ) |
|---|
| 315 |
{ |
|---|
| 316 |
input_item_t * p_input_item; |
|---|
| 317 |
libvlc_media_t * p_md; |
|---|
| 318 |
|
|---|
| 319 |
p_input_item = input_item_New( p_instance->p_libvlc_int, "vlc://nop", psz_name ); |
|---|
| 320 |
|
|---|
| 321 |
if (!p_input_item) |
|---|
| 322 |
{ |
|---|
| 323 |
libvlc_exception_raise( p_e, "Can't create md's input_item" ); |
|---|
| 324 |
return NULL; |
|---|
| 325 |
} |
|---|
| 326 |
|
|---|
| 327 |
p_md = libvlc_media_new_from_input_item( p_instance, |
|---|
| 328 |
p_input_item, p_e ); |
|---|
| 329 |
|
|---|
| 330 |
p_md->p_subitems = libvlc_media_list_new( p_md->p_libvlc_instance, NULL ); |
|---|
| 331 |
|
|---|
| 332 |
return p_md; |
|---|
| 333 |
} |
|---|
| 334 |
|
|---|
| 335 |
|
|---|
| 336 |
|
|---|
| 337 |
|
|---|
| 338 |
|
|---|
| 339 |
|
|---|
| 340 |
|
|---|
| 341 |
|
|---|
| 342 |
|
|---|
| 343 |
void libvlc_media_add_option( |
|---|
| 344 |
libvlc_media_t * p_md, |
|---|
| 345 |
const char * ppsz_option, |
|---|
| 346 |
libvlc_exception_t *p_e ) |
|---|
| 347 |
{ |
|---|
| 348 |
VLC_UNUSED(p_e); |
|---|
| 349 |
input_item_AddOpt( p_md->p_input_item, ppsz_option, |
|---|
| 350 |
VLC_INPUT_OPTION_UNIQUE|VLC_INPUT_OPTION_TRUSTED ); |
|---|
| 351 |
} |
|---|
| 352 |
|
|---|
| 353 |
|
|---|
| 354 |
|
|---|
| 355 |
|
|---|
| 356 |
void libvlc_media_release( libvlc_media_t *p_md ) |
|---|
| 357 |
{ |
|---|
| 358 |
if (!p_md) |
|---|
| 359 |
return; |
|---|
| 360 |
|
|---|
| 361 |
p_md->i_refcount--; |
|---|
| 362 |
|
|---|
| 363 |
if( p_md->i_refcount > 0 ) |
|---|
| 364 |
return; |
|---|
| 365 |
|
|---|
| 366 |
if( p_md->p_subitems ) |
|---|
| 367 |
libvlc_media_list_release( p_md->p_subitems ); |
|---|
| 368 |
|
|---|
| 369 |
uninstall_input_item_observer( p_md ); |
|---|
| 370 |
vlc_gc_decref( p_md->p_input_item ); |
|---|
| 371 |
|
|---|
| 372 |
|
|---|
| 373 |
libvlc_event_t event; |
|---|
| 374 |
event.type = libvlc_MediaFreed; |
|---|
| 375 |
event.u.media_freed.md = p_md; |
|---|
| 376 |
|
|---|
| 377 |
|
|---|
| 378 |
libvlc_event_send( p_md->p_event_manager, &event ); |
|---|
| 379 |
|
|---|
| 380 |
libvlc_event_manager_release( p_md->p_event_manager ); |
|---|
| 381 |
|
|---|
| 382 |
free( p_md ); |
|---|
| 383 |
} |
|---|
| 384 |
|
|---|
| 385 |
|
|---|
| 386 |
|
|---|
| 387 |
|
|---|
| 388 |
void libvlc_media_retain( libvlc_media_t *p_md ) |
|---|
| 389 |
{ |
|---|
| 390 |
if (!p_md) |
|---|
| 391 |
return; |
|---|
| 392 |
|
|---|
| 393 |
p_md->i_refcount++; |
|---|
| 394 |
} |
|---|
| 395 |
|
|---|
| 396 |
|
|---|
| 397 |
|
|---|
| 398 |
|
|---|
| 399 |
libvlc_media_t * |
|---|
| 400 |
libvlc_media_duplicate( libvlc_media_t *p_md_orig ) |
|---|
| 401 |
{ |
|---|
| 402 |
return libvlc_media_new_from_input_item( |
|---|
| 403 |
p_md_orig->p_libvlc_instance, p_md_orig->p_input_item, NULL ); |
|---|
| 404 |
} |
|---|
| 405 |
|
|---|
| 406 |
|
|---|
| 407 |
|
|---|
| 408 |
|
|---|
| 409 |
char * |
|---|
| 410 |
libvlc_media_get_mrl( libvlc_media_t * p_md, |
|---|
| 411 |
libvlc_exception_t * p_e ) |
|---|
| 412 |
{ |
|---|
| 413 |
VLC_UNUSED(p_e); |
|---|
| 414 |
return input_item_GetURI( p_md->p_input_item ); |
|---|
| 415 |
} |
|---|
| 416 |
|
|---|
| 417 |
|
|---|
| 418 |
|
|---|
| 419 |
|
|---|
| 420 |
|
|---|
| 421 |
char * libvlc_media_get_meta( libvlc_media_t *p_md, |
|---|
| 422 |
libvlc_meta_t e_meta, |
|---|
| 423 |
libvlc_exception_t *p_e ) |
|---|
| 424 |
{ |
|---|
| 425 |
char * psz_meta; |
|---|
| 426 |
VLC_UNUSED(p_e); |
|---|
| 427 |
|
|---|
| 428 |
|
|---|
| 429 |
|
|---|
| 430 |
preparse_if_needed( p_md ); |
|---|
| 431 |
|
|---|
| 432 |
psz_meta = input_item_GetMeta( p_md->p_input_item, |
|---|
| 433 |
libvlc_to_vlc_meta[e_meta] ); |
|---|
| 434 |
|
|---|
| 435 |
if( e_meta == libvlc_meta_ArtworkURL && !psz_meta ) |
|---|
| 436 |
{ |
|---|
| 437 |
playlist_AskForArtEnqueue( |
|---|
| 438 |
libvlc_priv(p_md->p_libvlc_instance->p_libvlc_int)->p_playlist, |
|---|
| 439 |
p_md->p_input_item ); |
|---|
| 440 |
} |
|---|
| 441 |
|
|---|
| 442 |
|
|---|
| 443 |
if( !psz_meta && e_meta == libvlc_meta_Title && p_md->p_input_item->psz_name ) |
|---|
| 444 |
{ |
|---|
| 445 |
free( psz_meta ); |
|---|
| 446 |
return strdup( p_md->p_input_item->psz_name ); |
|---|
| 447 |
} |
|---|
| 448 |
|
|---|
| 449 |
return psz_meta; |
|---|
| 450 |
} |
|---|
| 451 |
|
|---|
| 452 |
|
|---|
| 453 |
|
|---|
| 454 |
|
|---|
| 455 |
|
|---|
| 456 |
|
|---|
| 457 |
libvlc_state_t |
|---|
| 458 |
libvlc_media_get_state( libvlc_media_t *p_md, |
|---|
| 459 |
libvlc_exception_t *p_e ) |
|---|
| 460 |
{ |
|---|
| 461 |
VLC_UNUSED(p_e); |
|---|
| 462 |
return p_md->state; |
|---|
| 463 |
} |
|---|
| 464 |
|
|---|
| 465 |
|
|---|
| 466 |
|
|---|
| 467 |
|
|---|
| 468 |
|
|---|
| 469 |
void |
|---|
| 470 |
libvlc_media_set_state( libvlc_media_t *p_md, |
|---|
| 471 |
libvlc_state_t state, |
|---|
| 472 |
libvlc_exception_t *p_e ) |
|---|
| 473 |
{ |
|---|
| 474 |
libvlc_event_t event; |
|---|
| 475 |
VLC_UNUSED(p_e); |
|---|
| 476 |
|
|---|
| 477 |
p_md->state = state; |
|---|
| 478 |
|
|---|
| 479 |
|
|---|
| 480 |
event.type = libvlc_MediaStateChanged; |
|---|
| 481 |
event.u.media_state_changed.new_state = state; |
|---|
| 482 |
|
|---|
| 483 |
|
|---|
| 484 |
libvlc_event_send( p_md->p_event_manager, &event ); |
|---|
| 485 |
} |
|---|
| 486 |
|
|---|
| 487 |
|
|---|
| 488 |
|
|---|
| 489 |
|
|---|
| 490 |
libvlc_media_list_t * |
|---|
| 491 |
libvlc_media_subitems( libvlc_media_t * p_md, |
|---|
| 492 |
libvlc_exception_t * p_e ) |
|---|
| 493 |
{ |
|---|
| 494 |
VLC_UNUSED(p_e); |
|---|
| 495 |
|
|---|
| 496 |
if( p_md->p_subitems ) |
|---|
| 497 |
libvlc_media_list_retain( p_md->p_subitems ); |
|---|
| 498 |
return p_md->p_subitems; |
|---|
| 499 |
} |
|---|
| 500 |
|
|---|
| 501 |
|
|---|
| 502 |
|
|---|
| 503 |
|
|---|
| 504 |
libvlc_event_manager_t * |
|---|
| 505 |
libvlc_media_event_manager( libvlc_media_t * p_md, |
|---|
| 506 |
libvlc_exception_t * p_e ) |
|---|
| 507 |
{ |
|---|
| 508 |
VLC_UNUSED(p_e); |
|---|
| 509 |
|
|---|
| 510 |
return p_md->p_event_manager; |
|---|
| 511 |
} |
|---|
| 512 |
|
|---|
| 513 |
|
|---|
| 514 |
|
|---|
| 515 |
|
|---|
| 516 |
int64_t |
|---|
| 517 |
libvlc_media_get_duration( libvlc_media_t * p_md, |
|---|
| 518 |
libvlc_exception_t * p_e ) |
|---|
| 519 |
{ |
|---|
| 520 |
VLC_UNUSED(p_e); |
|---|
| 521 |
|
|---|
| 522 |
if( !p_md || !p_md->p_input_item) |
|---|
| 523 |
{ |
|---|
| 524 |
libvlc_exception_raise( p_e, "No input item" ); |
|---|
| 525 |
return -1; |
|---|
| 526 |
} |
|---|
| 527 |
|
|---|
| 528 |
return input_item_GetDuration( p_md->p_input_item ); |
|---|
| 529 |
} |
|---|
| 530 |
|
|---|
| 531 |
|
|---|
| 532 |
|
|---|
| 533 |
|
|---|
| 534 |
int |
|---|
| 535 |
libvlc_media_is_preparsed( libvlc_media_t * p_md, |
|---|
| 536 |
libvlc_exception_t * p_e ) |
|---|
| 537 |
{ |
|---|
| 538 |
VLC_UNUSED(p_e); |
|---|
| 539 |
|
|---|
| 540 |
if( !p_md || !p_md->p_input_item) |
|---|
| 541 |
{ |
|---|
| 542 |
libvlc_exception_raise( p_e, "No input item" ); |
|---|
| 543 |
return false; |
|---|
| 544 |
} |
|---|
| 545 |
|
|---|
| 546 |
return input_item_IsPreparsed( p_md->p_input_item ); |
|---|
| 547 |
} |
|---|
| 548 |
|
|---|
| 549 |
|
|---|
| 550 |
|
|---|
| 551 |
|
|---|
| 552 |
|
|---|
| 553 |
|
|---|
| 554 |
void |
|---|
| 555 |
libvlc_media_set_user_data( libvlc_media_t * p_md, |
|---|
| 556 |
void * p_new_user_data, |
|---|
| 557 |
libvlc_exception_t * p_e ) |
|---|
| 558 |
{ |
|---|
| 559 |
VLC_UNUSED(p_e); |
|---|
| 560 |
|
|---|
| 561 |
if( p_md ) |
|---|
| 562 |
{ |
|---|
| 563 |
p_md->p_user_data = p_new_user_data; |
|---|
| 564 |
} |
|---|
| 565 |
} |
|---|
| 566 |
|
|---|
| 567 |
|
|---|
| 568 |
|
|---|
| 569 |
|
|---|
| 570 |
|
|---|
| 571 |
|
|---|
| 572 |
void * |
|---|
| 573 |
libvlc_media_get_user_data( libvlc_media_t * p_md, |
|---|
| 574 |
libvlc_exception_t * p_e ) |
|---|
| 575 |
{ |
|---|
| 576 |
VLC_UNUSED(p_e); |
|---|
| 577 |
|
|---|
| 578 |
if( p_md ) |
|---|
| 579 |
{ |
|---|
| 580 |
return p_md->p_user_data; |
|---|
| 581 |
} |
|---|
| 582 |
else |
|---|
| 583 |
{ |
|---|
| 584 |
return NULL; |
|---|
| 585 |
} |
|---|
| 586 |
} |
|---|