~siretart/gxine/bug.542506

« back to all changes in this revision

Viewing changes to src/stream_info.c

  • Committer: Bazaar Package Importer
  • Author(s): Siggi Langauf
  • Date: 2005-01-05 01:49:18 UTC
  • mto: (2.1.1 etch) (1.1.9 upstream)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20050105014918-wgldiqcd79ck2b0v
Tags: upstream-0.4.1
ImportĀ upstreamĀ versionĀ 0.4.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 2001-2003 the xine project
 
2
 * Copyright (C) 2001-2004 the xine project
3
3
 *
4
4
 * This program is free software; you can redistribute it and/or modify
5
5
 * it under the terms of the GNU General Public License as published by
15
15
 * along with this program; if not, write to the Free Software
16
16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
17
 *
18
 
 * $Id: stream_info.c,v 1.6 2003/03/01 23:37:56 guenter Exp $
 
18
 * $Id: stream_info.c,v 1.12 2004/12/02 02:38:32 dsalt Exp $
19
19
 *
20
20
 * stream_info/metadata display dialog implementation
21
21
 */
22
22
 
23
 
#include <config.h>
 
23
#include "globals.h"
 
24
 
24
25
#include <X11/Xlib.h>
25
26
#include <gtk/gtk.h>
26
27
#include <gdk/gdk.h>
28
29
#include <stdio.h>
29
30
 
30
31
#include "globals.h"
31
 
#include "gtkxine.h"
32
32
#include "stream_info.h"
 
33
#include "utils.h"
33
34
 
34
35
static GtkWidget    *dlg;
35
36
static int           is_visible;
40
41
  GtkTreeIter  iter;
41
42
  const char *str;
42
43
 
43
 
  str = gtk_xine_get_meta_info (GTK_XINE (gtx), info);
 
44
  str = xine_get_meta_info (stream, info);
44
45
  if (!str)
45
46
    return;
46
47
 
69
70
 
70
71
  gtk_list_store_clear (meta_store);
71
72
 
72
 
  add_meta_entry ("Title:", XINE_META_INFO_TITLE);
73
 
  add_meta_entry ("Artist:", XINE_META_INFO_ARTIST);
74
 
  add_meta_entry ("Comment:", XINE_META_INFO_COMMENT);
75
 
  add_meta_entry ("Date:",    XINE_META_INFO_YEAR);
76
 
  add_meta_entry ("Audio Codec:", XINE_META_INFO_AUDIOCODEC);
 
73
  add_meta_entry (_("Title:"), XINE_META_INFO_TITLE);
 
74
  add_meta_entry (_("Artist:"), XINE_META_INFO_ARTIST);
 
75
  add_meta_entry (_("Comment:"), XINE_META_INFO_COMMENT);
 
76
  add_meta_entry (_("Date:"),    XINE_META_INFO_YEAR);
 
77
  add_meta_entry (_("Audio codec:"), XINE_META_INFO_AUDIOCODEC);
77
78
 
78
 
  channels   = gtk_xine_get_stream_info (GTK_XINE (gtx), XINE_STREAM_INFO_AUDIO_CHANNELS);
79
 
  bits       = gtk_xine_get_stream_info (GTK_XINE (gtx), XINE_STREAM_INFO_AUDIO_BITS);
80
 
  samplerate = gtk_xine_get_stream_info (GTK_XINE (gtx), XINE_STREAM_INFO_AUDIO_SAMPLERATE);
81
 
  bps        = gtk_xine_get_stream_info (GTK_XINE (gtx), XINE_STREAM_INFO_AUDIO_BITRATE) ;
 
79
  channels   = xine_get_stream_info (stream, XINE_STREAM_INFO_AUDIO_CHANNELS);
 
80
  bits       = xine_get_stream_info (stream, XINE_STREAM_INFO_AUDIO_BITS);
 
81
  samplerate = xine_get_stream_info (stream, XINE_STREAM_INFO_AUDIO_SAMPLERATE);
 
82
  bps        = xine_get_stream_info (stream, XINE_STREAM_INFO_AUDIO_BITRATE) ;
82
83
 
83
84
  if (channels) {
84
 
    snprintf (str, 80, "%d channels, %d bit, %3.1fkHz, %d bps",
 
85
    snprintf (str, 80, _("%d channels, %d bit, %3.1fkHz, %d bps"),
85
86
              channels, bits, samplerate/1000.0, bps);
86
87
 
87
 
    add_string_entry ("Audio Format:", str);
 
88
    add_string_entry (_("Audio format:"), str);
88
89
  }
89
90
 
90
91
 
91
 
  add_meta_entry ("Video Codec:", XINE_META_INFO_VIDEOCODEC);
92
 
 
93
 
  w = gtk_xine_get_stream_info (GTK_XINE (gtx), XINE_STREAM_INFO_VIDEO_WIDTH);
94
 
  h = gtk_xine_get_stream_info (GTK_XINE (gtx), XINE_STREAM_INFO_VIDEO_HEIGHT);
95
 
 
96
 
  if (gtk_xine_get_stream_info (GTK_XINE (gtx), XINE_STREAM_INFO_FRAME_DURATION) != 0.0)
97
 
    fps = 90000.0 / gtk_xine_get_stream_info (GTK_XINE (gtx), XINE_STREAM_INFO_FRAME_DURATION);
 
92
  add_meta_entry (_("Video codec:"), XINE_META_INFO_VIDEOCODEC);
 
93
 
 
94
  w = xine_get_stream_info (stream, XINE_STREAM_INFO_VIDEO_WIDTH);
 
95
  h = xine_get_stream_info (stream, XINE_STREAM_INFO_VIDEO_HEIGHT);
 
96
 
 
97
  if (xine_get_stream_info (stream, XINE_STREAM_INFO_FRAME_DURATION) != 0.0)
 
98
    fps = 90000.0 / xine_get_stream_info (stream, XINE_STREAM_INFO_FRAME_DURATION);
98
99
  else
99
100
    fps = 0.0;
100
101
 
101
 
  ratio = gtk_xine_get_stream_info (GTK_XINE (gtx), XINE_STREAM_INFO_VIDEO_RATIO) / 10000.0;
102
 
  bps   = gtk_xine_get_stream_info (GTK_XINE (gtx), XINE_STREAM_INFO_VIDEO_BITRATE) ;
 
102
  ratio = xine_get_stream_info (stream, XINE_STREAM_INFO_VIDEO_RATIO) / 10000.0;
 
103
  bps   = xine_get_stream_info (stream, XINE_STREAM_INFO_VIDEO_BITRATE) ;
103
104
  if (w) {
104
105
    snprintf (str, 80, "%dx%d, %2.1f fps, %4.2f:1, %d bps", w, h, fps, ratio, bps);
105
106
 
106
 
    add_string_entry ("Video Format:", str);
 
107
    add_string_entry (_("Video format:"), str);
107
108
  }
108
109
 
109
 
  add_meta_entry ("System Layer:", XINE_META_INFO_SYSTEMLAYER);
 
110
  add_meta_entry (_("System layer:"), XINE_META_INFO_SYSTEMLAYER);
110
111
 
111
112
}
112
113
 
