Commit b9413243 authored by Ghislain MARY's avatar Ghislain MARY

Refactor capture to add failure handler.

parent bbf0b47b
This diff is collapsed.
......@@ -41,6 +41,43 @@ using namespace Windows::Media::MediaProperties;
namespace libmswinrtvid
{
ref class MSWinRTCapHelper sealed {
internal:
MSWinRTCapHelper();
bool Initialize(Platform::String^ DeviceId);
bool StartPreview(int DeviceOrientation);
void StopPreview();
bool StartCapture(Windows::Media::MediaProperties::MediaEncodingProfile^ EncodingProfile);
void StopCapture();
void MSWinRTCapHelper::OnSampleAvailable(BYTE *buf, DWORD bufLen, LONGLONG presentationTime);
MSVideoSize SelectBestVideoSize(MSVideoSize vs);
mblk_t * GetSample();
property Platform::Agile<MediaCapture^> CaptureDevice
{
Platform::Agile<MediaCapture^> get() { return mCapture; }
}
private:
~MSWinRTCapHelper();
void OnCaptureFailed(Windows::Media::Capture::MediaCapture^ sender, Windows::Media::Capture::MediaCaptureFailedEventArgs^ errorEventArgs);
HANDLE mInitializationCompleted;
HANDLE mStartCompleted;
HANDLE mStopCompleted;
HANDLE mPreviewStartCompleted;
HANDLE mPreviewStopCompleted;
const GUID mRotationKey;
Platform::Agile<MediaCapture^> mCapture;
Windows::Foundation::EventRegistrationToken mMediaCaptureFailedEventRegistrationToken;
ComPtr<IMFMediaSink> mMediaSink;
MediaEncodingProfile^ mEncodingProfile;
int mDeviceOrientation;
ms_mutex_t mMutex;
MSYuvBufAllocator *mAllocator;
MSQueue mSamplesQueue;
};
class MSWinRTCap {
public:
MSWinRTCap();
......@@ -87,26 +124,14 @@ namespace libmswinrtvid
float mFps;
MSAverageFPS mAvgFps;
MSVideoSize mVideoSize;
MSQueue mSampleToSendQueue;
MSQueue mSampleToFreeQueue;
ms_mutex_t mMutex;
MSYuvBufAllocator *mAllocator;
uint64_t mStartTime;
int mCameraSensorRotation;
int mDeviceOrientation;
MSVideoStarter mStarter;
HANDLE mInitializationCompleted;
HANDLE mStartCompleted;
HANDLE mStopCompleted;
HANDLE mPreviewStartCompleted;
HANDLE mPreviewStopCompleted;
Windows::UI::Xaml::Controls::CaptureElement^ mCaptureElement;
Platform::String^ mDeviceId;
bool mFront;
bool mExternal;
Platform::Agile<MediaCapture^> mCapture;
MSWinRTCapHelper^ mHelper;
MediaEncodingProfile^ mEncodingProfile;
ComPtr<IMFMediaSink> mMediaSink;
const GUID mRotationKey;
};
}
......@@ -1306,7 +1306,7 @@ void MSWinRTMediaSink::ReportEndOfStream()
void MSWinRTMediaSink::OnSampleAvailable(BYTE *buf, DWORD bufLen, LONGLONG presentationTime)
{
MSWINRTMEDIASINK_DEBUG("MSWinRTMediaSink::OnSampleAvailable");
if (_capture != NULL) {
if (_capture != nullptr) {
_capture->OnSampleAvailable(buf, bufLen, presentationTime);
}
}
......@@ -31,7 +31,7 @@ using namespace Windows::Media::MediaProperties;
namespace libmswinrtvid {
class MSWinRTCap;
ref class MSWinRTCapHelper;
class MSWinRTMediaSink;
......@@ -361,7 +361,7 @@ namespace libmswinrtvid {
LONGLONG GetStartTime() const { return _llStartTime; }
void ReportEndOfStream();
void SetCaptureFilter(MSWinRTCap *capture) { _capture = capture; }
void SetCaptureFilter(MSWinRTCapHelper^ capture) { _capture = capture; }
void OnSampleAvailable(BYTE *buf, DWORD bufLen, LONGLONG presentationTime);
private:
......@@ -378,7 +378,7 @@ namespace libmswinrtvid {
private:
ComPtr<IMFStreamSink> _stream;
MSWinRTCap *_capture;
MSWinRTCapHelper^ _capture;
long _cRef; // reference count
CritSec _critSec; // critical section for thread safety
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment