first, we can capture the video stream of the camera in Silverlight Chinese. We can create a class and inherit from the videosink class. The videosink class is an abstract class (located in system. windows. in the media namespace (s), we need to implement the four methods
public abstract class videosink
{< br> Public videosink ();
Public capturesource {Get; Set ;}< br> protected abstract void oncapturestarted ();
protected abstract void oncapturestopped ();
protected abstract void onformatchange (videoformat);
// Sampledata is the data captured every 100 nanoseconds.
// The captured data streams can be stored in the appropriate carrier.
// Or encode or compress the data stream
Protected abstract void onsample (long sampletimeinhundrednanoseconds, long framedurationinhundrednanoseconds, byte [] sampledata );
}
Then, assign our capturesource to the capturesource in videosink so that videosink will automatically capture the data in the camera.
Although the data can be captured, in fact, I did capture the data, but the problem is that the captured data is too large. I tested that each 100 s of captured data can contain more than MB, if this huge amount of data is not processed, you can imagine how huge the data will be produced when we record a few minutes of video! I do not know video encoding, and Microsoft does not provide a dedicated coding tool in Silverlight. Therefore, the camera function is a good-looking and useful thing at present!
In fact, there is another problem, that is, the videosink is unstable when capturing data, which often leads to onformatchange. Once onformatchange occurs, the data capture will stop, I have not found a solution to this problem yet. I hope someone can give me some advice!