Skip to content

M71 PeerCC Unity and Callstats #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions idl/MediaSample.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@

/*

Copyright (c) 2017, Optical Tone Ltd.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.

*/

namespace org
{
namespace webRtc
{
typedef std::list<float> FloatList;

/// <summary>
/// MediaSample represents an object holder for a platform specific media sample.
/// </summary>
[special]
struct MediaSample
{
/// <summary>
/// Constructs a media sample object.
/// </summary>
[constructor, delete]
void MediaSample();

/// <summary>
/// Returns camera view transform which maps from the coordinate system to
/// the camera.
/// </summary>
FloatList getCameraViewTransform();

/// <summary>
/// Returns camera projection transform which maps from the camera to
/// pixels in the image.
/// </summary>
FloatList getCameraProjectionTransform();
};
}
}
9 changes: 8 additions & 1 deletion idl/VideoCapturer.idl
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ namespace org
void VideoCapturer();

[static]
VideoCapturer create(string name, string id);
VideoCapturer create(string name, string id, bool enableMrc);

[static]
PromiseWithVideoDeviceInfoList getDevices();
Expand Down Expand Up @@ -206,6 +206,13 @@ namespace org

[getter]
VideoCaptureState state;

/// <summary>
/// Event indicates new captured sample available.
/// </summary>
[event]
void onVideoSampleReceived(MediaSample sample);

};
}
}
65 changes: 47 additions & 18 deletions idl/WebRtc.idl
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,27 @@ namespace org
void EventQueue(Any queue);

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

/// <summary>
/// Gets or sets the default system dispatcher object.
/// Creates an event thread pool queue object. If a queue name already
/// exists an existing queue with that name will be returned.
/// </summary>
[static]
EventQueue createThreadQueuePool(
string queueName,
size_t minimumNumberOfThreads
);

/// <summary>
/// The default windows message queue for the system GUI thread.
/// </summary>
[static, getter, setter]
EventQueue singleton;
[static]
EventQueue getDefaultForUi();

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

[dictionary]
struct WebRtcLibConfiguration
{
/// <summary>
/// Gets or sets the default queue for delegate events. If not
/// specified then GUI queue is used.
/// </summary>
EventQueue queue;

/// <summary>
/// Gets or sets the default queue for processing frame events. If
/// not specified then the GUI queue is used.
/// </summary>
EventQueue frameProcessingQueue;

/// <summary>
/// Gets or sets if audio capturing is be enabled.
/// </summary>
bool audioCapturingEnabled = true;

/// <summary>
/// Gets or sets if audio rendering is enabled.
/// </summary>
bool audioRenderingEnabled = true;
};

