#include "gtk/rtp_player.h"
#include "gtk/stock_icons.h"
-#ifndef min
-#define min(a,b) (((a)<(b))?(a):(b))
-#endif
-#ifndef max
-#define max(a,b) (((a)>(b))?(a):(b))
-#endif
+#include "gtk/old-gtk-compat.h"
/*define this symbol to compile with G729 and G723 codecs*/
/*#define HAVE_G729_G723 1*/
static gboolean initialized = FALSE;
-voip_calls_tapinfo_t *voip_calls = NULL;
+static voip_calls_tapinfo_t *voip_calls = NULL;
/* Hash table with all the RTP streams */
static GHashTable* rtp_streams_hash = NULL;
static GtkWidget *main_scrolled_window = NULL;
static GtkWidget *jitter_spinner;
static GtkWidget *cb_use_rtp_timestamp;
+static GtkWidget *cb_view_as_time_of_day;
static GtkWidget *bt_decode;
static GtkWidget *bt_play;
static GtkWidget *bt_pause;
#define S_DROP_BY_JITT 1
#define S_WRONG_SEQ 2
#define S_WRONG_TIMESTAMP 3 /* The timestamp does not reflect the number of samples - samples have been dropped or silence inserted to match timestamp */
+#define S_SILENCE 4 /* Silence inserted by Wireshark, rather than contained in a packet */
/* Display channels constants */
#define MULT 80
#define MAX_NUM_COL_CONV 10
#if PORTAUDIO_API_1
-PortAudioStream *pa_stream;
+static PortAudioStream *pa_stream;
#else /* PORTAUDIO_API_1 */
-PaStream *pa_stream;
+static PaStream *pa_stream;
#endif /* PORTAUDIO_API_1 */
/* defines a RTP stream */
guint32 ssrc;
guint32 first_frame_number; /* first RTP frame for the stream */
double start_time; /* RTP stream start time in ms */
+ nstime_t start_time_abs;
gboolean play;
guint16 call_num;
GList* rtp_packets_list; /* List of RTP packets in the stream */
/* defines the RTP streams to be played in an audio channel */
typedef struct _rtp_channel_info {
double start_time; /* RTP stream start time in ms */
+ nstime_t start_time_abs;
double end_time; /* RTP stream end time in ms */
GArray *samples; /* the array with decoded audio */
guint16 call_num;
#else /* PORTAUDIO_API_1 */
PaTime cursor_prev;
#endif /* PORTAUDIO_API_1 */
- GdkGC *bg_gc[MAX_NUM_COL_CONV+1];
+ GdkColor bg_color[MAX_NUM_COL_CONV+1];
gboolean cursor_catch;
rtp_stream_info_t *first_stream; /* This is the first RTP stream in the channel */
guint32 num_packets;
/****************************************************************************/
-static void
+static void
rtp_key_destroy(gpointer key)
{
g_free(key);
}
/****************************************************************************/
-static void
+static void
rtp_channel_value_destroy(gpointer rci_arg)
{
rtp_channel_info_t *rci = rci_arg;
}
/****************************************************************************/
-static void
+static void
rtp_stream_value_destroy(gpointer rsi_arg)
{
rtp_stream_info_t *rsi = rsi_arg;
g_free(rp->payload_data);
g_free(rp);
rp = NULL;
-
+
rtp_packets_list = g_list_next(rtp_packets_list);
}
g_free((void *)(rsi->src_addr.data));
}
/****************************************************************************/
-static void
+static void
rtp_decoder_value_destroy(gpointer dec_arg)
{
rtp_decoder_t *dec = dec_arg;
/****************************************************************************/
static void
-set_sensitive_check_bt(gchar *key _U_ , rtp_channel_info_t *rci, guint *stop _U_ )
+set_sensitive_check_bt(gchar *key _U_ , rtp_channel_info_t *rci, guint *stop _U_ )
{
- gtk_widget_set_sensitive(rci->check_bt, !(*stop));
+ gtk_widget_set_sensitive(rci->check_bt, !(*stop));
}
/****************************************************************************/
-static void
+static void
bt_state(gboolean decode, gboolean play, gboolean pause, gboolean stop)
{
gboolean new_jitter_value = FALSE;
gtk_widget_set_sensitive(bt_decode, decode);
gtk_widget_set_sensitive(cb_use_rtp_timestamp, decode);
- if (GTK_TOGGLE_BUTTON(cb_use_rtp_timestamp)->active) {
+ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cb_use_rtp_timestamp))) {
gtk_widget_set_sensitive(jitter_spinner, FALSE);
} else {
gtk_widget_set_sensitive(jitter_spinner, decode);
}
-
+
if (new_jitter_buff != (int) gtk_spin_button_get_value((GtkSpinButton * )jitter_spinner)) {
new_jitter_value = TRUE;
}
/* set the sensitive state of play only if there is a channel selected */
- if ( play && (rtp_channels->rci[0] || rtp_channels->rci[1]) && !new_jitter_value) {
+ if ( play && (rtp_channels->rci[0] || rtp_channels->rci[1]) && !new_jitter_value) {
gtk_widget_set_sensitive(bt_play, TRUE);
} else {
gtk_widget_set_sensitive(bt_play, FALSE);
}
-
+
if (!new_jitter_value) {
gtk_widget_set_sensitive(bt_pause, pause);
gtk_widget_set_sensitive(bt_stop, stop);
/* Set sensitive to the check buttons based on the STOP state */
if (rtp_channels_hash)
- g_hash_table_foreach( rtp_channels_hash, (GHFunc)set_sensitive_check_bt, &stop);
+ g_hash_table_foreach( rtp_channels_hash, (GHFunc)set_sensitive_check_bt, &stop);
} else {
gtk_widget_set_sensitive(bt_pause, FALSE);
gtk_widget_set_sensitive(bt_stop, FALSE);
if (rtp_channels_hash)
- g_hash_table_foreach( rtp_channels_hash, (GHFunc)set_sensitive_check_bt, &false_val);
+ g_hash_table_foreach( rtp_channels_hash, (GHFunc)set_sensitive_check_bt, &false_val);
}
}
/****************************************************************************/
-void
+void
add_rtp_packet(const struct _rtp_info *rtp_info, packet_info *pinfo)
{
rtp_stream_info_t *stream_info = NULL;
stream_info->rtp_packets_list = NULL;
stream_info->first_frame_number = pinfo->fd->num;
stream_info->start_time = nstime_to_msec(&pinfo->fd->rel_ts);
+ stream_info->start_time_abs = pinfo->fd->abs_ts;
stream_info->call_num = 0;
stream_info->play = FALSE;
stream_info->num_packets = 0;
memcpy(new_rtp_packet->info, rtp_info, sizeof(struct _rtp_info));
new_rtp_packet->arrive_offset = nstime_to_msec(&pinfo->fd->rel_ts) - stream_info->start_time;
/* copy the RTP payload to the rtp_packet to be decoded later */
- if (rtp_info->info_payload_len) {
+ if (rtp_info->info_all_data_present && (rtp_info->info_payload_len != 0)) {
new_rtp_packet->payload_data = g_malloc(rtp_info->info_payload_len);
memcpy(new_rtp_packet->payload_data, &(rtp_info->info_data[rtp_info->info_payload_offset]), rtp_info->info_payload_len);
} else {
}
/****************************************************************************/
-/* Mark the RTP stream to be played. Use the voip_calls graph to see if the
+/* Mark the RTP stream to be played. Use the voip_calls graph to see if the
* setup_frame is there and then if the associated voip_call is selected.
*/
-static void
+static void
mark_rtp_stream_to_play(gchar *key _U_ , rtp_stream_info_t *rsi, gpointer ptr _U_)
{
GList* graph_list;
}
/****************************************************************************/
-/* Mark the ALL RTP stream to be played. This is called when calling the
+/* Mark the ALL RTP stream to be played. This is called when calling the
* RTP player from the "RTP Analysis" window
*/
-static void
+static void
mark_all_rtp_stream_to_play(gchar *key _U_ , rtp_stream_info_t *rsi, gpointer ptr _U_)
{
rsi->play = TRUE;
}
/****************************************************************************/
-/* Decode a RTP packet
+/* Decode a RTP packet
* Return the number of decoded bytes
*/
-static int
+static int
decode_rtp_packet(rtp_packet_t *rp, SAMPLE **out_buff, GHashTable *decoders_hash)
{
unsigned int payload_type;
decoder = g_malloc(sizeof(rtp_decoder_t));
decoder->handle = NULL;
decoder->context = NULL;
- p = match_strval(payload_type, rtp_payload_type_short_vals);
+ p = match_strval_ext(payload_type, &rtp_payload_type_short_vals_ext);
if (p) {
decoder->handle = find_codec(p);
if (decoder->handle)
tmp_buff = g_malloc(sizeof(SAMPLE) * rp->info->info_payload_len * 1);
decodeG711u(rp->payload_data, rp->info->info_payload_len,
tmp_buff, &decoded_bytes);
- break;
+ break;
case PT_PCMA: /* G.711 A-law */
tmp_buff = g_malloc(sizeof(SAMPLE) * rp->info->info_payload_len * 1);
decodeG711a(rp->payload_data, rp->info->info_payload_len,
tmp_buff, &decoded_bytes);
- break;
+ break;
#ifdef HAVE_G729_G723
case PT_G729: /* G.729 */
tmp_buff = g_malloc(sizeof(SAMPLE) * ((rp->info->info_payload_len + 8) / 10) * 80);
decodeG729(rp->payload_data, rp->info->info_payload_len,
tmp_buff, &decoded_bytes);
- break;
+ break;
case PT_G723: /* G.723 */
if (rp->info->info_payload_len%24 == 0) /* G723 High 6.4kbps */
- tmp_buff = g_malloc(sizeof(SAMPLE) * rp->info->info_payload_len * 10); /* G723 High 64kbps/6.4kbps = 10 */
+ tmp_buff = g_malloc(sizeof(SAMPLE) * rp->info->info_payload_len * 10); /* G723 High 64kbps/6.4kbps = 10 */
else if (rp->info->info_payload_len%20 == 0) /* G723 Low 5.3kbps */
- tmp_buff = g_malloc(sizeof(SAMPLE) * rp->info->info_payload_len * 13); /* G723 High 64kbps/5.3kbps = 13 */
+ tmp_buff = g_malloc(sizeof(SAMPLE) * rp->info->info_payload_len * 13); /* G723 High 64kbps/5.3kbps = 13 */
else {
return 0;
}
/****************************************************************************/
static void
-update_progress_bar(gfloat percentage)
+update_progress_bar(gfloat fraction)
{
if GTK_IS_PROGRESS_BAR(progress_bar)
- gtk_progress_bar_update(GTK_PROGRESS_BAR(progress_bar), percentage);
+ gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progress_bar), fraction);
/* Force gtk to redraw the window before starting decoding the packet */
while (gtk_events_pending())
/****************************************************************************/
/* Decode the RTP streams and add them to the RTP channels struct
*/
-static void
+static void
decode_rtp_stream(rtp_stream_info_t *rsi, gpointer ptr _U_)
{
GString *key_str = NULL;
double start_rtp_time = 0;
double diff;
double pack_period;
+#ifdef DEBUG /* ?? */
double total_time;
double total_time_prev;
+#endif
gint32 silence_frames;
int seq;
double delay;
double prev_diff;
+#ifdef DEBUG /* ?? */
double mean_delay;
double variation;
+#endif
int decoded_bytes;
int decoded_bytes_prev;
int jitter_buff;
sample_t silence;
sample_t sample;
guint8 status;
- guint32 start_timestamp;
+ guint32 start_timestamp;
GHashTable *decoders_hash = NULL;
guint32 progbar_nextstep;
silence.val = 0;
silence.status = S_NORMAL;
- /* skip it if we are not going to play it */
+ /* skip it if we are not going to play it */
if (rsi->play == FALSE) {
return;
}
rci = g_malloc(sizeof(rtp_channel_info_t));
rci->call_num = rsi->call_num;
rci->start_time = rsi->start_time;
- rci->end_time = rsi->start_time;
+ rci->start_time_abs = rsi->start_time_abs;
+ rci->end_time = rsi->start_time;
rci->selected = FALSE;
rci->frame_index = 0;
rci->drop_by_jitter_buff = 0;
arrive_time = start_time = 0;
arrive_time_prev = 0;
pack_period = 0;
+#ifdef DEBUG /* ?? */
total_time = 0;
total_time_prev = 0;
+#endif
seq = 0;
delay = 0;
prev_diff = 0;
+#ifdef DEBUG /* ?? */
mean_delay = 0;
variation = 0;
+#endif
start_timestamp = 0;
decoders_hash = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, rtp_decoder_value_destroy);
progbar_nextstep += progbar_quantum;
}
-
+
rp = rtp_packets_list->data;
if (first == TRUE) {
rtp_time = (double)(rp->info->info_timestamp-start_timestamp)/SAMPLE_RATE - start_rtp_time;
- if (GTK_TOGGLE_BUTTON(cb_use_rtp_timestamp)->active) {
+ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cb_use_rtp_timestamp))) {
arrive_time = rtp_time;
} else {
arrive_time = (double)rp->arrive_offset/1000 - start_time;
if (delay<0) delay = -delay;
if (diff<0) diff = -diff;
-
+
+#ifdef DEBUG
total_time = (double)rp->arrive_offset/1000;
-#if DEBUG
- printf("seq = %d arr = %f abs_diff = %f index = %d tim = %f ji=%d jb=%f\n",rp->info->info_seq_num,
+ printf("seq = %d arr = %f abs_diff = %f index = %d tim = %f ji=%d jb=%f\n",rp->info->info_seq_num,
total_time, diff, rci->samples->len, ((double)rci->samples->len/8000 - total_time)*1000, 0,
(mean_delay + 4*variation)*1000);
fflush(stdout);
#endif
- /* if the jitter buffer was exceeded */
+ /* if the jitter buffer was exceeded */
if ( diff*1000 > jitter_buff ) {
-#if DEBUG
+#ifdef DEBUG
printf("Packet drop by jitter buffer exceeded\n");
#endif
rci->drop_by_jitter_buff++;
/* if there was a silence period (more than two packetization period) resync the source */
if ( (rtp_time - rtp_time_prev) > pack_period*2 ){
-#if DEBUG
+#ifdef DEBUG
printf("Resync...\n");
#endif
-
silence_frames = (gint32)((arrive_time - arrive_time_prev)*SAMPLE_RATE - decoded_bytes_prev/2);
+
+ /* Fix for bug 4119/5902: don't insert too many silence frames.
+ * XXX - is there a better thing to do here?
+ */
+#define MAX_SILENCE_FRAMES 240000
+ if (silence_frames > MAX_SILENCE_FRAMES)
+ silence_frames = MAX_SILENCE_FRAMES;
+
for (i = 0; i< silence_frames; i++) {
silence.status = status;
g_array_append_val(rci->samples, silence);
rci->wrong_timestamp++;
status = S_WRONG_TIMESTAMP;
}
+
+ /* Fix for bug 4119/5902: don't insert too many silence frames.
+ * XXX - is there a better thing to do here?
+ */
+ if (silence_frames > MAX_SILENCE_FRAMES)
+ silence_frames = MAX_SILENCE_FRAMES;
+
for (i = 0; i< silence_frames; i++) {
silence.status = status;
g_array_append_val(rci->samples, silence);
g_array_append_val(rci->samples, sample);
status = S_NORMAL;
}
-
+
rtp_time_prev = rtp_time;
pack_period = (double)(decoded_bytes/2)/SAMPLE_RATE;
decoded_bytes_prev = decoded_bytes;
arrive_time_prev = arrive_time;
-
}
if (out_buff) {
}
/****************************************************************************/
-static gint
+static gint
h_scrollbar_changed(GtkWidget *widget _U_, gpointer user_data)
{
- rtp_channel_info_t *rci = (rtp_channel_info_t *)user_data;
+ rtp_channel_info_t *rci = user_data;
rci->cursor_catch = TRUE;
return TRUE;
}
/****************************************************************************/
static void
-stop_channels(void)
-{
+stop_channels(void)
+{
PaError err;
GtkWidget *dialog;
/* we should never be here if we are already in STOP */
- if(rtp_channels->stop){
- exit(10);
- }
+ g_assert(rtp_channels->stop == FALSE);
rtp_channels->stop = TRUE;
/* force a draw_cursor to stop it */
}
/****************************************************************************/
-/* Draw a cursor in a channel graph
+/* Draw a cursor in a channel graph
*/
-static void
+static void
draw_channel_cursor(rtp_channel_info_t *rci, guint32 start_index)
{
#if PORTAUDIO_API_1
- PaTimestamp index;
+ PaTimestamp idx;
#else /* PORTAUDIO_API_1 */
- PaTime index;
+ PaTime idx;
#endif /* PORTAUDIO_API_1 */
int i;
+ GtkAllocation widget_alloc;
+ cairo_t *cr;
if (!rci) return;
#if PORTAUDIO_API_1
- index = Pa_StreamTime( pa_stream ) - rtp_channels->pause_duration - rtp_channels->out_diff_time - start_index;
+ idx = Pa_StreamTime( pa_stream ) - rtp_channels->pause_duration - rtp_channels->out_diff_time - start_index;
#else /* PORTAUDIO_API_1 */
- index = ((guint32)(SAMPLE_RATE) * (Pa_GetStreamTime(pa_stream)-rtp_channels->pa_start_time))- rtp_channels->pause_duration - rtp_channels->out_diff_time - start_index;
+ idx = ((guint32)(SAMPLE_RATE) * (Pa_GetStreamTime(pa_stream)-rtp_channels->pa_start_time))- rtp_channels->pause_duration - rtp_channels->out_diff_time - start_index;
#endif /* PORTAUDIO_API_1 */
/* If we finished playing both channels, then stop them */
- if ( (rtp_channels && (!rtp_channels->stop) && (!rtp_channels->pause)) && (index > rtp_channels->max_frame_index) ) {
+ if ( (rtp_channels && (!rtp_channels->stop) && (!rtp_channels->pause)) && (idx > rtp_channels->max_frame_index) ) {
stop_channels();
return;
}
/* If only this channel finished, then return */
- if (index > rci->max_frame_index) {
+ if (idx > rci->max_frame_index) {
return;
}
+ gtk_widget_get_allocation(rci->draw_area, &widget_alloc);
/* draw the previous saved pixbuf line */
if (rci->cursor_pixbuf && (rci->cursor_prev>=0)) {
- gdk_draw_pixbuf(rci->pixmap, NULL, rci->cursor_pixbuf, 0, 0, (int) (rci->cursor_prev/MULT), 0, -1, -1, GDK_RGB_DITHER_NONE, 0 ,0);
+ cr = gdk_cairo_create (rci->pixmap);
+ gdk_cairo_set_source_pixbuf (cr, rci->cursor_pixbuf, 0, 0);
+ cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REPEAT);
+ cairo_rectangle (cr, rci->cursor_prev/MULT, 0, -1, -1);
+ cairo_fill (cr);
- gdk_draw_drawable(rci->draw_area->window,
- rci->draw_area->style->fg_gc[GTK_WIDGET_STATE(rci->draw_area)],
- rci->pixmap,
- (int) (rci->cursor_prev/MULT), 0,
- (int) (rci->cursor_prev/MULT), 0,
- 1, rci->draw_area->allocation.height-HEIGHT_TIME_LABEL);
+ gdk_cairo_set_source_pixmap (cr, rci->pixmap,idx/MULT, 0);
+ cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REPEAT);
+ cairo_rectangle (cr, rci->cursor_prev/MULT, 0, 1, widget_alloc.height-HEIGHT_TIME_LABEL);
+ cairo_fill (cr);
+ cairo_destroy (cr);
g_object_unref(rci->cursor_pixbuf);
rci->cursor_pixbuf = NULL;
}
- if (index>0 && (rci->cursor_prev>=0)) {
- rci->cursor_pixbuf = gdk_pixbuf_get_from_drawable(NULL, rci->pixmap, NULL, (int) (index/MULT), 0, 0, 0, 1, rci->draw_area->allocation.height-HEIGHT_TIME_LABEL);
-
- gdk_draw_line(rci->pixmap, rci->draw_area->style->black_gc,
- (int) (index/MULT),
- 0,
- (int) (index/MULT),
- rci->draw_area->allocation.height-HEIGHT_TIME_LABEL);
-
- gdk_draw_drawable(rci->draw_area->window,
- rci->draw_area->style->fg_gc[GTK_WIDGET_STATE(rci->draw_area)],
- rci->pixmap,
- (int) (index/MULT), 0,
- (int) (index/MULT), 0,
- 1, rci->draw_area->allocation.height-HEIGHT_TIME_LABEL);
+ if (idx>0 && (rci->cursor_prev>=0)) {
+ rci->cursor_pixbuf = gdk_pixbuf_get_from_drawable(NULL, rci->pixmap, NULL, (int) (idx/MULT), 0, 0, 0, 1, widget_alloc.height-HEIGHT_TIME_LABEL);
+
+ cr = gdk_cairo_create (rci->pixmap);
+ cairo_set_line_width (cr, 1.0);
+ cairo_move_to(cr, idx/MULT, 0);
+ cairo_line_to(cr, idx/MULT, widget_alloc.height-HEIGHT_TIME_LABEL);
+ cairo_stroke(cr);
+ cairo_destroy(cr);
+
+ cr = gdk_cairo_create (gtk_widget_get_window(rci->draw_area));
+ gdk_cairo_set_source_pixmap (cr, rci->pixmap,idx/MULT, 0);
+ cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REPEAT);
+ cairo_rectangle (cr, idx/MULT, 0, 1, widget_alloc.height-HEIGHT_TIME_LABEL);
+ cairo_fill (cr);
+ cairo_destroy (cr);
}
/* Disconnect the scroll bar "value" signal to not be called */
/* Move the horizontal scroll bar */
#if 0
if ( (rci->cursor_prev/MULT < (rci->h_scrollbar_adjustment->value+rci->h_scrollbar_adjustment->page_increment)) &&
- (index/MULT >= (rci->h_scrollbar_adjustment->value+rci->h_scrollbar_adjustment->page_increment)) ){
+ (idx/MULT >= (rci->h_scrollbar_adjustment->value+rci->h_scrollbar_adjustment->page_increment)) ){
for (i=1; i<10; i++) {
rci->h_scrollbar_adjustment->value += rci->h_scrollbar_adjustment->page_size/10;
gtk_adjustment_value_changed(rci->h_scrollbar_adjustment);
}
#endif
if (!rci->cursor_catch) {
- if (index/MULT < rci->h_scrollbar_adjustment->page_size/2) {
- rci->h_scrollbar_adjustment->value = rci->h_scrollbar_adjustment->lower;
- } else if (index/MULT > (rci->h_scrollbar_adjustment->upper - rci->h_scrollbar_adjustment->page_size/2)) {
- rci->h_scrollbar_adjustment->value = rci->h_scrollbar_adjustment->upper - rci->h_scrollbar_adjustment->page_size;
+ if (idx/MULT < gtk_adjustment_get_page_size(rci->h_scrollbar_adjustment)/2) {
+ gtk_adjustment_set_value(rci->h_scrollbar_adjustment, gtk_adjustment_get_lower(rci->h_scrollbar_adjustment));
+ } else if (idx/MULT > (gtk_adjustment_get_upper(rci->h_scrollbar_adjustment) - gtk_adjustment_get_page_size(rci->h_scrollbar_adjustment)/2)) {
+ gtk_adjustment_set_value(rci->h_scrollbar_adjustment, gtk_adjustment_get_upper(rci->h_scrollbar_adjustment) - gtk_adjustment_get_page_size(rci->h_scrollbar_adjustment));
} else {
- rci->h_scrollbar_adjustment->value = index/MULT - rci->h_scrollbar_adjustment->page_size/2;
+ gtk_adjustment_set_value(rci->h_scrollbar_adjustment, idx/MULT - gtk_adjustment_get_page_size(rci->h_scrollbar_adjustment)/2);
}
gtk_adjustment_value_changed(rci->h_scrollbar_adjustment);
- } else if ( (rci->cursor_prev/MULT < (rci->h_scrollbar_adjustment->value+rci->h_scrollbar_adjustment->page_increment)) &&
- (index/MULT >= (rci->h_scrollbar_adjustment->value+rci->h_scrollbar_adjustment->page_increment)) ){
+ } else if ( (rci->cursor_prev/MULT < gtk_adjustment_get_value(rci->h_scrollbar_adjustment)+gtk_adjustment_get_page_increment(rci->h_scrollbar_adjustment)) &&
+ (idx/MULT >= gtk_adjustment_get_value(rci->h_scrollbar_adjustment) + gtk_adjustment_get_page_increment(rci->h_scrollbar_adjustment)) ){
rci->cursor_catch = FALSE;
for (i=1; i<10; i++) {
- rci->h_scrollbar_adjustment->value = min(rci->h_scrollbar_adjustment->upper-rci->h_scrollbar_adjustment->page_size, rci->h_scrollbar_adjustment->value + (rci->h_scrollbar_adjustment->page_size/20));
+ gtk_adjustment_set_value(rci->h_scrollbar_adjustment, MIN(gtk_adjustment_get_upper(rci->h_scrollbar_adjustment)-gtk_adjustment_get_page_size(rci->h_scrollbar_adjustment), gtk_adjustment_get_value(rci->h_scrollbar_adjustment) + gtk_adjustment_get_page_size(rci->h_scrollbar_adjustment)/20));
gtk_adjustment_value_changed(rci->h_scrollbar_adjustment);
}
-
}
-
/* Connect back the "value" scroll signal */
g_signal_connect(rci->h_scrollbar_adjustment, "value_changed", G_CALLBACK(h_scrollbar_changed), rci);
#if 0
- if (index/MULT < rci->h_scrollbar_adjustment->page_increment) {
+ if (idx/MULT < rci->h_scrollbar_adjustment->page_increment) {
rci->h_scrollbar_adjustment->value = rci->h_scrollbar_adjustment->lower;
- } else if (index/MULT > (rci->h_scrollbar_adjustment->upper - rci->h_scrollbar_adjustment->page_size + rci->h_scrollbar_adjustment->page_increment)) {
+ } else if (idx/MULT > (rci->h_scrollbar_adjustment->upper - rci->h_scrollbar_adjustment->page_size + rci->h_scrollbar_adjustment->page_increment)) {
rci->h_scrollbar_adjustment->value = rci->h_scrollbar_adjustment->upper - rci->h_scrollbar_adjustment->page_size;
} else {
- if ( (index/MULT < rci->h_scrollbar_adjustment->value) || (index/MULT > (rci->h_scrollbar_adjustment->value+rci->h_scrollbar_adjustment->page_increment)) ){
- rci->h_scrollbar_adjustment->value = index/MULT;
+ if ( (idx/MULT < rci->h_scrollbar_adjustment->value) || (idx/MULT > (rci->h_scrollbar_adjustment->value+rci->h_scrollbar_adjustment->page_increment)) ){
+ rci->h_scrollbar_adjustment->value = idx/MULT;
}
}
#endif
#if 0
- if (index/MULT < rci->h_scrollbar_adjustment->page_size/2) {
+ if (idx/MULT < rci->h_scrollbar_adjustment->page_size/2) {
rci->h_scrollbar_adjustment->value = rci->h_scrollbar_adjustment->lower;
- } else if (index/MULT > (rci->h_scrollbar_adjustment->upper - rci->h_scrollbar_adjustment->page_size/2)) {
+ } else if (idx/MULT > (rci->h_scrollbar_adjustment->upper - rci->h_scrollbar_adjustment->page_size/2)) {
rci->h_scrollbar_adjustment->value = rci->h_scrollbar_adjustment->upper - rci->h_scrollbar_adjustment->page_size;
} else {
- rci->h_scrollbar_adjustment->value = index/MULT - rci->h_scrollbar_adjustment->page_size/2;
+ rci->h_scrollbar_adjustment->value = idx/MULT - rci->h_scrollbar_adjustment->page_size/2;
}
#endif
#if 0
gtk_adjustment_value_changed(rci->h_scrollbar_adjustment);
#endif
- rci->cursor_prev = index;
+ rci->cursor_prev = idx;
}
/****************************************************************************/
-/* Move and draw the cursor in the graph
+/* Move and draw the cursor in the graph
*/
-static gboolean
+static gboolean
draw_cursors(gpointer data _U_)
{
if (!rtp_channels) return FALSE;
init_rtp_channels_vals(void)
{
rtp_play_channels_t *rpci = rtp_channels;
-
+
/* if we only have one channel to play, we just use the info from that channel */
if (rpci->rci[0] == NULL) {
rpci->max_frame_index = rpci->rci[1]->max_frame_index;
/* if the two channels are to be played, then we need to sync both based on the start/end time of each one */
} else {
- rpci->max_frame_index = (guint32)(SAMPLE_RATE/1000) * (guint32)(max(rpci->rci[0]->end_time, rpci->rci[1]->end_time) -
- (guint32)min(rpci->rci[0]->start_time, rpci->rci[1]->start_time));
+ rpci->max_frame_index = (guint32)(SAMPLE_RATE/1000) * (guint32)(MAX(rpci->rci[0]->end_time, rpci->rci[1]->end_time) -
+ (guint32)MIN(rpci->rci[0]->start_time, rpci->rci[1]->start_time));
if (rpci->rci[0]->start_time < rpci->rci[1]->start_time) {
rpci->start_index[0] = 0;
} else {
rpci->start_index[1] = 0;
rpci->start_index[0] = (guint32)(SAMPLE_RATE/1000) * (guint32)(rpci->rci[0]->start_time - rpci->rci[1]->start_time);
- }
+ }
if (rpci->rci[0]->end_time < rpci->rci[1]->end_time) {
rpci->end_index[0] = rpci->max_frame_index - ((guint32)(SAMPLE_RATE/1000) * (guint32)(rpci->rci[1]->end_time - rpci->rci[0]->end_time));
} else {
rpci->end_index[1] = rpci->max_frame_index - ((guint32)(SAMPLE_RATE/1000) * (guint32)(rpci->rci[0]->end_time - rpci->rci[1]->end_time));
rpci->end_index[0] = rpci->max_frame_index;
- }
+ }
}
}
#if PORTAUDIO_API_1
static int paCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData)
+ unsigned long framesPerBuffer,
+ PaTimestamp outTime, void *userData)
{
#else /* PORTAUDIO_API_1 */
static int paCallback( const void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- const PaStreamCallbackTimeInfo* outTime,
- PaStreamCallbackFlags statusFlags _U_,
- void *userData)
+ unsigned long framesPerBuffer,
+ const PaStreamCallbackTimeInfo* outTime,
+ PaStreamCallbackFlags statusFlags _U_,
+ void *userData)
{
#endif /* PORTAUDIO_API_1 */
rtp_play_channels_t *rpci = (rtp_play_channels_t *)userData;
#if PORTAUDIO_API_1
rpci->out_diff_time = outTime - Pa_StreamTime(pa_stream) ;
#else /* PORTAUDIO_API_1 */
- rpci->out_diff_time = (guint32)(SAMPLE_RATE) * (outTime->outputBufferDacTime - Pa_GetStreamTime(pa_stream)) ;
+ rpci->out_diff_time = (guint32)(SAMPLE_RATE) * (outTime->outputBufferDacTime - Pa_GetStreamTime(pa_stream)) ;
#endif /* PORTAUDIO_API_1 */
}
/****************************************************************************/
-static void
-on_bt_check_clicked(GtkButton *button _U_, gpointer user_data _U_)
+static void
+on_bt_check_clicked(GtkButton *button _U_, gpointer user_data)
{
rtp_channel_info_t *rci = user_data;
int progbar_quantum;
gfloat progbar_val;
guint status;
- GdkGC *gc;
- GdkGC *red_gc;
- GdkGC *amber_gc;
GdkColor red_color = {0, 65535, 0, 0};
GdkColor amber_color = {0, 65535, 49152, 0};
-
+ GdkColor white_color = {0, 65535, 65535, 65535};
+ GdkColor black_color = {0, 0, 0, 0};
+
+ GdkColor *draw_color_p;
+ time_t seconds;
+ struct tm *timestamp;
+ GtkAllocation widget_alloc;
+ cairo_t *cr;
+
if (GDK_IS_DRAWABLE(rci->pixmap)) {
+ gtk_widget_get_allocation(rci->draw_area, &widget_alloc);
/* Clear out old plot */
- gdk_draw_rectangle(rci->pixmap,
- rci->bg_gc[1+rci->call_num%MAX_NUM_COL_CONV],
- TRUE,
- 0, 0,
- rci->draw_area->allocation.width,
- rci->draw_area->allocation.height);
+ cr = gdk_cairo_create (rci->pixmap);
+ gdk_cairo_set_source_color (cr, &rci->bg_color[1+rci->call_num%MAX_NUM_COL_CONV]);
+ cairo_rectangle (cr, 0, 0, widget_alloc.width,widget_alloc.height);
+ cairo_fill (cr);
+ cairo_destroy (cr);
+ cr = NULL;
small_layout = gtk_widget_create_pango_layout(rci->draw_area, NULL);
pango_layout_set_font_description(small_layout, pango_font_description_from_string("Helvetica,Sans,Bold 7"));
/* calculated the pixel offset to display integer seconds */
offset = ((double)rci->start_time/1000 - floor((double)rci->start_time/1000))*SAMPLE_RATE/MULT;
- gdk_draw_line(rci->pixmap, rci->draw_area->style->black_gc,
- 0,
- rci->draw_area->allocation.height-HEIGHT_TIME_LABEL,
- rci->draw_area->allocation.width,
- rci->draw_area->allocation.height-HEIGHT_TIME_LABEL);
+ cr = gdk_cairo_create (rci->pixmap);
+ cairo_set_line_width (cr, 1.0);
+ cairo_move_to(cr, 0, widget_alloc.height-HEIGHT_TIME_LABEL+0.5);
+ cairo_line_to(cr, widget_alloc.width, widget_alloc.height-HEIGHT_TIME_LABEL+0.5);
+ cairo_stroke(cr);
+ cairo_destroy(cr);
+ cr = NULL;
- imax = min(rci->draw_area->allocation.width,(gint)(rci->samples->len/MULT));
+ imax = MIN(widget_alloc.width,(gint)(rci->samples->len/MULT));
/* we update the progress bar 100 times */
bump that value by this amount. */
progbar_quantum = imax/100;
- red_gc = gdk_gc_new(rci->draw_area->window);
- gdk_gc_set_rgb_fg_color(red_gc, &red_color);
- amber_gc = gdk_gc_new(rci->draw_area->window);
- gdk_gc_set_rgb_fg_color(amber_gc, &amber_color);
-
for (i=0; i< imax; i++) {
sample.val = 0;
status = S_NORMAL;
for (j=0; j<MULT; j++) {
sample = g_array_index(rci->samples, sample_t, i*MULT+j);
- max = max(max, sample.val);
- min = min(min, sample.val);
+ max = MAX(max, sample.val);
+ min = MIN(min, sample.val);
if (sample.status == S_DROP_BY_JITT) status = S_DROP_BY_JITT;
if (sample.status == S_WRONG_TIMESTAMP) status = S_WRONG_TIMESTAMP;
+ if (sample.status == S_SILENCE) status = S_SILENCE;
}
+ /* Set the line color, default is black */
if (status == S_DROP_BY_JITT) {
- gc = red_gc;
+ draw_color_p = &red_color;
} else if (status == S_WRONG_TIMESTAMP) {
- gc = amber_gc;
+ draw_color_p = &amber_color;
+ } else if (status == S_SILENCE) {
+ draw_color_p = &white_color;
} else {
- gc = rci->draw_area->style->black_gc;
+ draw_color_p = &black_color;
}
- gdk_draw_line(rci->pixmap, gc,
- i,
- (gint)(( (0x7FFF+min) * (rci->draw_area->allocation.height-HEIGHT_TIME_LABEL))/0xFFFF),
- i,
- (gint)(( (0x7FFF+max) * (rci->draw_area->allocation.height-HEIGHT_TIME_LABEL))/0xFFFF));
+ /* if silence added by Wireshark, graphically show it with letter to indicate why */
+ if ((status == S_DROP_BY_JITT) || (status == S_WRONG_TIMESTAMP) || (status == S_SILENCE)) {
+ cr = gdk_cairo_create (rci->pixmap);
+ cairo_set_line_width (cr, 1.0);
+ gdk_cairo_set_source_color (cr, draw_color_p);
+ cairo_move_to(cr, i+0.5, 0);
+ cairo_line_to(cr, i+0.5, (widget_alloc.height-HEIGHT_TIME_LABEL)-1);
+ cairo_stroke(cr);
+ cairo_destroy(cr);
+ cr=NULL;
+
+ if (status == S_DROP_BY_JITT) g_snprintf(label_string, MAX_TIME_LABEL,"D");
+ if (status == S_WRONG_TIMESTAMP) g_snprintf(label_string, MAX_TIME_LABEL, "W");
+ if (status == S_SILENCE) g_snprintf(label_string, MAX_TIME_LABEL, "S");
- /*draw the time label and grid */
- if ( !((i*MULT)%(SAMPLE_RATE)) ) {
- gdk_draw_line(rci->pixmap, rci->draw_area->style->black_gc,
- (int) (i - offset),
- rci->draw_area->allocation.height-HEIGHT_TIME_LABEL,
- (int) (i - offset),
- rci->draw_area->allocation.height-HEIGHT_TIME_LABEL+4);
+ pango_layout_set_text(small_layout, label_string, -1);
+ pango_layout_get_pixel_size(small_layout, &label_width, &label_height);
+ cr = gdk_cairo_create (rci->pixmap);
+ gdk_cairo_set_source_color (cr, draw_color_p);
+ cairo_move_to (cr, i, 0);
+ pango_cairo_show_layout (cr, small_layout);
+ cairo_destroy (cr);
+ cr = NULL;
+ } else {
+ /* Draw a graphical representation of the sample */
+ cr = gdk_cairo_create (rci->pixmap);
+ cairo_set_line_width (cr, 1.0);
+ gdk_cairo_set_source_color (cr, draw_color_p);
+ cairo_move_to(cr, i+0.5, ( (0x7FFF+min) * (widget_alloc.height-HEIGHT_TIME_LABEL))/0xFFFF);
+ cairo_line_to(cr, i+0.5, ( (0x7FFF+max) * (widget_alloc.height-HEIGHT_TIME_LABEL))/0xFFFF);
+ cairo_stroke(cr);
+ cairo_destroy(cr);
+ }
+
+ /* Draw the x-axis (seconds since beginning of packet flow for this call) */
- g_snprintf(label_string, MAX_TIME_LABEL, "%.0f", floor(rci->start_time/1000) + i*MULT/SAMPLE_RATE);
+ /* Draw tick mark and put a number for each whole second */
+ if ( !((i*MULT)%(SAMPLE_RATE)) ) {
+ cr = gdk_cairo_create (rci->pixmap);
+ cairo_set_line_width (cr, 1.0);
+ cairo_move_to(cr, i - offset+0.5, widget_alloc.height-HEIGHT_TIME_LABEL);
+ cairo_line_to(cr, i+0.5, widget_alloc.height-HEIGHT_TIME_LABEL+4);
+ cairo_stroke(cr);
+ cairo_destroy(cr);
+ cr=NULL;
+
+ if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cb_view_as_time_of_day))) {
+ seconds = rci->start_time_abs.secs + i * MULT / SAMPLE_RATE;
+ timestamp = localtime(&seconds);
+ g_snprintf(label_string, MAX_TIME_LABEL, "%02d:%02d:%02d", timestamp->tm_hour, timestamp->tm_min, timestamp->tm_sec);
+ } else {
+ g_snprintf(label_string, MAX_TIME_LABEL, "%.0f s", floor(rci->start_time/1000) + i*MULT/SAMPLE_RATE);
+ }
pango_layout_set_text(small_layout, label_string, -1);
pango_layout_get_pixel_size(small_layout, &label_width, &label_height);
- gdk_draw_layout(rci->pixmap,
- rci->draw_area->style->black_gc,
- (int) (i - offset - label_width/2),
- rci->draw_area->allocation.height - label_height,
- small_layout);
- /* draw the 1/2 sec grid */
- } else if ( !((i*MULT)%(SAMPLE_RATE/2)) ) {
- gdk_draw_line(rci->pixmap, rci->draw_area->style->black_gc,
- (int) (i - offset),
- rci->draw_area->allocation.height-HEIGHT_TIME_LABEL,
- (int) (i - offset),
- rci->draw_area->allocation.height-HEIGHT_TIME_LABEL+2);
+ cr = gdk_cairo_create (rci->pixmap);
+ cairo_move_to (cr, i - offset - label_width/2, widget_alloc.height - label_height);
+ pango_cairo_show_layout (cr, small_layout);
+ cairo_destroy (cr);
+ cr = NULL;
+
+ /* Draw only a tick mark for half second intervals */
+ } else if ( !((i*MULT)%(SAMPLE_RATE/2)) ) {
+ cr = gdk_cairo_create (rci->pixmap);
+ cairo_set_line_width (cr, 1.0);
+ cairo_move_to(cr,i - offset+0.5, widget_alloc.height-HEIGHT_TIME_LABEL);
+ cairo_line_to(cr, (i - offset)+0.5, widget_alloc.height-HEIGHT_TIME_LABEL+2);
+ cairo_stroke(cr);
+ cairo_destroy(cr);
+ cr=NULL;
}
progbar_count++;
}
+ g_object_unref(G_OBJECT(small_layout));
}
}
/****************************************************************************/
-static gint expose_event_channels(GtkWidget *widget, GdkEventExpose *event)
+static gboolean expose_event_channels(GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
{
- rtp_channel_info_t *rci;
-
- rci=(rtp_channel_info_t *)g_object_get_data(G_OBJECT(widget), "rtp_channel_info_t");
- if(!rci){
- exit(10);
+ rtp_channel_info_t *rci = user_data;
+ cairo_t *cr;
+
+ if (gtk_widget_is_drawable(widget)){
+ cr = gdk_cairo_create (gtk_widget_get_window(widget));
+ gdk_cairo_set_source_pixmap (cr, rci->pixmap, event->area.x, event->area.y);
+ cairo_rectangle (cr, event->area.x,event->area.y, event->area.width, event->area.height);
+ cairo_fill (cr);
+ cairo_destroy(cr);
+ cr = NULL;
}
- if (GDK_IS_DRAWABLE(widget->window))
- gdk_draw_drawable(widget->window,
- widget->style->fg_gc[GTK_WIDGET_STATE(widget)],
- rci->pixmap,
- event->area.x, event->area.y,
- event->area.x, event->area.y,
- event->area.width, event->area.height);
-
return FALSE;
}
/****************************************************************************/
-static gint
-configure_event_channels(GtkWidget *widget, GdkEventConfigure *event _U_)
+static gboolean
+configure_event_channels(GtkWidget *widget, GdkEventConfigure *event _U_, gpointer user_data)
{
- rtp_channel_info_t *rci;
+ rtp_channel_info_t *rci = user_data;
int i;
+ GtkAllocation widget_alloc;
+ cairo_t *cr;
/* the first color is blue to highlight the selected item
* the other collors are the same as in the Voip Graph analysys
- * to match the same calls
+ * to match the same calls
*/
- static GdkColor col[MAX_NUM_COL_CONV+1] = {
- {0, 0x00FF, 0x00FF, 0xFFFF},
- {0, 0x90FF, 0xEEFF, 0x90FF},
- {0, 0xFFFF, 0xA0FF, 0x7AFF},
- {0, 0xFFFF, 0xB6FF, 0xC1FF},
- {0, 0xFAFF, 0xFAFF, 0xD2FF},
- {0, 0xFFFF, 0xFFFF, 0x33FF},
- {0, 0x66FF, 0xCDFF, 0xAAFF},
- {0, 0xE0FF, 0xFFFF, 0xFFFF},
- {0, 0xB0FF, 0xC4FF, 0xDEFF},
- {0, 0x87FF, 0xCEFF, 0xFAFF},
- {0, 0xD3FF, 0xD3FF, 0xD3FF}
- };
-
- rci=(rtp_channel_info_t *)g_object_get_data(G_OBJECT(widget), "rtp_channel_info_t");
- if(!rci){
- exit(10);
- }
+ static GdkColor col[MAX_NUM_COL_CONV+1] = {
+ {0, 0x00FF, 0x00FF, 0xFFFF},
+ {0, 0x90FF, 0xEEFF, 0x90FF},
+ {0, 0xFFFF, 0xA0FF, 0x7AFF},
+ {0, 0xFFFF, 0xB6FF, 0xC1FF},
+ {0, 0xFAFF, 0xFAFF, 0xD2FF},
+ {0, 0xFFFF, 0xFFFF, 0x33FF},
+ {0, 0x66FF, 0xCDFF, 0xAAFF},
+ {0, 0xE0FF, 0xFFFF, 0xFFFF},
+ {0, 0xB0FF, 0xC4FF, 0xDEFF},
+ {0, 0x87FF, 0xCEFF, 0xFAFF},
+ {0, 0xD3FF, 0xD3FF, 0xD3FF}
+ };
if(rci->pixmap){
g_object_unref(rci->pixmap);
rci->pixmap=NULL;
}
- rci->pixmap = gdk_pixmap_new(widget->window,
- widget->allocation.width,
- widget->allocation.height,
+ gtk_widget_get_allocation(widget, &widget_alloc);
+ rci->pixmap = gdk_pixmap_new(gtk_widget_get_window(widget),
+ widget_alloc.width,
+ widget_alloc.height,
-1);
- if ( GDK_IS_DRAWABLE(rci->pixmap) )
- gdk_draw_rectangle(rci->pixmap,
- widget->style->white_gc,
- TRUE,
- 0, 0,
- widget->allocation.width,
- widget->allocation.height);
+ if ( GDK_IS_DRAWABLE(rci->pixmap) ){
+ cr = gdk_cairo_create (rci->pixmap);
+ cairo_set_source_rgb (cr, 1, 1, 1);
+ cairo_rectangle (cr, 0, 0, widget_alloc.width,widget_alloc.height);
+ cairo_fill (cr);
+ cairo_destroy (cr);
+ }
/* create gc's for the background color of each channel */
for (i=0; i<MAX_NUM_COL_CONV+1; i++){
- rci->bg_gc[i]=gdk_gc_new(rci->pixmap);
- gdk_gc_set_rgb_fg_color(rci->bg_gc[i], &col[i]);
+ rci->bg_color[i].pixel=col[i].pixel;
+ rci->bg_color[i].red=col[i].red;
+ rci->bg_color[i].green=col[i].green;
+ rci->bg_color[i].blue=col[i].blue;
+
}
channel_draw(rci);
}
/****************************************************************************/
-static gint
-button_press_event_channel(GtkWidget *widget, GdkEventButton *event _U_)
+static gboolean
+button_press_event_channel(GtkWidget *widget _U_, GdkEventButton *event _U_, gpointer user_data)
{
- rtp_channel_info_t *rci;
+ rtp_channel_info_t *rci = user_data;
int this_channel;
guint32 prev_index;
- rci=(rtp_channel_info_t *)g_object_get_data(G_OBJECT(widget), "rtp_channel_info_t");
- if(!rci){
- exit(10);
- }
-
if (!rci->selected) {
/* only select a new channels if we are in STOP */
rtp_channels->channel = !(rtp_channels->channel);
rci->selected = TRUE;
- /* set the sensitive state of the buttons (decode, play, pause, stop) */
+ /* set the sensitive state of the buttons (decode, play, pause, stop) */
bt_state(TRUE, TRUE, FALSE, FALSE);
}
}
rci->frame_index = (unsigned int) (event->x * MULT);
-
+
prev_index = rtp_channels->frame_index;
rtp_channels->frame_index = rtp_channels->start_index[this_channel] + rci->frame_index;
rtp_channels->pause_duration += prev_index - rtp_channels->frame_index;
/* create the channel draw area */
rci->draw_area=gtk_drawing_area_new();
-
+
rci->scroll_window=gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (rci->scroll_window), GTK_POLICY_ALWAYS, GTK_POLICY_NEVER);
rci->h_scrollbar_adjustment = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(rci->scroll_window));
-
+
gtk_widget_set_size_request(rci->draw_area, (gint)(rci->samples->len/MULT), CHANNEL_HEIGHT);
gtk_container_add(GTK_CONTAINER(viewport), rci->draw_area);
gtk_container_add(GTK_CONTAINER(rci->scroll_window), viewport);
gtk_viewport_set_shadow_type(GTK_VIEWPORT(viewport), GTK_SHADOW_NONE);
- g_object_set_data(G_OBJECT(rci->draw_area), "rtp_channel_info_t", rci);
gtk_widget_add_events (rci->draw_area, GDK_BUTTON_PRESS_MASK);
+#if GTK_CHECK_VERSION(2,18,0)
+ gtk_widget_set_can_focus(rci->draw_area, TRUE);
+#else
GTK_WIDGET_SET_FLAGS(rci->draw_area, GTK_CAN_FOCUS);
+#endif
gtk_widget_grab_focus(rci->draw_area);
gtk_box_pack_start(GTK_BOX (channels_vb), rci->scroll_window, FALSE, FALSE, 0);
/* signals needed to handle backing pixmap */
- g_signal_connect(rci->draw_area, "expose_event", G_CALLBACK(expose_event_channels), NULL);
+ g_signal_connect(rci->draw_area, "expose_event", G_CALLBACK(expose_event_channels), rci);
g_signal_connect(rci->draw_area, "configure_event", G_CALLBACK(configure_event_channels), rci);
gtk_widget_add_events (rci->draw_area, GDK_BUTTON_PRESS_MASK);
g_signal_connect(rci->draw_area, "button_press_event", G_CALLBACK(button_press_event_channel), rci);
label = g_string_new("");
- if (GTK_TOGGLE_BUTTON(cb_use_rtp_timestamp)->active) {
+ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cb_use_rtp_timestamp))) {
g_string_printf(label, "From %s:%d to %s:%d Duration:%.2f Out of Seq: %d(%.1f%%) Wrong Timestamp: %d(%.1f%%)",
get_addr_name(&(rci->first_stream->src_addr)), rci->first_stream->src_port,
get_addr_name(&(rci->first_stream->dest_addr)), rci->first_stream->dest_port,
rci->check_bt = gtk_check_button_new_with_label(label->str);
gtk_box_pack_start(GTK_BOX (channels_vb), rci->check_bt, FALSE, FALSE, 1);
-
+
/* Create the Separator if it is not the last one */
(*counter)++;
if (*counter < g_hash_table_size(rtp_channels_hash)) {
/****************************************************************************/
static void
-count_channel_frames(gchar *key _U_ , rtp_channel_info_t *rci, gpointer ptr _U_ )
+count_channel_frames(gchar *key _U_ , rtp_channel_info_t *rci, gpointer ptr _U_ )
{
total_frames += rci->samples->len;
}
/****************************************************************************/
static void
-play_channels(void)
-{
+play_channels(void)
+{
PaError err;
GtkWidget *dialog;
/* we should never be here if we are in PLAY and !PAUSE */
- if(!rtp_channels->stop && !rtp_channels->pause){
- exit(10);
- }
+ g_assert(!rtp_channels->stop && !rtp_channels->pause);
/* if we are in PAUSE change the state */
if (rtp_channels->pause) {
}
#else /* PORTAUDIO_API_1 */
if (Pa_GetDefaultOutputDevice() != paNoDevice) {
- err = Pa_OpenDefaultStream(
+ err = Pa_OpenDefaultStream(
&pa_stream,
0,
NUM_CHANNELS, /* Stereo output */
PaHostApiIndex host_api_index;
const PaHostApiInfo *host_api_info;
-
+
for (host_api_index=0; host_api_index<host_api_count; host_api_index++)
{
/* Skip the default host API, that didn't work before */
if (host_api_index == default_host_api_index)
continue;
-
+
/* If we find a host API with a device, then take it. */
host_api_info = Pa_GetHostApiInfo(host_api_index);
if (host_api_info->deviceCount > 0)
stream_parameters.sampleFormat = PA_SAMPLE_TYPE; /* 16 bit Integer output */
stream_parameters.suggestedLatency = 0;
stream_parameters.hostApiSpecificStreamInfo = NULL;
-#if DEBUG
+#ifdef DEBUG
g_print("Trying Host API: %s\n", host_api_info->name);
#endif
err = Pa_OpenStream(
/****************************************************************************/
static void
-pause_channels(void)
-{
+pause_channels(void)
+{
rtp_channels->pause = !(rtp_channels->pause);
/* reactivate the cusrosr display if no in pause */
g_timeout_add_full(G_PRIORITY_DEFAULT_IDLE, MULT*1000/SAMPLE_RATE, draw_cursors, NULL, NULL);
}
- /* set the sensitive state of the buttons (decode, play, pause, stop) */
+ /* set the sensitive state of the buttons (decode, play, pause, stop) */
bt_state(FALSE, TRUE, FALSE, TRUE);
}
/****************************************************************************/
-static void
+static void
reset_rtp_channels(void)
{
rtp_channels->channel = 0;
/****************************************************************************/
static void
-remove_channel_to_window(gchar *key _U_ , rtp_channel_info_t *rci, gpointer ptr _U_ )
+remove_channel_to_window(gchar *key _U_ , rtp_channel_info_t *rci, gpointer ptr _U_ )
{
g_object_unref(rci->pixmap);
gtk_widget_destroy(rci->draw_area);
/****************************************************************************/
static void
-decode_streams(void)
-{
+decode_streams(void)
+{
guint statusbar_context;
guint counter;
statusbar_context = gtk_statusbar_get_context_id((GtkStatusbar *) info_bar, "main");
gtk_statusbar_push((GtkStatusbar *) info_bar, statusbar_context, " Decoding RTP packets...");
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_window_set_has_resize_grip(GTK_WINDOW(info_bar), FALSE);
+#else
gtk_statusbar_set_has_resize_grip(GTK_STATUSBAR(info_bar), FALSE);
-
+#endif
/* reset the number of packet to be decoded, this is used for the progress bar */
total_packets = 0;
/* reset the Progress Bar count */
progbar_count = 0;
- /* Mark the RTP streams to be played using the selected VoipCalls. If voip_calls is NULL
- then this was called from "RTP Analysis" so mark all strams */
+ /* Mark the RTP streams to be played using the selected VoipCalls. If voip_calls is NULL
+ then this was called from "RTP Analysis" so mark all strams */
if (rtp_streams_hash) {
- if (voip_calls)
+ if (voip_calls)
g_hash_table_foreach( rtp_streams_hash, (GHFunc)mark_rtp_stream_to_play, NULL);
else
g_hash_table_foreach( rtp_streams_hash, (GHFunc)mark_all_rtp_stream_to_play, NULL);
total_frames = 0;
/* Count the frames in all the RTP channels */
if (rtp_channels_hash)
- g_hash_table_foreach( rtp_channels_hash, (GHFunc)count_channel_frames, NULL);
+ g_hash_table_foreach( rtp_channels_hash, (GHFunc)count_channel_frames, NULL);
/* reset the Progress Bar count again for the progress of creating the channels view */
progbar_count = 0;
/* Display the RTP channels in the window */
counter = 0;
if (rtp_channels_hash)
- g_hash_table_foreach( rtp_channels_hash, (GHFunc)add_channel_to_window, &counter);
+ g_hash_table_foreach( rtp_channels_hash, (GHFunc)add_channel_to_window, &counter);
/* Resize the main scroll window to display no more than preferred (or default) max channels, scroll bar will be used if needed */
- if (prefs.rtp_player_max_visible < 1 || prefs.rtp_player_max_visible > 10)
- prefs.rtp_player_max_visible = RTP_PLAYER_DEFAULT_VISIBLE;
+ if (prefs.rtp_player_max_visible < 1 || prefs.rtp_player_max_visible > 10)
+ prefs.rtp_player_max_visible = RTP_PLAYER_DEFAULT_VISIBLE;
- gtk_widget_set_size_request(main_scrolled_window, CHANNEL_WIDTH,
- min(counter, prefs.rtp_player_max_visible) * (CHANNEL_HEIGHT+60));
+ gtk_widget_set_size_request(main_scrolled_window, CHANNEL_WIDTH,
+ MIN(counter, prefs.rtp_player_max_visible) * (CHANNEL_HEIGHT+60));
gtk_widget_show_all(main_scrolled_window);
gtk_widget_destroy(progress_bar);
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_window_set_has_resize_grip(GTK_WINDOW(info_bar), TRUE);
+#else
gtk_statusbar_set_has_resize_grip(GTK_STATUSBAR(info_bar), TRUE);
+#endif
gtk_statusbar_pop((GtkStatusbar *) info_bar, statusbar_context);
/* blank the status label */
}
/****************************************************************************/
-static void
+static void
+on_cb_view_as_time_of_day_clicked(GtkButton *button _U_, gpointer user_data _U_)
+{
+ /* Decode the streams again as if the decode button was pushed to update the time display */
+ decode_streams();
+}
+
+/****************************************************************************/
+static void
on_cb_use_rtp_clicked(GtkToggleButton *button _U_, gpointer user_data _U_)
{
/* set the sensitive state of the buttons (decode, play, pause, stop) */
}
/****************************************************************************/
-static void
+static void
on_bt_decode_clicked(GtkButton *button _U_, gpointer user_data _U_)
{
decode_streams();
}
/****************************************************************************/
-static void
+static void
on_bt_play_clicked(GtkButton *button _U_, gpointer user_data _U_)
{
play_channels();
}
/****************************************************************************/
-static void
+static void
on_bt_pause_clicked(GtkButton *button _U_, gpointer user_data _U_)
{
pause_channels();
}
/****************************************************************************/
-static void
+static void
on_bt_stop_clicked(GtkButton *button _U_, gpointer user_data _U_)
{
stop_channels();
/****************************************************************************/
static void
-rtp_player_on_destroy(GtkObject *object _U_, gpointer user_data _U_)
+rtp_player_on_destroy(GObject *object _U_, gpointer user_data _U_)
{
PaError err;
GtkWidget *dialog;
{
GtkWidget *main_vb;
GtkWidget *hbuttonbox;
+ GtkWidget *timestamp_hb;
GtkWidget *h_jitter_buttons_box;
GtkWidget *bt_close;
GtkAdjustment *jitter_spinner_adj;
const gchar *title_name_ptr;
gchar *win_name;
- GtkTooltips *tooltips = gtk_tooltips_new();
-
title_name_ptr = cf_get_display_name(&cfile);
- win_name = g_strdup_printf("%s - VoIP - RTP Player", title_name_ptr);
+ win_name = g_strdup_printf("%s - VoIP - RTP Player", title_name_ptr);
rtp_player_dlg_w = dlg_window_new(win_name); /* transient_for top_level */
gtk_window_set_destroy_with_parent (GTK_WINDOW(rtp_player_dlg_w), TRUE);
main_vb = gtk_vbox_new (FALSE, 0);
gtk_container_add(GTK_CONTAINER(rtp_player_dlg_w), main_vb);
gtk_container_set_border_width (GTK_CONTAINER (main_vb), 2);
-
+
main_scrolled_window=gtk_scrolled_window_new(NULL, NULL);
gtk_container_set_border_width (GTK_CONTAINER (main_scrolled_window), 4);
gtk_widget_set_size_request(main_scrolled_window, CHANNEL_WIDTH, 0);
gtk_container_set_border_width (GTK_CONTAINER (channels_vb), 2);
gtk_scrolled_window_add_with_viewport((GtkScrolledWindow *) main_scrolled_window, channels_vb);
+ timestamp_hb = gtk_hbox_new(FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(main_vb), timestamp_hb, FALSE, FALSE, 0);
+ cb_view_as_time_of_day = gtk_check_button_new_with_label("View as time of day");
+ gtk_box_pack_start(GTK_BOX(timestamp_hb), cb_view_as_time_of_day, TRUE, FALSE, 0); /* Centered */
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cb_view_as_time_of_day), FALSE);
+ gtk_widget_set_tooltip_text(cb_view_as_time_of_day, "View the timestamps as time of day instead of seconds since beginning of capture");
+ g_signal_connect(cb_view_as_time_of_day, "toggled", G_CALLBACK(on_cb_view_as_time_of_day_clicked), NULL);
+
h_jitter_buttons_box = gtk_hbox_new (FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (h_jitter_buttons_box), 10);
gtk_box_pack_start (GTK_BOX(main_vb), h_jitter_buttons_box, FALSE, FALSE, 0);
label = gtk_label_new("Jitter buffer [ms] ");
gtk_box_pack_start(GTK_BOX(h_jitter_buttons_box), label, FALSE, FALSE, 0);
-
+
jitter_spinner_adj = (GtkAdjustment *) gtk_adjustment_new (50, 0, 500, 5, 10, 0);
jitter_spinner = gtk_spin_button_new (jitter_spinner_adj, 5, 0);
gtk_box_pack_start(GTK_BOX(h_jitter_buttons_box), jitter_spinner, FALSE, FALSE, 0);
- gtk_tooltips_set_tip (tooltips, jitter_spinner, "The simulated jitter buffer in [ms]", NULL);
- g_signal_connect(GTK_OBJECT (jitter_spinner_adj), "value_changed", G_CALLBACK(jitter_spinner_value_changed), NULL);
-
+ gtk_widget_set_tooltip_text (jitter_spinner, "The simulated jitter buffer in [ms]");
+ g_signal_connect(G_OBJECT (jitter_spinner_adj), "value_changed", G_CALLBACK(jitter_spinner_value_changed), NULL);
cb_use_rtp_timestamp = gtk_check_button_new_with_label("Use RTP timestamp");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cb_use_rtp_timestamp), FALSE);
gtk_box_pack_start(GTK_BOX(h_jitter_buttons_box), cb_use_rtp_timestamp, FALSE, FALSE, 10);
g_signal_connect(cb_use_rtp_timestamp, "toggled", G_CALLBACK(on_cb_use_rtp_clicked), NULL);
- gtk_tooltips_set_tip (tooltips, cb_use_rtp_timestamp, "Use RTP Timestamp instead of the arriving packet time. This will not reproduce the RTP stream as the user heard it, but is useful when the RTP is being tunneled and the original packet timing is missing", NULL);
+ gtk_widget_set_tooltip_text (cb_use_rtp_timestamp, "Use RTP Timestamp instead of the arriving packet time. This will not reproduce the RTP stream as the user heard it, but is useful when the RTP is being tunneled and the original packet timing is missing");
/* button row */
hbuttonbox = gtk_hbutton_box_new ();
bt_decode = gtk_button_new_from_stock(WIRESHARK_STOCK_DECODE);
gtk_container_add(GTK_CONTAINER(hbuttonbox), bt_decode);
g_signal_connect(bt_decode, "clicked", G_CALLBACK(on_bt_decode_clicked), NULL);
- gtk_tooltips_set_tip (tooltips, bt_decode, "Decode the RTP stream(s)", NULL);
+ gtk_widget_set_tooltip_text (bt_decode, "Decode the RTP stream(s)");
bt_play = gtk_button_new_from_stock(GTK_STOCK_MEDIA_PLAY);
gtk_container_add(GTK_CONTAINER(hbuttonbox), bt_play);
g_signal_connect(bt_play, "clicked", G_CALLBACK(on_bt_play_clicked), NULL);
- gtk_tooltips_set_tip (tooltips, bt_play, "Play the RTP channel(s)", NULL);
+ gtk_widget_set_tooltip_text (bt_play, "Play the RTP channel(s)");
- bt_pause = gtk_button_new_from_stock(GTK_STOCK_MEDIA_PAUSE);
+ bt_pause = gtk_button_new_from_stock(GTK_STOCK_MEDIA_PAUSE);
gtk_container_add(GTK_CONTAINER(hbuttonbox), bt_pause);
g_signal_connect(bt_pause, "clicked", G_CALLBACK(on_bt_pause_clicked), NULL);
- gtk_tooltips_set_tip (tooltips, bt_pause, "Pause the RTP channel(s)", NULL);
+ gtk_widget_set_tooltip_text (bt_pause, "Pause the RTP channel(s)");
- bt_stop = gtk_button_new_from_stock(GTK_STOCK_MEDIA_STOP);
+ bt_stop = gtk_button_new_from_stock(GTK_STOCK_MEDIA_STOP);
gtk_container_add(GTK_CONTAINER(hbuttonbox), bt_stop);
g_signal_connect(bt_stop, "clicked", G_CALLBACK(on_bt_stop_clicked), NULL);
- gtk_tooltips_set_tip (tooltips, bt_stop, "Stop the RTP channel(s)", NULL);
+ gtk_widget_set_tooltip_text (bt_stop, "Stop the RTP channel(s)");
bt_close = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
gtk_container_add (GTK_CONTAINER (hbuttonbox), bt_close);
+#if GTK_CHECK_VERSION(2,18,0)
+ gtk_widget_set_can_default(bt_close, TRUE);
+#else
GTK_WIDGET_SET_FLAGS(bt_close, GTK_CAN_DEFAULT);
- gtk_tooltips_set_tip (tooltips, bt_close, "Close this dialog", NULL);
+#endif
+ gtk_widget_set_tooltip_text (bt_close, "Close this dialog");
window_set_cancel_button(rtp_player_dlg_w, bt_close, window_cancel_button_cb);
g_signal_connect(rtp_player_dlg_w, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
/* statusbar */
info_bar = gtk_statusbar_new();
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_window_set_has_resize_grip(GTK_WINDOW(info_bar), TRUE);
+#else
gtk_statusbar_set_has_resize_grip(GTK_STATUSBAR(info_bar), TRUE);
-
+#endif
gtk_box_pack_start(GTK_BOX(stat_hbox), info_bar, TRUE, TRUE, 0);
/* statusbar hbox */
/* set the sensitive state of the buttons (decode, play, pause, stop) */
bt_state(TRUE, FALSE, FALSE, FALSE);
-
+
gtk_widget_show_all(rtp_player_dlg_w);
/* Force gtk to redraw the window before starting decoding the packet */
err = Pa_Initialize();
if( err != paNoError ) {
dialog = gtk_message_dialog_new ((GtkWindow *) rtp_player_dlg_w,
- GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR,GTK_BUTTONS_CLOSE,
- "Can not Initialize the PortAudio Library.\n Error: %s", Pa_GetErrorText( err ));
+ GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR,GTK_BUTTONS_CLOSE,
+ "Can not Initialize the PortAudio Library.\n Error: %s", Pa_GetErrorText( err ));
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
initialized = FALSE;
reset_rtp_channels();
-#if DEBUG
+#ifdef DEBUG
g_print("Pa_GetHostApiCount() = %d\n", Pa_GetHostApiCount());
g_print("Pa_GetDefaultHostApi() = %d\n", Pa_GetDefaultHostApi());
-
+
if ((Pa_GetHostApiCount() >= 0) && (Pa_GetDefaultHostApi() >= 0))
{
unsigned int i;
PaHostApiIndex api_index;
const PaHostApiInfo *api_info = Pa_GetHostApiInfo( (unsigned int)Pa_GetDefaultHostApi() );
g_print("Default PaHostApiInfo.type = %d (%s)\n", api_info->type, api_info->name);
-
+
for (i=0; i<(unsigned int)Pa_GetHostApiCount(); i++)
{
api_info = Pa_GetHostApiInfo( i );
g_print("PaHostApiInfo[%u].type = %d (%s)\n", i, api_info->type, api_info->name);
}
-
+
api_index = Pa_HostApiTypeIdToHostApiIndex( paALSA );
if (api_index < 0)
{
/* create the dialog window */
rtp_player_dlg_create();
-
+
}
#endif /* HAVE_LIBPORTAUDIO */