]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/info_panels.cpp
Fix compilation
[vlc] / modules / gui / qt4 / components / info_panels.cpp
index 73daea9b162249c1ed52a5eff63dbf71c52369f2..76d176e1112c7f4e916c38bd979a13e108ae75c3 100644 (file)
@@ -32,6 +32,8 @@
 #include "components/interface_widgets.hpp"
 
 #include <assert.h>
+#include <vlc_url.h>
+#include <vlc_meta.h>
 
 #include <QTreeWidget>
 #include <QHeaderView>
@@ -184,26 +186,25 @@ void MetaPanel::update( input_item_t *p_item )
     free( psz_meta );
 
     /* Name / Title */
-    psz_meta = input_item_GetTitle( p_item );
-    char *psz_name = input_item_GetName( p_item );
-    if( !EMPTY_STR( psz_meta ) )
+    psz_meta = input_item_GetTitleFbName( p_item );
+    if( psz_meta )
+    {
         title_text->setText( qfu( psz_meta ) );
-    else if( !EMPTY_STR( psz_name ) )
-        title_text->setText( qfu( psz_name ) );
-    else title_text->setText( "" );
-    free( psz_meta );
-    free( psz_name );
+        free( psz_meta );
+    }
+    else
+        title_text->setText( "" );
 
     /* URL / URI */
     psz_meta = input_item_GetURL( p_item );
     if( !EMPTY_STR( psz_meta ) )
-        emit uriSet( QString( psz_meta ) );
+        emit uriSet( qfu( psz_meta ) );
     else
     {
         free( psz_meta );
         psz_meta = input_item_GetURI( p_item );
         if( !EMPTY_STR( psz_meta ) )
-            emit uriSet( QString( psz_meta ) );
+            emit uriSet( qfu( psz_meta ) );
     }
     free( psz_meta );
 
@@ -217,7 +218,8 @@ void MetaPanel::update( input_item_t *p_item )
     UPDATE_META( NowPlaying, nowplaying_text );
     UPDATE_META( Publisher, publisher_text );
 //    UPDATE_META( Setting, setting_text );
-//    UPDATE_META( EncodedBy, encodedby_text );
+//FIXME this is wrong if has Publisher and EncodedBy fields
+    UPDATE_META( EncodedBy, publisher_text );
 
     UPDATE_META( Date, date_text );
     UPDATE_META( TrackNum, seqnum_text );
@@ -226,6 +228,21 @@ void MetaPanel::update( input_item_t *p_item )
 #undef UPDATE_META_INT
 #undef UPDATE_META
 
+    // If a artURL is available as a local file, directly display it !
+
+    QString file;
+    char *psz_art = input_item_GetArtURL( p_item );
+    if( psz_art && !strncmp( psz_art, "file://", 7 ) &&
+                decode_URI( psz_art + 7 ) )
+#ifdef WIN32
+        file = qfu( psz_art + 8 ); // Remove extra / on Win32 URI.
+#else
+        file = qfu( psz_art + 7 );
+#endif
+    free( psz_art );
+
+    art_cover->showArtUpdate( file );
+
 }
 
 /**
@@ -233,31 +250,9 @@ void MetaPanel::update( input_item_t *p_item )
  **/
 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() ) );
@@ -270,14 +265,8 @@ void MetaPanel::saveMeta()
     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
@@ -362,7 +351,6 @@ void ExtraMetaPanel::update( input_item_t *p_item )
         return;
     }
 
-    QStringList tempItem;
     QList<QTreeWidgetItem *> items;
 
     extraMetaTree->clear();
@@ -375,13 +363,12 @@ void ExtraMetaPanel::update( input_item_t *p_item )
         return;
     }
 
