[longomatch] Adapt Multimedia to last changes
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Adapt Multimedia to last changes
- Date: Sun, 18 Dec 2011 21:42:10 +0000 (UTC)
commit 9edf0289e8205baf75fd1ebdca106230e17aba5f
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Fri Dec 9 19:54:21 2011 +0100
Adapt Multimedia to last changes
LongoMatch.Multimedia/Common/Enum.cs | 4 --
LongoMatch.Multimedia/Common/Handlers.cs | 11 +----
LongoMatch.Multimedia/Editor/EditorState.cs | 32 -----------
LongoMatch.Multimedia/Editor/GstVideoSplitter.cs | 6 ++-
.../Interfaces/IFramesCapturer.cs | 38 -------------
LongoMatch.Multimedia/Interfaces/IPlayer.cs | 14 ++---
LongoMatch.Multimedia/Interfaces/IVideoEditor.cs | 58 --------------------
LongoMatch.Multimedia/LongoMatch.Multimedia.mdp | 8 ++--
LongoMatch.Multimedia/MultimediaFactory.cs | 29 ++++++++---
LongoMatch.Multimedia/Player/GstPlayer.cs | 17 +++---
LongoMatch.Multimedia/Utils/FramesCapturer.cs | 30 ++++-------
LongoMatch.Multimedia/Utils/PreviewMediaFile.cs | 7 ++-
12 files changed, 60 insertions(+), 194 deletions(-)
---
diff --git a/LongoMatch.Multimedia/Common/Enum.cs b/LongoMatch.Multimedia/Common/Enum.cs
index 8e86481..a4ab87f 100644
--- a/LongoMatch.Multimedia/Common/Enum.cs
+++ b/LongoMatch.Multimedia/Common/Enum.cs
@@ -47,10 +47,6 @@ namespace LongoMatch.Video.Common
EmptyFile,
}
- public enum CapturerType {
- Fake,
- Live,
- }
public enum VideoQuality {
Low = 1000,
diff --git a/LongoMatch.Multimedia/Common/Handlers.cs b/LongoMatch.Multimedia/Common/Handlers.cs
index 64fb353..409a5a4 100644
--- a/LongoMatch.Multimedia/Common/Handlers.cs
+++ b/LongoMatch.Multimedia/Common/Handlers.cs
@@ -22,19 +22,10 @@ using Gdk;
namespace LongoMatch.Video.Common
{
- public delegate void PlayListSegmentDoneHandler();
- public delegate void SegmentClosedHandler();
- public delegate void SegmentDoneHandler();
- public delegate void SeekEventHandler(long pos);
- public delegate void VolumeChangedHandler(double level);
- public delegate void NextButtonClickedHandler();
- public delegate void PrevButtonClickedHandler();
public delegate void ProgressHandler(float progress);
- public delegate void FramesProgressHandler(int actual, int total, Pixbuf frame);
+ public delegate void FramesProgressHandler(int actual, int total, Image frame);
public delegate void DrawFrameHandler(int time);
public delegate void EllpasedTimeHandler(int ellapsedTime);
-
-
public delegate void ErrorHandler(object o, ErrorArgs args);
public delegate void PercentCompletedHandler(object o, PercentCompletedArgs args);
public delegate void StateChangeHandler(object o, StateChangeArgs args);
diff --git a/LongoMatch.Multimedia/Editor/GstVideoSplitter.cs b/LongoMatch.Multimedia/Editor/GstVideoSplitter.cs
index 1be6ac1..9638c69 100644
--- a/LongoMatch.Multimedia/Editor/GstVideoSplitter.cs
+++ b/LongoMatch.Multimedia/Editor/GstVideoSplitter.cs
@@ -23,8 +23,10 @@ namespace LongoMatch.Video.Editor {
using System;
using System.Collections;
using System.Runtime.InteropServices;
+
+ using LongoMatch.Interfaces;
using LongoMatch.Common;
- using LongoMatch.Multimedia.Interfaces;
+ using LongoMatch.Interfaces.Multimedia;
using LongoMatch.Video.Common;
@@ -33,7 +35,7 @@ namespace LongoMatch.Video.Editor {
[DllImport("libcesarplayer.dll")]
static extern unsafe IntPtr gst_video_editor_new(out IntPtr err);
- public event ProgressHandler Progress;
+ public event LongoMatch.Handlers.ProgressHandler Progress;
public unsafe GstVideoSplitter() : base(IntPtr.Zero)
{
diff --git a/LongoMatch.Multimedia/Interfaces/IPlayer.cs b/LongoMatch.Multimedia/Interfaces/IPlayer.cs
index 43b2ab6..3269cf1 100644
--- a/LongoMatch.Multimedia/Interfaces/IPlayer.cs
+++ b/LongoMatch.Multimedia/Interfaces/IPlayer.cs
@@ -20,19 +20,15 @@
using System;
using Gtk;
-using Gdk;
using LongoMatch.Video.Common;
+using Image = LongoMatch.Common.Image;
namespace LongoMatch.Multimedia.Interfaces
{
public interface IPlayer
{
-
-
// Events
-
-
event ErrorHandler Error;
event System.EventHandler Eos;
event StateChangeHandler StateChange;
@@ -68,7 +64,7 @@ namespace LongoMatch.Multimedia.Interfaces
set;
}
- Pixbuf DrawingPixbuf {
+ Image DrawingPixbuf {
set;
}
@@ -90,7 +86,7 @@ namespace LongoMatch.Multimedia.Interfaces
set;
}
- Pixbuf LogoPixbuf {
+ Image LogoPixbuf {
set;
}
@@ -135,9 +131,9 @@ namespace LongoMatch.Multimedia.Interfaces
bool SeekToPreviousFrame(float rate,bool in_segment);
- Pixbuf GetCurrentFrame(int outwidth, int outheight);
+ Image GetCurrentFrame(int outwidth, int outheight);
- Pixbuf GetCurrentFrame();
+ Image GetCurrentFrame();
void CancelProgramedStop();
diff --git a/LongoMatch.Multimedia/LongoMatch.Multimedia.mdp b/LongoMatch.Multimedia/LongoMatch.Multimedia.mdp
index e7708e0..f12d30f 100644
--- a/LongoMatch.Multimedia/LongoMatch.Multimedia.mdp
+++ b/LongoMatch.Multimedia/LongoMatch.Multimedia.mdp
@@ -16,12 +16,10 @@
<Contents>
<File subtype="Code" buildaction="Compile" name="Player/GstPlayer.cs" />
<File subtype="Code" buildaction="Compile" name="Player/ObjectManager.cs" />
- <File subtype="Code" buildaction="Compile" name="Editor/EditorState.cs" />
<File subtype="Code" buildaction="Compile" name="Editor/GstVideoSplitter.cs" />
<File subtype="Code" buildaction="Compile" name="Editor/VideoSegment.cs" />
<File subtype="Code" buildaction="Compile" name="Common/Constants.cs" />
<File subtype="Code" buildaction="Compile" name="Common/Enum.cs" />
- <File subtype="Code" buildaction="Compile" name="Common/Handlers.cs" />
<File subtype="Directory" buildaction="Compile" name="Capturer" />
<File subtype="Code" buildaction="Compile" name="Capturer/ObjectManager.cs" />
<File subtype="Code" buildaction="Compile" name="Capturer/FakeCapturer.cs" />
@@ -50,11 +48,13 @@
<File subtype="Directory" buildaction="Compile" name="Utils" />
<File subtype="Directory" buildaction="Compile" name="Interfaces" />
<File subtype="Code" buildaction="Compile" name="Interfaces/ICapturer.cs" />
- <File subtype="Code" buildaction="Compile" name="Interfaces/IFramesCapturer.cs" />
<File subtype="Code" buildaction="Compile" name="Interfaces/IPlayer.cs" />
- <File subtype="Code" buildaction="Compile" name="Interfaces/IVideoEditor.cs" />
<File subtype="Code" buildaction="Compile" name="Utils/VideoDevice.cs" />
<File subtype="Code" buildaction="Compile" name="Utils/GStreamer.cs" />
+ <File subtype="Directory" buildaction="Compile" name="Interfaces" />
+ <File subtype="Directory" buildaction="Compile" name="Interfaces" />
+ <File subtype="Directory" buildaction="Compile" name="Interfaces" />
+ <File subtype="Code" buildaction="Compile" name="Common/Handlers.cs" />
</Contents>
<References>
<ProjectReference type="Project" localcopy="True" refto="libcesarplayer" />
diff --git a/LongoMatch.Multimedia/MultimediaFactory.cs b/LongoMatch.Multimedia/MultimediaFactory.cs
index 9b34c69..1181a45 100644
--- a/LongoMatch.Multimedia/MultimediaFactory.cs
+++ b/LongoMatch.Multimedia/MultimediaFactory.cs
@@ -19,9 +19,14 @@
//
using System;
+using System.Collections.Generic;
using System.Runtime.InteropServices;
+using LongoMatch.Common;
+using LongoMatch.Interfaces.Multimedia;
using LongoMatch.Multimedia.Interfaces;
+using LongoMatch.Multimedia.Utils;
+using LongoMatch.Store;
using LongoMatch.Video.Capturer;
using LongoMatch.Video.Player;
using LongoMatch.Video.Editor;
@@ -32,7 +37,7 @@ namespace LongoMatch.Video
{
- public class MultimediaFactory
+ public class MultimediaFactory: IMultimediaToolkit
{
OperatingSystem oS;
@@ -42,7 +47,7 @@ namespace LongoMatch.Video
oS = Environment.OSVersion;
}
- public IPlayer getPlayer(int width, int height) {
+ public IPlayer GetPlayer(int width, int height) {
switch(oS.Platform) {
case PlatformID.Unix:
return new GstPlayer(width,height,PlayerUseType.Video);
@@ -55,7 +60,7 @@ namespace LongoMatch.Video
}
}
- public IMetadataReader getMetadataReader() {
+ public IMetadataReader GetMetadataReader() {
switch(oS.Platform) {
case PlatformID.Unix:
@@ -69,7 +74,7 @@ namespace LongoMatch.Video
}
}
- public IFramesCapturer getFramesCapturer() {
+ public IFramesCapturer GetFramesCapturer() {
switch(oS.Platform) {
case PlatformID.Unix:
return new GstPlayer(1,1,PlayerUseType.Capture);
@@ -82,7 +87,7 @@ namespace LongoMatch.Video
}
}
- public IVideoEditor getVideoEditor() {
+ public IVideoEditor GetVideoEditor() {
switch(oS.Platform) {
case PlatformID.Unix:
return new GstVideoSplitter();
@@ -95,7 +100,7 @@ namespace LongoMatch.Video
}
}
- public ICapturer getCapturer(CapturerType type) {
+ public ICapturer GetCapturer(CapturerType type) {
switch(type) {
case CapturerType.Fake:
return new FakeCapturer();
@@ -107,7 +112,17 @@ namespace LongoMatch.Video
return new FakeCapturer();
}
}
-
+
+ public MediaFile DiscoverFile (string file) {
+ return PreviewMediaFile.DiscoverFile(file);
+ }
+
+ public List<Device> VideoDevices {
+ get {
+ return VideoDevice.ListVideoDevices();
+ }
+ }
+
[DllImport("libcesarplayer.dll")]
static extern void gst_init (int argc, string argv);
public static void InitBackend() {
diff --git a/LongoMatch.Multimedia/Player/GstPlayer.cs b/LongoMatch.Multimedia/Player/GstPlayer.cs
index 2774461..6135393 100644
--- a/LongoMatch.Multimedia/Player/GstPlayer.cs
+++ b/LongoMatch.Multimedia/Player/GstPlayer.cs
@@ -21,6 +21,7 @@ namespace LongoMatch.Video.Player {
using System;
using System.Collections;
using System.Runtime.InteropServices;
+ using LongoMatch.Interfaces.Multimedia;
using LongoMatch.Multimedia.Interfaces;
using LongoMatch.Video.Common;
using LongoMatch.Video.Utils;
@@ -1065,18 +1066,18 @@ namespace LongoMatch.Video.Player {
[DllImport("libcesarplayer.dll")]
static extern void bacon_video_widget_set_logo_pixbuf(IntPtr raw, IntPtr logo);
- public Gdk.Pixbuf LogoPixbuf {
+ public LongoMatch.Common.Image LogoPixbuf {
set {
- bacon_video_widget_set_logo_pixbuf(Handle, value == null ? IntPtr.Zero : value.Handle);
+ bacon_video_widget_set_logo_pixbuf(Handle, value.Value == null ? IntPtr.Zero : value.Value.Handle);
}
}
[DllImport("libcesarplayer.dll")]
static extern void bacon_video_widget_set_drawing_pixbuf(IntPtr raw, IntPtr drawing_mode);
- public Gdk.Pixbuf DrawingPixbuf {
+ public LongoMatch.Common.Image DrawingPixbuf {
set {
- bacon_video_widget_set_drawing_pixbuf(Handle, value == null ? IntPtr.Zero : value.Handle);
+ bacon_video_widget_set_drawing_pixbuf(Handle, value.Value == null ? IntPtr.Zero : value.Value.Handle);
}
}
@@ -1133,7 +1134,7 @@ namespace LongoMatch.Video.Player {
static extern IntPtr bacon_video_widget_unref_pixbuf(IntPtr raw);
- public Gdk.Pixbuf GetCurrentFrame(int outwidth, int outheight) {
+ public LongoMatch.Common.Image GetCurrentFrame(int outwidth, int outheight) {
IntPtr raw_ret = bacon_video_widget_get_current_frame(Handle);
Gdk.Pixbuf unmanaged = GLib.Object.GetObject(raw_ret) as Gdk.Pixbuf;
if(unmanaged == null)
@@ -1153,10 +1154,10 @@ namespace LongoMatch.Video.Player {
managed = unmanaged.ScaleSimple(outwidth,outheight,Gdk.InterpType.Bilinear);
unmanaged.Dispose();
bacon_video_widget_unref_pixbuf(raw_ret);
- return managed;
+ return new LongoMatch.Common.Image(managed);
}
- public Gdk.Pixbuf GetCurrentFrame() {
+ public LongoMatch.Common.Image GetCurrentFrame() {
return GetCurrentFrame(-1,-1);
}
@@ -1411,6 +1412,6 @@ namespace LongoMatch.Video.Player {
public void CancelProgramedStop() {
this.SegmentSeek(this.CurrentTime,this.StreamLength,1);
}
-
+
}
}
diff --git a/LongoMatch.Multimedia/Utils/FramesCapturer.cs b/LongoMatch.Multimedia/Utils/FramesCapturer.cs
index 47018b4..4bb43f3 100644
--- a/LongoMatch.Multimedia/Utils/FramesCapturer.cs
+++ b/LongoMatch.Multimedia/Utils/FramesCapturer.cs
@@ -19,12 +19,12 @@
//
using System;
-using LongoMatch.Video.Utils;
-using LongoMatch.Video;
-using Gdk;
-using Gtk;
using System.Threading;
-using LongoMatch.Multimedia.Interfaces;
+using Gtk;
+
+using LongoMatch.Common;
+using LongoMatch.Interfaces.Multimedia;
+using LongoMatch.Video;
using LongoMatch.Video.Common;
namespace LongoMatch.Video.Utils
@@ -44,12 +44,12 @@ namespace LongoMatch.Video.Utils
private const int THUMBNAIL_MAX_HEIGHT=250;
private const int THUMBNAIL_MAX_WIDTH=300;
- public event FramesProgressHandler Progress;
+ public event LongoMatch.Handlers.FramesProgressHandler Progress;
public FramesSeriesCapturer(string videoFile,long start, long stop, uint interval, string outputDir)
{
MultimediaFactory mf= new MultimediaFactory();
- this.capturer=mf.getFramesCapturer();
+ this.capturer=mf.GetFramesCapturer();
this.capturer.Open(videoFile);
this.start= start;
this.stop = stop;
@@ -70,8 +70,7 @@ namespace LongoMatch.Video.Utils
public void CaptureFrames() {
long pos;
- Pixbuf frame;
- Pixbuf scaledFrame=null;
+ LongoMatch.Common.Image frame;
int i = 0;
System.IO.Directory.CreateDirectory(outputDir);
@@ -87,20 +86,13 @@ namespace LongoMatch.Video.Utils
capturer.Pause();
frame = capturer.GetCurrentFrame();
if(frame != null) {
- frame.Save(System.IO.Path.Combine(outputDir,seriesName+"_" + i +".png"),"png");
- int h = frame.Height;
- int w = frame.Width;
- double rate = (double)w/(double)h;
- if(h>w)
- scaledFrame = frame.ScaleSimple((int)(THUMBNAIL_MAX_HEIGHT*rate),THUMBNAIL_MAX_HEIGHT,InterpType.Bilinear);
- else
- scaledFrame = frame.ScaleSimple(THUMBNAIL_MAX_WIDTH,(int)(THUMBNAIL_MAX_WIDTH/rate),InterpType.Bilinear);
- frame.Dispose();
+ frame.Save(System.IO.Path.Combine(outputDir,seriesName+"_" + i +".png"));
+ frame.Scale(THUMBNAIL_MAX_WIDTH, THUMBNAIL_MAX_HEIGHT);
}
if(Progress != null)
Application.Invoke(delegate {
- Progress(i+1,totalFrames,scaledFrame);
+ Progress(i+1, totalFrames, frame);
});
pos += interval;
i++;
diff --git a/LongoMatch.Multimedia/Utils/PreviewMediaFile.cs b/LongoMatch.Multimedia/Utils/PreviewMediaFile.cs
index 6015449..570ad35 100644
--- a/LongoMatch.Multimedia/Utils/PreviewMediaFile.cs
+++ b/LongoMatch.Multimedia/Utils/PreviewMediaFile.cs
@@ -17,6 +17,7 @@
//
using System;
+using LongoMatch.Interfaces.Multimedia;
using LongoMatch.Multimedia.Interfaces;
using LongoMatch.Store;
using LongoMatch.Video;
@@ -44,14 +45,14 @@ namespace LongoMatch.Video.Utils
int fps=0;
int height=0;
int width=0;
- Pixbuf preview=null;
+ LongoMatch.Common.Image preview=null;
MultimediaFactory factory;
IMetadataReader reader;
IFramesCapturer thumbnailer;
try {
factory = new MultimediaFactory();
- reader = factory.getMetadataReader();
+ reader = factory.GetMetadataReader();
reader.Open(filePath);
hasVideo = (bool) reader.GetMetadata(MetadataType.HasVideo);
hasAudio = (bool) reader.GetMetadata(MetadataType.HasAudio);
@@ -61,7 +62,7 @@ namespace LongoMatch.Video.Utils
if(hasVideo) {
VideoEncoderType = (string) reader.GetMetadata(MetadataType.VideoEncoderType);
fps = (int) reader.GetMetadata(MetadataType.Fps);
- thumbnailer = factory.getFramesCapturer();
+ thumbnailer = factory.GetFramesCapturer();
thumbnailer.Open(filePath);
thumbnailer.SeekTime(1000,false);
preview = thumbnailer.GetCurrentFrame(THUMBNAIL_MAX_WIDTH,THUMBNAIL_MAX_HEIGHT);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]