[brasero] Improve size display for Video projects
- From: Philippe Rouquier <philippr src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [brasero] Improve size display for Video projects
- Date: Sat, 8 Aug 2009 18:31:47 +0000 (UTC)
commit f543fbb1f75c9d4e0bb5fad786f475e245d4c70d
Author: Philippe Rouquier <bonfire-app wanadoo fr>
Date: Fri Aug 7 14:32:38 2009 +0200
Improve size display for Video projects
Fix a bug in brasero-dest-selection.c where the available size was not correctly picked
libbrasero-burn/brasero-dest-selection.c | 15 +++++++++++++-
libbrasero-burn/brasero-status-dialog.c | 16 +++++++++++++-
libbrasero-burn/brasero-track-stream.c | 31 +++++++++++++++++++++++------
src/brasero-project-manager.c | 6 +++-
src/brasero-project.c | 15 +++++++++----
5 files changed, 66 insertions(+), 17 deletions(-)
---
diff --git a/libbrasero-burn/brasero-dest-selection.c b/libbrasero-burn/brasero-dest-selection.c
index 5271bd9..3aa65f6 100644
--- a/libbrasero-burn/brasero-dest-selection.c
+++ b/libbrasero-burn/brasero-dest-selection.c
@@ -556,6 +556,7 @@ brasero_dest_selection_format_medium_string (BraseroMediumSelection *selection,
&data_blocks,
&session_bytes);
+ /* Determine the size available for burning */
if (flags & (BRASERO_BURN_FLAG_MERGE|BRASERO_BURN_FLAG_APPEND)) {
brasero_medium_get_free_space (medium,
&size_bytes,
@@ -569,7 +570,7 @@ brasero_dest_selection_format_medium_string (BraseroMediumSelection *selection,
* its free space would be 0. This is the best way to do it
* instead of checking for a CLOSED medium as it allows the
* overwrite media to be appended or merged if need be. */
- if ((!blocks || blocks > data_blocks)
+ if ((flags & BRASERO_BURN_FLAG_BLANK_BEFORE_WRITE)
&& (brasero_burn_library_get_media_capabilities (media) & BRASERO_MEDIUM_REWRITABLE))
brasero_medium_get_capacity (medium,
&size_bytes,
@@ -601,6 +602,18 @@ brasero_dest_selection_format_medium_string (BraseroMediumSelection *selection,
/* format the size */
if (brasero_track_type_get_has_stream (input)
+ && BRASERO_STREAM_FORMAT_HAS_VIDEO (brasero_track_type_get_stream_format (input))) {
+ guint64 free_time;
+
+ /* This is an embarassing problem: this is an approximation
+ * based on the fact that 2 hours = 4.3GiB */
+ free_time = size_bytes - session_bytes;
+ free_time = free_time * 72000LL / 47LL;
+ size_string = brasero_units_get_time_string (free_time,
+ TRUE,
+ TRUE);
+ }
+ else if (brasero_track_type_get_has_stream (input)
|| (brasero_track_type_get_has_medium (input)
&& (brasero_track_type_get_medium_type (input) & BRASERO_MEDIUM_HAS_AUDIO)))
size_string = brasero_units_get_time_string (BRASERO_BYTES_TO_DURATION (size_bytes - session_bytes),
diff --git a/libbrasero-burn/brasero-status-dialog.c b/libbrasero-burn/brasero-status-dialog.c
index aeb4e9c..5020b41 100644
--- a/libbrasero-burn/brasero-status-dialog.c
+++ b/libbrasero-burn/brasero-status-dialog.c
@@ -110,8 +110,20 @@ brasero_status_dialog_update (BraseroStatusDialog *self,
type = brasero_track_type_new ();
brasero_burn_session_get_input_type (priv->session, type);
- if (brasero_track_type_get_has_stream (type))
- size_str = brasero_units_get_time_string (session_bytes, TRUE, FALSE);
+ if (brasero_track_type_get_has_stream (type)) {
+ if (BRASERO_STREAM_FORMAT_HAS_VIDEO (brasero_track_type_get_stream_format (type))) {
+ guint64 free_time;
+
+ /* This is an embarassing problem: this is an approximation based on the fact that
+ * 2 hours = 4.3GiB */
+ free_time = session_bytes * 72000LL / 47LL;
+ size_str = brasero_units_get_time_string (free_time,
+ TRUE,
+ TRUE);
+ }
+ else
+ size_str = brasero_units_get_time_string (session_bytes, TRUE, FALSE);
+ }
/* NOTE: this is perfectly fine as brasero_track_type_get_medium_type ()
* will return BRASERO_MEDIUM_NONE if this is not a MEDIUM track type */
else if (brasero_track_type_get_medium_type (type) & BRASERO_MEDIUM_HAS_AUDIO)
diff --git a/libbrasero-burn/brasero-track-stream.c b/libbrasero-burn/brasero-track-stream.c
index 3d323e3..3367cf5 100644
--- a/libbrasero-burn/brasero-track-stream.c
+++ b/libbrasero-burn/brasero-track-stream.c
@@ -258,18 +258,35 @@ brasero_track_stream_get_size (BraseroTrack *track,
goffset *block_size)
{
BraseroTrackStreamPrivate *priv;
+ BraseroStreamFormat format;
priv = BRASERO_TRACK_STREAM_PRIVATE (track);
- if (blocks) {
- guint64 length = 0;
+ format = brasero_track_stream_get_format (BRASERO_TRACK_STREAM (track));
+ if (!BRASERO_STREAM_FORMAT_HAS_VIDEO (format)) {
+ if (blocks) {
+ guint64 length = 0;
- brasero_track_stream_get_length (BRASERO_TRACK_STREAM (track), &length);
- *blocks = length * 75LL / 1000000000LL;
- }
+ brasero_track_stream_get_length (BRASERO_TRACK_STREAM (track), &length);
+ *blocks = length * 75LL / 1000000000LL;
+ }
- if (block_size)
- *block_size = 2352;
+ if (block_size)
+ *block_size = 2352;
+ }
+ else {
+ if (blocks) {
+ guint64 length = 0;
+
+ /* This is based on a simple formula:
+ * 4700000000 bytes means 2 hours */
+ brasero_track_stream_get_length (BRASERO_TRACK_STREAM (track), &length);
+ *blocks = length * 47LL / 72000LL / 2048LL;
+ }
+
+ if (block_size)
+ *block_size = 2048;
+ }
return BRASERO_BURN_OK;
}
diff --git a/src/brasero-project-manager.c b/src/brasero-project-manager.c
index b7d753f..1198ca9 100644
--- a/src/brasero-project-manager.c
+++ b/src/brasero-project-manager.c
@@ -249,7 +249,8 @@ brasero_project_manager_set_statusbar (BraseroProjectManager *manager,
if (!invalid_num && valid_num) {
gchar *size_string;
- if (manager->priv->type == BRASERO_PROJECT_TYPE_AUDIO)
+ if (manager->priv->type == BRASERO_PROJECT_TYPE_AUDIO
+ || manager->priv->type == BRASERO_PROJECT_TYPE_VIDEO)
size_string = brasero_units_get_time_string (files_size, TRUE, FALSE);
else if (manager->priv->type == BRASERO_PROJECT_TYPE_DATA)
size_string = g_format_size_for_display (files_size);
@@ -264,7 +265,8 @@ brasero_project_manager_set_statusbar (BraseroProjectManager *manager,
else if (valid_num) {
gchar *size_string = NULL;
- if (manager->priv->type == BRASERO_PROJECT_TYPE_AUDIO) {
+ if (manager->priv->type == BRASERO_PROJECT_TYPE_AUDIO
+ || manager->priv->type == BRASERO_PROJECT_TYPE_VIDEO) {
size_string = brasero_units_get_time_string (files_size, TRUE, FALSE);
status_string = g_strdup_printf (ngettext ("%d file is supported (%s)", "%d files are supported (%s)", valid_num),
valid_num,
diff --git a/src/brasero-project.c b/src/brasero-project.c
index 539d6c2..368bd53 100644
--- a/src/brasero-project.c
+++ b/src/brasero-project.c
@@ -776,16 +776,21 @@ brasero_disc_get_use_info_notebook (BraseroProject *project)
gchar *
brasero_project_get_sectors_string (gint64 sectors,
- gboolean time_format)
+ BraseroTrackType *type)
{
gint64 size_bytes;
- if (time_format) {
- size_bytes = sectors * GST_SECOND / 75;
+ if (brasero_track_type_get_has_stream (type)) {
+ if (BRASERO_STREAM_FORMAT_HAS_VIDEO (brasero_track_type_get_stream_format (type)))
+ /* This is an embarassing problem: this is an approximation
+ * based on the fact that 2 hours = 4.3GiB */
+ size_bytes = sectors * 2048LL * 72000LL / 47LL;
+ else
+ size_bytes = sectors * GST_SECOND / 75LL;
return brasero_units_get_time_string (size_bytes, TRUE, FALSE);
}
else {
- size_bytes = sectors * 2048;
+ size_bytes = sectors * 2048LL;
return g_format_size_for_display (size_bytes);
}
}
@@ -814,7 +819,7 @@ brasero_project_update_project_size (BraseroProject *project)
session_type = brasero_track_type_new ();
brasero_burn_session_get_input_type (BRASERO_BURN_SESSION (project->priv->session), session_type);
- string = brasero_project_get_sectors_string (sectors, !brasero_track_type_get_has_data (session_type));
+ string = brasero_project_get_sectors_string (sectors, session_type);
brasero_track_type_free (session_type);
size_str = g_strdup_printf (_("Project estimated size: %s"), string);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]