-    vlc_dictionary_t * p_dict = &p_meta->extra_tags;
-    char ** ppsz_allkey = vlc_dictionary_all_keys( p_dict );
+    char ** ppsz_allkey = vlc_meta_CopyExtraNames( p_meta);
 
     for( int i = 0; ppsz_allkey[i] ; i++ )
     {
-        const char * psz_value = (const char *)vlc_dictionary_value_for_key(
-                p_dict, ppsz_allkey[i] );
+        const char * psz_value = vlc_meta_GetExtra( p_meta, ppsz_allkey[i] );
+        QStringList tempItem;
         tempItem.append( qfu( ppsz_allkey[i] ) + " : ");
         tempItem.append( qfu( psz_value ) );
         items.append( new QTreeWidgetItem ( extraMetaTree, tempItem ) );
@@ -422,7 +409,10 @@ InfoPanel::InfoPanel( QWidget *parent,
 
      InfoTree = new QTreeWidget(this);
      InfoTree->setColumnCount( 1 );
+     InfoTree->setColumnWidth( 0, 20000 );
      InfoTree->header()->hide();
+//     InfoTree->header()->setStretchLastSection(false);
+//     InfoTree->header()->setResizeMode(QHeaderView::ResizeToContents);
      layout->addWidget(InfoTree, 1, 0 );
 }
 
@@ -490,8 +480,8 @@ InputStatsPanel::InputStatsPanel( QWidget *parent,
 
      QList<QTreeWidgetItem *> items;
 
-     QLabel *topLabel = new QLabel( qtr( "Statistics about the currently "
-                 "playing media or stream." ) );
+     QLabel *topLabel = new QLabel( qtr( "Current"
+                 " media / stream " "statistics") );
      topLabel->setWordWrap( true );
      layout->addWidget( topLabel, 0, 0 );
 
@@ -516,35 +506,43 @@ InputStatsPanel::InputStatsPanel( QWidget *parent,
     /* Create the main categories */
     CREATE_CATEGORY( audio, qtr("Audio") );
     CREATE_CATEGORY( video, qtr("Video") );
-    CREATE_CATEGORY( input, qtr("Input") );
-    CREATE_CATEGORY( streaming, qtr("Streaming") );
+    CREATE_CATEGORY( input, qtr("Input/Read") );
+    CREATE_CATEGORY( streaming, qtr("Output/Written/Sent") );
 
-    CREATE_AND_ADD_TO_CAT( read_media_stat, qtr("Read at media"),
+    CREATE_AND_ADD_TO_CAT( read_media_stat, qtr("Media data size"),
                            "0", input , "kB" );
     CREATE_AND_ADD_TO_CAT( input_bitrate_stat, qtr("Input bitrate"),
                            "0", input, "kb/s" );
-    CREATE_AND_ADD_TO_CAT( demuxed_stat, qtr("Demuxed"), "0", input, "kB") ;
-    CREATE_AND_ADD_TO_CAT( stream_bitrate_stat, qtr("Stream bitrate"),
+    CREATE_AND_ADD_TO_CAT( demuxed_stat, qtr("Demuxed data size"), "0", input, "kB") ;
+    CREATE_AND_ADD_TO_CAT( stream_bitrate_stat, qtr("Content bitrate"),
                            "0", input, "kb/s" );
-
-    CREATE_AND_ADD_TO_CAT( vdecoded_stat, qtr("Decoded blocks"),
-                           "0", video, "" );
-    CREATE_AND_ADD_TO_CAT( vdisplayed_stat, qtr("Displayed frames"),
-                           "0", video, "" );
-    CREATE_AND_ADD_TO_CAT( vlost_frames_stat, qtr("Lost frames"),
-                           "0", video, "" );
-
-    CREATE_AND_ADD_TO_CAT( send_stat, qtr("Sent packets"), "0", streaming, "" );
-    CREATE_AND_ADD_TO_CAT( send_bytes_stat, qtr("Sent bytes"),
+    CREATE_AND_ADD_TO_CAT( corrupted_stat, qtr("Discarded (corrupted)"),
+                           "0", input, "" );
+    CREATE_AND_ADD_TO_CAT( discontinuity_stat, qtr("Dropped (discontinued)"),
+                           "0", input, "" );
+
+    CREATE_AND_ADD_TO_CAT( vdecoded_stat, qtr("Decoded"),
+                           "0", video, qtr("blocks") );
+    CREATE_AND_ADD_TO_CAT( vdisplayed_stat, qtr("Displayed"),
+                           "0", video, qtr("frames") );
+    CREATE_AND_ADD_TO_CAT( vlost_frames_stat, qtr("Lost"),
+                           "0", video, qtr("frames") );
+
+    CREATE_AND_ADD_TO_CAT( send_stat, qtr("Sent"), "0", streaming, qtr("packets") );
+    CREATE_AND_ADD_TO_CAT( send_bytes_stat, qtr("Sent"),
                            "0", streaming, "kB" );
-    CREATE_AND_ADD_TO_CAT( send_bitrate_stat, qtr("Sent bitrate"),
+    CREATE_AND_ADD_TO_CAT( send_bitrate_stat, qtr("Upstream rate"),
                            "0", streaming, "kb/s" );
 
-    CREATE_AND_ADD_TO_CAT( adecoded_stat, qtr("Decoded blocks"),
-                           "0", audio, "" );
-    CREATE_AND_ADD_TO_CAT( aplayed_stat, qtr("Played buffers"),
-                           "0", audio, "" );
-    CREATE_AND_ADD_TO_CAT( alost_stat, qtr("Lost buffers"), "0", audio, "" );
+    CREATE_AND_ADD_TO_CAT( adecoded_stat, qtr("Decoded"),
+                           "0", audio, qtr("blocks") );
+    CREATE_AND_ADD_TO_CAT( aplayed_stat, qtr("Played"),
+                           "0", audio, qtr("buffers") );
+    CREATE_AND_ADD_TO_CAT( alost_stat, qtr("Lost"), "0", audio, qtr("buffers") );
+
+#undef CREATE_AND_ADD_TO_CAT
+#undef CREATE_CATEGORY
+#undef CREATE_TREE_ITEM
 
     input->setExpanded( true );
     video->setExpanded( true );
@@ -576,6 +574,8 @@ void InputStatsPanel::update( input_item_t *p_item )
                     (float)(p_item->p_stats->i_demux_read_bytes)/1000 );
     UPDATE( stream_bitrate_stat, "%6.0f",
                     (float)(p_item->p_stats->f_demux_bitrate * 8000 ));
+    UPDATE( corrupted_stat, "%5i", p_item->p_stats->i_demux_corrupted );
+    UPDATE( discontinuity_stat, "%5i", p_item->p_stats->i_demux_discontinuity );
 
     /* Video */
     UPDATE( vdecoded_stat, "%5i", p_item->p_stats->i_decoded_video );
@@ -594,6 +594,8 @@ void InputStatsPanel::update( input_item_t *p_item )
     UPDATE( aplayed_stat, "%5i", p_item->p_stats->i_played_abuffers );
     UPDATE( alost_stat, "%5i", p_item->p_stats->i_lost_abuffers );
 
+#undef UPDATE
+
     vlc_mutex_unlock(& p_item->p_stats->lock );
 }