123
124
 
124
125
    is_visible = TRUE;
125
126
    gtk_widget_show_all (dlg);
126
 
    gtk_widget_map (dlg);
127
 
  }
128
 
}
129
 
 
130
 
static gboolean close_cb (GtkWidget* widget, gpointer data) {
131
 
  is_visible = FALSE;
132
 
  gtk_widget_unmap (dlg);
133
 
 
134
 
  return TRUE;
 
127
  }
 
128
}
 
129
 
 
130
static void response_cb (GtkDialog *dbox, int response, gpointer data)
 
131
{
 
132
  switch (response)
 
133
  {
 
134
  case GTK_RESPONSE_YES:
 
135
    update_metadata ();
 
136
    break;
 
137
  default:
 
138
    is_visible = FALSE;
 
139
    gtk_widget_hide (dlg);
 
140
  }
 
141
}
 
142
 
 
143
static JSBool js_stream_info_show (JSContext *cx, JSObject *obj, uintN argc, 
 
144
                                   jsval *argv, jsval *rval) {
 
145
 
 
146
  /* se_t *se = (se_t *) JS_GetContextPrivate(cx); */
 
147
 
 
148
  se_log_fncall ("stream_info_show");
 
149
 
 
150
  stream_info_show ();
 
151
  
 
152
  return JS_TRUE;
135
153
}
136
154
 
137
155
void stream_info_init (void) {
138
156
 
139
 
  GtkWidget            *tree_view, *button, *scrolled_window;
 
157
  GtkWidget            *tree_view, *scrolled_window;
140
158
  GtkCellRenderer      *cell;
141
159
  GtkTreeViewColumn    *column;
142
160
 
143
161
  /* create dialog */
144
162
 
145
 
  dlg = gtk_dialog_new ();
146
 
  gtk_window_set_title (GTK_WINDOW (dlg), "Stream Meta Info");
 
163
  dlg = gtk_dialog_new_with_buttons (_("Stream meta-info"), NULL, 0,
 
164
                                GTK_STOCK_REFRESH, GTK_RESPONSE_YES,
 
165
                                GTK_STOCK_CLOSE, GTK_RESPONSE_DELETE_EVENT,
 
166
                                NULL);
147
167
  gtk_window_set_default_size (GTK_WINDOW (dlg), 500, 400);
148
 
  g_signal_connect (GTK_OBJECT (dlg), "delete_event",
149
 
                    G_CALLBACK (close_cb), NULL );
 
168
  hide_on_delete (dlg, &is_visible);
 
169
  g_signal_connect (GTK_OBJECT(dlg), "response",
 
170
                    GTK_SIGNAL_FUNC(response_cb), NULL);
150
171
 
151
 
  button = gtk_dialog_add_button (GTK_DIALOG (dlg), GTK_STOCK_CLOSE, 1);
152
 
  g_signal_connect (GTK_OBJECT(button), "clicked", 
153
 
                    G_CALLBACK(close_cb), 
154
 
                    NULL);
155
 
  
156
172
  /* add list to hold meta info */
157
173
 
158
174
  meta_store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
161
177
  gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (tree_view), TRUE);
162
178
 
163
179
  cell = gtk_cell_renderer_text_new ();
164
 
  column = gtk_tree_view_column_new_with_attributes ("field",
 
180
  column = gtk_tree_view_column_new_with_attributes (_("Field"),
165
181
                                                     cell,
166
182
                                                     "text", 0,
167
183
                                                     NULL);
168
184
  gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view),
169
185
                               GTK_TREE_VIEW_COLUMN (column));
170
186
 
171
 
  column = gtk_tree_view_column_new_with_attributes ("data from stream",
 
187
  column = gtk_tree_view_column_new_with_attributes (_("Data from stream"),
172
188
                                                     cell,
173
189
                                                     "text", 1,
174
190
                                                     NULL);
185
201
                      TRUE, TRUE, 2);
186
202
 
187
203
  is_visible = FALSE;
 
204
 
 
205
  se_defun (gse, NULL, "stream_info_show", js_stream_info_show, 0, 0,
 
206
            SE_GROUP_DIALOGUE, N_("[bool]"), NULL);
188
207
}
189
208