/// <summary>
/// Setup methods for the ORTC Lib stack.
/// Setup methods for the WebRtc Lib stack.
/// </summary>
[static]
interface WebRtcLib
{
/// <summary>
/// Initialize the ORTC stack.
/// Initialize the WebRtc stack.
/// </summary>
[static, default]
void setup();

/// <summary>
/// Initialize the ORTC stack with a target event queue for delegate events.
/// </summary>
[static, altname(setupWithQueue)]
void setup(EventQueue queue);

/// <summary>
/// Initialize the ORTC stack with a target event queue for delegate events
/// and set audio engine recording and playout to enabled or disabled state
/// (if omitted, the default value is true for both parameters).
/// Initialize the WebRtc stack with setup configurations.
/// </summary>
[static, altname(setupWithQueueAndAudioDevicePararms)]
void setup(EventQueue queue, bool recordingEnabled, bool playoutEnabled);
[static, altname(setupWithConfiguration)]
void setup(WebRtcLibConfiguration configuration);

/// <summary>
/// Gets or sets the NTP server time discovered in milliseconds since
Expand Down
1 change: 1 addition & 0 deletions idl/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"Error.idl",
"MediaSource.idl",
"MediaElement.idl",
"MediaSample.idl",
"StatsReport.idl",
"StatsProvider.idl",
"Certificate.idl",
Expand Down
44 changes: 22 additions & 22 deletions windows/wrapper/impl_org_webRtc.cpp
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@

#include <zsLib/Log.h>

#include "Org.WebRtc.Glue.events.h"
#include "Org.WebRtc.Glue.events.jman.h"

namespace wrapper { namespace impl { namespace org { namespace webRtc { ZS_IMPLEMENT_SUBSYSTEM(wrapper_org_webRtc); } } } }

#include <zsLib/Log.h>
#include "Org.WebRtc.Glue.events.h"
#include "Org.WebRtc.Glue.events.jman.h"
namespace wrapper { namespace impl { namespace org { namespace webRtc { ZS_IMPLEMENT_SUBSYSTEM(wrapper_org_webRtc); } } } }
ZS_EVENTING_SUBSYSTEM_DEFAULT_LEVEL(wrapper_org_webRtc, Debug)

namespace wrapper {
namespace impl {
namespace org {
namespace webRtc {

void initSubsystems() noexcept
{
namespace wrapper {
namespace impl {
namespace org {
namespace webRtc {
void initSubsystems() noexcept
{
ZS_GET_SUBSYSTEM_LOG_LEVEL(ZS_GET_OTHER_SUBSYSTEM(wrapper::impl::org::webRtc, wrapper_org_webRtc));
ZS_EVENTING_REGISTER(Org_WebRtc_Glue);
}

} // namespace webRtc
} // namespace impl
} // namespace org
} // namespace webRtc
}
} // namespace webRtc
} // namespace impl
} // namespace org
} // namespace webRtc
73 changes: 45 additions & 28 deletions windows/wrapper/impl_org_webRtc_EventQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@
#include "impl_org_webRtc_EventQueue.h"
#include "impl_org_webRtc_helpers.h"

#include <zsLib/IMessageQueueManager.h>
#include <zsLib/IMessageQueueThread.h>
#include <zsLib/IMessageQueueDispatcher.h>

#include <zsLib/SafeInt.h>

using ::zsLib::String;
using ::zsLib::Optional;
Expand Down Expand Up @@ -71,8 +74,7 @@ namespace wrapper { namespace impl { namespace org { namespace webRtc {

#endif // CPPWINRT_VERSION

#else

#endif //WINUWP

namespace wrapper { namespace impl { namespace org { namespace webRtc {
ZS_DECLARE_STRUCT_PTR(EventQueueWrapperAny);
Expand All @@ -83,15 +85,6 @@ namespace wrapper { namespace impl { namespace org { namespace webRtc {
};
} } } }

#endif //WINUWP

//------------------------------------------------------------------------------
static wrapper::org::webRtc::EventQueuePtr &getSingleton() noexcept
{
static wrapper::org::webRtc::EventQueuePtr singleton_ {};
return singleton_;
}

//------------------------------------------------------------------------------
wrapper::impl::org::webRtc::EventQueue::EventQueue() noexcept
{
Expand Down Expand Up @@ -119,29 +112,36 @@ void wrapper::impl::org::webRtc::EventQueue::wrapper_init_org_webRtc_EventQueue(
}

//------------------------------------------------------------------------------
wrapper::org::webRtc::EventQueuePtr wrapper::org::webRtc::EventQueue::getDefaultForUi() noexcept
wrapper::org::webRtc::EventQueuePtr wrapper::org::webRtc::EventQueue::getOrCreateThreadQueueByName(String queueName) noexcept
{
#ifndef WINUWP
auto result {std::make_shared<wrapper::impl::org::webRtc::EventQueue>()};
auto any {std::make_shared<wrapper::impl::org::webRtc::EventQueueWrapperAny>()};
any->queue_ = zsLib::IMessageQueueThread::singletonUsingCurrentGUIThreadsMessageQueue();
auto result{ std::make_shared<wrapper::impl::org::webRtc::EventQueue>() };
auto any{ std::make_shared<wrapper::impl::org::webRtc::EventQueueWrapperAny>() };
any->queue_ = zsLib::IMessageQueueManager::getMessageQueue(queueName);
result->queue_ = any;
return result;
#else
return get_singleton();
#endif //ndef WINUWP
}

//------------------------------------------------------------------------------
wrapper::org::webRtc::EventQueuePtr wrapper::org::webRtc::EventQueue::get_singleton() noexcept
wrapper::org::webRtc::EventQueuePtr wrapper::org::webRtc::EventQueue::createThreadQueuePool(
String queueName,
uint64_t minimumNumberOfThreads
) noexcept
{
return getSingleton();
auto result{ std::make_shared<wrapper::impl::org::webRtc::EventQueue>() };
auto any{ std::make_shared<wrapper::impl::org::webRtc::EventQueueWrapperAny>() };
any->queue_ = zsLib::IMessageQueueManager::getThreadPoolQueue(queueName, SafeInt<size_t>(minimumNumberOfThreads));
result->queue_ = any;
return result;
}

//------------------------------------------------------------------------------
void wrapper::org::webRtc::EventQueue::set_singleton(wrapper::org::webRtc::EventQueuePtr value) noexcept
wrapper::org::webRtc::EventQueuePtr wrapper::org::webRtc::EventQueue::getDefaultForUi() noexcept
{
getSingleton() = value;
auto result {std::make_shared<wrapper::impl::org::webRtc::EventQueue>()};
auto any {std::make_shared<wrapper::impl::org::webRtc::EventQueueWrapperAny>()};
any->queue_ = zsLib::IMessageQueueThread::singletonUsingCurrentGUIThreadsMessageQueue();
result->queue_ = any;
return result;
}

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

#endif // CPPWINRT_VERSION

#else
#endif //WINUWP

wrapper::org::webRtc::EventQueuePtr wrapper::impl::org::webRtc::EventQueue::toWrapper(::zsLib::IMessageQueuePtr queue) noexcept
{
auto any {make_shared<wrapper::impl::org::webRtc::EventQueueWrapperAny>()};
{
auto any{ make_shared<wrapper::impl::org::webRtc::EventQueueWrapperAny>() };
any->queue_ = queue;
auto result = wrapper::org::webRtc::EventQueue::wrapper_create();
result->wrapper_init_org_webRtc_EventQueue(any);
Expand All @@ -219,8 +219,25 @@ ::zsLib::IMessageQueuePtr wrapper::impl::org::webRtc::EventQueue::toNative(wrapp
AnyPtr any = queue->get_queue();
if (!any) return nullptr;
auto castedAny = ZS_DYNAMIC_PTR_CAST(wrapper::impl::org::webRtc::EventQueueWrapperAny, any);
if (!castedAny) return nullptr;
if (!castedAny) {
#ifdef CPPWINRT_VERSION
{
auto dispatcher = toNative_winrt(queue);
if (dispatcher) {
return zsLib::IMessageQueueDispatcher::create(dispatcher);
}
}
#endif // CPPWINRT_VERSION
#ifdef __cplusplus_winrt
{
auto dispatcher = toNative_cx(queue);
if (dispatcher) {
return zsLib::IMessageQueueDispatcher::create(dispatcher);
}
}
#endif //__cplusplus_winrt
return nullptr;
}
return castedAny->queue_;
}

#endif //WINUWP
3 changes: 1 addition & 2 deletions windows/wrapper/impl_org_webRtc_EventQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ namespace wrapper {
ZS_NO_DISCARD() static wrapper::org::webRtc::EventQueuePtr toWrapper(winrt::Windows::UI::Core::CoreDispatcher queue) noexcept;
ZS_NO_DISCARD() static winrt::Windows::UI::Core::CoreDispatcher toNative_winrt(wrapper::org::webRtc::EventQueuePtr queue) noexcept;
#endif // CPPWINRT_VERSION
#else
#endif //WINUWP
ZS_NO_DISCARD() static wrapper::org::webRtc::EventQueuePtr toWrapper(::zsLib::IMessageQueuePtr queue) noexcept;
ZS_NO_DISCARD() static ::zsLib::IMessageQueuePtr toNative(wrapper::org::webRtc::EventQueuePtr queue) noexcept;
#endif //WINUWP

};

Expand Down
Loading