[longomatch] Get Pixel Aspect Ratio information from the video stream too
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Get Pixel Aspect Ratio information from the video stream too
- Date: Sat, 11 Aug 2012 15:05:16 +0000 (UTC)
commit d93fc346b81632f27698f0c845ce53f295da1eb9
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Sat Aug 11 15:26:09 2012 +0200
Get Pixel Aspect Ratio information from the video stream too
LongoMatch.Core/Store/MediaFile.cs | 14 +++++++++
LongoMatch.Multimedia/Common/Enum.cs | 1 +
LongoMatch.Multimedia/Utils/PreviewMediaFile.cs | 4 ++-
libcesarplayer/bacon-video-widget-gst-0.10.c | 36 ++++++++++++++++++++++-
libcesarplayer/bacon-video-widget.h | 4 ++-
5 files changed, 56 insertions(+), 3 deletions(-)
---
diff --git a/LongoMatch.Core/Store/MediaFile.cs b/LongoMatch.Core/Store/MediaFile.cs
index 7afa9e1..62d49c1 100644
--- a/LongoMatch.Core/Store/MediaFile.cs
+++ b/LongoMatch.Core/Store/MediaFile.cs
@@ -39,6 +39,7 @@ namespace LongoMatch.Store
string audioCodec;
uint videoHeight;
uint videoWidth;
+ double par;
byte[] thumbnailBuf;
@@ -53,6 +54,7 @@ namespace LongoMatch.Store
string audioCodec,
uint videoWidth,
uint videoHeight,
+ double par,
Image preview)
{
this.filePath = filePath;
@@ -69,6 +71,7 @@ namespace LongoMatch.Store
else
this.fps = fps;
this.Preview = preview;
+ Par = par;
}
public string FilePath {
@@ -156,6 +159,17 @@ namespace LongoMatch.Store
}
}
+ public double Par {
+ get {
+ if (par == null)
+ return 1;
+ return par;
+ }
+ set {
+ par = value;
+ }
+ }
+
public Image Preview {
get {
if(thumbnailBuf != null)
diff --git a/LongoMatch.Multimedia/Common/Enum.cs b/LongoMatch.Multimedia/Common/Enum.cs
index a4ab87f..38f1e66 100644
--- a/LongoMatch.Multimedia/Common/Enum.cs
+++ b/LongoMatch.Multimedia/Common/Enum.cs
@@ -115,6 +115,7 @@ namespace LongoMatch.Video.Common
AudioEncoderType,
AudioSampleRate,
AudioChannels,
+ Par,
}
diff --git a/LongoMatch.Multimedia/Utils/PreviewMediaFile.cs b/LongoMatch.Multimedia/Utils/PreviewMediaFile.cs
index 570ad35..f1c6c23 100644
--- a/LongoMatch.Multimedia/Utils/PreviewMediaFile.cs
+++ b/LongoMatch.Multimedia/Utils/PreviewMediaFile.cs
@@ -45,6 +45,7 @@ namespace LongoMatch.Video.Utils
int fps=0;
int height=0;
int width=0;
+ double par = 1;
LongoMatch.Common.Image preview=null;
MultimediaFactory factory;
IMetadataReader reader;
@@ -73,13 +74,14 @@ namespace LongoMatch.Video.Utils
}
height = (int) reader.GetMetadata(MetadataType.DimensionX);
width = (int) reader.GetMetadata(MetadataType.DimensionY);
+ par = (double) reader.GetMetadata(MetadataType.Par);
reader.Close();
reader.Dispose();
return new LongoMatch.Store.MediaFile(filePath,duration*1000,
(ushort)fps,hasAudio,
hasVideo,VideoEncoderType,
AudioEncoderType,(uint)height,
- (uint)width,preview);
+ (uint)width, par, preview);
}
catch(GLib.GException ex) {
throw new Exception(Catalog.GetString("Invalid video file:")+"\n"+ex.Message);
diff --git a/libcesarplayer/bacon-video-widget-gst-0.10.c b/libcesarplayer/bacon-video-widget-gst-0.10.c
index 19728e2..7e84709 100644
--- a/libcesarplayer/bacon-video-widget-gst-0.10.c
+++ b/libcesarplayer/bacon-video-widget-gst-0.10.c
@@ -4391,7 +4391,8 @@ static struct _metadata_map_info
BVW_INFO_AUDIO_BITRATE, "audio-bitrate"}, {
BVW_INFO_AUDIO_CODEC, "audio-codec"}, {
BVW_INFO_AUDIO_SAMPLE_RATE, "samplerate"}, {
- BVW_INFO_AUDIO_CHANNELS, "channels"}
+ BVW_INFO_AUDIO_CHANNELS, "channels"}, {
+ BVW_INFO_PAR, "pixel-aspect-ratio"}
};
static const gchar *
@@ -4629,6 +4630,37 @@ bacon_video_widget_get_metadata_string (BaconVideoWidget * bvw,
}
static void
+bacon_video_widget_get_metadata_double (BaconVideoWidget * bvw,
+ BvwMetadataType type, GValue * value)
+{
+ gdouble metadata_double = 0;
+
+ g_value_init (value, G_TYPE_DOUBLE);
+
+ if (bvw->priv->play == NULL) {
+ g_value_set_double (value, 0);
+ return;
+ }
+
+ switch (type) {
+ case BVW_INFO_PAR:
+ {
+ int movie_par_n = gst_value_get_fraction_numerator (bvw->priv->movie_par);
+ int movie_par_d = gst_value_get_fraction_denominator (bvw->priv->movie_par);
+ metadata_double = (gdouble) movie_par_n / (gdouble) movie_par_d;
+ break;
+ }
+ default:
+ g_assert_not_reached();
+ }
+
+ g_value_set_double (value, metadata_double);
+ GST_DEBUG ("%s = %f", get_metadata_type_name (type), metadata_double);
+
+ return;
+}
+
+static void
bacon_video_widget_get_metadata_int (BaconVideoWidget * bvw,
BvwMetadataType type, GValue * value)
{
@@ -4921,6 +4953,8 @@ bacon_video_widget_get_metadata (BaconVideoWidget * bvw,
g_value_take_object (value, pixbuf);
}
}
+ case BVW_INFO_PAR:
+ bacon_video_widget_get_metadata_double (bvw, type, value);
break;
default:
g_return_if_reached ();
diff --git a/libcesarplayer/bacon-video-widget.h b/libcesarplayer/bacon-video-widget.h
index 7f9e7a0..d2e5746 100644
--- a/libcesarplayer/bacon-video-widget.h
+++ b/libcesarplayer/bacon-video-widget.h
@@ -247,7 +247,9 @@ bacon_video_widget_error_quark (void)
BVW_INFO_AUDIO_BITRATE,
BVW_INFO_AUDIO_CODEC,
BVW_INFO_AUDIO_SAMPLE_RATE,
- BVW_INFO_AUDIO_CHANNELS
+ BVW_INFO_AUDIO_CHANNELS,
+ /* Added later */
+ BVW_INFO_PAR,
} BvwMetadataType;
EXPORT void bacon_video_widget_get_metadata (BaconVideoWidget * bvw,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]