- Posts: 2
- Joined: Tue Dec 29, 2015 7:05 am
I'm trying to use H.264ProRecorder and capture image data by using C sharp Form application
But I got InvalidCastExeption when casting IDeckLink instance object to IBMDStreamingDeviceInput as follows.
Could you suggest me what is the proper way to do it?
Here's my minimum code
Somehow starting it by MTA or casting to it by another thread (not main thread) doesn't throw any Exception. Is this a best solution?
Software:::::Visual Studio 2013 Professional, .Net framework 4.5, Visual C# Form Appication
Environment:::::Windows 7 Professional 64bit, Intel(R) Core(TM) i7-4470/3.4GHz, RAN16GB
But I got InvalidCastExeption when casting IDeckLink instance object to IBMDStreamingDeviceInput as follows.
Could you suggest me what is the proper way to do it?
Here's my minimum code
- Code: Select all
using System;
using System.Windows.Forms;
using DeckLinkAPI
namespace Test
{
public partial class Form1 : Form, IBMDStreamingDeviceNotifiationCallback
{
private IDeckLink device;
private CBMDStreamingDiscovery discovery;
public Form1()
{
InitializeComponent();
this.discovery = new CBMDStreamingDiscovery();
this.discovery.InstallDeviceNotification(this);
}
private void button_start_Click(object sender, EventArgs e)
{
// this line throws InvalidCastException (HRESULT 0x80004002)
var input = (IBMDStreamingDeviceInput)this.device;
input.StartCapture();
}
public void StreamingDeviceArrived(IDeckLink device)
{
this.device = device;
}
public void StreamingDeviceModeChanged(IDeckLink device, _BMDStreamingDeviceMode mode)
{
}
public void StreamingDeviceRemoved(IDeckLink device)
{
}
}
}
Somehow starting it by MTA or casting to it by another thread (not main thread) doesn't throw any Exception. Is this a best solution?
Software:::::Visual Studio 2013 Professional, .Net framework 4.5, Visual C# Form Appication
Environment:::::Windows 7 Professional 64bit, Intel(R) Core(TM) i7-4470/3.4GHz, RAN16GB