Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
e56193e8
Commit
e56193e8
authored
Jan 11, 2006
by
Clément Stenac
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Misc stats work (Refs:#473)
parent
8ea1f624
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
150 additions
and
14 deletions
+150
-14
include/vlc_input.h
include/vlc_input.h
+6
-0
include/vlc_messages.h
include/vlc_messages.h
+24
-1
include/vlc_symbols.h
include/vlc_symbols.h
+16
-0
src/input/input.c
src/input/input.c
+4
-1
src/input/stream.c
src/input/stream.c
+6
-2
src/misc/stats.c
src/misc/stats.c
+89
-10
src/playlist/item.c
src/playlist/item.c
+2
-0
src/playlist/playlist.c
src/playlist/playlist.c
+3
-0
No files found.
include/vlc_input.h
View file @
e56193e8
...
...
@@ -64,6 +64,8 @@ struct input_item_t
vlc_bool_t
b_fixed_name
;
/**< Can the interface change the name ?*/
input_stats_t
*
p_stats
;
/**< Statistics */
vlc_mutex_t
lock
;
/**< Item cannot be changed without this lock */
};
...
...
@@ -91,6 +93,10 @@ static inline void vlc_input_item_Init( vlc_object_t *p_o, input_item_t *p_i )
p_i
->
es
=
0
;
p_i
->
i_type
=
ITEM_TYPE_UNKNOWN
;
p_i
->
b_fixed_name
=
VLC_TRUE
;
p_i
->
p_stats
=
(
input_stats_t
*
)
malloc
(
sizeof
(
input_stats_t
)
);
vlc_mutex_init
(
p_o
,
&
p_i
->
p_stats
->
lock
);
vlc_mutex_init
(
p_o
,
&
p_i
->
lock
);
}
...
...
include/vlc_messages.h
View file @
e56193e8
...
...
@@ -25,6 +25,10 @@
*****************************************************************************/
#include <stdarg.h>
int
vlc_mutex_lock
(
vlc_mutex_t
*
)
;
int
vlc_mutex_unlock
(
vlc_mutex_t
*
)
;
/**
* \defgroup messages Messages
* This library provides basic functions for threads to interact with user
...
...
@@ -239,7 +243,20 @@ struct stats_handler_t
VLC_EXPORT
(
int
,
__stats_Update
,
(
vlc_object_t
*
,
char
*
,
vlc_value_t
)
);
#define stats_Create( a,b,c,d ) __stats_Create( VLC_OBJECT(a), b, c, d )
VLC_EXPORT
(
int
,
__stats_Create
,
(
vlc_object_t
*
,
char
*
,
int
,
int
)
);
#define stats_Get( a,b,c,d ) __stats_Create( VLC_OBJECT(a), b, c, d )
VLC_EXPORT
(
int
,
__stats_Get
,
(
vlc_object_t
*
,
int
,
char
*
,
vlc_value_t
*
)
);
#define stats_GetInteger( a,b,c,d ) __stats_GetInteger( VLC_OBJECT(a), b, c, d )
static
inline
int
__stats_GetInteger
(
vlc_object_t
*
p_obj
,
int
i_id
,
char
*
psz_name
,
int
*
value
)
{
vlc_value_t
val
;
int
i_ret
=
__stats_Get
(
p_obj
,
i_id
,
psz_name
,
&
val
);
*
value
=
val
.
i_int
;
return
i_ret
;
}
#define stats_UpdateInteger( a,b,c ) __stats_UpdateInteger( VLC_OBJECT(a),b,c )
static
inline
int
__stats_UpdateInteger
(
vlc_object_t
*
p_obj
,
char
*
psz_name
,
int
i
)
{
...
...
@@ -247,11 +264,13 @@ static inline int __stats_UpdateInteger( vlc_object_t *p_obj, char *psz_name,
val
.
i_int
=
i
;
return
__stats_Update
(
p_obj
,
psz_name
,
val
);
}
#define stats_UpdateInteger( a,b,c ) __stats_UpdateInteger( VLC_OBJECT(a),b,c )
struct
input_stats_t
{
vlc_mutex_t
lock
;
/* Input */
int
i_read_packets
;
int
i_read_bytes
;
...
...
@@ -265,3 +284,7 @@ struct input_stats_t
int
i_displayed_pictures
;
int
i_lost_pictures
;
};
VLC_EXPORT
(
void
,
stats_ComputeInputStats
,
(
input_thread_t
*
,
input_stats_t
*
)
);
VLC_EXPORT
(
void
,
stats_ReinitInputStats
,
(
input_stats_t
*
)
);
VLC_EXPORT
(
void
,
stats_DumpInputStats
,
(
input_stats_t
*
)
);
include/vlc_symbols.h
View file @
e56193e8
...
...
@@ -29,6 +29,7 @@ void vlm_MediaDelete (vlm_t *, vlm_media_t *, const char *);
int
__var_Destroy
(
vlc_object_t
*
,
const
char
*
);
int
playlist_ItemSetDuration
(
playlist_item_t
*
,
mtime_t
);
void
aout_Delete
(
aout_instance_t
*
);
void
stats_ComputeInputStats
(
input_thread_t
*
,
input_stats_t
*
);
int
playlist_Control
(
playlist_t
*
,
int
,
...);
vlc_acl_t
*
__ACL_Create
(
vlc_object_t
*
p_this
,
vlc_bool_t
b_allow
);
playlist_item_t
*
playlist_ItemGetByPos
(
playlist_t
*
,
int
);
...
...
@@ -120,6 +121,7 @@ void vout_SynchroDecode (vout_synchro_t *);
int
playlist_Delete
(
playlist_t
*
,
int
);
void
aout_FiltersPlay
(
aout_instance_t
*
p_aout
,
aout_filter_t
**
pp_filters
,
int
i_nb_filters
,
aout_buffer_t
**
pp_input_buffer
);
int
__stats_Update
(
vlc_object_t
*
,
char
*
,
vlc_value_t
);
int
__stats_Get
(
vlc_object_t
*
,
int
,
char
*
,
vlc_value_t
*
);
char
*
httpd_ClientIP
(
httpd_client_t
*
cl
,
char
*
psz_ip
);
int
__intf_UserProgress
(
vlc_object_t
*
,
const
char
*
,
const
char
*
,
float
);
void
httpd_FileDelete
(
httpd_file_t
*
);
...
...
@@ -241,6 +243,7 @@ int osd_ConfigLoader (vlc_object_t *, const char *, osd_menu_t **);
int
aout_Restart
(
aout_instance_t
*
p_aout
);
void
*
__vlc_object_create
(
vlc_object_t
*
,
int
);
int
__aout_VolumeInfos
(
vlc_object_t
*
,
audio_volume_t
*
);
void
stats_DumpInputStats
(
input_stats_t
*
);
const
iso639_lang_t
*
GetLang_2T
(
const
char
*
);
int
__intf_Interact
(
vlc_object_t
*
,
interaction_dialog_t
*
);
int
playlist_NodeAddItem
(
playlist_t
*
,
playlist_item_t
*
,
int
,
playlist_item_t
*
,
int
,
int
);
...
...
@@ -251,6 +254,7 @@ int playlist_LockControl (playlist_t *, int, ...);
vlc_bool_t
vlc_current_charset
(
char
**
);
char
*
__net_Gets
(
vlc_object_t
*
p_this
,
int
fd
,
v_socket_t
*
);
void
aout_DateMove
(
audio_date_t
*
,
mtime_t
);
void
stats_ReinitInputStats
(
input_stats_t
*
);
void
sout_MuxDelete
(
sout_mux_t
*
);
void
vout_InitFormat
(
video_frame_format_t
*
,
uint32_t
,
int
,
int
,
int
);
void
vout_UnlinkPicture
(
vout_thread_t
*
,
picture_t
*
);
...
...
@@ -873,6 +877,10 @@ struct module_symbols_t
void
(
*
__intf_UserHide_inner
)
(
vlc_object_t
*
,
int
);
int
(
*
__stats_Create_inner
)
(
vlc_object_t
*
,
char
*
,
int
,
int
);
int
(
*
__stats_Update_inner
)
(
vlc_object_t
*
,
char
*
,
vlc_value_t
);
int
(
*
__stats_Get_inner
)
(
vlc_object_t
*
,
int
,
char
*
,
vlc_value_t
*
);
void
(
*
stats_ComputeInputStats_inner
)
(
input_thread_t
*
,
input_stats_t
*
);
void
(
*
stats_DumpInputStats_inner
)
(
input_stats_t
*
);
void
(
*
stats_ReinitInputStats_inner
)
(
input_stats_t
*
);
};
# if defined (__PLUGIN__)
# define aout_FiltersCreatePipeline (p_symbols)->aout_FiltersCreatePipeline_inner
...
...
@@ -1295,6 +1303,10 @@ struct module_symbols_t
# define __intf_UserHide (p_symbols)->__intf_UserHide_inner
# define __stats_Create (p_symbols)->__stats_Create_inner
# define __stats_Update (p_symbols)->__stats_Update_inner
# define __stats_Get (p_symbols)->__stats_Get_inner
# define stats_ComputeInputStats (p_symbols)->stats_ComputeInputStats_inner
# define stats_DumpInputStats (p_symbols)->stats_DumpInputStats_inner
# define stats_ReinitInputStats (p_symbols)->stats_ReinitInputStats_inner
# elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__)
/******************************************************************
* STORE_SYMBOLS: store VLC APIs into p_symbols for plugin access.
...
...
@@ -1720,6 +1732,10 @@ struct module_symbols_t
((p_symbols)->__intf_UserHide_inner) = __intf_UserHide; \
((p_symbols)->__stats_Create_inner) = __stats_Create; \
((p_symbols)->__stats_Update_inner) = __stats_Update; \
((p_symbols)->__stats_Get_inner) = __stats_Get; \
((p_symbols)->stats_ComputeInputStats_inner) = stats_ComputeInputStats; \
((p_symbols)->stats_DumpInputStats_inner) = stats_DumpInputStats; \
((p_symbols)->stats_ReinitInputStats_inner) = stats_ReinitInputStats; \
(p_symbols)->net_ConvertIPv4_deprecated = NULL; \
# endif
/* __PLUGIN__ */
...
...
src/input/input.c
View file @
e56193e8
...
...
@@ -150,6 +150,8 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
p_input
->
input
.
b_eof
=
VLC_FALSE
;
p_input
->
input
.
i_cr_average
=
0
;
stats_ReinitInputStats
(
p_item
->
p_stats
);
/* No slave */
p_input
->
i_slave
=
0
;
p_input
->
slave
=
NULL
;
...
...
@@ -673,8 +675,9 @@ static int Init( input_thread_t * p_input, vlc_bool_t b_quick )
if
(
!
b_quick
)
{
stats_Create
(
p_input
,
"read_bytes"
,
VLC_VAR_INTEGER
,
STATS_COUNTER
);
stats_Create
(
p_input
,
"read_packets"
,
VLC_VAR_INTEGER
,
STATS_COUNTER
);
stats_Create
(
p_input
,
"input_bitrate"
,
VLC_VAR_FLOAT
,
STATS_DERIVATIVE
);
STATS_DERIVATIVE
);
psz
=
var_GetString
(
p_input
,
"sout"
);
if
(
*
psz
&&
strncasecmp
(
p_input
->
input
.
p_item
->
psz_uri
,
"vlc:"
,
4
)
)
{
...
...
src/input/stream.c
View file @
e56193e8
...
...
@@ -1569,6 +1569,9 @@ static int AReadStream( stream_t *s, void *p_read, int i_read )
if
(
!
p_sys
->
i_list
)
{
i_read
=
p_access
->
pf_read
(
p_access
,
p_read
,
i_read
);
stats_UpdateInteger
(
s
->
p_parent
->
p_parent
,
"read_bytes"
,
i_read
);
stats_UpdateInteger
(
s
->
p_parent
->
p_parent
,
"input_bitrate"
,
i_read
);
stats_UpdateInteger
(
s
->
p_parent
->
p_parent
,
"read_packets"
,
1
);
return
i_read
;
}
...
...
@@ -1597,8 +1600,9 @@ static int AReadStream( stream_t *s, void *p_read, int i_read )
}
/* Update read bytes in input */
stats_UpdateInteger
(
s
->
p_parent
,
"read_bytes"
,
i_read
);
stats_UpdateInteger
(
s
->
p_parent
->
p_parent
,
"read_bytes"
,
i_read
);
stats_UpdateInteger
(
s
->
p_parent
->
p_parent
,
"input_bitrate"
,
i_read
);
stats_UpdateInteger
(
s
->
p_parent
->
p_parent
,
"read_packets"
,
1
);
return
i_read
;
}
...
...
src/misc/stats.c
View file @
e56193e8
...
...
@@ -27,6 +27,7 @@
#include <stdio.h>
/* required */
#include <vlc/vlc.h>
#include <vlc_input.h>
/*****************************************************************************
* Local prototypes
...
...
@@ -48,6 +49,9 @@ int __stats_Create( vlc_object_t *p_this, char *psz_name, int i_type,
{
counter_t
*
p_counter
;
stats_handler_t
*
p_handler
=
stats_HandlerGet
(
p_this
);
if
(
!
p_handler
)
return
VLC_ENOMEM
;
vlc_mutex_lock
(
&
p_handler
->
object_lock
);
p_counter
=
(
counter_t
*
)
malloc
(
sizeof
(
counter_t
)
)
;
...
...
@@ -63,6 +67,8 @@ int __stats_Create( vlc_object_t *p_this, char *psz_name, int i_type,
p_handler
->
i_counters
,
p_counter
);
vlc_mutex_unlock
(
&
p_handler
->
object_lock
);
return
VLC_SUCCESS
;
}
...
...
@@ -70,24 +76,106 @@ int __stats_Create( vlc_object_t *p_this, char *psz_name, int i_type,
int
__stats_Update
(
vlc_object_t
*
p_this
,
char
*
psz_name
,
vlc_value_t
val
)
{
int
i_ret
;
counter_t
*
p_counter
;
/* Get stats handler singleton */
stats_handler_t
*
p_handler
=
stats_HandlerGet
(
p_this
);
if
(
!
p_handler
)
return
VLC_ENOMEM
;
vlc_mutex_lock
(
&
p_handler
->
object_lock
);
/* Look for existing element */
p_counter
=
stats_GetCounter
(
p_handler
,
p_this
->
i_object_id
,
psz_name
);
if
(
!
p_counter
)
{
vlc_mutex_unlock
(
&
p_handler
->
object_lock
);
vlc_object_release
(
p_handler
);
return
VLC_ENOOBJ
;
}
return
stats_CounterUpdate
(
p_handler
,
p_counter
,
val
);
i_ret
=
stats_CounterUpdate
(
p_handler
,
p_counter
,
val
);
vlc_mutex_unlock
(
&
p_handler
->
object_lock
);
return
i_ret
;
}
int
__stats_Get
(
vlc_object_t
*
p_this
,
int
i_object_id
,
char
*
psz_name
,
vlc_value_t
*
val
)
{
counter_t
*
p_counter
;
/* Get stats handler singleton */
stats_handler_t
*
p_handler
=
stats_HandlerGet
(
p_this
);
if
(
!
p_handler
)
return
VLC_ENOMEM
;
vlc_mutex_lock
(
&
p_handler
->
object_lock
);
/* Look for existing element */
p_counter
=
stats_GetCounter
(
p_handler
,
i_object_id
,
psz_name
);
if
(
!
p_counter
)
{
vlc_mutex_unlock
(
&
p_handler
->
object_lock
);
vlc_object_release
(
p_handler
);
return
VLC_ENOOBJ
;
}
if
(
p_counter
->
i_samples
==
0
)
{
vlc_mutex_unlock
(
&
p_handler
->
object_lock
);
return
VLC_EGENERIC
;
}
/* FIXME: Does not work for all types, maybe */
*
val
=
p_counter
->
pp_samples
[
0
]
->
value
;
vlc_object_release
(
p_handler
);
vlc_mutex_unlock
(
&
p_handler
->
object_lock
);
return
VLC_SUCCESS
;;
}
void
stats_ComputeInputStats
(
input_thread_t
*
p_input
,
input_stats_t
*
p_stats
)
{
vlc_mutex_lock
(
&
p_stats
->
lock
);
/* read_packets and read_bytes are common to all streams */
stats_GetInteger
(
p_input
,
p_input
->
i_object_id
,
"read_packets"
,
&
p_stats
->
i_read_packets
);
stats_GetInteger
(
p_input
,
p_input
->
i_object_id
,
"read_bytes"
,
&
p_stats
->
i_read_bytes
);
vlc_mutex_unlock
(
&
p_stats
->
lock
);
}
void
stats_ReinitInputStats
(
input_stats_t
*
p_stats
)
{
p_stats
->
i_read_packets
=
p_stats
->
i_read_bytes
=
p_stats
->
f_last_bitrate
=
p_stats
->
f_average_bitrate
=
p_stats
->
i_displayed_pictures
=
p_stats
->
i_lost_pictures
=
0
;
}
void
stats_DumpInputStats
(
input_stats_t
*
p_stats
)
{
vlc_mutex_lock
(
&
p_stats
->
lock
);
fprintf
(
stderr
,
"Read packets : %i (%i bytes)
\n
"
,
p_stats
->
i_read_packets
,
p_stats
->
i_read_bytes
);
vlc_mutex_unlock
(
&
p_stats
->
lock
);
}
/********************************************************************
* Following functions are local
********************************************************************/
/**
* Update a statistics counter, according to its type
* If needed, perform a bit of computation (derivative, mostly)
* This function must be entered with stats handler lock
* \param p_handler stats handler singleton
* \param p_counter the counter to update
* \param val the "new" value
* \return an error code
*/
static
int
stats_CounterUpdate
(
stats_handler_t
*
p_handler
,
counter_t
*
p_counter
,
vlc_value_t
val
)
...
...
@@ -244,12 +332,3 @@ static stats_handler_t* stats_HandlerCreate( vlc_object_t *p_this )
}
void
stats_ComputeInputStats
(
input_thread_t
*
p_input
,
input_stats_t
*
p_stats
)
{
int
i
;
/* read_packets and read_bytes are common to all streams */
//p_stats->i_read_packets = stats_GetInteger( p_input, "read_packets" );
// p_stats->i_read_bytes = stats_GetInteger( p_input, "read_bytes" );
}
src/playlist/item.c
View file @
e56193e8
...
...
@@ -63,6 +63,8 @@ playlist_item_t * playlist_ItemNewWithType( vlc_object_t *p_obj,
memset
(
p_item
,
0
,
sizeof
(
playlist_item_t
)
);
vlc_input_item_Init
(
p_obj
,
&
p_item
->
input
);
p_item
->
input
.
psz_uri
=
strdup
(
psz_uri
);
if
(
psz_name
!=
NULL
)
p_item
->
input
.
psz_name
=
strdup
(
psz_name
);
...
...
src/playlist/playlist.c
View file @
e56193e8
...
...
@@ -618,6 +618,9 @@ static void RunThread ( playlist_t *p_playlist )
/* If there is an input, check that it doesn't need to die. */
if
(
p_playlist
->
p_input
)
{
stats_ComputeInputStats
(
p_playlist
->
p_input
,
p_playlist
->
p_input
->
input
.
p_item
->
p_stats
);
/* This input is dead. Remove it ! */
if
(
p_playlist
->
p_input
->
b_dead
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment