Skip to content

Commit 5442897

Browse files
authored
Merge pull request #15 from webrtc-uwp/Robin/m71-peercc-unity
M71 PeerCC Unity and Callstats
2 parents 6e91f6f + 73be1da commit 5442897

38 files changed

+1808
-151
lines changed

idl/MediaSample.idl

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
2+
/*
3+
4+
Copyright (c) 2017, Optical Tone Ltd.
5+
All rights reserved.
6+
7+
Redistribution and use in source and binary forms, with or without
8+
modification, are permitted provided that the following conditions are met:
9+
10+
1. Redistributions of source code must retain the above copyright notice, this
11+
list of conditions and the following disclaimer.
12+
2. Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
16+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
20+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
27+
The views and conclusions contained in the software and documentation are those
28+
of the authors and should not be interpreted as representing official policies,
29+
either expressed or implied, of the FreeBSD Project.
30+
31+
*/
32+
33+
namespace org
34+
{
35+
namespace webRtc
36+
{
37+
typedef std::list<float> FloatList;
38+
39+
/// <summary>
40+
/// MediaSample represents an object holder for a platform specific media sample.
41+
/// </summary>
42+
[special]
43+
struct MediaSample
44+
{
45+
/// <summary>
46+
/// Constructs a media sample object.
47+
/// </summary>
48+
[constructor, delete]
49+
void MediaSample();
50+
51+
/// <summary>
52+
/// Returns camera view transform which maps from the coordinate system to
53+
/// the camera.
54+
/// </summary>
55+
FloatList getCameraViewTransform();
56+
57+
/// <summary>
58+
/// Returns camera projection transform which maps from the camera to
59+
/// pixels in the image.
60+
/// </summary>
61+
FloatList getCameraProjectionTransform();
62+
};
63+
}
64+
}

idl/VideoCapturer.idl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ namespace org
100100
void VideoCapturer();
101101

102102
[static]
103-
VideoCapturer create(string name, string id);
103+
VideoCapturer create(string name, string id, bool enableMrc);
104104

105105
[static]
106106
PromiseWithVideoDeviceInfoList getDevices();
@@ -206,6 +206,13 @@ namespace org
206206

207207
[getter]
208208
VideoCaptureState state;
209+
210+
/// <summary>
211+
/// Event indicates new captured sample available.
212+
/// </summary>
213+
[event]
214+
void onVideoSampleReceived(MediaSample sample);
215+
209216
};
210217
}
211218
}

idl/WebRtc.idl

Lines changed: 47 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -153,16 +153,27 @@ namespace org
153153
void EventQueue(Any queue);
154154

155155
/// <summary>
156-
/// The default windows message queue for the system GUI thread.
156+
/// Gets or creates an event queue by queue name. If the queue is not
157+
/// found then a new thread queue will be created.
157158
/// </summary>
158159
[static]
159-
EventQueue getDefaultForUi();
160+
EventQueue getOrCreateThreadQueueByName(string queueName);
160161

161162
/// <summary>
162-
/// Gets or sets the default system dispatcher object.
163+
/// Creates an event thread pool queue object. If a queue name already
164+
/// exists an existing queue with that name will be returned.
165+
/// </summary>
166+
[static]
167+
EventQueue createThreadQueuePool(
168+
string queueName,
169+
size_t minimumNumberOfThreads
170+
);
171+
172+
/// <summary>
173+
/// The default windows message queue for the system GUI thread.
163174
/// </summary>
164-
[static, getter, setter]
165-
EventQueue singleton;
175+
[static]
176+
EventQueue getDefaultForUi();
166177

167178
/// <summary>
168179
/// Gets a native queue from an event queue object.
@@ -186,31 +197,49 @@ namespace org
186197
Any extract(EventQueue queue);
187198
};
188199

