Reputation: 7170
i need to build a simple application who allow to record 2 or more video stream (max. 4) from ipcam / webcam, like a very simple surveillance system. What component (dll or similar) can you indicate to me ?
Upvotes: 0
Views: 406
Reputation: 3534
it will be a multithreaded application. in which each thread (worker) records from a source (usb video) to a destination (file stream).
you could do something like this (pseudo c#) i hope it gives you a basic idea...
class Worker
{
bool _record;
ISource _source;
IDestination _dest;
public Worker(ISource source, IDestination dest)
{
_source = source;
_dest = dest;
}
public void Record()
{
lock(this)
_record = true;
pos = 0;
while(_record)
{
var buffer = new byte[4096];
len = _source.Read(pos, buffer);
pos += len;
dest.Write(buffer, len);
}
}
public void Stop()
{
lock (this)
_record = false;
}
}
class Program
{
public static Main()
{
var w1 = new Worker(new UsbVideo(), new FileDestination());
Thread.Start(w1.Record);
...
Console.Readline();
w1.Stop();
}
}
Upvotes: 1