Refactored ViERenderImpl and ViERTP_RTCPImpl.
Review URL: http://webrtc-codereview.appspot.com/329005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1232 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
7752d11056
commit
8da2417c9d
@ -162,7 +162,7 @@ public:
|
|||||||
|
|
||||||
// This function gets the RTCP status for the specified channel.
|
// This function gets the RTCP status for the specified channel.
|
||||||
virtual int GetRTCPStatus(const int videoChannel,
|
virtual int GetRTCPStatus(const int videoChannel,
|
||||||
ViERTCPMode& rtcpMode) = 0;
|
ViERTCPMode& rtcpMode) const = 0;
|
||||||
|
|
||||||
// This function sets the RTCP canonical name (CNAME) for the RTCP reports
|
// This function sets the RTCP canonical name (CNAME) for the RTCP reports
|
||||||
// on a specific channel.
|
// on a specific channel.
|
||||||
@ -172,7 +172,7 @@ public:
|
|||||||
// This function gets the RTCP canonical name (CNAME) for the RTCP reports
|
// This function gets the RTCP canonical name (CNAME) for the RTCP reports
|
||||||
// sent the specified channel.
|
// sent the specified channel.
|
||||||
virtual int GetRTCPCName(const int videoChannel,
|
virtual int GetRTCPCName(const int videoChannel,
|
||||||
char rtcpCName[KMaxRTCPCNameLength]) = 0;
|
char rtcpCName[KMaxRTCPCNameLength]) const = 0;
|
||||||
|
|
||||||
// This function gets the RTCP canonical name (CNAME) for the RTCP reports
|
// This function gets the RTCP canonical name (CNAME) for the RTCP reports
|
||||||
// received on the specified channel.
|
// received on the specified channel.
|
||||||
@ -260,7 +260,7 @@ public:
|
|||||||
// This function gets the RTP keep-alive status.
|
// This function gets the RTP keep-alive status.
|
||||||
virtual int GetRTPKeepAliveStatus(
|
virtual int GetRTPKeepAliveStatus(
|
||||||
const int videoChannel, bool& enabled, char& unkownPayloadType,
|
const int videoChannel, bool& enabled, char& unkownPayloadType,
|
||||||
unsigned int& deltaTransmitTimeSeconds) = 0;
|
unsigned int& deltaTransmitTimeSeconds) const = 0;
|
||||||
|
|
||||||
// This function enables capturing of RTP packets to a binary file on a
|
// This function enables capturing of RTP packets to a binary file on a
|
||||||
// specific channel and for a given direction. The file can later be
|
// specific channel and for a given direction. The file can later be
|
||||||
|
@ -8,557 +8,386 @@
|
|||||||
* be found in the AUTHORS file in the root of the source tree.
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
#include "video_engine/vie_render_impl.h"
|
||||||
* vie_render_impl.cc
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "vie_render_impl.h"
|
|
||||||
|
|
||||||
// Defines
|
|
||||||
#include "engine_configurations.h"
|
#include "engine_configurations.h"
|
||||||
#include "vie_defines.h"
|
#include "modules/video_render/main/interface/video_render.h"
|
||||||
|
#include "modules/video_render/main/interface/video_render_defines.h"
|
||||||
#include "trace.h"
|
#include "system_wrappers/interface/trace.h"
|
||||||
#include "video_render.h"
|
#include "video_engine/main/interface/vie_errors.h"
|
||||||
#include "video_render_defines.h"
|
#include "video_engine/vie_capturer.h"
|
||||||
#include "vie_errors.h"
|
#include "video_engine/vie_channel.h"
|
||||||
#include "vie_impl.h"
|
#include "video_engine/vie_channel_manager.h"
|
||||||
#include "vie_capturer.h"
|
#include "video_engine/vie_defines.h"
|
||||||
#include "vie_channel.h"
|
#include "video_engine/vie_frame_provider_base.h"
|
||||||
#include "vie_frame_provider_base.h"
|
#include "video_engine/vie_impl.h"
|
||||||
#include "vie_channel_manager.h"
|
#include "video_engine/vie_input_manager.h"
|
||||||
#include "vie_input_manager.h"
|
#include "video_engine/vie_render_manager.h"
|
||||||
#include "vie_render_manager.h"
|
|
||||||
#include "video_engine/vie_renderer.h"
|
#include "video_engine/vie_renderer.h"
|
||||||
|
|
||||||
namespace webrtc
|
namespace webrtc {
|
||||||
{
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
ViERender* ViERender::GetInterface(VideoEngine* video_engine) {
|
||||||
// GetInterface
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
ViERender* ViERender::GetInterface(VideoEngine* videoEngine)
|
|
||||||
{
|
|
||||||
#ifdef WEBRTC_VIDEO_ENGINE_RENDER_API
|
#ifdef WEBRTC_VIDEO_ENGINE_RENDER_API
|
||||||
if (videoEngine == NULL)
|
if (!video_engine) {
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
VideoEngineImpl* vieImpl = reinterpret_cast<VideoEngineImpl*> (videoEngine);
|
|
||||||
ViERenderImpl* vieRenderImpl = vieImpl;
|
|
||||||
(*vieRenderImpl)++; // Increase ref count
|
|
||||||
|
|
||||||
return vieRenderImpl;
|
|
||||||
#else
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
VideoEngineImpl* vie_impl = reinterpret_cast<VideoEngineImpl*>(video_engine);
|
||||||
|
ViERenderImpl* vie_render_impl = vie_impl;
|
||||||
|
// Increase ref count.
|
||||||
|
(*vie_render_impl)++;
|
||||||
|
return vie_render_impl;
|
||||||
|
#else
|
||||||
|
return NULL;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
int ViERenderImpl::Release() {
|
||||||
// Release
|
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, instance_id_,
|
||||||
//
|
"ViERender::Release()");
|
||||||
// Releases the interface, i.e. reduces the reference counter. The number of
|
// Decrease ref count
|
||||||
// remaining references is returned, -1 if released too many times.
|
(*this)--;
|
||||||
// ----------------------------------------------------------------------------
|
WebRtc_Word32 ref_count = GetCount();
|
||||||
|
if (ref_count < 0) {
|
||||||
int ViERenderImpl::Release()
|
WEBRTC_TRACE(kTraceWarning, kTraceVideo, instance_id_,
|
||||||
{
|
"ViERender release too many times");
|
||||||
WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, instance_id_,
|
return -1;
|
||||||
"ViERender::Release()");
|
}
|
||||||
(*this)--; // Decrease ref count
|
WEBRTC_TRACE(kTraceInfo, kTraceVideo, instance_id_,
|
||||||
|
"ViERender reference count: %d", ref_count);
|
||||||
WebRtc_Word32 refCount = GetCount();
|
return ref_count;
|
||||||
if (refCount < 0)
|
|
||||||
{
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceVideo, instance_id_,
|
|
||||||
"ViERender release too many times");
|
|
||||||
// SetLastError()
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideo, instance_id_,
|
|
||||||
"ViERender reference count: %d", refCount);
|
|
||||||
return refCount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
ViERenderImpl::ViERenderImpl() {
|
||||||
// Constructor
|
WEBRTC_TRACE(kTraceMemory, kTraceVideo, instance_id_,
|
||||||
// ----------------------------------------------------------------------------
|
"ViERenderImpl::ViERenderImpl() Ctor");
|
||||||
|
|
||||||
ViERenderImpl::ViERenderImpl()
|
|
||||||
{
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceMemory, webrtc::kTraceVideo, instance_id_,
|
|
||||||
"ViERenderImpl::ViERenderImpl() Ctor");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
ViERenderImpl::~ViERenderImpl() {
|
||||||
// Destructor
|
WEBRTC_TRACE(kTraceMemory, kTraceVideo, instance_id_,
|
||||||
// ----------------------------------------------------------------------------
|
"ViERenderImpl::~ViERenderImpl() Dtor");
|
||||||
|
|
||||||
ViERenderImpl::~ViERenderImpl()
|
|
||||||
{
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceMemory, webrtc::kTraceVideo, instance_id_,
|
|
||||||
"ViERenderImpl::~ViERenderImpl() Dtor");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================
|
|
||||||
// Registration of render module
|
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// RegisterVideoRenderModule
|
|
||||||
//
|
|
||||||
// Registers a video render module, must be called before
|
|
||||||
// AddRenderer is called for an input stream associated
|
|
||||||
// with the same window as the module.
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
int ViERenderImpl::RegisterVideoRenderModule(
|
int ViERenderImpl::RegisterVideoRenderModule(
|
||||||
VideoRender& renderModule)
|
VideoRender& render_module) {
|
||||||
{
|
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_),
|
||||||
WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, ViEId(instance_id_),
|
"%s (&render_module: %p)", __FUNCTION__, &render_module);
|
||||||
"%s (&renderModule: %p)", __FUNCTION__, &renderModule);
|
if (render_manager_.RegisterVideoRenderModule(render_module) != 0) {
|
||||||
|
SetLastError(kViERenderUnknownError);
|
||||||
if (render_manager_.RegisterVideoRenderModule(renderModule) != 0)
|
return -1;
|
||||||
{
|
}
|
||||||
// Error logging is done in RegisterVideoRenderModule
|
return 0;
|
||||||
SetLastError(kViERenderUnknownError);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// DeRegisterVideoRenderModule
|
|
||||||
//
|
|
||||||
// De-registers a video render module, must be called after
|
|
||||||
// RemoveRenderer has been called for all input streams associated
|
|
||||||
// with the same window as the module.
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
int ViERenderImpl::DeRegisterVideoRenderModule(
|
int ViERenderImpl::DeRegisterVideoRenderModule(
|
||||||
VideoRender& renderModule)
|
VideoRender& render_module) {
|
||||||
{
|
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_),
|
||||||
WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, ViEId(instance_id_),
|
"%s (&render_module: %p)", __FUNCTION__, &render_module);
|
||||||
"%s (&renderModule: %p)", __FUNCTION__, &renderModule);
|
if (render_manager_.DeRegisterVideoRenderModule(render_module) != 0) {
|
||||||
if (render_manager_.DeRegisterVideoRenderModule(renderModule) != 0)
|
// Error logging is done in ViERenderManager::DeRegisterVideoRenderModule.
|
||||||
{
|
SetLastError(kViERenderUnknownError);
|
||||||
// Error logging is done in DeRegisterVideoRenderModule
|
return -1;
|
||||||
SetLastError(kViERenderUnknownError);
|
}
|
||||||
return -1;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================
|
int ViERenderImpl::AddRenderer(const int render_id, void* window,
|
||||||
// Add renderer
|
const unsigned int z_order, const float left,
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
int ViERenderImpl::AddRenderer(const int renderId, void* window,
|
|
||||||
const unsigned int zOrder, const float left,
|
|
||||||
const float top, const float right,
|
const float top, const float right,
|
||||||
const float bottom)
|
const float bottom) {
|
||||||
{
|
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_),
|
||||||
WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, ViEId(instance_id_),
|
"%s (render_id: %d, window: 0x%p, z_order: %u, left: %f, "
|
||||||
"%s (renderId: %d, window: 0x%p, zOrder: %u, left: %f, "
|
"top: %f, right: %f, bottom: %f)",
|
||||||
"top: %f, right: %f, bottom: %f)",
|
__FUNCTION__, render_id, window, z_order, left, top, right,
|
||||||
__FUNCTION__, renderId, window, zOrder, left, top, right,
|
bottom);
|
||||||
bottom);
|
if (!Initialized()) {
|
||||||
if (!Initialized())
|
SetLastError(kViENotInitialized);
|
||||||
{
|
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
|
||||||
SetLastError(kViENotInitialized);
|
"%s - ViE instance %d not initialized", __FUNCTION__,
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(instance_id_),
|
instance_id_);
|
||||||
"%s - ViE instance %d not initialized", __FUNCTION__,
|
return -1;
|
||||||
instance_id_);
|
}
|
||||||
return -1;
|
{
|
||||||
|
ViERenderManagerScoped rs(render_manager_);
|
||||||
|
if (rs.Renderer(render_id) != NULL) {
|
||||||
|
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
|
||||||
|
"%s - Renderer already exist %d.", __FUNCTION__,
|
||||||
|
render_id);
|
||||||
|
SetLastError(kViERenderAlreadyExists);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (render_id >= kViEChannelIdBase && render_id <= kViEChannelIdMax) {
|
||||||
|
// This is a channel.
|
||||||
|
ViEChannelManagerScoped cm(channel_manager_);
|
||||||
|
ViEFrameProviderBase* frame_provider = cm.Channel(render_id);
|
||||||
|
if (!frame_provider) {
|
||||||
|
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
|
||||||
|
"%s: FrameProvider id %d doesn't exist", __FUNCTION__,
|
||||||
|
render_id);
|
||||||
|
SetLastError(kViERenderInvalidRenderId);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
ViERenderer* renderer = render_manager_.AddRenderStream(render_id,
|
||||||
|
window, z_order,
|
||||||
|
left, top,
|
||||||
|
right, bottom);
|
||||||
|
if (!renderer) {
|
||||||
|
SetLastError(kViERenderUnknownError);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return frame_provider->RegisterFrameCallback(render_id, renderer);
|
||||||
|
} else {
|
||||||
|
// Camera or file.
|
||||||
|
ViEInputManagerScoped is(input_manager_);
|
||||||
|
ViEFrameProviderBase* frame_provider = is.FrameProvider(render_id);
|
||||||
|
if (!frame_provider) {
|
||||||
|
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
|
||||||
|
"%s: FrameProvider id %d doesn't exist", __FUNCTION__,
|
||||||
|
render_id);
|
||||||
|
SetLastError(kViERenderInvalidRenderId);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
ViERenderer* renderer = render_manager_.AddRenderStream(render_id,
|
||||||
|
window, z_order,
|
||||||
|
left, top,
|
||||||
|
right, bottom);
|
||||||
|
if (!renderer) {
|
||||||
|
SetLastError(kViERenderUnknownError);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return frame_provider->RegisterFrameCallback(render_id, renderer);
|
||||||
|
}
|
||||||
|
SetLastError(kViERenderInvalidRenderId);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
{ // Check if the renderer exist already
|
int ViERenderImpl::RemoveRenderer(const int render_id) {
|
||||||
ViERenderManagerScoped rs(render_manager_);
|
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_),
|
||||||
if (rs.Renderer(renderId) != NULL)
|
"%s(render_id: %d)", __FUNCTION__, render_id);
|
||||||
{
|
if (!Initialized()) {
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(instance_id_),
|
SetLastError(kViENotInitialized);
|
||||||
"%s - Renderer already exist %d.", __FUNCTION__,
|
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
|
||||||
renderId);
|
"%s - ViE instance %d not initialized", __FUNCTION__,
|
||||||
SetLastError(kViERenderAlreadyExists);
|
instance_id_);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (renderId >= kViEChannelIdBase && renderId <= kViEChannelIdMax)
|
ViERenderer* renderer = NULL;
|
||||||
{
|
{
|
||||||
// This is a channel
|
ViERenderManagerScoped rs(render_manager_);
|
||||||
ViEChannelManagerScoped cm(channel_manager_);
|
renderer = rs.Renderer(render_id);
|
||||||
ViEFrameProviderBase* frameProvider = cm.Channel(renderId);
|
if (!renderer) {
|
||||||
if (frameProvider == NULL)
|
WEBRTC_TRACE(kTraceWarning, kTraceVideo, ViEId(instance_id_),
|
||||||
{
|
"%s No render exist with render_id: %d", __FUNCTION__,
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(instance_id_),
|
render_id);
|
||||||
"%s: FrameProvider id %d doesn't exist", __FUNCTION__,
|
SetLastError(kViERenderInvalidRenderId);
|
||||||
renderId);
|
return -1;
|
||||||
SetLastError(kViERenderInvalidRenderId);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
ViERenderer* renderer = render_manager_.AddRenderStream(renderId,
|
|
||||||
window, zOrder,
|
|
||||||
left, top,
|
|
||||||
right, bottom);
|
|
||||||
if (renderer == NULL)
|
|
||||||
{
|
|
||||||
SetLastError(kViERenderUnknownError);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return frameProvider->RegisterFrameCallback(renderId, renderer);
|
|
||||||
}
|
}
|
||||||
else // camera or file
|
// Leave the scope lock since we don't want to lock two managers
|
||||||
{
|
// simultanousely.
|
||||||
ViEInputManagerScoped is(input_manager_);
|
}
|
||||||
ViEFrameProviderBase* frameProvider = is.FrameProvider(renderId);
|
if (render_id >= kViEChannelIdBase && render_id <= kViEChannelIdMax) {
|
||||||
if (frameProvider == NULL)
|
// This is a channel.
|
||||||
{
|
ViEChannelManagerScoped cm(channel_manager_);
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(instance_id_),
|
ViEChannel* channel = cm.Channel(render_id);
|
||||||
"%s: FrameProvider id %d doesn't exist", __FUNCTION__,
|
if (!channel) {
|
||||||
renderId);
|
WEBRTC_TRACE(kTraceWarning, kTraceVideo, ViEId(instance_id_),
|
||||||
SetLastError(kViERenderInvalidRenderId);
|
"%s: no channel with id %d exists ", __FUNCTION__,
|
||||||
return -1;
|
render_id);
|
||||||
}
|
SetLastError(kViERenderInvalidRenderId);
|
||||||
ViERenderer* renderer = render_manager_.AddRenderStream(renderId,
|
return -1;
|
||||||
window, zOrder,
|
|
||||||
left, top,
|
|
||||||
right, bottom);
|
|
||||||
if (renderer == NULL)
|
|
||||||
{
|
|
||||||
SetLastError(kViERenderUnknownError);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return frameProvider->RegisterFrameCallback(renderId, renderer);
|
|
||||||
}
|
}
|
||||||
|
channel->DeregisterFrameCallback(renderer);
|
||||||
|
} else {
|
||||||
|
// Provider owned by inputmanager, i.e. file or capture device.
|
||||||
|
ViEInputManagerScoped is(input_manager_);
|
||||||
|
ViEFrameProviderBase* provider = is.FrameProvider(render_id);
|
||||||
|
if (!provider) {
|
||||||
|
WEBRTC_TRACE(kTraceWarning, kTraceVideo, ViEId(instance_id_),
|
||||||
|
"%s: no provider with id %d exists ", __FUNCTION__,
|
||||||
|
render_id);
|
||||||
|
SetLastError(kViERenderInvalidRenderId);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
provider->DeregisterFrameCallback(renderer);
|
||||||
|
}
|
||||||
|
if (render_manager_.RemoveRenderStream(render_id) != 0) {
|
||||||
|
SetLastError(kViERenderUnknownError);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ViERenderImpl::StartRender(const int render_id) {
|
||||||
|
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, render_id),
|
||||||
|
"%s(channel: %d)", __FUNCTION__, render_id);
|
||||||
|
ViERenderManagerScoped rs(render_manager_);
|
||||||
|
ViERenderer* renderer = rs.Renderer(render_id);
|
||||||
|
if (!renderer) {
|
||||||
|
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, render_id),
|
||||||
|
"%s: No renderer with render Id %d exist.", __FUNCTION__,
|
||||||
|
render_id);
|
||||||
SetLastError(kViERenderInvalidRenderId);
|
SetLastError(kViERenderInvalidRenderId);
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
if (renderer->StartRender() != 0) {
|
||||||
|
SetLastError(kViERenderUnknownError);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ViERenderImpl::RemoveRenderer(const int renderId)
|
int ViERenderImpl::StopRender(const int render_id) {
|
||||||
{
|
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, render_id),
|
||||||
WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, ViEId(instance_id_),
|
"%s(channel: %d)", __FUNCTION__, render_id);
|
||||||
"%s(renderId: %d)", __FUNCTION__, renderId);
|
ViERenderManagerScoped rs(render_manager_);
|
||||||
if (!Initialized())
|
ViERenderer* renderer = rs.Renderer(render_id);
|
||||||
{
|
if (!renderer) {
|
||||||
SetLastError(kViENotInitialized);
|
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, render_id),
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(instance_id_),
|
"%s: No renderer with render_id %d exist.", __FUNCTION__,
|
||||||
"%s - ViE instance %d not initialized", __FUNCTION__,
|
render_id);
|
||||||
instance_id_);
|
SetLastError(kViERenderInvalidRenderId);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
if (renderer->StopRender() != 0) {
|
||||||
ViERenderer* renderer = NULL;
|
SetLastError(kViERenderUnknownError);
|
||||||
{
|
return -1;
|
||||||
ViERenderManagerScoped rs(render_manager_);
|
}
|
||||||
renderer = rs.Renderer(renderId);
|
return 0;
|
||||||
if (!renderer)
|
|
||||||
{
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceVideo, ViEId(instance_id_),
|
|
||||||
"%s No render exist with renderId: %d", __FUNCTION__,
|
|
||||||
renderId);
|
|
||||||
SetLastError(kViERenderInvalidRenderId);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
} // Leave the scope lock since we don't want to lock two managers
|
|
||||||
// simultanousely
|
|
||||||
|
|
||||||
if (renderId >= kViEChannelIdBase && renderId <= kViEChannelIdMax)
|
|
||||||
{
|
|
||||||
// This is a channel
|
|
||||||
ViEChannelManagerScoped cm(channel_manager_);
|
|
||||||
ViEChannel* channel = cm.Channel(renderId);
|
|
||||||
if (!channel)
|
|
||||||
{
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceVideo, ViEId(instance_id_),
|
|
||||||
"%s: no channel with id %d exists ", __FUNCTION__,
|
|
||||||
renderId);
|
|
||||||
SetLastError(kViERenderInvalidRenderId);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
channel->DeregisterFrameCallback(renderer);
|
|
||||||
}
|
|
||||||
else //Provider owned by inputmanager - ie file or capture device
|
|
||||||
{
|
|
||||||
ViEInputManagerScoped is(input_manager_);
|
|
||||||
ViEFrameProviderBase* provider = is.FrameProvider(renderId);
|
|
||||||
if (!provider)
|
|
||||||
{
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceVideo, ViEId(instance_id_),
|
|
||||||
"%s: no provider with id %d exists ", __FUNCTION__,
|
|
||||||
renderId);
|
|
||||||
SetLastError(kViERenderInvalidRenderId);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
provider->DeregisterFrameCallback(renderer);
|
|
||||||
|
|
||||||
}
|
|
||||||
if (render_manager_.RemoveRenderStream(renderId) != 0)
|
|
||||||
{
|
|
||||||
SetLastError(kViERenderUnknownError);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================
|
int ViERenderImpl::ConfigureRender(int render_id, const unsigned int z_order,
|
||||||
// Start/stop
|
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// StartRender
|
|
||||||
//
|
|
||||||
// Starts rendering the stream from the channel
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
int ViERenderImpl::StartRender(const int renderId)
|
|
||||||
{
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo,
|
|
||||||
ViEId(instance_id_, renderId), "%s(channel: %d)", __FUNCTION__,
|
|
||||||
renderId);
|
|
||||||
|
|
||||||
ViERenderManagerScoped rs(render_manager_);
|
|
||||||
ViERenderer* ptrRender = rs.Renderer(renderId);
|
|
||||||
if (ptrRender == NULL)
|
|
||||||
{
|
|
||||||
// No renderer for this channel
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo,
|
|
||||||
ViEId(instance_id_, renderId),
|
|
||||||
"%s: No renderer with render Id %d exist.", __FUNCTION__,
|
|
||||||
renderId);
|
|
||||||
SetLastError(kViERenderInvalidRenderId);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ptrRender->StartRender() != 0)
|
|
||||||
{
|
|
||||||
SetLastError(kViERenderUnknownError);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// StopRender
|
|
||||||
//
|
|
||||||
// Stop rendering a stream
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
int ViERenderImpl::StopRender(const int renderId)
|
|
||||||
{
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo,
|
|
||||||
ViEId(instance_id_, renderId), "%s(channel: %d)", __FUNCTION__,
|
|
||||||
renderId);
|
|
||||||
|
|
||||||
ViERenderManagerScoped rs(render_manager_);
|
|
||||||
ViERenderer* ptrRender = rs.Renderer(renderId);
|
|
||||||
if (ptrRender == NULL)
|
|
||||||
{
|
|
||||||
// No renderer for this channel
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo,
|
|
||||||
ViEId(instance_id_, renderId),
|
|
||||||
"%s: No renderer with renderId %d exist.", __FUNCTION__,
|
|
||||||
renderId);
|
|
||||||
SetLastError(kViERenderInvalidRenderId);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (ptrRender->StopRender() != 0)
|
|
||||||
{
|
|
||||||
SetLastError(kViERenderUnknownError);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ============================================================================
|
|
||||||
// Stream configurations
|
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// ConfigureRender
|
|
||||||
//
|
|
||||||
// Reconfigures an already added render stream
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
int ViERenderImpl::ConfigureRender(int renderId, const unsigned int zOrder,
|
|
||||||
const float left, const float top,
|
const float left, const float top,
|
||||||
const float right, const float bottom)
|
const float right, const float bottom) {
|
||||||
{
|
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, render_id),
|
||||||
WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, ViEId(instance_id_, renderId),
|
"%s(channel: %d)", __FUNCTION__, render_id);
|
||||||
"%s(channel: %d)", __FUNCTION__, renderId);
|
ViERenderManagerScoped rs(render_manager_);
|
||||||
|
ViERenderer* renderer = rs.Renderer(render_id);
|
||||||
ViERenderManagerScoped rs(render_manager_);
|
if (!renderer) {
|
||||||
ViERenderer* ptrRender = rs.Renderer(renderId);
|
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, render_id),
|
||||||
if (ptrRender == NULL)
|
"%s: No renderer with render_id %d exist.", __FUNCTION__,
|
||||||
{
|
render_id);
|
||||||
// No renderer for this channel
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo,
|
|
||||||
ViEId(instance_id_, renderId),
|
|
||||||
"%s: No renderer with renderId %d exist.", __FUNCTION__,
|
|
||||||
renderId);
|
|
||||||
SetLastError(kViERenderInvalidRenderId);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ptrRender->ConfigureRenderer(zOrder, left, top, right, bottom) != 0)
|
|
||||||
{
|
|
||||||
SetLastError(kViERenderUnknownError);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// MirrorRenderStream
|
|
||||||
//
|
|
||||||
// Enables mirror rendering
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
int ViERenderImpl::MirrorRenderStream(const int renderId, const bool enable,
|
|
||||||
const bool mirrorXAxis,
|
|
||||||
const bool mirrorYAxis)
|
|
||||||
{
|
|
||||||
ViERenderManagerScoped rs(render_manager_);
|
|
||||||
ViERenderer* ptrRender = rs.Renderer(renderId);
|
|
||||||
if (ptrRender == NULL)
|
|
||||||
{
|
|
||||||
// No renderer for this channel
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo,
|
|
||||||
ViEId(instance_id_, renderId),
|
|
||||||
"%s: No renderer with renderId %d exist.", __FUNCTION__,
|
|
||||||
renderId);
|
|
||||||
SetLastError(kViERenderInvalidRenderId);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (ptrRender->EnableMirroring(renderId, enable, mirrorXAxis, mirrorYAxis)
|
|
||||||
!= 0)
|
|
||||||
{
|
|
||||||
SetLastError(kViERenderUnknownError);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ============================================================================
|
|
||||||
// External render
|
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// AddRenderer
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
int ViERenderImpl::AddRenderer(const int renderId,
|
|
||||||
webrtc::RawVideoType videoInputFormat,
|
|
||||||
ExternalRenderer* externalRenderer)
|
|
||||||
{
|
|
||||||
// check if the client requested a format that we can convert the frames to
|
|
||||||
if (videoInputFormat != webrtc::kVideoI420
|
|
||||||
&& videoInputFormat != webrtc::kVideoYV12
|
|
||||||
&& videoInputFormat != webrtc::kVideoYUY2
|
|
||||||
&& videoInputFormat != webrtc::kVideoUYVY
|
|
||||||
&& videoInputFormat != webrtc::kVideoARGB
|
|
||||||
&& videoInputFormat != webrtc::kVideoRGB24
|
|
||||||
&& videoInputFormat != webrtc::kVideoRGB565
|
|
||||||
&& videoInputFormat != webrtc::kVideoARGB4444
|
|
||||||
&& videoInputFormat != webrtc::kVideoARGB1555)
|
|
||||||
{
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo,
|
|
||||||
ViEId(instance_id_, renderId),
|
|
||||||
"%s: Unsupported video frame format requested",
|
|
||||||
__FUNCTION__, renderId);
|
|
||||||
SetLastError(kViERenderInvalidFrameFormat);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Initialized())
|
|
||||||
{
|
|
||||||
SetLastError(kViENotInitialized);
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(instance_id_),
|
|
||||||
"%s - ViE instance %d not initialized", __FUNCTION__,
|
|
||||||
instance_id_);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
{ // Check if the renderer exist already
|
|
||||||
ViERenderManagerScoped rs(render_manager_);
|
|
||||||
if (rs.Renderer(renderId) != NULL)
|
|
||||||
{
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(instance_id_),
|
|
||||||
"%s - Renderer already exist %d.", __FUNCTION__,
|
|
||||||
renderId);
|
|
||||||
SetLastError(kViERenderAlreadyExists);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (renderId >= kViEChannelIdBase && renderId <= kViEChannelIdMax)
|
|
||||||
{
|
|
||||||
// This is a channel
|
|
||||||
ViEChannelManagerScoped cm(channel_manager_);
|
|
||||||
ViEFrameProviderBase* frameProvider = cm.Channel(renderId);
|
|
||||||
if (frameProvider == NULL)
|
|
||||||
{
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(instance_id_),
|
|
||||||
"%s: FrameProvider id %d doesn't exist", __FUNCTION__,
|
|
||||||
renderId);
|
|
||||||
SetLastError(kViERenderInvalidRenderId);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
ViERenderer* ptrRender = render_manager_.AddRenderStream(renderId, NULL,
|
|
||||||
0, 0.0f, 0.0f,
|
|
||||||
1.0f, 1.0f);
|
|
||||||
if (ptrRender == NULL)
|
|
||||||
{
|
|
||||||
SetLastError(kViERenderUnknownError);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (-1 == ptrRender->SetExternalRenderer(renderId, videoInputFormat,
|
|
||||||
externalRenderer))
|
|
||||||
{
|
|
||||||
SetLastError(kViERenderUnknownError);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return frameProvider->RegisterFrameCallback(renderId, ptrRender);
|
|
||||||
}
|
|
||||||
else // camera or file
|
|
||||||
{
|
|
||||||
ViEInputManagerScoped is(input_manager_);
|
|
||||||
ViEFrameProviderBase* frameProvider = is.FrameProvider(renderId);
|
|
||||||
if (frameProvider == NULL)
|
|
||||||
{
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(instance_id_),
|
|
||||||
"%s: FrameProvider id %d doesn't exist", __FUNCTION__,
|
|
||||||
renderId);
|
|
||||||
SetLastError(kViERenderInvalidRenderId);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
ViERenderer* ptrRender = render_manager_.AddRenderStream(renderId, NULL,
|
|
||||||
0, 0.0f, 0.0f,
|
|
||||||
1.0f, 1.0f);
|
|
||||||
if (ptrRender == NULL)
|
|
||||||
{
|
|
||||||
SetLastError(kViERenderUnknownError);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (-1 == ptrRender->SetExternalRenderer(renderId, videoInputFormat,
|
|
||||||
externalRenderer))
|
|
||||||
{
|
|
||||||
SetLastError(kViERenderUnknownError);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return frameProvider->RegisterFrameCallback(renderId, ptrRender);
|
|
||||||
}
|
|
||||||
SetLastError(kViERenderInvalidRenderId);
|
SetLastError(kViERenderInvalidRenderId);
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (renderer->ConfigureRenderer(z_order, left, top, right, bottom) != 0) {
|
||||||
|
SetLastError(kViERenderUnknownError);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace webrtc
|
int ViERenderImpl::MirrorRenderStream(const int render_id, const bool enable,
|
||||||
|
const bool mirror_xaxis,
|
||||||
|
const bool mirror_yaxis) {
|
||||||
|
ViERenderManagerScoped rs(render_manager_);
|
||||||
|
ViERenderer* renderer = rs.Renderer(render_id);
|
||||||
|
if (!renderer) {
|
||||||
|
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, render_id),
|
||||||
|
"%s: No renderer with render_id %d exist.", __FUNCTION__,
|
||||||
|
render_id);
|
||||||
|
SetLastError(kViERenderInvalidRenderId);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (renderer->EnableMirroring(render_id, enable, mirror_xaxis, mirror_yaxis)
|
||||||
|
!= 0) {
|
||||||
|
SetLastError(kViERenderUnknownError);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ViERenderImpl::AddRenderer(const int render_id,
|
||||||
|
RawVideoType video_input_format,
|
||||||
|
ExternalRenderer* external_renderer) {
|
||||||
|
// Check if the client requested a format that we can convert the frames to.
|
||||||
|
if (video_input_format != kVideoI420 &&
|
||||||
|
video_input_format != kVideoYV12 &&
|
||||||
|
video_input_format != kVideoYUY2 &&
|
||||||
|
video_input_format != kVideoUYVY &&
|
||||||
|
video_input_format != kVideoARGB &&
|
||||||
|
video_input_format != kVideoRGB24 &&
|
||||||
|
video_input_format != kVideoRGB565 &&
|
||||||
|
video_input_format != kVideoARGB4444 &&
|
||||||
|
video_input_format != kVideoARGB1555) {
|
||||||
|
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, render_id),
|
||||||
|
"%s: Unsupported video frame format requested",
|
||||||
|
__FUNCTION__, render_id);
|
||||||
|
SetLastError(kViERenderInvalidFrameFormat);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (!Initialized()) {
|
||||||
|
SetLastError(kViENotInitialized);
|
||||||
|
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
|
||||||
|
"%s - ViE instance %d not initialized", __FUNCTION__,
|
||||||
|
instance_id_);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
// Verify the renderer exists.
|
||||||
|
ViERenderManagerScoped rs(render_manager_);
|
||||||
|
if (!rs.Renderer(render_id)) {
|
||||||
|
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
|
||||||
|
"%s - Renderer already exist %d.", __FUNCTION__,
|
||||||
|
render_id);
|
||||||
|
SetLastError(kViERenderAlreadyExists);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (render_id >= kViEChannelIdBase && render_id <= kViEChannelIdMax) {
|
||||||
|
// This is a channel.
|
||||||
|
ViEChannelManagerScoped cm(channel_manager_);
|
||||||
|
ViEFrameProviderBase* frame_provider = cm.Channel(render_id);
|
||||||
|
if (!frame_provider) {
|
||||||
|
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
|
||||||
|
"%s: FrameProvider id %d doesn't exist", __FUNCTION__,
|
||||||
|
render_id);
|
||||||
|
SetLastError(kViERenderInvalidRenderId);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
ViERenderer* renderer = render_manager_.AddRenderStream(render_id, NULL,
|
||||||
|
0, 0.0f, 0.0f,
|
||||||
|
1.0f, 1.0f);
|
||||||
|
if (!renderer) {
|
||||||
|
SetLastError(kViERenderUnknownError);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (renderer->SetExternalRenderer(render_id, video_input_format,
|
||||||
|
external_renderer) == -1) {
|
||||||
|
SetLastError(kViERenderUnknownError);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return frame_provider->RegisterFrameCallback(render_id, renderer);
|
||||||
|
} else {
|
||||||
|
// Camera or file.
|
||||||
|
ViEInputManagerScoped is(input_manager_);
|
||||||
|
ViEFrameProviderBase* frame_provider = is.FrameProvider(render_id);
|
||||||
|
if (!frame_provider) {
|
||||||
|
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_),
|
||||||
|
"%s: FrameProvider id %d doesn't exist", __FUNCTION__,
|
||||||
|
render_id);
|
||||||
|
SetLastError(kViERenderInvalidRenderId);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
ViERenderer* renderer = render_manager_.AddRenderStream(render_id, NULL,
|
||||||
|
0, 0.0f, 0.0f,
|
||||||
|
1.0f, 1.0f);
|
||||||
|
if (!renderer) {
|
||||||
|
SetLastError(kViERenderUnknownError);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (renderer->SetExternalRenderer(render_id, video_input_format,
|
||||||
|
external_renderer) == -1) {
|
||||||
|
SetLastError(kViERenderUnknownError);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return frame_provider->RegisterFrameCallback(render_id, renderer);
|
||||||
|
}
|
||||||
|
SetLastError(kViERenderInvalidRenderId);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace webrtc
|
||||||
|
@ -8,70 +8,46 @@
|
|||||||
* be found in the AUTHORS file in the root of the source tree.
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
#ifndef WEBRTC_VIDEO_ENGINE_VIE_RENDER_IMPL_H_
|
||||||
* vie_render_impl.h
|
#define WEBRTC_VIDEO_ENGINE_VIE_RENDER_IMPL_H_
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef WEBRTC_VIDEO_ENGINE_MAIN_SOURCE_VIE_RENDER_IMPL_H_
|
|
||||||
#define WEBRTC_VIDEO_ENGINE_MAIN_SOURCE_VIE_RENDER_IMPL_H_
|
|
||||||
|
|
||||||
#include "vie_defines.h"
|
|
||||||
|
|
||||||
|
#include "modules/video_render/main/interface/video_render_defines.h"
|
||||||
#include "typedefs.h"
|
#include "typedefs.h"
|
||||||
#include "video_render_defines.h"
|
#include "video_engine/main/interface/vie_render.h"
|
||||||
#include "vie_ref_count.h"
|
#include "video_engine/vie_ref_count.h"
|
||||||
#include "vie_render.h"
|
#include "video_engine/vie_shared_data.h"
|
||||||
#include "vie_shared_data.h"
|
|
||||||
|
|
||||||
namespace webrtc
|
namespace webrtc {
|
||||||
{
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
class ViERenderImpl
|
||||||
// ViERenderImpl
|
: public virtual ViESharedData,
|
||||||
// ----------------------------------------------------------------------------
|
public ViERender,
|
||||||
|
public ViERefCount {
|
||||||
|
public:
|
||||||
|
// Implements ViERender
|
||||||
|
virtual int Release();
|
||||||
|
virtual int RegisterVideoRenderModule(VideoRender& render_module);
|
||||||
|
virtual int DeRegisterVideoRenderModule(VideoRender& render_module);
|
||||||
|
virtual int AddRenderer(const int render_id, void* window,
|
||||||
|
const unsigned int z_order, const float left,
|
||||||
|
const float top, const float right,
|
||||||
|
const float bottom);
|
||||||
|
virtual int RemoveRenderer(const int render_id);
|
||||||
|
virtual int StartRender(const int render_id);
|
||||||
|
virtual int StopRender(const int render_id);
|
||||||
|
virtual int ConfigureRender(int render_id, const unsigned int z_order,
|
||||||
|
const float left, const float top,
|
||||||
|
const float right, const float bottom);
|
||||||
|
virtual int MirrorRenderStream(const int render_id, const bool enable,
|
||||||
|
const bool mirror_xaxis,
|
||||||
|
const bool mirror_yaxis);
|
||||||
|
virtual int AddRenderer(const int render_id, RawVideoType video_input_format,
|
||||||
|
ExternalRenderer* renderer);
|
||||||
|
|
||||||
class ViERenderImpl: public virtual ViESharedData,
|
protected:
|
||||||
public ViERender,
|
ViERenderImpl();
|
||||||
public ViERefCount
|
virtual ~ViERenderImpl();
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual int Release();
|
|
||||||
|
|
||||||
// Registration of render module
|
|
||||||
virtual int RegisterVideoRenderModule(VideoRender& renderModule);
|
|
||||||
|
|
||||||
virtual int DeRegisterVideoRenderModule(
|
|
||||||
VideoRender& renderModule);
|
|
||||||
|
|
||||||
// Add/remove renderer
|
|
||||||
virtual int AddRenderer(const int renderId, void* window,
|
|
||||||
const unsigned int zOrder, const float left,
|
|
||||||
const float top, const float right,
|
|
||||||
const float bottom);
|
|
||||||
|
|
||||||
virtual int RemoveRenderer(const int renderId);
|
|
||||||
|
|
||||||
// Start/stop
|
|
||||||
virtual int StartRender(const int renderId);
|
|
||||||
|
|
||||||
virtual int StopRender(const int renderId);
|
|
||||||
|
|
||||||
virtual int ConfigureRender(int renderId, const unsigned int zOrder,
|
|
||||||
const float left, const float top,
|
|
||||||
const float right, const float bottom);
|
|
||||||
|
|
||||||
virtual int MirrorRenderStream(const int renderId, const bool enable,
|
|
||||||
const bool mirrorXAxis,
|
|
||||||
const bool mirrorYAxis);
|
|
||||||
|
|
||||||
// External render
|
|
||||||
virtual int AddRenderer(const int renderId,
|
|
||||||
webrtc::RawVideoType videoInputFormat,
|
|
||||||
ExternalRenderer* renderer);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
ViERenderImpl();
|
|
||||||
virtual ~ViERenderImpl();
|
|
||||||
};
|
};
|
||||||
} // namespace webrtc
|
|
||||||
#endif // WEBRTC_VIDEO_ENGINE_MAIN_SOURCE_VIE_RENDER_IMPL_H_
|
} // namespace webrtc
|
||||||
|
#endif // WEBRTC_VIDEO_ENGINE_VIE_RENDER_IMPL_H_
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -8,150 +8,108 @@
|
|||||||
* be found in the AUTHORS file in the root of the source tree.
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
#ifndef WEBRTC_VIDEO_ENGINE_VIE_RTP_RTCP_IMPL_H_
|
||||||
* vie_rtp_rtcp_impl.h
|
#define WEBRTC_VIDEO_ENGINE_VIE_RTP_RTCP_IMPL_H_
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef WEBRTC_VIDEO_ENGINE_MAIN_SOURCE_VIE_RTP_RTCP_IMPL_H_
|
#include "modules/rtp_rtcp/interface/rtp_rtcp_defines.h"
|
||||||
#define WEBRTC_VIDEO_ENGINE_MAIN_SOURCE_VIE_RTP_RTCP_IMPL_H_
|
|
||||||
|
|
||||||
#include "vie_defines.h"
|
|
||||||
|
|
||||||
#include "rtp_rtcp_defines.h"
|
|
||||||
#include "typedefs.h"
|
#include "typedefs.h"
|
||||||
#include "vie_ref_count.h"
|
#include "video_engine/main/interface/vie_rtp_rtcp.h"
|
||||||
#include "vie_rtp_rtcp.h"
|
#include "video_engine/vie_ref_count.h"
|
||||||
#include "vie_shared_data.h"
|
#include "video_engine/vie_shared_data.h"
|
||||||
|
|
||||||
namespace webrtc
|
namespace webrtc {
|
||||||
{
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
class ViERTP_RTCPImpl
|
||||||
// ViERTP_RTCPImpl
|
: public virtual ViESharedData,
|
||||||
// ----------------------------------------------------------------------------
|
public ViERTP_RTCP,
|
||||||
|
public ViERefCount {
|
||||||
|
public:
|
||||||
|
// Implements ViERTP_RTCP
|
||||||
|
virtual int Release();
|
||||||
|
virtual int SetLocalSSRC(const int video_channel,
|
||||||
|
const unsigned int SSRC,
|
||||||
|
const StreamType usage,
|
||||||
|
const unsigned char simulcast_idx);
|
||||||
|
virtual int GetLocalSSRC(const int video_channel, unsigned int& SSRC) const;
|
||||||
|
virtual int SetRemoteSSRCType(const int video_channel,
|
||||||
|
const StreamType usage,
|
||||||
|
const unsigned int SSRC) const;
|
||||||
|
virtual int GetRemoteSSRC(const int video_channel, unsigned int& SSRC) const;
|
||||||
|
virtual int GetRemoteCSRCs(const int video_channel,
|
||||||
|
unsigned int CSRCs[kRtpCsrcSize]) const;
|
||||||
|
virtual int SetStartSequenceNumber(const int video_channel,
|
||||||
|
unsigned short sequence_number);
|
||||||
|
virtual int SetRTCPStatus(const int video_channel,
|
||||||
|
const ViERTCPMode rtcp_mode);
|
||||||
|
virtual int GetRTCPStatus(const int video_channel,
|
||||||
|
ViERTCPMode& rtcp_mode) const;
|
||||||
|
virtual int SetRTCPCName(const int video_channel,
|
||||||
|
const char rtcp_cname[KMaxRTCPCNameLength]);
|
||||||
|
virtual int GetRTCPCName(const int video_channel,
|
||||||
|
char rtcp_cname[KMaxRTCPCNameLength]) const;
|
||||||
|
virtual int GetRemoteRTCPCName(const int video_channel,
|
||||||
|
char rtcp_cname[KMaxRTCPCNameLength]) const;
|
||||||
|
virtual int SendApplicationDefinedRTCPPacket(
|
||||||
|
const int video_channel,
|
||||||
|
const unsigned char sub_type,
|
||||||
|
unsigned int name,
|
||||||
|
const char* data,
|
||||||
|
unsigned short data_length_in_bytes);
|
||||||
|
virtual int SetNACKStatus(const int video_channel, const bool enable);
|
||||||
|
virtual int SetFECStatus(const int video_channel, const bool enable,
|
||||||
|
const unsigned char payload_typeRED,
|
||||||
|
const unsigned char payload_typeFEC);
|
||||||
|
virtual int SetHybridNACKFECStatus(const int video_channel, const bool enable,
|
||||||
|
const unsigned char payload_typeRED,
|
||||||
|
const unsigned char payload_typeFEC);
|
||||||
|
virtual int SetKeyFrameRequestMethod(const int video_channel,
|
||||||
|
const ViEKeyFrameRequestMethod method);
|
||||||
|
virtual int SetTMMBRStatus(const int video_channel, const bool enable);
|
||||||
|
virtual int GetReceivedRTCPStatistics(const int video_channel,
|
||||||
|
unsigned short& fraction_lost,
|
||||||
|
unsigned int& cumulative_lost,
|
||||||
|
unsigned int& extended_max,
|
||||||
|
unsigned int& jitter,
|
||||||
|
int& rtt_ms) const;
|
||||||
|
virtual int GetSentRTCPStatistics(const int video_channel,
|
||||||
|
unsigned short& fraction_lost,
|
||||||
|
unsigned int& cumulative_lost,
|
||||||
|
unsigned int& extended_max,
|
||||||
|
unsigned int& jitter, int& rtt_ms) const;
|
||||||
|
virtual int GetRTPStatistics(const int video_channel,
|
||||||
|
unsigned int& bytes_sent,
|
||||||
|
unsigned int& packets_sent,
|
||||||
|
unsigned int& bytes_received,
|
||||||
|
unsigned int& packets_received) const;
|
||||||
|
virtual int GetBandwidthUsage(const int video_channel,
|
||||||
|
unsigned int& total_bitrate_sent,
|
||||||
|
unsigned int& video_bitrate_sent,
|
||||||
|
unsigned int& fec_bitrate_sent,
|
||||||
|
unsigned int& nackBitrateSent) const;
|
||||||
|
virtual int SetRTPKeepAliveStatus(
|
||||||
|
const int video_channel, bool enable, const char unknown_payload_type,
|
||||||
|
const unsigned int delta_transmit_time_seconds);
|
||||||
|
virtual int GetRTPKeepAliveStatus(
|
||||||
|
const int video_channel,
|
||||||
|
bool& enabled,
|
||||||
|
char& unkown_payload_type,
|
||||||
|
unsigned int& delta_transmit_time_seconds) const;
|
||||||
|
virtual int StartRTPDump(const int video_channel,
|
||||||
|
const char file_nameUTF8[1024],
|
||||||
|
RTPDirections direction);
|
||||||
|
virtual int StopRTPDump(const int video_channel, RTPDirections direction);
|
||||||
|
virtual int RegisterRTPObserver(const int video_channel,
|
||||||
|
ViERTPObserver& observer);
|
||||||
|
virtual int DeregisterRTPObserver(const int video_channel);
|
||||||
|
virtual int RegisterRTCPObserver(const int video_channel,
|
||||||
|
ViERTCPObserver& observer);
|
||||||
|
virtual int DeregisterRTCPObserver(const int video_channel);
|
||||||
|
|
||||||
class ViERTP_RTCPImpl : public virtual ViESharedData,
|
protected:
|
||||||
public ViERTP_RTCP,
|
ViERTP_RTCPImpl();
|
||||||
public ViERefCount
|
virtual ~ViERTP_RTCPImpl();
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual int Release();
|
|
||||||
|
|
||||||
// SSRC/CSRC
|
|
||||||
virtual int SetLocalSSRC(const int videoChannel,
|
|
||||||
const unsigned int SSRC,
|
|
||||||
const StreamType usage,
|
|
||||||
const unsigned char simulcastIdx);
|
|
||||||
|
|
||||||
virtual int GetLocalSSRC(const int videoChannel, unsigned int& SSRC) const;
|
|
||||||
|
|
||||||
virtual int SetRemoteSSRCType(const int videoChannel,
|
|
||||||
const StreamType usage,
|
|
||||||
const unsigned int SSRC) const;
|
|
||||||
|
|
||||||
virtual int GetRemoteSSRC(const int videoChannel, unsigned int& SSRC) const;
|
|
||||||
|
|
||||||
virtual int GetRemoteCSRCs(const int videoChannel,
|
|
||||||
unsigned int CSRCs[kRtpCsrcSize]) const;
|
|
||||||
|
|
||||||
virtual int SetStartSequenceNumber(const int videoChannel,
|
|
||||||
unsigned short sequenceNumber);
|
|
||||||
|
|
||||||
// RTCP
|
|
||||||
virtual int SetRTCPStatus(const int videoChannel,
|
|
||||||
const ViERTCPMode rtcpMode);
|
|
||||||
|
|
||||||
virtual int GetRTCPStatus(const int videoChannel, ViERTCPMode& rtcpMode);
|
|
||||||
|
|
||||||
virtual int SetRTCPCName(const int videoChannel,
|
|
||||||
const char rtcpCName[KMaxRTCPCNameLength]);
|
|
||||||
|
|
||||||
virtual int GetRTCPCName(const int videoChannel,
|
|
||||||
char rtcpCName[KMaxRTCPCNameLength]);
|
|
||||||
|
|
||||||
virtual int GetRemoteRTCPCName(const int videoChannel,
|
|
||||||
char rtcpCName[KMaxRTCPCNameLength]) const;
|
|
||||||
|
|
||||||
virtual int
|
|
||||||
SendApplicationDefinedRTCPPacket(const int videoChannel,
|
|
||||||
const unsigned char subType,
|
|
||||||
unsigned int name, const char* data,
|
|
||||||
unsigned short dataLengthInBytes);
|
|
||||||
|
|
||||||
virtual int SetNACKStatus(const int videoChannel, const bool enable);
|
|
||||||
|
|
||||||
virtual int SetFECStatus(const int videoChannel, const bool enable,
|
|
||||||
const unsigned char payloadTypeRED,
|
|
||||||
const unsigned char payloadTypeFEC);
|
|
||||||
virtual int SetHybridNACKFECStatus(const int videoChannel, const bool enable,
|
|
||||||
const unsigned char payloadTypeRED,
|
|
||||||
const unsigned char payloadTypeFEC);
|
|
||||||
|
|
||||||
virtual int SetKeyFrameRequestMethod(const int videoChannel,
|
|
||||||
const ViEKeyFrameRequestMethod method);
|
|
||||||
|
|
||||||
virtual int SetTMMBRStatus(const int videoChannel, const bool enable);
|
|
||||||
|
|
||||||
// Statistics
|
|
||||||
virtual int GetReceivedRTCPStatistics(
|
|
||||||
const int videoChannel, unsigned short& fractionLost,
|
|
||||||
unsigned int& cumulativeLost, unsigned int& extendedMax,
|
|
||||||
unsigned int& jitter, int& rttMs) const;
|
|
||||||
|
|
||||||
virtual int GetSentRTCPStatistics(const int videoChannel,
|
|
||||||
unsigned short& fractionLost,
|
|
||||||
unsigned int& cumulativeLost,
|
|
||||||
unsigned int& extendedMax,
|
|
||||||
unsigned int& jitter, int& rttMs) const;
|
|
||||||
|
|
||||||
virtual int GetRTPStatistics(const int videoChannel,
|
|
||||||
unsigned int& bytesSent,
|
|
||||||
unsigned int& packetsSent,
|
|
||||||
unsigned int& bytesReceived,
|
|
||||||
unsigned int& packetsReceived) const;
|
|
||||||
|
|
||||||
virtual int GetBandwidthUsage(const int videoChannel,
|
|
||||||
unsigned int& totalBitrateSent,
|
|
||||||
unsigned int& videoBitrateSent,
|
|
||||||
unsigned int& fecBitrateSent,
|
|
||||||
unsigned int& nackBitrateSent) const;
|
|
||||||
|
|
||||||
// Keep alive
|
|
||||||
virtual int SetRTPKeepAliveStatus(
|
|
||||||
const int videoChannel, bool enable, const char unknownPayloadType,
|
|
||||||
const unsigned int deltaTransmitTimeSeconds);
|
|
||||||
|
|
||||||
virtual int GetRTPKeepAliveStatus(const int videoChannel, bool& enabled,
|
|
||||||
char& unkownPayloadType,
|
|
||||||
unsigned int& deltaTransmitTimeSeconds);
|
|
||||||
|
|
||||||
// Dump RTP stream, for debug purpose
|
|
||||||
virtual int StartRTPDump(const int videoChannel,
|
|
||||||
const char fileNameUTF8[1024],
|
|
||||||
RTPDirections direction);
|
|
||||||
|
|
||||||
virtual int StopRTPDump(const int videoChannel, RTPDirections direction);
|
|
||||||
|
|
||||||
// Callbacks
|
|
||||||
virtual int RegisterRTPObserver(const int videoChannel,
|
|
||||||
ViERTPObserver& observer);
|
|
||||||
|
|
||||||
virtual int DeregisterRTPObserver(const int videoChannel);
|
|
||||||
|
|
||||||
virtual int RegisterRTCPObserver(const int videoChannel,
|
|
||||||
ViERTCPObserver& observer);
|
|
||||||
|
|
||||||
virtual int DeregisterRTCPObserver(const int videoChannel);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
ViERTP_RTCPImpl();
|
|
||||||
virtual ~ViERTP_RTCPImpl();
|
|
||||||
|
|
||||||
private:
|
|
||||||
RTCPMethod ViERTCPModeToRTCPMethod(ViERTCPMode apiMode);
|
|
||||||
ViERTCPMode RTCPMethodToViERTCPMode(RTCPMethod moduleMethod);
|
|
||||||
KeyFrameRequestMethod
|
|
||||||
APIRequestToModuleRequest(const ViEKeyFrameRequestMethod apiMethod);
|
|
||||||
};
|
};
|
||||||
} // namespace webrtc
|
|
||||||
#endif // WEBRTC_VIDEO_ENGINE_MAIN_SOURCE_VIE_RTP_RTCP_IMPL_H_
|
} // namespace webrtc
|
||||||
|
|
||||||
|
#endif // WEBRTC_VIDEO_ENGINE_VIE_RTP_RTCP_IMPL_H_
|
||||||
|
Loading…
Reference in New Issue
Block a user