typedef struct vlm_t vlm_t;
typedef struct vlm_message_t vlm_message_t;
-/* divers */
+/* misc */
typedef struct vlc_meta_t vlc_meta_t;
-typedef struct meta_export_t meta_export_t;
/* Stats */
typedef struct counter_t counter_t;
ALBUM_ART_ALL
};
-struct meta_export_t
+typedef struct meta_export_t
{
+ VLC_COMMON_MEMBERS
input_item_t *p_item;
const char *psz_file;
-};
+} meta_export_t;
+
+VLC_EXPORT( int, input_item_WriteMeta, (vlc_object_t *, input_item_t *) );
#endif
- (IBAction)saveMetaData:(id)sender
{
- playlist_t * p_playlist = pl_Hold( VLCIntf );
-
if( !p_item ) goto error;
- meta_export_t p_export;
- p_export.p_item = p_item;
-
- /* we can write meta data only in a file */
- vlc_mutex_lock( &p_item->lock );
- int i_type = p_item->i_type;
- vlc_mutex_unlock( &p_item->lock );
-
- if( i_type != ITEM_TYPE_FILE )
- goto error;
-
- char *psz_uri_orig = input_item_GetURI( p_item );
- char *psz_uri = psz_uri_orig;
- if( !strncmp( psz_uri, "file://", 7 ) )
- psz_uri += 7; /* strlen("file://") = 7 */
-
- p_export.psz_file = strndup( psz_uri, PATH_MAX );
- free( psz_uri_orig );
-
#define utf8( o_blub ) \
[[o_blub stringValue] UTF8String]
input_item_SetDescription( p_item, utf8( o_description_txt ) );
input_item_SetLanguage( p_item, utf8( o_language_txt ) );
- PL_LOCK;
- p_playlist->p_private = &p_export;
-
- module_t *p_mod = module_need( p_playlist, "meta writer", NULL, false );
- if( p_mod )
- module_unneed( p_playlist, p_mod );
- PL_UNLOCK;
+ playlist_t * p_playlist = pl_Hold( VLCIntf );
+ input_item_WriteMeta( p_playlist, p_item );
var_SetBool( p_playlist, "intf-change", true );
[self updatePanelWithItem: p_item];
return;
error:
- pl_Release( VLCIntf );
NSRunAlertPanel(_NS("Error while saving meta"),
_NS("VLC was unable to save the meta data."),
_NS("OK"), nil, nil);
**/
void MetaPanel::saveMeta()
{
- playlist_t *p_playlist;
-
- meta_export_t p_export;
- p_export.p_item = p_input;
-
if( p_input == NULL )
return;
- /* we can write meta data only in a file */
- vlc_mutex_lock( &p_input->lock );
- int i_type = p_input->i_type;
- vlc_mutex_unlock( &p_input->lock );
- if( i_type == ITEM_TYPE_FILE )
- {
- char *psz_uri_orig = input_item_GetURI( p_input );
- char *psz_uri = psz_uri_orig;
- if( !strncmp( psz_uri, "file://", 7 ) )
- psz_uri += 7; /* strlen("file://") = 7 */
-
- p_export.psz_file = strndup( psz_uri, PATH_MAX );
- free( psz_uri_orig );
- }
- else
- return;
-
/* now we read the modified meta data */
input_item_SetTitle( p_input, qtu( title_text->text() ) );
input_item_SetArtist( p_input, qtu( artist_text->text() ) );
input_item_SetPublisher( p_input, qtu( publisher_text->text() ) );
input_item_SetDescription( p_input, qtu( description_text->text() ) );
- p_playlist = pl_Hold( p_intf );
- PL_LOCK;
- p_playlist->p_private = &p_export;
-
- module_t *p_mod = module_need( p_playlist, "meta writer", NULL, false );
- if( p_mod )
- module_unneed( p_playlist, p_mod );
- PL_UNLOCK;
+ playlist_t *p_playlist = pl_Hold( p_intf );
+ input_item_WriteMeta( VLC_OBJECT(p_playlist), p_input );
pl_Release( p_intf );
/* Reset the status of the mode. No need to emit any signal because parent
static int WriteMeta( vlc_object_t *p_this )
{
- playlist_t *p_playlist = (playlist_t *)p_this;
- meta_export_t *p_export = (meta_export_t *)p_playlist->p_private;
+ meta_export_t *p_export = (meta_export_t *)p_this;
input_item_t *p_item = p_export->p_item;
FileRef f;
#include <vlc_common.h>
#include <vlc_playlist.h>
+#include <vlc_url.h>
+
#include "input_internal.h"
#include "../playlist/art.h"
free( psz_arturl );
}
+int input_item_WriteMeta( vlc_object_t *obj, input_item_t *p_item )
+{
+ meta_export_t *p_export =
+ vlc_custom_create( obj, sizeof( *p_export ), VLC_OBJECT_GENERIC,
+ "meta writer" );
+ if( p_export == NULL )
+ return VLC_ENOMEM;
+ vlc_object_attach( p_export, obj );
+ p_export->p_item = p_item;
+
+ int type;
+ vlc_mutex_lock( &p_item->lock );
+ type = p_item->i_type;
+ vlc_mutex_unlock( &p_item->lock );
+ if( type != ITEM_TYPE_FILE )
+ {
+ char *psz_uri = input_item_GetURI( p_item );
+
+#warning FIXME: function for URI->path conversion!
+ decode_URI( psz_uri );
+ if( !strncmp( psz_uri, "file://", 7 ) )
+ {
+ p_export->psz_file = strdup( psz_uri + 7 );
+ free( psz_uri );
+ }
+ else
+#warning This should not happen!
+ p_export->psz_file = psz_uri;
+ }
+ else
+ {
+ vlc_object_release( p_export );
+ return VLC_EGENERIC;
+ }
+
+ module_t *p_mod = module_need( p_export, "meta writer", NULL, false );
+ if( p_mod )
+ module_unneed( p_export, p_mod );
+ vlc_object_release( p_export );
+ return VLC_SUCCESS;
+}
input_item_SetMeta
input_item_SetName
input_item_SetURI
+input_item_WriteMeta
input_MetaTypeToLocalizedString
__input_Read
input_SplitMRL