You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
661 lines
22 KiB
661 lines
22 KiB
/*****************************************************************************
|
|
* info_panels.cpp : Panels for the information dialogs
|
|
****************************************************************************
|
|
* Copyright (C) 2006-2007 the VideoLAN team
|
|
*
|
|
* Authors: Clément Stenac <zorglub@videolan.org>
|
|
* Jean-Baptiste Kempf <jb@videolan.org>
|
|
* Ilkka Ollakka <ileoo@videolan.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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
|
|
*****************************************************************************/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
# include "config.h"
|
|
#endif
|
|
|
|
#include "qt.hpp"
|
|
#include "info_panels.hpp"
|
|
#include "widgets/native/interface_widgets.hpp"
|
|
#include "info_widgets.hpp"
|
|
#include "dialogs/fingerprint/fingerprintdialog.hpp"
|
|
#include "dialogs/fingerprint/chromaprint.hpp"
|
|
|
|
#include <cassert>
|
|
#include <vlc_url.h>
|
|
#include <vlc_meta.h>
|
|
#include <vlc_input_item.h>
|
|
#include <vlc_list.hpp>
|
|
|
|
#include <QTreeWidget>
|
|
#include <QTableWidget>
|
|
#include <QHeaderView>
|
|
#include <QStringList>
|
|
#include <QGridLayout>
|
|
#include <QLineEdit>
|
|
#include <QLabel>
|
|
#include <QTextEdit>
|
|
#include <QApplication>
|
|
#include <QPushButton>
|
|
#include <QRegularExpression>
|
|
#include <QMessageBox>
|
|
|
|
/************************************************************************
|
|
* Single panels
|
|
************************************************************************/
|
|
|
|
/**
|
|
* First Panel - Meta Info
|
|
* All the usual MetaData are displayed and can be changed.
|
|
**/
|
|
MetaPanel::MetaPanel( QWidget *parent,
|
|
qt_intf_t *_p_intf )
|
|
: QWidget( parent ), p_intf( _p_intf )
|
|
{
|
|
QGridLayout *metaLayout = new QGridLayout( this );
|
|
metaLayout->setVerticalSpacing( 0 );
|
|
|
|
QFont smallFont = QApplication::font();
|
|
smallFont.setPointSize( smallFont.pointSize() - 1 );
|
|
smallFont.setBold( true );
|
|
|
|
int line = 0; /* Counter for GridLayout */
|
|
p_input = NULL;
|
|
QLabel *label;
|
|
|
|
#define ADD_META( string, widget, col, colspan ) { \
|
|
label = new QLabel( qfu( string ) ); label->setFont( smallFont ); \
|
|
label->setContentsMargins( 3, 2, 0, 0 ); \
|
|
metaLayout->addWidget( label, line++, col, 1, colspan ); \
|
|
widget = new QLineEdit; \
|
|
metaLayout->addWidget( widget, line, col, 1, colspan ); \
|
|
connect( widget, &QLineEdit::textEdited, this, &MetaPanel::enterEditMode ); \
|
|
}
|
|
|
|
/* Title, artist and album*/
|
|
ADD_META( VLC_META_TITLE, title_text, 0, 10 ); line++;
|
|
ADD_META( VLC_META_ARTIST, artist_text, 0, 10 ); line++;
|
|
ADD_META( VLC_META_ALBUM, collection_text, 0, 7 );
|
|
|
|
/* Date */
|
|
label = new QLabel( qfu( VLC_META_DATE ) );
|
|
label->setFont( smallFont ); label->setContentsMargins( 3, 2, 0, 0 );
|
|
metaLayout->addWidget( label, line - 1, 7, 1, 2 );
|
|
|
|
/* Date (Should be in years) */
|
|
date_text = new QLineEdit;
|
|
date_text->setAlignment( Qt::AlignRight );
|
|
date_text->setInputMask("0000");
|
|
date_text->setMaximumWidth( 140 );
|
|
metaLayout->addWidget( date_text, line, 7, 1, -1 );
|
|
line++;
|
|
|
|
/* Genre Name */
|
|
/* TODO List id3genres.h is not includable yet ? */
|
|
ADD_META( VLC_META_GENRE, genre_text, 0, 7 );
|
|
|
|
/* Number - on the same line */
|
|
label = new QLabel( qfu( VLC_META_TRACK_NUMBER ) );
|
|
label->setFont( smallFont ); label->setContentsMargins( 3, 2, 0, 0 );
|
|
metaLayout->addWidget( label, line - 1, 7, 1, 3 );
|
|
|
|
seqnum_text = new QLineEdit;
|
|
seqnum_text->setMaximumWidth( 64 );
|
|
seqnum_text->setAlignment( Qt::AlignRight );
|
|
metaLayout->addWidget( seqnum_text, line, 7, 1, 1 );
|
|
|
|
label = new QLabel( "/" ); label->setFont( smallFont );
|
|
metaLayout->addWidget( label, line, 8, 1, 1 );
|
|
|
|
seqtot_text = new QLineEdit;
|
|
seqtot_text->setMaximumWidth( 64 );
|
|
seqtot_text->setAlignment( Qt::AlignRight );
|
|
metaLayout->addWidget( seqtot_text, line, 9, 1, 1 );
|
|
line++;
|
|
|
|
/* Now Playing - Useful for live feeds (HTTP, DVB, ETC...) */
|
|
ADD_META( VLC_META_NOW_PLAYING, nowplaying_text, 0, 7 );
|
|
nowplaying_text->setReadOnly( true ); line--;
|
|
|
|
/* Language on the same line */
|
|
ADD_META( VLC_META_LANGUAGE, language_text, 7, -1 ); line++;
|
|
ADD_META( VLC_META_PUBLISHER, publisher_text, 0, 7 );
|
|
|
|
/* Fingerprint button on the same line */
|
|
fingerprintButton = new QPushButton( qtr("&Fingerprint") );
|
|
fingerprintButton->setToolTip( qtr( "Find meta data using audio fingerprinting" ) );
|
|
fingerprintButton->setEnabled( false );
|
|
metaLayout->addWidget( fingerprintButton, line++, 7 , 1, -1, Qt::AlignCenter );
|
|
connect( fingerprintButton, &QPushButton::clicked, this, &MetaPanel::fingerprint );
|
|
|
|
/* ART_URL */
|
|
art_cover = new CoverArtLabel( this, p_intf );
|
|
metaLayout->addWidget( art_cover, line, 7, 6, 3, Qt::AlignCenter );
|
|
|
|
ADD_META( VLC_META_COPYRIGHT, copyright_text, 0, 7 ); line++;
|
|
|
|
fingerprintButton->setMinimumWidth( std::max( fingerprintButton->minimumSizeHint().width(),
|
|
art_cover->minimumSizeHint().width() ) );
|
|
|
|
ADD_META( VLC_META_ENCODED_BY, encodedby_text, 0, 7 ); line++;
|
|
|
|
label = new QLabel( qtr( "Comments" ) ); label->setFont( smallFont );
|
|
label->setContentsMargins( 3, 2, 0, 0 );
|
|
metaLayout->addWidget( label, line++, 0, 1, 7 );
|
|
description_text = new QTextEdit;
|
|
description_text->setAcceptRichText( false );
|
|
metaLayout->addWidget( description_text, line, 0, 1, 7 );
|
|
connect( description_text, &QTextEdit::textChanged, this, &MetaPanel::enterEditMode );
|
|
|
|
/* VLC_META_SETTING: Useless */
|
|
/* ADD_META( TRACKID ) Useless ? */
|
|
/* ADD_URI - Do not show it, done outside */
|
|
|
|
metaLayout->setColumnStretch( 1, 20 );
|
|
metaLayout->setColumnMinimumWidth ( 1, 80 );
|
|
metaLayout->setRowStretch( line, 10 );
|
|
#undef ADD_META
|
|
|
|
connect( seqnum_text, &QLineEdit::textEdited, this, &MetaPanel::enterEditMode );
|
|
connect( seqtot_text, &QLineEdit::textEdited, this, &MetaPanel::enterEditMode );
|
|
|
|
connect( date_text, &QLineEdit::textEdited, this, &MetaPanel::enterEditMode );
|
|
// connect( THEMIM, QOverload<input_item_t *>::of(&PlayerController::artChanged),
|
|
// this, &MetaPanel::enterEditMode );
|
|
|
|
/* We are not yet in Edit Mode */
|
|
b_inEditMode = false;
|
|
}
|
|
|
|
/**
|
|
* Update all the MetaData and art
|
|
**/
|
|
void MetaPanel::update( const SharedInputItem& p_item )
|
|
{
|
|
input_item_t * const inputItem = p_item.get();
|
|
|
|
if( !inputItem )
|
|
{
|
|
clear();
|
|
return;
|
|
}
|
|
|
|
/* Don't update if you are in edit mode */
|
|
if( b_inEditMode ) return;
|
|
p_input = p_item;
|
|
|
|
char *psz_meta;
|
|
#define UPDATE_META( meta, widget ) { \
|
|
psz_meta = input_item_Get##meta( inputItem ); \
|
|
widget->setText( !EMPTY_STR( psz_meta ) ? qfu( psz_meta ) : "" ); \
|
|
free( psz_meta ); }
|
|
|
|
#define UPDATE_META_INT( meta, widget ) { \
|
|
psz_meta = input_item_Get##meta( inputItem ); \
|
|
if( !EMPTY_STR( psz_meta ) ) \
|
|
widget->setValue( atoi( psz_meta ) ); } \
|
|
free( psz_meta );
|
|
|
|
/* Name / Title */
|
|
psz_meta = input_item_GetTitleFbName( inputItem );
|
|
if( psz_meta )
|
|
{
|
|
title_text->setText( qfu( psz_meta ) );
|
|
free( psz_meta );
|
|
}
|
|
else
|
|
title_text->setText( "" );
|
|
|
|
/* URL / URI */
|
|
psz_meta = input_item_GetURI( inputItem );
|
|
if( !EMPTY_STR( psz_meta ) )
|
|
emit uriSet( qfu( psz_meta ) );
|
|
fingerprintButton->setEnabled( Chromaprint::isSupported( QString( psz_meta ) ) );
|
|
free( psz_meta );
|
|
|
|
/* Other classic though */
|
|
UPDATE_META( Artist, artist_text );
|
|
UPDATE_META( Genre, genre_text );
|
|
UPDATE_META( Copyright, copyright_text );
|
|
UPDATE_META( Album, collection_text );
|
|
disconnect( description_text, &QTextEdit::textChanged, this, &MetaPanel::enterEditMode );
|
|
UPDATE_META( Description, description_text );
|
|
connect( description_text, &QTextEdit::textChanged, this, &MetaPanel::enterEditMode );
|
|
UPDATE_META( Language, language_text );
|
|
UPDATE_META( Publisher, publisher_text );
|
|
UPDATE_META( EncodedBy, encodedby_text );
|
|
|
|
UPDATE_META( Date, date_text );
|
|
UPDATE_META( TrackNum, seqnum_text );
|
|
UPDATE_META( TrackTotal, seqtot_text );
|
|
|
|
/* Now Playing || ES Now Playing */
|
|
psz_meta = input_item_GetNowPlayingFb( inputItem );
|
|
if( !EMPTY_STR( psz_meta ) )
|
|
nowplaying_text->setText( qfu( psz_meta ) );
|
|
free( psz_meta );
|
|
|
|
#undef UPDATE_META_INT
|
|
#undef UPDATE_META
|
|
|
|
art_cover->setItem( p_item );
|
|
}
|
|
|
|
/**
|
|
* Save the MetaData, triggered by parent->save Button
|
|
**/
|
|
bool MetaPanel::saveMeta()
|
|
{
|
|
const auto input = p_input.get();
|
|
|
|
if( input == NULL ) {
|
|
QMessageBox::warning( this, qtr("Metadata"), qtr("Not editing a file") );
|
|
return false;
|
|
}
|
|
|
|
/* now we read the modified meta data */
|
|
input_item_SetTitle( input, qtu( title_text->text() ) );
|
|
input_item_SetArtist( input, qtu( artist_text->text() ) );
|
|
input_item_SetAlbum( input, qtu( collection_text->text() ) );
|
|
input_item_SetGenre( input, qtu( genre_text->text() ) );
|
|
input_item_SetTrackNum( input, qtu( seqnum_text->text() ) );
|
|
input_item_SetTrackTotal( input, qtu( seqtot_text->text() ) );
|
|
input_item_SetDate( input, qtu( date_text->text() ) );
|
|
input_item_SetLanguage( input, qtu( language_text->text() ) );
|
|
|
|
input_item_SetCopyright( input, qtu( copyright_text->text() ) );
|
|
input_item_SetPublisher( input, qtu( publisher_text->text() ) );
|
|
input_item_SetDescription( input, qtu( description_text->toPlainText() ) );
|
|
|
|
/* Reset the status of the mode. No need to emit any signal because parent
|
|
is the only caller */
|
|
b_inEditMode = false;
|
|
int vlcret = input_item_WriteMeta( VLC_OBJECT(p_intf), input );
|
|
if (vlcret != VLC_SUCCESS) {
|
|
QMessageBox::warning( this, qtr("Metadata"), qtr("Failed to save metadata") );
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
|
|
bool MetaPanel::isInEditMode()
|
|
{
|
|
return b_inEditMode;
|
|
}
|
|
|
|
void MetaPanel::enterEditMode()
|
|
{
|
|
setEditMode( true );
|
|
}
|
|
|
|
void MetaPanel::setEditMode( bool b_editing )
|
|
{
|
|
b_inEditMode = b_editing;
|
|
if( b_editing )emit editing();
|
|
}
|
|
|
|
/*
|
|
* Clear all the metadata widgets
|
|
*/
|
|
void MetaPanel::clear()
|
|
{
|
|
title_text->clear();
|
|
artist_text->clear();
|
|
genre_text->clear();
|
|
copyright_text->clear();
|
|
collection_text->clear();
|
|
seqnum_text->clear();
|
|
seqtot_text->clear();
|
|
disconnect( description_text, &QTextEdit::textChanged, this, &MetaPanel::enterEditMode );
|
|
description_text->clear();
|
|
connect( description_text, &QTextEdit::textChanged, this, &MetaPanel::enterEditMode );
|
|
date_text->clear();
|
|
language_text->clear();
|
|
nowplaying_text->clear();
|
|
publisher_text->clear();
|
|
encodedby_text->clear();
|
|
art_cover->clear();
|
|
fingerprintButton->setEnabled( false );
|
|
|
|
setEditMode( false );
|
|
emit uriSet( "" );
|
|
}
|
|
|
|
void MetaPanel::fingerprint()
|
|
{
|
|
FingerprintDialog *dialog = new FingerprintDialog( this, p_intf, p_input.get() );
|
|
connect( dialog, &FingerprintDialog::metaApplied, this, &MetaPanel::fingerprintUpdate );
|
|
dialog->setAttribute( Qt::WA_DeleteOnClose, true );
|
|
dialog->show();
|
|
}
|
|
|
|
void MetaPanel::fingerprintUpdate( const SharedInputItem& p_item )
|
|
{
|
|
update( p_item );
|
|
setEditMode( true );
|
|
}
|
|
|
|
/**
|
|
* Second Panel - Shows the extra metadata in a table, non editable.
|
|
**/
|
|
ExtraMetaPanel::ExtraMetaPanel( QWidget *parent ) : QWidget( parent )
|
|
{
|
|
QGridLayout *layout = new QGridLayout(this);
|
|
|
|
QLabel *topLabel = new QLabel( qtr( "Extra metadata and other information"
|
|
" are shown in this panel.\n" ) );
|
|
topLabel->setWordWrap( true );
|
|
layout->addWidget( topLabel, 0, 0 );
|
|
|
|
extraMeta = new QTableWidget( this );
|
|
extraMeta->verticalHeader()->hide();
|
|
extraMeta->setAlternatingRowColors( true );
|
|
|
|
extraMeta->setColumnCount( 2 );
|
|
extraMeta->setHorizontalHeaderLabels({ qtr( "Property" ),
|
|
qtr( "Value" ) });
|
|
extraMeta->horizontalHeader()->setStretchLastSection(true);
|
|
extraMeta->resizeRowsToContents();
|
|
|
|
extraMeta->setVerticalScrollMode( QAbstractItemView::ScrollPerPixel );
|
|
extraMeta->setHorizontalScrollMode( QAbstractItemView::ScrollPerPixel );
|
|
|
|
extraMeta->setSelectionBehavior( QAbstractItemView::SelectRows );
|
|
|
|
extraMeta->setEditTriggers( QAbstractItemView::NoEditTriggers );
|
|
extraMeta->setSelectionMode( QAbstractItemView::SingleSelection );
|
|
|
|
layout->addWidget( extraMeta, 1, 0 );
|
|
}
|
|
|
|
/**
|
|
* Update the Extra Metadata from p_meta->i_extras
|
|
**/
|
|
void ExtraMetaPanel::update( input_item_t *p_item )
|
|
{
|
|
extraMeta->setRowCount(0);
|
|
|
|
if( !p_item )
|
|
return;
|
|
|
|
vlc_mutex_locker meta_lock( &p_item->lock );
|
|
vlc_meta_t *p_meta = p_item->p_meta;
|
|
|
|
if( !p_meta )
|
|
return;
|
|
|
|
struct AddRowHelper {
|
|
AddRowHelper( QTableWidget* target ) : target( target ) { }
|
|
|
|
void operator()( char const* psz_key, char const* psz_value )
|
|
{
|
|
int idx = target->rowCount();
|
|
|
|
target->insertRow( idx );
|
|
|
|
QTableWidgetItem *key = new QTableWidgetItem( qfu( psz_key ) );
|
|
|
|
key->setTextAlignment( Qt::AlignRight );
|
|
key->setFlags( key->flags() ^ Qt::ItemIsSelectable );
|
|
|
|
target->setItem( idx, 0, key );
|
|
target->setItem( idx, 1, new QTableWidgetItem( qfu( psz_value ) ) );
|
|
}
|
|
|
|
QTableWidget* target;
|
|
|
|
} add_row ( extraMeta );
|
|
|
|
if( char const* psz_disc = vlc_meta_Get( p_meta, vlc_meta_DiscNumber ) )
|
|
add_row( VLC_META_DISCNUMBER, psz_disc );
|
|
|
|
if( char const* psz_url = vlc_meta_Get( p_meta, vlc_meta_URL ) )
|
|
add_row( VLC_META_URL, psz_url );
|
|
|
|
char ** ppsz_keys = vlc_meta_CopyExtraNames( p_meta );
|
|
if( ppsz_keys )
|
|
{
|
|
for( int i = 0; ppsz_keys[i]; ++i )
|
|
{
|
|
add_row( ppsz_keys[i], vlc_meta_GetExtra( p_meta, ppsz_keys[i] ) );
|
|
free( ppsz_keys[i] );
|
|
}
|
|
|
|
free( ppsz_keys );
|
|
}
|
|
|
|
extraMeta->verticalHeader()->resizeSections( QHeaderView::ResizeToContents );
|
|
}
|
|
|
|
/**
|
|
* Clear the ExtraMetaData Tree
|
|
**/
|
|
void ExtraMetaPanel::clear()
|
|
{
|
|
extraMeta->clear();
|
|
}
|
|
|
|
/**
|
|
* Third panel - Stream info
|
|
* Display all codecs and muxers info that we could gather.
|
|
**/
|
|
InfoPanel::InfoPanel( QWidget *parent ) : QWidget( parent )
|
|
{
|
|
QGridLayout *layout = new QGridLayout(this);
|
|
|
|
QLabel *topLabel = new QLabel( qtr( "Information about what your media or"
|
|
" stream is made of.\nMuxer, Audio and Video Codecs, Subtitles "
|
|
"are shown." ) );
|
|
topLabel->setWordWrap( true );
|
|
layout->addWidget( topLabel, 0, 0 );
|
|
|
|
InfoTree = new QTreeWidget(this);
|
|
InfoTree->setColumnCount( 1 );
|
|
InfoTree->header()->hide();
|
|
InfoTree->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
|
layout->addWidget(InfoTree, 1, 0 );
|
|
}
|
|
|
|
/**
|
|
* Update the Codecs information on parent->update()
|
|
**/
|
|
void InfoPanel::update( input_item_t *p_item)
|
|
{
|
|
if( !p_item )
|
|
{
|
|
clear();
|
|
return;
|
|
}
|
|
|
|
InfoTree->clear();
|
|
QTreeWidgetItem *current_item = NULL;
|
|
QTreeWidgetItem *child_item = NULL;
|
|
|
|
vlc_mutex_locker locker( &p_item->lock );
|
|
|
|
for (auto &cat : vlc::from(p_item->categories, &info_category_t::node))
|
|
{
|
|
if (info_category_IsHidden(&cat))
|
|
continue;
|
|
|
|
current_item = new QTreeWidgetItem();
|
|
current_item->setText(0, qfu(cat.psz_name));
|
|
InfoTree->addTopLevelItem( current_item );
|
|
|
|
for (auto &info : vlc::from(cat.infos, &info_t::node))
|
|
{
|
|
child_item = new QTreeWidgetItem ();
|
|
child_item->setText(0, qfu(info.psz_name) + ": " + qfu(info.psz_value));
|
|
current_item->addChild(child_item);
|
|
}
|
|
current_item->setExpanded( true );
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Clear the tree
|
|
**/
|
|
void InfoPanel::clear()
|
|
{
|
|
InfoTree->clear();
|
|
}
|
|
|
|
/**
|
|
* Save all the information to a file
|
|
* Not yet implemented.
|
|
**/
|
|
/*
|
|
void InfoPanel::saveCodecsInfo()
|
|
{}
|
|
*/
|
|
|
|
/**
|
|
* Fourth Panel - Stats
|
|
* Displays the Statistics for reading/displaying in a tree
|
|
*/
|
|
InputStatsPanel::InputStatsPanel( QWidget *parent ): QWidget( parent )
|
|
{
|
|
QVBoxLayout *layout = new QVBoxLayout(this);
|
|
|
|
QLabel *topLabel = new QLabel( qtr( "Current"
|
|
" media / stream " "statistics") );
|
|
topLabel->setWordWrap( true );
|
|
layout->addWidget( topLabel, 0 );
|
|
|
|
StatsTree = new QTreeWidget(this);
|
|
StatsTree->setColumnCount( 3 );
|
|
StatsTree->setHeaderHidden( true );
|
|
|
|
#define CREATE_TREE_ITEM( itemName, itemText, itemValue, unit ) { \
|
|
itemName = \
|
|
new QTreeWidgetItem((QStringList () << itemText << itemValue << unit )); \
|
|
itemName->setTextAlignment( 1 , Qt::AlignRight ) ; }
|
|
|
|
#define CREATE_CATEGORY( catName, itemText ) { \
|
|
CREATE_TREE_ITEM( catName, itemText , "", "" ); \
|
|
catName->setExpanded( true ); \
|
|
StatsTree->addTopLevelItem( catName ); }
|
|
|
|
#define CREATE_AND_ADD_TO_CAT( itemName, itemText, itemValue, catName, unit ){ \
|
|
CREATE_TREE_ITEM( itemName, itemText, itemValue, unit ); \
|
|
catName->addChild( itemName ); }
|
|
|
|
/* Create the main categories */
|
|
CREATE_CATEGORY( audio, qtr("Audio") );
|
|
CREATE_CATEGORY( video, qtr("Video") );
|
|
CREATE_CATEGORY( input, qtr("Input/Read") );
|
|
|
|
CREATE_AND_ADD_TO_CAT( read_media_stat, qtr("Media data size"),
|
|
"0", input , "KiB" );
|
|
CREATE_AND_ADD_TO_CAT( input_bitrate_stat, qtr("Input bitrate"),
|
|
"0", input, "kb/s" );
|
|
input_bitrate_graph = new QTreeWidgetItem();
|
|
input_bitrate_stat->addChild( input_bitrate_graph );
|
|
CREATE_AND_ADD_TO_CAT( demuxed_stat, qtr("Demuxed data size"), "0", input, "KiB") ;
|
|
CREATE_AND_ADD_TO_CAT( stream_bitrate_stat, qtr("Content bitrate"),
|
|
"0", input, "kb/s" );
|
|
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( vlate_stat, qtr("Late"),
|
|
"0", video, qtr("frames") );
|
|
CREATE_AND_ADD_TO_CAT( vlost_frames_stat, qtr("Lost"),
|
|
"0", video, qtr("frames") );
|
|
|
|
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 );
|
|
audio->setExpanded( true );
|
|
|
|
StatsTree->resizeColumnToContents( 0 );
|
|
StatsTree->setColumnWidth( 1 , 200 );
|
|
|
|
layout->addWidget(StatsTree, 4 );
|
|
|
|
statsView = new VLCStatsView( this );
|
|
statsView->setFrameStyle( QFrame::NoFrame );
|
|
statsView->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed );
|
|
input_bitrate_graph->setSizeHint( 1, QSize(0, 100) );
|
|
QString graphlabel =
|
|
QString( "<font style=\"color:#ff8c00\">%1</font><br/>%2" )
|
|
.arg( qtr("Last 60 seconds") )
|
|
.arg( qtr("Overall") );
|
|
StatsTree->setItemWidget( input_bitrate_graph, 0, new QLabel( graphlabel ) );
|
|
StatsTree->setItemWidget( input_bitrate_graph, 1, statsView );
|
|
}
|
|
|
|
void InputStatsPanel::hideEvent( QHideEvent * event )
|
|
{
|
|
statsView->reset();
|
|
QWidget::hideEvent( event );
|
|
}
|
|
|
|
/**
|
|
* Update the Statistics
|
|
**/
|
|
void InputStatsPanel::update( const input_stats_t& stats )
|
|
{
|
|
if ( !isVisible() ) return;
|
|
|
|
|
|
#define UPDATE_INT( widget, calc... ) \
|
|
{ widget->setText( 1, QString::number( (qulonglong)calc ) ); }
|
|
|
|
#define UPDATE_FLOAT( widget, calc ) \
|
|
widget->setText( 1 , QString().setNum(calc, 'f', 0).leftJustified(6) )
|
|
|
|
UPDATE_INT( read_media_stat, (stats.i_read_bytes / 1024 ) );
|
|
UPDATE_FLOAT( input_bitrate_stat, (float)(stats.f_input_bitrate * 8000 ));
|
|
UPDATE_INT( demuxed_stat, (stats.i_demux_read_bytes / 1024 ) );
|
|
UPDATE_FLOAT( stream_bitrate_stat, (float)(stats.f_demux_bitrate * 8000 ));
|
|
UPDATE_INT( corrupted_stat, stats.i_demux_corrupted );
|
|
UPDATE_INT( discontinuity_stat, stats.i_demux_discontinuity );
|
|
|
|
statsView->addValue( stats.f_input_bitrate * 8000 );
|
|
|
|
/* Video */
|
|
UPDATE_INT( vdecoded_stat, stats.i_decoded_video );
|
|
UPDATE_INT( vdisplayed_stat, stats.i_displayed_pictures );
|
|
UPDATE_INT( vlate_stat, stats.i_late_pictures );
|
|
UPDATE_INT( vlost_frames_stat, stats.i_lost_pictures );
|
|
|
|
/* Audio*/
|
|
UPDATE_INT( adecoded_stat, stats.i_decoded_audio );
|
|
UPDATE_INT( aplayed_stat, stats.i_played_abuffers );
|
|
UPDATE_INT( alost_stat, stats.i_lost_abuffers );
|
|
|
|
#undef UPDATE_INT
|
|
#undef UPDATE_FLOAT
|
|
}
|
|
|
|
void InputStatsPanel::clear()
|
|
{
|
|
}
|
|
|