[longomatch] Update final encoded media info in the live capture
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Update final encoded media info in the live capture
- Date: Thu, 8 Jan 2015 17:20:55 +0000 (UTC)
commit cb545ea42da856d58252c66e720c1d0bba786584
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Thu Jan 8 18:15:45 2015 +0100
Update final encoded media info in the live capture
LongoMatch.Core/Handlers/Multimedia.cs | 1 +
LongoMatch.Core/Interfaces/GUI/ICapturerBin.cs | 4 +-
LongoMatch.Core/Interfaces/Multimedia/ICapturer.cs | 1 +
LongoMatch.GUI.Multimedia/Gui/CapturerBin.cs | 15 ++++-
LongoMatch.GUI.Multimedia/Gui/PlayerCapturerBin.cs | 10 +++-
LongoMatch.Multimedia/Capturer/FakeCapturer.cs | 1 +
.../Capturer/GstCameraCapturer.cs | 63 ++++++++++++++++++++
LongoMatch.Multimedia/Common/Handlers.cs | 28 +++++++++
LongoMatch.Services/Services/ProjectsManager.cs | 2 +-
libcesarplayer/baconvideowidget-marshal.c | 47 +++++++++++++++
libcesarplayer/baconvideowidget-marshal.h | 8 +++
libcesarplayer/baconvideowidget-marshal.list | 1 +
libcesarplayer/gst-camera-capturer.c | 20 ++++++-
libcesarplayer/gst-camera-capturer.h | 1 +
14 files changed, 194 insertions(+), 8 deletions(-)
---
diff --git a/LongoMatch.Core/Handlers/Multimedia.cs b/LongoMatch.Core/Handlers/Multimedia.cs
index 4011f33..3a0ea56 100644
--- a/LongoMatch.Core/Handlers/Multimedia.cs
+++ b/LongoMatch.Core/Handlers/Multimedia.cs
@@ -43,6 +43,7 @@ namespace LongoMatch.Core.Handlers
public delegate void PercentCompletedHandler(float percent);
public delegate void StateChangeHandler(bool playing);
public delegate void TickHandler(Time currentTime);
+ public delegate void MediaInfoHandler(int width, int height, int parN, int parD);
public delegate void EosHandler();
public delegate void ReadyToSeekHandler();
}
diff --git a/LongoMatch.Core/Interfaces/GUI/ICapturerBin.cs b/LongoMatch.Core/Interfaces/GUI/ICapturerBin.cs
index dfcd7ed..b85d1a6 100644
--- a/LongoMatch.Core/Interfaces/GUI/ICapturerBin.cs
+++ b/LongoMatch.Core/Interfaces/GUI/ICapturerBin.cs
@@ -21,6 +21,7 @@ using LongoMatch.Core.Common;
using LongoMatch.Core.Handlers;
using LongoMatch.Core.Store;
using System.Collections.Generic;
+using LongoMatch.Core.Interfaces.Multimedia;
namespace LongoMatch.Core.Interfaces.GUI
{
@@ -32,8 +33,9 @@ namespace LongoMatch.Core.Interfaces.GUI
CaptureSettings CaptureSettings {get;}
List<string> PeriodsNames {set;}
List<Period> Periods { get; set; }
+ ICapturer Capturer { get; }
- void Run (CaptureSettings settings);
+ void Run (CaptureSettings settings, MediaFile outputFile);
void StartPeriod();
void PausePeriod();
void ResumePeriod();
diff --git a/LongoMatch.Core/Interfaces/Multimedia/ICapturer.cs
b/LongoMatch.Core/Interfaces/Multimedia/ICapturer.cs
index e023460..e05a2ca 100644
--- a/LongoMatch.Core/Interfaces/Multimedia/ICapturer.cs
+++ b/LongoMatch.Core/Interfaces/Multimedia/ICapturer.cs
@@ -33,6 +33,7 @@ namespace LongoMatch.Core.Interfaces.Multimedia
event EllpasedTimeHandler EllapsedTime;
event ErrorHandler Error;
event DeviceChangeHandler DeviceChange;
+ event MediaInfoHandler MediaInfo;
void Configure (CaptureSettings settings, IntPtr window_handle);
diff --git a/LongoMatch.GUI.Multimedia/Gui/CapturerBin.cs b/LongoMatch.GUI.Multimedia/Gui/CapturerBin.cs
index 3088d56..3408135 100644
--- a/LongoMatch.GUI.Multimedia/Gui/CapturerBin.cs
+++ b/LongoMatch.GUI.Multimedia/Gui/CapturerBin.cs
@@ -47,6 +47,7 @@ namespace LongoMatch.Gui
DateTime currentPeriodStart;
List<string> gamePeriods;
TimelineEvent lastevent;
+ MediaFile outputFile;
public CapturerBin ()
{
@@ -311,15 +312,16 @@ namespace LongoMatch.Gui
}
}
- public void Run (CaptureSettings settings)
+ public void Run (CaptureSettings settings, MediaFile outputFile)
{
Reset ();
if (type == CapturerType.Live) {
Capturer = Config.MultimediaToolkit.GetCapturer ();
+ this.outputFile = outputFile;
this.settings = settings;
- videowindow.Ratio = (float)settings.EncodingSettings.VideoStandard.Width /
- settings.EncodingSettings.VideoStandard.Height;
+ videowindow.Ratio = (float) outputFile.VideoWidth / outputFile.VideoHeight;
Capturer.Error += OnError;
+ Capturer.MediaInfo += HandleMediaInfo;
Capturer.DeviceChange += OnDeviceChange;
Periods = new List<Period> ();
if (videowindow.Ready) {
@@ -472,5 +474,12 @@ namespace LongoMatch.Gui
}
+ void HandleMediaInfo (int width, int height, int parN, int parD)
+ {
+ videowindow.Ratio = (float) width / height * parN / parD;
+ outputFile.VideoWidth = (uint) width;
+ outputFile.VideoHeight = (uint) height;
+ outputFile.Par = (float) parN / parD;
+ }
}
}
diff --git a/LongoMatch.GUI.Multimedia/Gui/PlayerCapturerBin.cs
b/LongoMatch.GUI.Multimedia/Gui/PlayerCapturerBin.cs
index dec6bbb..0f8cc18 100644
--- a/LongoMatch.GUI.Multimedia/Gui/PlayerCapturerBin.cs
+++ b/LongoMatch.GUI.Multimedia/Gui/PlayerCapturerBin.cs
@@ -124,6 +124,12 @@ namespace LongoMatch.Gui
#region Capturer
+ public ICapturer Capturer {
+ get {
+ return capturerbin.Capturer;
+ }
+ }
+
public Time CurrentCaptureTime {
get {
return capturerbin.CurrentCaptureTime;
@@ -171,8 +177,8 @@ namespace LongoMatch.Gui
capturerbin.StopPeriod ();
}
- public void Run (CaptureSettings settings) {
- capturerbin.Run (settings);
+ public void Run (CaptureSettings settings, MediaFile outputFile) {
+ capturerbin.Run (settings, outputFile);
}
public void PausePeriod ()
diff --git a/LongoMatch.Multimedia/Capturer/FakeCapturer.cs b/LongoMatch.Multimedia/Capturer/FakeCapturer.cs
index 5c6ba6c..b82d790 100644
--- a/LongoMatch.Multimedia/Capturer/FakeCapturer.cs
+++ b/LongoMatch.Multimedia/Capturer/FakeCapturer.cs
@@ -30,6 +30,7 @@ namespace LongoMatch.Video.Capturer
public event EllpasedTimeHandler EllapsedTime;
public event ErrorHandler Error;
public event DeviceChangeHandler DeviceChange;
+ public event MediaInfoHandler MediaInfo;
LiveSourceTimer timer;
diff --git a/LongoMatch.Multimedia/Capturer/GstCameraCapturer.cs
b/LongoMatch.Multimedia/Capturer/GstCameraCapturer.cs
index 4c9d5f5..a281b0e 100644
--- a/LongoMatch.Multimedia/Capturer/GstCameraCapturer.cs
+++ b/LongoMatch.Multimedia/Capturer/GstCameraCapturer.cs
@@ -39,6 +39,7 @@ namespace LongoMatch.Video.Capturer {
public event EllpasedTimeHandler EllapsedTime;
public event ErrorHandler Error;
public event DeviceChangeHandler DeviceChange;
+ public event MediaInfoHandler MediaInfo;
private LiveSourceTimer timer;
@@ -100,6 +101,12 @@ namespace LongoMatch.Video.Capturer {
DeviceChange (args.DeviceChange);
}
};
+
+ this.GlibMediaInfo += (o, args) => {
+ if (MediaInfo != null) {
+ MediaInfo (args.Width, args.Height, args.ParN, args.ParD);
+ }
+ };
}
#pragma warning disable 0169
@@ -287,6 +294,62 @@ namespace LongoMatch.Video.Capturer {
sig.RemoveDelegate(value);
}
}
+
+ [UnmanagedFunctionPointer (CallingConvention.Cdecl)]
+ delegate void MediaInfoVMDelegate (IntPtr gcc, int width, int height, int par_n, int par_d);
+
+ static MediaInfoVMDelegate MediaInfoVMCallback;
+
+ static void media_info_cb (IntPtr gcc, int width, int height, int par_n, int par_d)
+ {
+ try {
+ GstCameraCapturer gcc_managed = GLib.Object.GetObject (gcc, false) as
GstCameraCapturer;
+ gcc_managed.OnMediaInfo (width, height, par_n, par_d);
+ } catch (Exception e) {
+ GLib.ExceptionManager.RaiseUnhandledException (e, false);
+ }
+ }
+
+ private static void OverrideMediaInfo (GLib.GType gtype)
+ {
+ if (MediaInfoVMCallback == null)
+ MediaInfoVMCallback = new MediaInfoVMDelegate (media_info_cb);
+ OverrideVirtualMethod (gtype, "media-info", MediaInfoVMCallback);
+ }
+
+ [GLib.DefaultSignalHandler(Type=typeof(GstCameraCapturer),
ConnectionMethod="OverrideMediaInfo")]
+ protected virtual void OnMediaInfo (int width, int height, int par_n, int par_d)
+ {
+ GLib.Value ret = GLib.Value.Empty;
+ GLib.ValueArray inst_and_params = new GLib.ValueArray (6);
+ GLib.Value[] vals = new GLib.Value [6];
+ vals [0] = new GLib.Value (this);
+ inst_and_params.Append (vals [0]);
+ vals [1] = new GLib.Value (width);
+ inst_and_params.Append (vals [1]);
+ vals [2] = new GLib.Value (height);
+ inst_and_params.Append (vals [2]);
+ vals [3] = new GLib.Value (par_n);
+ inst_and_params.Append (vals [3]);
+ vals [4] = new GLib.Value (par_d);
+ inst_and_params.Append (vals [4]);
+ g_signal_chain_from_overridden (inst_and_params.ArrayPtr, ref ret);
+ foreach (GLib.Value v in vals)
+ v.Dispose ();
+ }
+
+ [GLib.Signal("media-info")]
+ public event GlibMediaInfoHandler GlibMediaInfo {
+ add {
+ GLib.Signal sig = GLib.Signal.Lookup (this, "media-info",
typeof(MediaInfoArgs));
+ sig.AddDelegate (value);
+ }
+ remove {
+ GLib.Signal sig = GLib.Signal.Lookup (this, "media-info",
typeof(MediaInfoArgs));
+ sig.RemoveDelegate (value);
+ }
+ }
+
#pragma warning restore 0169
public void Configure (CaptureSettings settings, IntPtr window_handle) {
diff --git a/LongoMatch.Multimedia/Common/Handlers.cs b/LongoMatch.Multimedia/Common/Handlers.cs
index 6ac8be0..82f790e 100644
--- a/LongoMatch.Multimedia/Common/Handlers.cs
+++ b/LongoMatch.Multimedia/Common/Handlers.cs
@@ -28,6 +28,7 @@ namespace LongoMatch.Video.Common
public delegate void GlibPercentCompletedHandler (object o,PercentCompletedArgs args);
public delegate void GlibStateChangeHandler (object o,StateChangeArgs args);
public delegate void GlibTickHandler (object o,TickArgs args);
+ public delegate void GlibMediaInfoHandler (object o, MediaInfoArgs args);
public delegate void GlibDeviceChangeHandler (object o,DeviceChangeArgs args);
public class ErrorArgs : GLib.SignalArgs
{
@@ -85,4 +86,31 @@ namespace LongoMatch.Video.Common
}
}
}
+
+ public class MediaInfoArgs : GLib.SignalArgs
+ {
+ public int Width {
+ get {
+ return (int) Args[0];
+ }
+ }
+
+ public int Height {
+ get {
+ return (int) Args[1];
+ }
+ }
+
+ public int ParN {
+ get {
+ return (int) Args[2];
+ }
+ }
+
+ public int ParD {
+ get {
+ return (int) Args[3];
+ }
+ }
+ }
}
diff --git a/LongoMatch.Services/Services/ProjectsManager.cs b/LongoMatch.Services/Services/ProjectsManager.cs
index 48d747c..73accb1 100644
--- a/LongoMatch.Services/Services/ProjectsManager.cs
+++ b/LongoMatch.Services/Services/ProjectsManager.cs
@@ -196,7 +196,7 @@ namespace LongoMatch.Services
projectType == ProjectType.URICaptureProject ||
projectType == ProjectType.FakeCaptureProject) {
try {
- Capturer.Run (props);
+ Capturer.Run (props, project.Description.FileSet.GetAngle
(MediaFileAngle.Angle1));
} catch (Exception ex) {
Log.Exception (ex);
guiToolkit.ErrorMessage (ex.Message);
diff --git a/libcesarplayer/baconvideowidget-marshal.c b/libcesarplayer/baconvideowidget-marshal.c
index e9e0403..e47a962 100644
--- a/libcesarplayer/baconvideowidget-marshal.c
+++ b/libcesarplayer/baconvideowidget-marshal.c
@@ -239,6 +239,53 @@ baconvideowidget_marshal_VOID__INT64_INT64_DOUBLE (GClosure *closure,
data2);
}
+/* VOID:INT,INT,INT,INT (./baconvideowidget-marshal.list:5) */
+extern void baconvideowidget_marshal_VOID__INT_INT_INT_INT (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+void
+baconvideowidget_marshal_VOID__INT_INT_INT_INT (GClosure *closure,
+ GValue *return_value G_GNUC_UNUSED,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint G_GNUC_UNUSED,
+ gpointer marshal_data)
+{
+ typedef void (*GMarshalFunc_VOID__INT_INT_INT_INT) (gpointer data1,
+ gint arg_1,
+ gint arg_2,
+ gint arg_3,
+ gint arg_4,
+ gpointer data2);
+ register GMarshalFunc_VOID__INT_INT_INT_INT callback;
+ register GCClosure *cc = (GCClosure*) closure;
+ register gpointer data1, data2;
+
+ g_return_if_fail (n_param_values == 5);
+
+ if (G_CCLOSURE_SWAP_DATA (closure))
+ {
+ data1 = closure->data;
+ data2 = g_value_peek_pointer (param_values + 0);
+ }
+ else
+ {
+ data1 = g_value_peek_pointer (param_values + 0);
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__INT_INT_INT_INT) (marshal_data ? marshal_data : cc->callback);
+
+ callback (data1,
+ g_marshal_value_peek_int (param_values + 1),
+ g_marshal_value_peek_int (param_values + 2),
+ g_marshal_value_peek_int (param_values + 3),
+ g_marshal_value_peek_int (param_values + 4),
+ data2);
+}
+
G_END_DECLS
#endif /* __baconvideowidget_marshal_MARSHAL_H__ */
diff --git a/libcesarplayer/baconvideowidget-marshal.h b/libcesarplayer/baconvideowidget-marshal.h
index eb11464..1a4c729 100644
--- a/libcesarplayer/baconvideowidget-marshal.h
+++ b/libcesarplayer/baconvideowidget-marshal.h
@@ -38,6 +38,14 @@ extern void baconvideowidget_marshal_VOID__INT64_INT64_DOUBLE (GClosure *clo
gpointer invocation_hint,
gpointer marshal_data);
+/* VOID:INT,INT,INT,INT (./baconvideowidget-marshal.list:5) */
+extern void baconvideowidget_marshal_VOID__INT_INT_INT_INT (GClosure *closure,
+ GValue *return_value,
+ guint n_param_values,
+ const GValue *param_values,
+ gpointer invocation_hint,
+ gpointer marshal_data);
+
G_END_DECLS
#endif /* __baconvideowidget_marshal_MARSHAL_H__ */
diff --git a/libcesarplayer/baconvideowidget-marshal.list b/libcesarplayer/baconvideowidget-marshal.list
index edfa31c..73fe670 100644
--- a/libcesarplayer/baconvideowidget-marshal.list
+++ b/libcesarplayer/baconvideowidget-marshal.list
@@ -2,3 +2,4 @@ VOID:INT64,INT64,DOUBLE,BOOLEAN
VOID:STRING,BOOLEAN,BOOLEAN
BOOLEAN:BOXED,BOXED,BOOLEAN
VOID:INT64,INT64,DOUBLE
+VOID:INT,INT,INT,INT
diff --git a/libcesarplayer/gst-camera-capturer.c b/libcesarplayer/gst-camera-capturer.c
index 9f046e4..78d22f3 100644
--- a/libcesarplayer/gst-camera-capturer.c
+++ b/libcesarplayer/gst-camera-capturer.c
@@ -35,6 +35,7 @@
#include "gstscreenshot.h"
#include "common.h"
#include "video-utils.h"
+#include "baconvideowidget-marshal.h"
GST_DEBUG_CATEGORY (_cesarplayer_gst_debug_cat);
@@ -47,6 +48,7 @@ enum
SIGNAL_EOS,
SIGNAL_STATE_CHANGED,
SIGNAL_DEVICE_CHANGE,
+ SIGNAL_MEDIA_INFO,
LAST_SIGNAL
};
@@ -70,6 +72,8 @@ struct GstCameraCapturerPrivate
/*Video input info */
gint video_width; /* Movie width */
gint video_height; /* Movie height */
+ gint video_par_n;
+ gint video_par_d;
gint video_fps_n;
gint video_fps_d;
@@ -259,6 +263,15 @@ gst_camera_capturer_class_init (GstCameraCapturerClass * klass)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstCameraCapturerClass, device_change),
NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
+
+ gcc_signals[SIGNAL_MEDIA_INFO] =
+ g_signal_new ("media-info",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstCameraCapturerClass, media_info),
+ NULL, NULL,
+ baconvideowidget_marshal_VOID__INT_INT_INT_INT,
+ G_TYPE_NONE, 4, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT);
}
/***********************************
@@ -919,7 +932,7 @@ static gboolean
gst_camera_capturer_fill_decodebin_source (GstCameraCapturer * gcc)
{
GstElement *bin, *decodebin, *colorspace, *deinterlacer;
- GstPad *video_pad, *src_pad;
+ GstPad *video_pad;
GST_INFO_OBJECT (gcc, "Creating dv source");
@@ -1383,9 +1396,14 @@ gcc_get_video_stream_info (GstPad * pad, GstPad * peer, GstCameraCapturer * gcc)
if (!
(gst_structure_get_fraction
(s, "framerate", &gcc->priv->video_fps_n, &gcc->priv->video_fps_d)
+ && gst_structure_get_fraction (s, "pixel-aspect-ratio",
+ &gcc->priv->video_par_n, &gcc->priv->video_par_d)
&& gst_structure_get_int (s, "width", &gcc->priv->video_width)
&& gst_structure_get_int (s, "height", &gcc->priv->video_height)))
return FALSE;
+ g_signal_emit (gcc, gcc_signals[SIGNAL_MEDIA_INFO], 0,
+ gcc->priv->video_width, gcc->priv->video_height,
+ gcc->priv->video_par_n, gcc->priv->video_par_d);
}
return FALSE;
}
diff --git a/libcesarplayer/gst-camera-capturer.h b/libcesarplayer/gst-camera-capturer.h
index 5f8b959..a7829b2 100644
--- a/libcesarplayer/gst-camera-capturer.h
+++ b/libcesarplayer/gst-camera-capturer.h
@@ -55,6 +55,7 @@ struct _GstCameraCapturerClass
void (*eos) (GstCameraCapturer * gcc);
void (*error) (GstCameraCapturer * gcc, const char *message);
void (*device_change) (GstCameraCapturer * gcc, gint *device_change);
+ void (*media_info) (GstCameraCapturer * gcc, gint width, gint height, gint par_n, gint par_d);
};
struct _GstCameraCapturer
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]