diff options
author | Frank Enderle <frank.enderle@anamica.de> | 2010-04-11 13:03:25 +0200 |
---|---|---|
committer | Frank Enderle <frank.enderle@anamica.de> | 2010-04-11 13:03:25 +0200 |
commit | 289b5e385d114d002654ee3188bcfb43deb26aee (patch) | |
tree | 56b155ec42ea50d00b9a99b9e837940f6dc647e7 | |
parent | 2bdbfec226e39c0875f9771ffb6a33732f9ed7af (diff) | |
download | xine-lib-289b5e385d114d002654ee3188bcfb43deb26aee.tar.gz xine-lib-289b5e385d114d002654ee3188bcfb43deb26aee.tar.bz2 |
Report NBC buffer stats to the application using new event XINE_EVENT_NBC_STATS
This event reports the buffer status for network streams (NBC) back to the
application, providing a way to measure if the stream delivers data fast
enough. This enables the application to slow down the stream playback to
get the buffers filling more quickly. (This is only a sample application of
the event.)
The event reports all vital data like fill percentage, remaining buffer in
seconds and discontinuity, separately for audio and video, whether the nbc
layer is actually buffering, the operation type (put or get) and also if the
buffering is enabled at all.
In essence, it's the output you get from nbc if you run xine-lib in
verbose mode on the console, but in raw data.
-rw-r--r-- | include/xine.h.in | 18 | ||||
-rw-r--r-- | src/input/net_buf_ctrl.c | 28 |
2 files changed, 45 insertions, 1 deletions
diff --git a/include/xine.h.in b/include/xine.h.in index a8d8ddd5b..9cde0593e 100644 --- a/include/xine.h.in +++ b/include/xine.h.in @@ -1721,6 +1721,7 @@ void xine_config_reset (xine_t *self) XINE_PROTECTED; #define XINE_EVENT_DROPPED_FRAMES 12 /* number of dropped frames is too high */ #define XINE_EVENT_MRL_REFERENCE_EXT 13 /* demuxer->frontend: MRL reference(s) for the real stream */ #define XINE_EVENT_AUDIO_AMP_LEVEL 14 /* report current audio amp level (l/r/mute) */ +#define XINE_EVENT_NBC_STATS 15 /* nbc buffer status */ /* input events coming from frontend */ @@ -1905,6 +1906,23 @@ typedef struct { } xine_progress_data_t; /* + * nbc buffer status + */ +typedef struct { + int v_percent; /* fill of video buffer */ + int64_t v_remaining; /* remaining time in ms till underrun */ + int64_t v_bitrate; /* current bitrate */ + int v_in_disc; /* in discontinuity */ + int a_percent; /* like video, but for audio */ + int64_t a_remaining; + int64_t a_bitrate; + int a_in_disc; + int buffering; /* currently filling buffer */ + int enabled; /* buffer disabled by engine */ + int type; /* 0=buffer put, 1=buffer get */ +} xine_nbc_stats_data_t; + +/* * mrl reference data is sent by demuxers when a reference stream is found. * this stream just contains pointers (urls) to the real data, which are * passed to frontend using this event type. (examples: .asx, .mov and .ram) diff --git a/src/input/net_buf_ctrl.c b/src/input/net_buf_ctrl.c index e8af1ae3f..ba17423fb 100644 --- a/src/input/net_buf_ctrl.c +++ b/src/input/net_buf_ctrl.c @@ -96,7 +96,6 @@ static void report_progress (xine_stream_t *stream, int p) { xine_event_send (stream, &event); } - static void nbc_set_speed_pause (nbc_t *this) { xine_stream_t *stream = this->stream; @@ -138,6 +137,29 @@ static void display_stats (nbc_t *this) { fflush(stdout); } +static void report_stats (nbc_t *this, int type) { + xine_event_t event; + xine_nbc_stats_data_t bs; + + bs.v_percent = this->video_fifo_fill; + bs.v_remaining = this->video_fifo_length; + bs.v_bitrate = this->video_br; + bs.v_in_disc = this->video_in_disc; + bs.a_percent = this->audio_fifo_fill; + bs.a_remaining = this->audio_fifo_length; + bs.a_bitrate = this->audio_br; + bs.a_in_disc = this->audio_in_disc; + bs.buffering = this->buffering; + bs.enabled = this->enabled; + bs.type = type; + + event.type = XINE_EVENT_NBC_STATS; + event.data = &bs; + event.data_length = sizeof (xine_nbc_stats_data_t); + + xine_event_send (this->stream, &event); +} + /* Try to compute the length of the fifo in 1/1000 s * 2 methods : * if the bitrate is known @@ -347,6 +369,8 @@ static void nbc_put_cb (fifo_buffer_t *fifo, } if(this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG) display_stats(this); + + report_stats(this, 0); } } else { @@ -466,6 +490,8 @@ static void nbc_get_cb (fifo_buffer_t *fifo, if(this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG) display_stats(this); + + report_stats(this, 1); } } else { /* discontinuity management */ |