Skip to content

Commit 40f5bea

Browse files
author
Sergej Jovanovic
authored
Merge pull request #20 from webrtc-uwp/Robin/m71-dot-net
Robin/m71 dot net
2 parents e6fa33c + dec3a61 commit 40f5bea

File tree

83 files changed

+2638
-1741
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+2638
-1741
lines changed

idl/MediaElement.idl

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,26 +38,13 @@ namespace org
3838
/// <summary>
3939
/// MediaSource represents an object holder for a platform specific media element.
4040
/// </summary>
41-
[special]
42-
struct MediaElement
41+
interface MediaElement
4342
{
4443
/// <summary>
4544
/// Constructs a media element object.
4645
/// </summary>
4746
[constructor, delete]
4847
void MediaElement();
49-
50-
/// <summary>
51-
/// Constructs a media element object from a native media element type.
52-
/// </summary>
53-
[constructor, default, altname(MediaElementWithNativeQueue)]
54-
void MediaElement(Any element);
55-
56-
/// <summary>
57-
/// Gets the platform specific media element.
58-
/// </summary>
59-
[getter]
60-
Any element;
6148
};
6249

6350

idl/VideoBuffers.idl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ namespace org
107107
VideoFrameNativeBuffer nativeFrame;
108108
};
109109

110+
[disposable]
110111
interface VideoFramePlanarYuvBuffer : VideoFrameBuffer
111112
{
112113
[constructor, default, delete]
@@ -155,6 +156,7 @@ namespace org
155156
VideoData v;
156157
};
157158

159+
[disposable]
158160
interface VideoFramePlanarYuvaBuffer : VideoFramePlanarYuvBuffer
159161
{
160162
[constructor, default, delete]
@@ -171,6 +173,7 @@ namespace org
171173
VideoData a;
172174
};
173175

176+
[disposable]
174177
interface VideoFrameNativeBuffer : VideoFrameBuffer
175178
{
176179
[constructor, default, delete]

windows/wrapper/impl_org_webRtc_EventQueue.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11

2-
#ifdef WINUWP
3-
42
#ifdef __has_include
53
#if __has_include(<winrt/windows.ui.core.h>)
64
#include <winrt/windows.ui.core.h>
75
#endif //__has_include(<winrt/windows.ui.core.h>)
86
#endif //__has_include
97

10-
#else
11-
128
#include <zsLib/IMessageQueue.h>
13-
#endif //WINUWP
149

1510
#include "impl_org_webRtc_EventQueue.h"
1611
#include "impl_org_webRtc_helpers.h"
@@ -92,7 +87,6 @@ wrapper::org::webRtc::EventQueuePtr wrapper::org::webRtc::EventQueue::getDefault
9287
return result;
9388
}
9489

95-
#ifdef WINUWP
9690
#ifdef CPPWINRT_VERSION
9791

9892
wrapper::org::webRtc::EventQueuePtr wrapper::impl::org::webRtc::EventQueue::toWrapper(winrt::Windows::UI::Core::CoreDispatcher queue) noexcept
@@ -117,8 +111,6 @@ winrt::Windows::UI::Core::CoreDispatcher wrapper::impl::org::webRtc::EventQueue:
117111

118112
#endif // CPPWINRT_VERSION
119113

