-
Notifications
You must be signed in to change notification settings - Fork 74
/
Copy pathBackEndCapture.h
executable file
·110 lines (87 loc) · 3.24 KB
/
BackEndCapture.h
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
//
// This is the source code of Telegram for Windows Phone v. 3.x.x.
// It is licensed under GNU GPL v. 2 or later.
// You should have received a copy of the license in this archive (see LICENSE).
//
// Copyright Evgeny Nadymov, 2013-present.
//
#pragma once
#include "windows.h"
#include "implements.h"
#include "ICallControllerStatusListener.h"
#include "BackEndTransport.h"
#include <Windows.Phone.Media.Capture.h>
#include <Windows.Phone.Media.Capture.Native.h>
namespace PhoneVoIPApp
{
namespace BackEnd
{
public delegate void CameraLocationChangedEventHandler(PhoneVoIPApp::BackEnd::CameraLocation);
class CaptureSampleSink :
public Microsoft::WRL::RuntimeClass<
Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::RuntimeClassType::ClassicCom>,
ICameraCaptureSampleSink>
{
DWORD m_dwSampleCount;
BackEndTransport ^m_transport;
public:
STDMETHODIMP RuntimeClassInitialize(BackEndTransport ^transportController)
{
m_dwSampleCount = 0;
m_transport = transportController;
return S_OK;
}
DWORD GetSampleCount()
{
return m_dwSampleCount;
}
IFACEMETHODIMP_(void)
OnSampleAvailable(
ULONGLONG hnsPresentationTime,
ULONGLONG hnsSampleDuration,
DWORD cbSample,
BYTE* pSample)
{
m_dwSampleCount++;
if (m_transport)
{
m_transport->WriteVideo(pSample, cbSample, hnsPresentationTime, hnsSampleDuration);
}
}
void SetTransport(BackEndTransport ^transport)
{
m_transport = transport;
}
};
public ref class BackEndCapture sealed
{
public:
// Constructor
BackEndCapture();
void SetTransport(BackEndTransport^ transport);
void Start(CameraLocation cameraLocation);
void Stop();
void ToggleCamera();
event CameraLocationChangedEventHandler^ CameraLocationChanged;
private:
// Destructor
~BackEndCapture();
void InitCapture();
void ToggleCameraThread(Windows::Foundation::IAsyncAction^ operation);
// Has capture started?
bool started;
// Events to signal whether capture has stopped/started
HANDLE hStopCompleted;
HANDLE hStartCompleted;
Windows::Foundation::IAsyncAction^ m_ToggleThread;
// Transport
BackEndTransport^ transportController;
// Native sink and video device
CaptureSampleSink *pVideoSink;
IAudioVideoCaptureDeviceNative *pVideoDevice;
Windows::Phone::Media::Capture::CameraSensorLocation cameraLocation;
Windows::Phone::Media::Capture::AudioVideoCaptureDevice ^videoOnlyDevice;
Windows::Foundation::IAsyncAction ^videoCaptureAction;
};
}
}