SourceDescriptions.cs.svn-base
1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// Camara Vision
//
// Copyright © Andrew Kirillov, 2005-2006
// andrew.kirillov@gmail.com
//
namespace mjpeg
{
using System;
using System.Xml;
using videosource;
/// <summary>
/// MJPEGSourceDescription
/// </summary>
public class MJPEGSourceDescription : IVideoSourceDescription
{
// Name property
public string Name
{
get { return "MJPEG stream"; }
}
// Description property
public string Description
{
get { return "Retrieve Motion JPEG stream from the specified URL"; }
}
// Return settings page
public IVideoSourcePage GetSettingsPage()
{
return new MJPEGSourcePage();
}
// Save configuration
public void SaveConfiguration(XmlTextWriter writer, object config)
{
MJPEGConfiguration cfg = (MJPEGConfiguration) config;
if (cfg != null)
{
writer.WriteAttributeString("source", cfg.source);
writer.WriteAttributeString("login", cfg.login);
writer.WriteAttributeString("password", cfg.password);
}
}
// Load configuration
public object LoadConfiguration(XmlTextReader reader)
{
MJPEGConfiguration config = new MJPEGConfiguration();
try
{
config.source = reader.GetAttribute("source");
config.login = reader.GetAttribute("login");
config.password = reader.GetAttribute("password");
}
catch (Exception)
{
}
return (object) config;
}
// Create video source object
public IVideoSource CreateVideoSource(object config)
{
MJPEGConfiguration cfg = (MJPEGConfiguration) config;
if (cfg != null)
{
MJPEGSource source = new MJPEGSource();
source.VideoSource = cfg.source;
source.Login = cfg.login;
source.Password = cfg.password;
return (IVideoSource) source;
}
return null;
}
}
}