120-
#endif //WINUWP
121-
122114
wrapper::org::webRtc::EventQueuePtr wrapper::impl::org::webRtc::EventQueue::toWrapper(::zsLib::IMessageQueuePtr queue) noexcept
123115
{
124116
if (!queue)
@@ -136,7 +128,9 @@ ::zsLib::IMessageQueuePtr wrapper::impl::org::webRtc::EventQueue::toNative(wrapp
136128
auto converted = ZS_DYNAMIC_PTR_CAST(WrapperImplType, queue);
137129
if (!converted)
138130
return {};
131+
#ifdef CPPWINRT_VERSION
139132
if (converted->dispatcher_)
140133
return zsLib::IMessageQueueDispatcher::create(converted->dispatcher_);
134+
#endif //CPPWINRT_VERSION
141135
return converted->queue_;
142136
}

windows/wrapper/impl_org_webRtc_EventQueue.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11

22
#pragma once
33

4-
#ifdef WINUWP
5-
64
#ifdef __has_include
75
#if __has_include(<winrt/windows.ui.core.h>)
86
#include <winrt/windows.ui.core.h>
97
#endif //__has_include(<winrt/windows.ui.core.h>)
108
#endif //__has_include
119

12-
#endif //WINUWP
13-
1410
#include "types.h"
1511
#include "generated/org_webRtc_EventQueue.h"
1612

@@ -27,22 +23,16 @@ namespace wrapper {
2723

2824
EventQueueWeakPtr thisWeak_;
2925

30-
#ifdef WINUWP
3126
#ifdef CPPWINRT_VERSION
3227
winrt::Windows::UI::Core::CoreDispatcher dispatcher_ {nullptr};
3328
#endif // CPPWINRT_VERSION
34-
#endif //WINUWP
3529
zsLib::IMessageQueuePtr queue_;
3630

3731
EventQueue() noexcept;
3832
virtual ~EventQueue() noexcept;
3933

40-
#ifdef WINUWP
41-
#ifdef CPPWINRT_VERSION
4234
ZS_NO_DISCARD() static wrapper::org::webRtc::EventQueuePtr toWrapper(winrt::Windows::UI::Core::CoreDispatcher queue) noexcept;
4335
ZS_NO_DISCARD() static winrt::Windows::UI::Core::CoreDispatcher toNative_winrt(WrapperTypePtr queue) noexcept;
44-
#endif // CPPWINRT_VERSION
45-
#endif //WINUWP
4636
ZS_NO_DISCARD() static wrapper::org::webRtc::EventQueuePtr toWrapper(::zsLib::IMessageQueuePtr queue) noexcept;
4737
ZS_NO_DISCARD() static ::zsLib::IMessageQueuePtr toNative(WrapperTypePtr queue) noexcept;
4838

Lines changed: 24 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11

2-
#ifdef WINUWP
3-
42
#ifdef __has_include
53
#if __has_include(<winrt/Windows.UI.Xaml.Controls.h>)
64
#include <winrt/Windows.UI.Xaml.Controls.h>
75
#endif //__has_include(<winrt/Windows.UI.Xaml.Controls.h>)
86
#endif //__has_include
97

10-
#else
11-
8+
#ifndef WINUWP
129
#ifdef _WIN32
10+
#include <WinSock2.h>
1311
#include <Windows.h>
1412
#endif //_WIN32
15-
16-
#endif //WINUWP
13+
#endif //ndef WINUWP
1714

1815
#include "impl_org_webRtc_MediaElement.h"
1916
#include "impl_org_webRtc_helpers.h"
@@ -40,35 +37,6 @@ using ::std::map;
4037
ZS_DECLARE_TYPEDEF_PTR(wrapper::impl::org::webRtc::MediaElement::WrapperImplType, WrapperImplType);
4138
ZS_DECLARE_TYPEDEF_PTR(WrapperImplType::WrapperType, WrapperType);
4239

43-
#ifdef WINUWP
44-
45-
#ifdef CPPWINRT_VERSION
46-
47-
namespace wrapper { namespace impl { namespace org { namespace webRtc {
48-
ZS_DECLARE_STRUCT_PTR(MediaElementWrapperAnyCx);
49-
50-
struct MediaElementWrapperAnyWinrt : Any
51-
{
52-
winrt::Windows::UI::Xaml::Controls::MediaElement element_ {nullptr};
53-
};
54-
} } } }
55-
56-
#endif // CPPWINRT_VERSION
57-
58-
#else
59-
60-
61-
namespace wrapper { namespace impl { namespace org { namespace webRtc {
62-
ZS_DECLARE_STRUCT_PTR(MediaElementWrapperAny);
63-
64-
struct MediaElementWrapperAny : Any
65-
{
66-
HWND element_ {};
67-
};
68-
} } } }
69-
70-
#endif //WINUWP
71-
7240
//------------------------------------------------------------------------------
7341
wrapper::impl::org::webRtc::MediaElement::MediaElement() noexcept
7442
{
@@ -88,67 +56,49 @@ wrapper::impl::org::webRtc::MediaElement::~MediaElement() noexcept
8856
thisWeak_.reset();
8957
}
9058

91-
//------------------------------------------------------------------------------
92-
void wrapper::impl::org::webRtc::MediaElement::wrapper_init_org_webRtc_MediaElement(AnyPtr element) noexcept
93-
{
94-
ZS_ASSERT(element);
95-
element_ = element;
96-
}
9759

98-
//------------------------------------------------------------------------------
99-
AnyPtr wrapper::impl::org::webRtc::MediaElement::get_element() noexcept
100-
{
101-
return element_;
102-
}
103-
104-
105-
#ifdef WINUWP
10660
#ifdef CPPWINRT_VERSION
10761

10862
wrapper::org::webRtc::MediaElementPtr wrapper::impl::org::webRtc::MediaElement::toWrapper(winrt::Windows::UI::Xaml::Controls::MediaElement const & element) noexcept
10963
{
110-
auto any{ make_shared<wrapper::impl::org::webRtc::MediaElementWrapperAnyWinrt>() };
111-
any->element_ = element;
11264
auto result = make_shared<WrapperImplType>();
11365
result->thisWeak_ = result;
114-
result->element_ = any;
66+
result->elementXaml_ = element;
11567
return result;
11668
}
11769

118-
winrt::Windows::UI::Xaml::Controls::MediaElement wrapper::impl::org::webRtc::MediaElement::toNative_winrt(wrapper::org::webRtc::MediaElementPtr element) noexcept
70+
winrt::Windows::UI::Xaml::Controls::MediaElement wrapper::impl::org::webRtc::MediaElement::toNative_winrt(wrapper::org::webRtc::MediaElementPtr wrapper) noexcept
11971
{
120-
if (!element)
121-
return {nullptr};
122-
AnyPtr any = element->get_element();
123-
if (!any) return nullptr;
124-
auto castedAny = ZS_DYNAMIC_PTR_CAST(wrapper::impl::org::webRtc::MediaElementWrapperAnyWinrt, any);
125-
if (!castedAny)
126-
return {nullptr};
127-
return castedAny->element_;
72+
if (!wrapper) return {nullptr};
73+
auto converted = ZS_DYNAMIC_PTR_CAST(WrapperImplType, wrapper);
74+
ZS_ASSERT(converted);
75+
if (!converted) return {nullptr};
76+
return converted->elementXaml_;
12877
}
12978

13079
#endif // CPPWINRT_VERSION
13180

132-
#else
81+
#ifndef WINUWP
82+
#ifdef _WIN32
13383

13484
wrapper::org::webRtc::MediaElementPtr wrapper::impl::org::webRtc::MediaElement::toWrapper(HWND element) noexcept
13585
{
136-
auto any{ make_shared<wrapper::impl::org::webRtc::MediaElementWrapperAny>() };
137-
any->element_ = element;
138-
auto result = wrapper::org::webRtc::MediaElement::wrapper_create();
139-
any->element_ = element;
86+
if (NULL == element) return {};
87+
auto result = std::make_shared<WrapperImplType>();
88+
result->thisWeak_ = result;
89+
result->elementHwnd_ = element;
14090
return result;
14191
}
14292

143-
HWND wrapper::impl::org::webRtc::MediaElement::toNative(wrapper::org::webRtc::MediaElementPtr element) noexcept
93+
HWND wrapper::impl::org::webRtc::MediaElement::toNative(wrapper::org::webRtc::MediaElementPtr wrapper) noexcept
14494
{
145-
if (!element) return nullptr;
146-
AnyPtr any = element->get_element();
147-
if (!any) return nullptr;
148-
auto castedAny = ZS_DYNAMIC_PTR_CAST(wrapper::impl::org::webRtc::MediaElementWrapperAny, any);
149-
if (!castedAny) return nullptr;
150-
return castedAny->element_;
95+
if (!wrapper) return {};
96+
auto converted = ZS_DYNAMIC_PTR_CAST(WrapperImplType, wrapper);
97+
ZS_ASSERT(converted);
98+
if (!converted) return {};
99+
return converted->elementHwnd_;
151100
}
152101

153-
#endif //WINUWP
102+
#endif //_WIN32
103+
#endif //ndef WINUWP
154104

windows/wrapper/impl_org_webRtc_MediaElement.h

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,30 @@ namespace wrapper {
2121
AnyPtr element_{};
2222
MediaElementWeakPtr thisWeak_;
2323

24-
MediaElement() noexcept;
25-
virtual ~MediaElement() noexcept;
26-
24+
#ifdef CPPWINRT_VERSION
25+
winrt::Windows::UI::Xaml::Controls::MediaElement elementXaml_ {nullptr};
26+
#endif // CPPWINRT_VERSION
2727

28-
// methods MediaElement
29-
void wrapper_init_org_webRtc_MediaElement(AnyPtr element) noexcept override;
28+
#ifndef WINUWP
29+
#ifdef _WIN32
30+
HWND elementHwnd_{};
31+
#endif //_WIN32
32+
#endif //ndef WINUWP
3033

31-
// properties MediaElement
32-
AnyPtr get_element() noexcept override;
34+
MediaElement() noexcept;
35+
virtual ~MediaElement() noexcept;
3336

34-
#ifdef WINUWP
3537
#ifdef CPPWINRT_VERSION
3638
ZS_NO_DISCARD() static wrapper::org::webRtc::MediaElementPtr toWrapper(winrt::Windows::UI::Xaml::Controls::MediaElement const & element) noexcept;
37-
ZS_NO_DISCARD() static winrt::Windows::UI::Xaml::Controls::MediaElement toNative_winrt(wrapper::org::webRtc::MediaElementPtr element) noexcept;
39+
ZS_NO_DISCARD() static winrt::Windows::UI::Xaml::Controls::MediaElement toNative_winrt(wrapper::org::webRtc::MediaElementPtr wrapper) noexcept;
3840
#endif // CPPWINRT_VERSION
39-
#else
41+
42+
#ifndef WINUWP
4043
#ifdef _WIN32
4144
ZS_NO_DISCARD() static wrapper::org::webRtc::MediaElementPtr toWrapper(HWND element) noexcept;
42-
ZS_NO_DISCARD() static element toNative(wrapper::org::webRtc::MediaElementPtr element) noexcept;
45+
ZS_NO_DISCARD() static HWND toNative(wrapper::org::webRtc::MediaElementPtr wrapper) noexcept;
4346
#endif //_WIN32
44-
#endif //WINUWP
47+
#endif //ndef WINUWP
4548

4649
};
4750

windows/wrapper/impl_org_webRtc_MediaSample.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11

2-
#ifdef WINUWP
3-
42
#ifdef __has_include
53
#if __has_include(<winrt/base.h>)
64
#include <winrt/base.h>
75
#endif //__has_include(<winrt/base.h>)
86
#endif //__has_include
97

10-
#else
11-
8+
#ifndef WINUWP
129
#ifdef _WIN32
10+
#include <WinSock2.h>
1311
#include <Windows.h>
1412
#endif //_WIN32
15-
1613
#endif //WINUWP
1714

1815
#include "impl_org_webRtc_MediaSample.h"
@@ -59,7 +56,6 @@ wrapper::impl::org::webRtc::MediaSample::~MediaSample() noexcept
5956
thisWeak_.reset();
6057
}
6158

62-
#ifdef WINUWP
6359
#ifdef CPPWINRT_VERSION
6460
//------------------------------------------------------------------------------
6561
void wrapper::impl::org::webRtc::MediaSample::wrapper_dispose() noexcept
@@ -87,5 +83,3 @@ winrt::com_ptr<IMFSample> wrapper::impl::org::webRtc::MediaSample::toNative(wrap
8783
}
8884

8985
#endif // CPPWINRT_VERSION
90-
#endif //WINUWP
91-

windows/wrapper/impl_org_webRtc_MediaSample.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,20 @@ namespace wrapper {
1818

1919
MediaSampleWeakPtr thisWeak_;
2020
zsLib::Lock lock_;
21-
#ifdef WINUWP
21+
2222
#ifdef CPPWINRT_VERSION
2323
winrt::com_ptr<IMFSample> sample_;
2424
#endif //CPPWINRT_VERSION
25-
#endif //WINUWP
2625

2726
MediaSample() noexcept;
2827
virtual ~MediaSample() noexcept;
2928

3029
void wrapper_dispose() noexcept override;
3130

32-
#ifdef WINUWP
3331
#ifdef CPPWINRT_VERSION
3432
ZS_NO_DISCARD() static wrapper::org::webRtc::MediaSamplePtr toWrapper(winrt::com_ptr<IMFSample> const & sample) noexcept;
3533
ZS_NO_DISCARD() static winrt::com_ptr<IMFSample> toNative(wrapper::org::webRtc::MediaSamplePtr sample) noexcept;
3634
#endif //CPPWINRT_VERSION
37-
#endif //WINUWP
3835

3936
};
4037

0 commit comments

Comments
 (0)