200+
[dictionary]
201+
struct WebRtcLibConfiguration
202+
{
203+
/// <summary>
204+
/// Gets or sets the default queue for delegate events. If not
205+
/// specified then GUI queue is used.
206+
/// </summary>
207+
EventQueue queue;
208+
209+
/// <summary>
210+
/// Gets or sets the default queue for processing frame events. If
211+
/// not specified then the GUI queue is used.
212+
/// </summary>
213+
EventQueue frameProcessingQueue;
214+
215+
/// <summary>
216+
/// Gets or sets if audio capturing is be enabled.
217+
/// </summary>
218+
bool audioCapturingEnabled = true;
219+
220+
/// <summary>
221+
/// Gets or sets if audio rendering is enabled.
222+
/// </summary>
223+
bool audioRenderingEnabled = true;
224+
};
225+
189226
/// <summary>
190-
/// Setup methods for the ORTC Lib stack.
227+
/// Setup methods for the WebRtc Lib stack.
191228
/// </summary>
192229
[static]
193230
interface WebRtcLib
194231
{
195232
/// <summary>
196-
/// Initialize the ORTC stack.
233+
/// Initialize the WebRtc stack.
197234
/// </summary>
198235
[static, default]
199236
void setup();
200237

201238
/// <summary>
202-
/// Initialize the ORTC stack with a target event queue for delegate events.
203-
/// </summary>
204-
[static, altname(setupWithQueue)]
205-
void setup(EventQueue queue);
206-
207-
/// <summary>
208-
/// Initialize the ORTC stack with a target event queue for delegate events
209-
/// and set audio engine recording and playout to enabled or disabled state
210-
/// (if omitted, the default value is true for both parameters).
239+
/// Initialize the WebRtc stack with setup configurations.
211240
/// </summary>
212-
[static, altname(setupWithQueueAndAudioDevicePararms)]
213-
void setup(EventQueue queue, bool recordingEnabled, bool playoutEnabled);
241+
[static, altname(setupWithConfiguration)]
242+
void setup(WebRtcLibConfiguration configuration);
214243

215244
/// <summary>
216245
/// Gets or sets the NTP server time discovered in milliseconds since

idl/config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"Error.idl",
2727
"MediaSource.idl",
2828
"MediaElement.idl",
29+
"MediaSample.idl",
2930
"StatsReport.idl",
3031
"StatsProvider.idl",
3132
"Certificate.idl",

windows/wrapper/impl_org_webRtc.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
2-
#include <zsLib/Log.h>
3-
4-
#include "Org.WebRtc.Glue.events.h"
5-
#include "Org.WebRtc.Glue.events.jman.h"
6-
7-
namespace wrapper { namespace impl { namespace org { namespace webRtc { ZS_IMPLEMENT_SUBSYSTEM(wrapper_org_webRtc); } } } }
8-
1+
2+
#include <zsLib/Log.h>
3+
4+
#include "Org.WebRtc.Glue.events.h"
5+
#include "Org.WebRtc.Glue.events.jman.h"
6+
7+
namespace wrapper { namespace impl { namespace org { namespace webRtc { ZS_IMPLEMENT_SUBSYSTEM(wrapper_org_webRtc); } } } }
8+
99
ZS_EVENTING_SUBSYSTEM_DEFAULT_LEVEL(wrapper_org_webRtc, Debug)
10-
11-
namespace wrapper {
12-
namespace impl {
13-
namespace org {
14-
namespace webRtc {
15-
16-
void initSubsystems() noexcept
17-
{
10+
11+
namespace wrapper {
12+
namespace impl {
13+
namespace org {
14+
namespace webRtc {
15+
16+
void initSubsystems() noexcept
17+
{
1818
ZS_GET_SUBSYSTEM_LOG_LEVEL(ZS_GET_OTHER_SUBSYSTEM(wrapper::impl::org::webRtc, wrapper_org_webRtc));
1919
ZS_EVENTING_REGISTER(Org_WebRtc_Glue);
20-
}
21-
22-
} // namespace webRtc
23-
} // namespace impl
24-
} // namespace org
25-
} // namespace webRtc
20+
}
21+
22+
} // namespace webRtc
23+
} // namespace impl
24+
} // namespace org
25+
} // namespace webRtc

windows/wrapper/impl_org_webRtc_EventQueue.cpp

Lines changed: 45 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@
1919
#include "impl_org_webRtc_EventQueue.h"
2020
#include "impl_org_webRtc_helpers.h"
2121

22+
#include <zsLib/IMessageQueueManager.h>
2223
#include <zsLib/IMessageQueueThread.h>
24+
#include <zsLib/IMessageQueueDispatcher.h>
2325

26+
#include <zsLib/SafeInt.h>
2427

2528
using ::zsLib::String;
2629
using ::zsLib::Optional;
@@ -71,8 +74,7 @@ namespace wrapper { namespace impl { namespace org { namespace webRtc {
7174

7275
#endif // CPPWINRT_VERSION
7376

74-
#else
75-
77+
#endif //WINUWP
7678

7779
namespace wrapper { namespace impl { namespace org { namespace webRtc {
7880
ZS_DECLARE_STRUCT_PTR(EventQueueWrapperAny);
@@ -83,15 +85,6 @@ namespace wrapper { namespace impl { namespace org { namespace webRtc {
8385
};
8486
} } } }
8587

86-
#endif //WINUWP
87-
88-
//------------------------------------------------------------------------------
89-
static wrapper::org::webRtc::EventQueuePtr &getSingleton() noexcept
90-
{
91-
static wrapper::org::webRtc::EventQueuePtr singleton_ {};
92-
return singleton_;
93-
}
94-
9588
//------------------------------------------------------------------------------
9689
wrapper::impl::org::webRtc::EventQueue::EventQueue() noexcept
9790
{
@@ -119,29 +112,36 @@ void wrapper::impl::org::webRtc::EventQueue::wrapper_init_org_webRtc_EventQueue(
119112
}
120113

121114
//------------------------------------------------------------------------------
122-
wrapper::org::webRtc::EventQueuePtr wrapper::org::webRtc::EventQueue::getDefaultForUi() noexcept
115+
wrapper::org::webRtc::EventQueuePtr wrapper::org::webRtc::EventQueue::getOrCreateThreadQueueByName(String queueName) noexcept
123116
{
124-
#ifndef WINUWP
125-
auto result {std::make_shared<wrapper::impl::org::webRtc::EventQueue>()};
126-
auto any {std::make_shared<wrapper::impl::org::webRtc::EventQueueWrapperAny>()};
127-
any->queue_ = zsLib::IMessageQueueThread::singletonUsingCurrentGUIThreadsMessageQueue();
117+
auto result{ std::make_shared<wrapper::impl::org::webRtc::EventQueue>() };
118+
auto any{ std::make_shared<wrapper::impl::org::webRtc::EventQueueWrapperAny>() };
119+
any->queue_ = zsLib::IMessageQueueManager::getMessageQueue(queueName);
128120
result->queue_ = any;
129121
return result;
130-
#else
131-
return get_singleton();
132-
#endif //ndef WINUWP
133122
}
134123

135124
//------------------------------------------------------------------------------
136-
wrapper::org::webRtc::EventQueuePtr wrapper::org::webRtc::EventQueue::get_singleton() noexcept
125+
wrapper::org::webRtc::EventQueuePtr wrapper::org::webRtc::EventQueue::createThreadQueuePool(
126+
String queueName,
127+
uint64_t minimumNumberOfThreads
128+
) noexcept
137129
{
138-
return getSingleton();
130+
auto result{ std::make_shared<wrapper::impl::org::webRtc::EventQueue>() };
131+
auto any{ std::make_shared<wrapper::impl::org::webRtc::EventQueueWrapperAny>() };
132+
any->queue_ = zsLib::IMessageQueueManager::getThreadPoolQueue(queueName, SafeInt<size_t>(minimumNumberOfThreads));
133+
result->queue_ = any;
134+
return result;
139135
}
140136

141137
//------------------------------------------------------------------------------
142-
void wrapper::org::webRtc::EventQueue::set_singleton(wrapper::org::webRtc::EventQueuePtr value) noexcept
138+
wrapper::org::webRtc::EventQueuePtr wrapper::org::webRtc::EventQueue::getDefaultForUi() noexcept
143139
{
144-
getSingleton() = value;
140+
auto result {std::make_shared<wrapper::impl::org::webRtc::EventQueue>()};
141+
auto any {std::make_shared<wrapper::impl::org::webRtc::EventQueueWrapperAny>()};
142+
any->queue_ = zsLib::IMessageQueueThread::singletonUsingCurrentGUIThreadsMessageQueue();
143+
result->queue_ = any;
144+
return result;
145145
}
146146

147147
#ifdef WINUWP
@@ -202,11 +202,11 @@ winrt::Windows::UI::Core::CoreDispatcher wrapper::impl::org::webRtc::EventQueue:
202202

203203
#endif // CPPWINRT_VERSION
204204

205-
#else
205+
#endif //WINUWP
206206

207207
wrapper::org::webRtc::EventQueuePtr wrapper::impl::org::webRtc::EventQueue::toWrapper(::zsLib::IMessageQueuePtr queue) noexcept
208-
{
209-
auto any {make_shared<wrapper::impl::org::webRtc::EventQueueWrapperAny>()};
208+
{
209+
auto any{ make_shared<wrapper::impl::org::webRtc::EventQueueWrapperAny>() };
210210
any->queue_ = queue;
211211
auto result = wrapper::org::webRtc::EventQueue::wrapper_create();
212212
result->wrapper_init_org_webRtc_EventQueue(any);
@@ -219,8 +219,25 @@ ::zsLib::IMessageQueuePtr wrapper::impl::org::webRtc::EventQueue::toNative(wrapp
219219
AnyPtr any = queue->get_queue();
220220
if (!any) return nullptr;
221221
auto castedAny = ZS_DYNAMIC_PTR_CAST(wrapper::impl::org::webRtc::EventQueueWrapperAny, any);
222-
if (!castedAny) return nullptr;
222+
if (!castedAny) {
223+
#ifdef CPPWINRT_VERSION
224+
{
225+
auto dispatcher = toNative_winrt(queue);
226+
if (dispatcher) {
227+
return zsLib::IMessageQueueDispatcher::create(dispatcher);
228+
}
229+
}
230+
#endif // CPPWINRT_VERSION
231+
#ifdef __cplusplus_winrt
232+
{
233+
auto dispatcher = toNative_cx(queue);
234+
if (dispatcher) {
235+
return zsLib::IMessageQueueDispatcher::create(dispatcher);
236+
}
237+
}
238+
#endif //__cplusplus_winrt
239+
return nullptr;
240+
}
223241
return castedAny->queue_;
224242
}
225243

226-
#endif //WINUWP

windows/wrapper/impl_org_webRtc_EventQueue.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,9 @@ namespace wrapper {
3737
ZS_NO_DISCARD() static wrapper::org::webRtc::EventQueuePtr toWrapper(winrt::Windows::UI::Core::CoreDispatcher queue) noexcept;
3838
ZS_NO_DISCARD() static winrt::Windows::UI::Core::CoreDispatcher toNative_winrt(wrapper::org::webRtc::EventQueuePtr queue) noexcept;
3939
#endif // CPPWINRT_VERSION
40-
#else
40+
#endif //WINUWP
4141
ZS_NO_DISCARD() static wrapper::org::webRtc::EventQueuePtr toWrapper(::zsLib::IMessageQueuePtr queue) noexcept;
4242
ZS_NO_DISCARD() static ::zsLib::IMessageQueuePtr toNative(wrapper::org::webRtc::EventQueuePtr queue) noexcept;
43-
#endif //WINUWP
4443

4544
};
4645

0 commit comments

Comments
 (0)