Replace MapWrapper with std::map<>.
MapWrapper was needed on some platforms where STL wasn't supported, we now use std::map<> directly. BUG=2164 TEST=trybots R=henrike@webrtc.org, phoglund@webrtc.org, stefan@webrtc.org, wu@webrtc.org Review URL: https://webrtc-codereview.appspot.com/2001004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@4530 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
dd14b2add1
commit
4ca7d3f9fe
@ -12,7 +12,6 @@
|
|||||||
#define WEBRTC_MODULES_AUDIO_CONFERENCE_MIXER_INTERFACE_AUDIO_CONFERENCE_MIXER_DEFINES_H_
|
#define WEBRTC_MODULES_AUDIO_CONFERENCE_MIXER_INTERFACE_AUDIO_CONFERENCE_MIXER_DEFINES_H_
|
||||||
|
|
||||||
#include "webrtc/modules/interface/module_common_types.h"
|
#include "webrtc/modules/interface/module_common_types.h"
|
||||||
#include "webrtc/system_wrappers/interface/map_wrapper.h"
|
|
||||||
#include "webrtc/typedefs.h"
|
#include "webrtc/typedefs.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
@ -87,19 +86,6 @@ protected:
|
|||||||
AudioMixerOutputReceiver() {}
|
AudioMixerOutputReceiver() {}
|
||||||
virtual ~AudioMixerOutputReceiver() {}
|
virtual ~AudioMixerOutputReceiver() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class AudioRelayReceiver
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// This callback function provides the mix decision for this mix iteration.
|
|
||||||
// mixerList is a list of elements of the type
|
|
||||||
// [int,MixerParticipant*]
|
|
||||||
virtual void NewAudioToRelay(const int32_t id,
|
|
||||||
const MapWrapper& mixerList) = 0;
|
|
||||||
protected:
|
|
||||||
AudioRelayReceiver() {}
|
|
||||||
virtual ~AudioRelayReceiver() {}
|
|
||||||
};
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
#endif // WEBRTC_MODULES_AUDIO_CONFERENCE_MIXER_INTERFACE_AUDIO_CONFERENCE_MIXER_DEFINES_H_
|
#endif // WEBRTC_MODULES_AUDIO_CONFERENCE_MIXER_INTERFACE_AUDIO_CONFERENCE_MIXER_DEFINES_H_
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
#include "webrtc/modules/audio_processing/include/audio_processing.h"
|
#include "webrtc/modules/audio_processing/include/audio_processing.h"
|
||||||
#include "webrtc/modules/utility/interface/audio_frame_operations.h"
|
#include "webrtc/modules/utility/interface/audio_frame_operations.h"
|
||||||
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
||||||
#include "webrtc/system_wrappers/interface/map_wrapper.h"
|
|
||||||
#include "webrtc/system_wrappers/interface/trace.h"
|
#include "webrtc/system_wrappers/interface/trace.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
@ -240,7 +239,7 @@ int32_t AudioConferenceMixerImpl::Process()
|
|||||||
ListWrapper mixList;
|
ListWrapper mixList;
|
||||||
ListWrapper rampOutList;
|
ListWrapper rampOutList;
|
||||||
ListWrapper additionalFramesList;
|
ListWrapper additionalFramesList;
|
||||||
MapWrapper mixedParticipantsMap;
|
std::map<int, MixerParticipant*> mixedParticipantsMap;
|
||||||
{
|
{
|
||||||
CriticalSectionScoped cs(_cbCrit.get());
|
CriticalSectionScoped cs(_cbCrit.get());
|
||||||
|
|
||||||
@ -297,19 +296,15 @@ int32_t AudioConferenceMixerImpl::Process()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateToMix(mixList, rampOutList, mixedParticipantsMap,
|
UpdateToMix(mixList, rampOutList, &mixedParticipantsMap,
|
||||||
remainingParticipantsAllowedToMix);
|
remainingParticipantsAllowedToMix);
|
||||||
|
|
||||||
GetAdditionalAudio(additionalFramesList);
|
GetAdditionalAudio(additionalFramesList);
|
||||||
UpdateMixedStatus(mixedParticipantsMap);
|
UpdateMixedStatus(mixedParticipantsMap);
|
||||||
_scratchParticipantsToMixAmount = mixedParticipantsMap.Size();
|
_scratchParticipantsToMixAmount =
|
||||||
|
static_cast<uint32_t>(mixedParticipantsMap.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear mixedParticipantsMap to avoid memory leak warning.
|
|
||||||
// Please note that the mixedParticipantsMap doesn't own any dynamically
|
|
||||||
// allocated memory.
|
|
||||||
while(mixedParticipantsMap.Erase(mixedParticipantsMap.First()) == 0) {}
|
|
||||||
|
|
||||||
// Get an AudioFrame for mixing from the memory pool.
|
// Get an AudioFrame for mixing from the memory pool.
|
||||||
AudioFrame* mixedAudio = NULL;
|
AudioFrame* mixedAudio = NULL;
|
||||||
if(_audioFramePool->PopMemory(mixedAudio) == -1)
|
if(_audioFramePool->PopMemory(mixedAudio) == -1)
|
||||||
@ -718,9 +713,8 @@ int32_t AudioConferenceMixerImpl::GetLowestMixingFrequencyFromList(
|
|||||||
void AudioConferenceMixerImpl::UpdateToMix(
|
void AudioConferenceMixerImpl::UpdateToMix(
|
||||||
ListWrapper& mixList,
|
ListWrapper& mixList,
|
||||||
ListWrapper& rampOutList,
|
ListWrapper& rampOutList,
|
||||||
MapWrapper& mixParticipantList,
|
std::map<int, MixerParticipant*>* mixParticipantList,
|
||||||
uint32_t& maxAudioFrameCounter)
|
uint32_t& maxAudioFrameCounter) {
|
||||||
{
|
|
||||||
WEBRTC_TRACE(kTraceStream, kTraceAudioMixerServer, _id,
|
WEBRTC_TRACE(kTraceStream, kTraceAudioMixerServer, _id,
|
||||||
"UpdateToMix(mixList,rampOutList,mixParticipantList,%d)",
|
"UpdateToMix(mixList,rampOutList,mixParticipantList,%d)",
|
||||||
maxAudioFrameCounter);
|
maxAudioFrameCounter);
|
||||||
@ -811,39 +805,30 @@ void AudioConferenceMixerImpl::UpdateToMix(
|
|||||||
replaceItem->GetItem());
|
replaceItem->GetItem());
|
||||||
|
|
||||||
bool replaceWasMixed = false;
|
bool replaceWasMixed = false;
|
||||||
MapItem* replaceParticipant = mixParticipantList.Find(
|
std::map<int, MixerParticipant*>::iterator it =
|
||||||
replaceFrame->id_);
|
mixParticipantList->find(replaceFrame->id_);
|
||||||
|
|
||||||
// When a frame is pushed to |activeList| it is also pushed
|
// When a frame is pushed to |activeList| it is also pushed
|
||||||
// to mixParticipantList with the frame's id. This means
|
// to mixParticipantList with the frame's id. This means
|
||||||
// that the Find call above should never fail.
|
// that the Find call above should never fail.
|
||||||
if(replaceParticipant == NULL)
|
assert(it != mixParticipantList->end());
|
||||||
{
|
it->second->_mixHistory->WasMixed(replaceWasMixed);
|
||||||
assert(false);
|
|
||||||
|
mixParticipantList->erase(replaceFrame->id_);
|
||||||
|
activeList.Erase(replaceItem);
|
||||||
|
|
||||||
|
activeList.PushFront(static_cast<void*>(audioFrame));
|
||||||
|
(*mixParticipantList)[audioFrame->id_] = participant;
|
||||||
|
assert(mixParticipantList->size() <=
|
||||||
|
kMaximumAmountOfMixedParticipants);
|
||||||
|
|
||||||
|
if (replaceWasMixed) {
|
||||||
|
RampOut(*replaceFrame);
|
||||||
|
rampOutList.PushBack(static_cast<void*>(replaceFrame));
|
||||||
|
assert(rampOutList.GetSize() <=
|
||||||
|
kMaximumAmountOfMixedParticipants);
|
||||||
} else {
|
} else {
|
||||||
static_cast<MixerParticipant*>(
|
_audioFramePool->PushMemory(replaceFrame);
|
||||||
replaceParticipant->GetItem())->_mixHistory->
|
|
||||||
WasMixed(replaceWasMixed);
|
|
||||||
|
|
||||||
mixParticipantList.Erase(replaceFrame->id_);
|
|
||||||
activeList.Erase(replaceItem);
|
|
||||||
|
|
||||||
activeList.PushFront(static_cast<void*>(audioFrame));
|
|
||||||
mixParticipantList.Insert(
|
|
||||||
audioFrame->id_,
|
|
||||||
static_cast<void*>(participant));
|
|
||||||
assert(mixParticipantList.Size() <=
|
|
||||||
kMaximumAmountOfMixedParticipants);
|
|
||||||
|
|
||||||
if(replaceWasMixed)
|
|
||||||
{
|
|
||||||
RampOut(*replaceFrame);
|
|
||||||
rampOutList.PushBack(
|
|
||||||
static_cast<void*>(replaceFrame));
|
|
||||||
assert(rampOutList.GetSize() <=
|
|
||||||
kMaximumAmountOfMixedParticipants);
|
|
||||||
} else {
|
|
||||||
_audioFramePool->PushMemory(replaceFrame);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(wasMixed)
|
if(wasMixed)
|
||||||
@ -858,9 +843,8 @@ void AudioConferenceMixerImpl::UpdateToMix(
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
activeList.PushFront(static_cast<void*>(audioFrame));
|
activeList.PushFront(static_cast<void*>(audioFrame));
|
||||||
mixParticipantList.Insert(audioFrame->id_,
|
(*mixParticipantList)[audioFrame->id_] = participant;
|
||||||
static_cast<void*>(participant));
|
assert(mixParticipantList->size() <=
|
||||||
assert(mixParticipantList.Size() <=
|
|
||||||
kMaximumAmountOfMixedParticipants);
|
kMaximumAmountOfMixedParticipants);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -902,9 +886,9 @@ void AudioConferenceMixerImpl::UpdateToMix(
|
|||||||
if(mixList.GetSize() < maxAudioFrameCounter + mixListStartSize)
|
if(mixList.GetSize() < maxAudioFrameCounter + mixListStartSize)
|
||||||
{
|
{
|
||||||
mixList.PushBack(pair->audioFrame);
|
mixList.PushBack(pair->audioFrame);
|
||||||
mixParticipantList.Insert(pair->audioFrame->id_,
|
(*mixParticipantList)[pair->audioFrame->id_] =
|
||||||
static_cast<void*>(pair->participant));
|
pair->participant;
|
||||||
assert(mixParticipantList.Size() <=
|
assert(mixParticipantList->size() <=
|
||||||
kMaximumAmountOfMixedParticipants);
|
kMaximumAmountOfMixedParticipants);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -923,9 +907,8 @@ void AudioConferenceMixerImpl::UpdateToMix(
|
|||||||
if(mixList.GetSize() < maxAudioFrameCounter + mixListStartSize)
|
if(mixList.GetSize() < maxAudioFrameCounter + mixListStartSize)
|
||||||
{
|
{
|
||||||
mixList.PushBack(pair->audioFrame);
|
mixList.PushBack(pair->audioFrame);
|
||||||
mixParticipantList.Insert(pair->audioFrame->id_,
|
(*mixParticipantList)[pair->audioFrame->id_] = pair->participant;
|
||||||
static_cast<void*>(pair->participant));
|
assert(mixParticipantList->size() <=
|
||||||
assert(mixParticipantList.Size() <=
|
|
||||||
kMaximumAmountOfMixedParticipants);
|
kMaximumAmountOfMixedParticipants);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -983,11 +966,11 @@ void AudioConferenceMixerImpl::GetAdditionalAudio(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AudioConferenceMixerImpl::UpdateMixedStatus(
|
void AudioConferenceMixerImpl::UpdateMixedStatus(
|
||||||
MapWrapper& mixedParticipantsMap)
|
std::map<int, MixerParticipant*>& mixedParticipantsMap)
|
||||||
{
|
{
|
||||||
WEBRTC_TRACE(kTraceStream, kTraceAudioMixerServer, _id,
|
WEBRTC_TRACE(kTraceStream, kTraceAudioMixerServer, _id,
|
||||||
"UpdateMixedStatus(mixedParticipantsMap)");
|
"UpdateMixedStatus(mixedParticipantsMap)");
|
||||||
assert(mixedParticipantsMap.Size() <= kMaximumAmountOfMixedParticipants);
|
assert(mixedParticipantsMap.size() <= kMaximumAmountOfMixedParticipants);
|
||||||
|
|
||||||
// Loop through all participants. If they are in the mix map they
|
// Loop through all participants. If they are in the mix map they
|
||||||
// were mixed.
|
// were mixed.
|
||||||
@ -998,15 +981,14 @@ void AudioConferenceMixerImpl::UpdateMixedStatus(
|
|||||||
MixerParticipant* participant =
|
MixerParticipant* participant =
|
||||||
static_cast<MixerParticipant*>(participantItem->GetItem());
|
static_cast<MixerParticipant*>(participantItem->GetItem());
|
||||||
|
|
||||||
MapItem* mixedItem = mixedParticipantsMap.First();
|
for (std::map<int, MixerParticipant*>::iterator it =
|
||||||
while(mixedItem)
|
mixedParticipantsMap.begin();
|
||||||
{
|
it != mixedParticipantsMap.end();
|
||||||
if(participant == mixedItem->GetItem())
|
++it) {
|
||||||
{
|
if (it->second == participant) {
|
||||||
isMixed = true;
|
isMixed = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
mixedItem = mixedParticipantsMap.Next(mixedItem);
|
|
||||||
}
|
}
|
||||||
participant->_mixHistory->SetIsMixed(isMixed);
|
participant->_mixHistory->SetIsMixed(isMixed);
|
||||||
participantItem = _participantList.Next(participantItem);
|
participantItem = _participantList.Next(participantItem);
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
#ifndef WEBRTC_MODULES_AUDIO_CONFERENCE_MIXER_SOURCE_AUDIO_CONFERENCE_MIXER_IMPL_H_
|
#ifndef WEBRTC_MODULES_AUDIO_CONFERENCE_MIXER_SOURCE_AUDIO_CONFERENCE_MIXER_IMPL_H_
|
||||||
#define WEBRTC_MODULES_AUDIO_CONFERENCE_MIXER_SOURCE_AUDIO_CONFERENCE_MIXER_IMPL_H_
|
#define WEBRTC_MODULES_AUDIO_CONFERENCE_MIXER_SOURCE_AUDIO_CONFERENCE_MIXER_IMPL_H_
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
#include "webrtc/engine_configurations.h"
|
#include "webrtc/engine_configurations.h"
|
||||||
#include "webrtc/modules/audio_conference_mixer/interface/audio_conference_mixer.h"
|
#include "webrtc/modules/audio_conference_mixer/interface/audio_conference_mixer.h"
|
||||||
#include "webrtc/modules/audio_conference_mixer/source/level_indicator.h"
|
#include "webrtc/modules/audio_conference_mixer/source/level_indicator.h"
|
||||||
@ -99,9 +101,11 @@ private:
|
|||||||
// rampOutList contain AudioFrames corresponding to an audio stream that
|
// rampOutList contain AudioFrames corresponding to an audio stream that
|
||||||
// used to be mixed but shouldn't be mixed any longer. These AudioFrames
|
// used to be mixed but shouldn't be mixed any longer. These AudioFrames
|
||||||
// should be ramped out over this AudioFrame to avoid audio discontinuities.
|
// should be ramped out over this AudioFrame to avoid audio discontinuities.
|
||||||
void UpdateToMix(ListWrapper& mixList, ListWrapper& rampOutList,
|
void UpdateToMix(
|
||||||
MapWrapper& mixParticipantList,
|
ListWrapper& mixList,
|
||||||
uint32_t& maxAudioFrameCounter);
|
ListWrapper& rampOutList,
|
||||||
|
std::map<int, MixerParticipant*>* mixParticipantList,
|
||||||
|
uint32_t& maxAudioFrameCounter);
|
||||||
|
|
||||||
// Return the lowest mixing frequency that can be used without having to
|
// Return the lowest mixing frequency that can be used without having to
|
||||||
// downsample any audio.
|
// downsample any audio.
|
||||||
@ -113,7 +117,8 @@ private:
|
|||||||
|
|
||||||
// Update the MixHistory of all MixerParticipants. mixedParticipantsList
|
// Update the MixHistory of all MixerParticipants. mixedParticipantsList
|
||||||
// should contain a map of MixerParticipants that have been mixed.
|
// should contain a map of MixerParticipants that have been mixed.
|
||||||
void UpdateMixedStatus(MapWrapper& mixedParticipantsList);
|
void UpdateMixedStatus(
|
||||||
|
std::map<int, MixerParticipant*>& mixedParticipantsList);
|
||||||
|
|
||||||
// Clears audioFrameList and reclaims all memory associated with it.
|
// Clears audioFrameList and reclaims all memory associated with it.
|
||||||
void ClearAudioFrameList(ListWrapper& audioFrameList);
|
void ClearAudioFrameList(ListWrapper& audioFrameList);
|
||||||
|
@ -161,11 +161,12 @@ int32_t DeviceInfoAndroid::GetDeviceName(
|
|||||||
|
|
||||||
int32_t DeviceInfoAndroid::CreateCapabilityMap(
|
int32_t DeviceInfoAndroid::CreateCapabilityMap(
|
||||||
const char* deviceUniqueIdUTF8) {
|
const char* deviceUniqueIdUTF8) {
|
||||||
MapItem* item = NULL;
|
for (std::map<int, VideoCaptureCapability*>::iterator it =
|
||||||
while ((item = _captureCapabilities.Last())) {
|
_captureCapabilities.begin();
|
||||||
delete (VideoCaptureCapability*) item->GetItem();
|
it != _captureCapabilities.end();
|
||||||
_captureCapabilities.Erase(item);
|
++it)
|
||||||
}
|
delete it->second;
|
||||||
|
_captureCapabilities.clear();
|
||||||
|
|
||||||
JNIEnv *env;
|
JNIEnv *env;
|
||||||
jclass javaCmDevInfoClass;
|
jclass javaCmDevInfoClass;
|
||||||
@ -247,7 +248,7 @@ int32_t DeviceInfoAndroid::CreateCapabilityMap(
|
|||||||
WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideoCapture, _id,
|
WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideoCapture, _id,
|
||||||
"%s: Cap width %d, height %d, fps %d", __FUNCTION__,
|
"%s: Cap width %d, height %d, fps %d", __FUNCTION__,
|
||||||
cap->width, cap->height, cap->maxFPS);
|
cap->width, cap->height, cap->maxFPS);
|
||||||
_captureCapabilities.Insert(i, cap);
|
_captureCapabilities[i] = cap;
|
||||||
}
|
}
|
||||||
|
|
||||||
_lastUsedDeviceNameLength = strlen((char*) deviceUniqueIdUTF8);
|
_lastUsedDeviceNameLength = strlen((char*) deviceUniqueIdUTF8);
|
||||||
@ -259,9 +260,9 @@ int32_t DeviceInfoAndroid::CreateCapabilityMap(
|
|||||||
|
|
||||||
VideoCaptureAndroid::ReleaseAndroidDeviceInfoObjects(attached);
|
VideoCaptureAndroid::ReleaseAndroidDeviceInfoObjects(attached);
|
||||||
WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideoCapture, _id,
|
WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideoCapture, _id,
|
||||||
"CreateCapabilityMap %d", _captureCapabilities.Size());
|
"CreateCapabilityMap %d", _captureCapabilities.size());
|
||||||
|
|
||||||
return _captureCapabilities.Size();
|
return _captureCapabilities.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t DeviceInfoAndroid::GetOrientation(
|
int32_t DeviceInfoAndroid::GetOrientation(
|
||||||
|
@ -31,13 +31,13 @@ DeviceInfoImpl::DeviceInfoImpl(const int32_t id)
|
|||||||
DeviceInfoImpl::~DeviceInfoImpl(void)
|
DeviceInfoImpl::~DeviceInfoImpl(void)
|
||||||
{
|
{
|
||||||
_apiLock.AcquireLockExclusive();
|
_apiLock.AcquireLockExclusive();
|
||||||
// Reset old capability list
|
|
||||||
MapItem* item = NULL;
|
for (VideoCaptureCapabilityMap::iterator it = _captureCapabilities.begin();
|
||||||
while ((item = _captureCapabilities.Last()))
|
it != _captureCapabilities.end();
|
||||||
{
|
++it) {
|
||||||
delete (VideoCaptureCapability*) item->GetItem();
|
delete it->second;
|
||||||
_captureCapabilities.Erase(item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
free(_lastUsedDeviceName);
|
free(_lastUsedDeviceName);
|
||||||
_apiLock.ReleaseLockExclusive();
|
_apiLock.ReleaseLockExclusive();
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ int32_t DeviceInfoImpl::NumberOfCapabilities(
|
|||||||
{
|
{
|
||||||
//yes
|
//yes
|
||||||
_apiLock.ReleaseLockShared();
|
_apiLock.ReleaseLockShared();
|
||||||
return _captureCapabilities.Size();
|
return static_cast<int32_t>(_captureCapabilities.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Need to get exclusive rights to create the new capability map.
|
// Need to get exclusive rights to create the new capability map.
|
||||||
@ -116,7 +116,7 @@ int32_t DeviceInfoImpl::GetCapability(const char* deviceUniqueIdUTF8,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the number is valid
|
// Make sure the number is valid
|
||||||
if (deviceCapabilityNumber >= (unsigned int) _captureCapabilities.Size())
|
if (deviceCapabilityNumber >= (unsigned int) _captureCapabilities.size())
|
||||||
{
|
{
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCapture, _id,
|
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCapture, _id,
|
||||||
"deviceCapabilityNumber %d is invalid in call to GetCapability",
|
"deviceCapabilityNumber %d is invalid in call to GetCapability",
|
||||||
@ -124,23 +124,23 @@ int32_t DeviceInfoImpl::GetCapability(const char* deviceUniqueIdUTF8,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
MapItem* item = _captureCapabilities.Find(deviceCapabilityNumber);
|
VideoCaptureCapabilityMap::iterator item =
|
||||||
if (!item)
|
_captureCapabilities.find(deviceCapabilityNumber);
|
||||||
|
|
||||||
|
if (item == _captureCapabilities.end())
|
||||||
{
|
{
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCapture, _id,
|
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCapture, _id,
|
||||||
"Failed to find capability number %d of %d possible",
|
"Failed to find capability number %d of %d possible",
|
||||||
deviceCapabilityNumber, _captureCapabilities.Size());
|
deviceCapabilityNumber, _captureCapabilities.size());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoCaptureCapability* capPointer = static_cast<VideoCaptureCapability*>
|
if (item->second == NULL)
|
||||||
(item->GetItem());
|
|
||||||
if (!capPointer)
|
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
capability = *capPointer;
|
capability = *item->second;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,16 +183,16 @@ int32_t DeviceInfoImpl::GetBestMatchedCapability(
|
|||||||
RawVideoType bestRawType = kVideoUnknown;
|
RawVideoType bestRawType = kVideoUnknown;
|
||||||
webrtc::VideoCodecType bestCodecType = webrtc::kVideoCodecUnknown;
|
webrtc::VideoCodecType bestCodecType = webrtc::kVideoCodecUnknown;
|
||||||
|
|
||||||
const int32_t numberOfCapabilies = _captureCapabilities.Size();
|
const int32_t numberOfCapabilies =
|
||||||
|
static_cast<int32_t>(_captureCapabilities.size());
|
||||||
|
|
||||||
for (int32_t tmp = 0; tmp < numberOfCapabilies; ++tmp) // Loop through all capabilities
|
for (int32_t tmp = 0; tmp < numberOfCapabilies; ++tmp) // Loop through all capabilities
|
||||||
{
|
{
|
||||||
MapItem* item = _captureCapabilities.Find(tmp);
|
VideoCaptureCapabilityMap::iterator item = _captureCapabilities.find(tmp);
|
||||||
if (!item)
|
if (item == _captureCapabilities.end())
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
VideoCaptureCapability& capability = *static_cast<VideoCaptureCapability*>
|
VideoCaptureCapability& capability = *item->second;
|
||||||
(item->GetItem());
|
|
||||||
|
|
||||||
const int32_t diffWidth = capability.width - requested.width;
|
const int32_t diffWidth = capability.width - requested.width;
|
||||||
const int32_t diffHeight = capability.height - requested.height;
|
const int32_t diffHeight = capability.height - requested.height;
|
||||||
@ -298,15 +298,14 @@ int32_t DeviceInfoImpl::GetBestMatchedCapability(
|
|||||||
bestWidth, bestHeight, bestFrameRate, bestRawType);
|
bestWidth, bestHeight, bestFrameRate, bestRawType);
|
||||||
|
|
||||||
// Copy the capability
|
// Copy the capability
|
||||||
MapItem* item = _captureCapabilities.Find(bestformatIndex);
|
VideoCaptureCapabilityMap::iterator item =
|
||||||
if (!item)
|
_captureCapabilities.find(bestformatIndex);
|
||||||
|
if (item == _captureCapabilities.end())
|
||||||
return -1;
|
return -1;
|
||||||
VideoCaptureCapability* capPointer =
|
if (item->second == NULL)
|
||||||
static_cast<VideoCaptureCapability*> (item->GetItem());
|
|
||||||
if (!capPointer)
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
resulting = *capPointer;
|
resulting = *item->second;
|
||||||
|
|
||||||
return bestformatIndex;
|
return bestformatIndex;
|
||||||
}
|
}
|
||||||
|
@ -11,9 +11,10 @@
|
|||||||
#ifndef WEBRTC_MODULES_VIDEO_CAPTURE_MAIN_SOURCE_DEVICE_INFO_IMPL_H_
|
#ifndef WEBRTC_MODULES_VIDEO_CAPTURE_MAIN_SOURCE_DEVICE_INFO_IMPL_H_
|
||||||
#define WEBRTC_MODULES_VIDEO_CAPTURE_MAIN_SOURCE_DEVICE_INFO_IMPL_H_
|
#define WEBRTC_MODULES_VIDEO_CAPTURE_MAIN_SOURCE_DEVICE_INFO_IMPL_H_
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
#include "webrtc/modules/video_capture/include/video_capture.h"
|
#include "webrtc/modules/video_capture/include/video_capture.h"
|
||||||
#include "webrtc/modules/video_capture/video_capture_delay.h"
|
#include "webrtc/modules/video_capture/video_capture_delay.h"
|
||||||
#include "webrtc/system_wrappers/interface/map_wrapper.h"
|
|
||||||
#include "webrtc/system_wrappers/interface/rw_lock_wrapper.h"
|
#include "webrtc/system_wrappers/interface/rw_lock_wrapper.h"
|
||||||
|
|
||||||
namespace webrtc
|
namespace webrtc
|
||||||
@ -57,7 +58,8 @@ protected:
|
|||||||
protected:
|
protected:
|
||||||
// Data members
|
// Data members
|
||||||
int32_t _id;
|
int32_t _id;
|
||||||
MapWrapper _captureCapabilities;
|
typedef std::map<int, VideoCaptureCapability*> VideoCaptureCapabilityMap;
|
||||||
|
VideoCaptureCapabilityMap _captureCapabilities;
|
||||||
RWLockWrapper& _apiLock;
|
RWLockWrapper& _apiLock;
|
||||||
char* _lastUsedDeviceName;
|
char* _lastUsedDeviceName;
|
||||||
uint32_t _lastUsedDeviceNameLength;
|
uint32_t _lastUsedDeviceNameLength;
|
||||||
|
@ -219,12 +219,13 @@ int32_t DeviceInfoLinux::CreateCapabilityMap(
|
|||||||
|
|
||||||
// now fd will point to the matching device
|
// now fd will point to the matching device
|
||||||
// reset old capability map
|
// reset old capability map
|
||||||
MapItem* item = NULL;
|
for (std::map<int, VideoCaptureCapability*>::iterator it =
|
||||||
while ((item = _captureCapabilities.Last()))
|
_captureCapabilities.begin();
|
||||||
{
|
it != _captureCapabilities.end();
|
||||||
delete static_cast<VideoCaptureCapability*> (item->GetItem());
|
++it) {
|
||||||
_captureCapabilities.Erase(item);
|
delete it->second;
|
||||||
}
|
}
|
||||||
|
_captureCapabilities.clear();
|
||||||
|
|
||||||
int size = FillCapabilityMap(fd);
|
int size = FillCapabilityMap(fd);
|
||||||
close(fd);
|
close(fd);
|
||||||
@ -235,8 +236,11 @@ int32_t DeviceInfoLinux::CreateCapabilityMap(
|
|||||||
_lastUsedDeviceNameLength + 1);
|
_lastUsedDeviceNameLength + 1);
|
||||||
memcpy(_lastUsedDeviceName, deviceUniqueIdUTF8, _lastUsedDeviceNameLength + 1);
|
memcpy(_lastUsedDeviceName, deviceUniqueIdUTF8, _lastUsedDeviceNameLength + 1);
|
||||||
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideoCapture, _id, "CreateCapabilityMap %d",
|
WEBRTC_TRACE(webrtc::kTraceInfo,
|
||||||
_captureCapabilities.Size());
|
webrtc::kTraceVideoCapture,
|
||||||
|
_id,
|
||||||
|
"CreateCapabilityMap %u",
|
||||||
|
static_cast<unsigned int>(_captureCapabilities.size()));
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
@ -314,7 +318,7 @@ int32_t DeviceInfoLinux::FillCapabilityMap(int fd)
|
|||||||
cap->maxFPS = 30;
|
cap->maxFPS = 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
_captureCapabilities.Insert(index, cap);
|
_captureCapabilities[index] = cap;
|
||||||
index++;
|
index++;
|
||||||
WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideoCapture, _id,
|
WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideoCapture, _id,
|
||||||
"Camera capability, width:%d height:%d type:%d fps:%d",
|
"Camera capability, width:%d height:%d type:%d fps:%d",
|
||||||
@ -324,9 +328,12 @@ int32_t DeviceInfoLinux::FillCapabilityMap(int fd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideoCapture, _id, "CreateCapabilityMap %d",
|
WEBRTC_TRACE(webrtc::kTraceInfo,
|
||||||
_captureCapabilities.Size());
|
webrtc::kTraceVideoCapture,
|
||||||
return _captureCapabilities.Size();
|
_id,
|
||||||
|
"CreateCapabilityMap %u",
|
||||||
|
static_cast<unsigned int>(_captureCapabilities.size()));
|
||||||
|
return _captureCapabilities.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace videocapturemodule
|
} // namespace videocapturemodule
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
#include "webrtc/modules/video_capture/device_info_impl.h"
|
#include "webrtc/modules/video_capture/device_info_impl.h"
|
||||||
#include "webrtc/modules/video_capture/mac/qtkit/video_capture_qtkit_utility.h"
|
#include "webrtc/modules/video_capture/mac/qtkit/video_capture_qtkit_utility.h"
|
||||||
#include "webrtc/modules/video_capture/video_capture_impl.h"
|
#include "webrtc/modules/video_capture/video_capture_impl.h"
|
||||||
#include "webrtc/system_wrappers/interface/map_wrapper.h"
|
|
||||||
|
|
||||||
|
|
||||||
@class VideoCaptureMacQTKitInfoObjC;
|
@class VideoCaptureMacQTKitInfoObjC;
|
||||||
|
@ -367,23 +367,18 @@ IBaseFilter * DeviceInfoDS::GetDeviceFilter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t DeviceInfoDS::GetWindowsCapability(
|
int32_t DeviceInfoDS::GetWindowsCapability(
|
||||||
const int32_t capabilityIndex,
|
const int32_t capabilityIndex,
|
||||||
VideoCaptureCapabilityWindows& windowsCapability)
|
VideoCaptureCapabilityWindows& windowsCapability) {
|
||||||
|
ReadLockScoped cs(_apiLock);
|
||||||
|
|
||||||
{
|
std::map<int, VideoCaptureCapability*>::iterator item =
|
||||||
ReadLockScoped cs(_apiLock);
|
_captureCapabilities.find(capabilityIndex);
|
||||||
// Make sure the number is valid
|
if (item == _captureCapabilities.end())
|
||||||
if (capabilityIndex >= _captureCapabilities.Size() || capabilityIndex < 0)
|
return -1;
|
||||||
return -1;
|
|
||||||
|
|
||||||
MapItem* item = _captureCapabilities.Find(capabilityIndex);
|
windowsCapability =
|
||||||
if (!item)
|
*static_cast<VideoCaptureCapabilityWindows*>(item->second);
|
||||||
return -1;
|
return 0;
|
||||||
|
|
||||||
VideoCaptureCapabilityWindows* capPointer =
|
|
||||||
static_cast<VideoCaptureCapabilityWindows*> (item->GetItem());
|
|
||||||
windowsCapability = *capPointer;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t DeviceInfoDS::CreateCapabilityMap(
|
int32_t DeviceInfoDS::CreateCapabilityMap(
|
||||||
@ -391,15 +386,15 @@ int32_t DeviceInfoDS::CreateCapabilityMap(
|
|||||||
|
|
||||||
{
|
{
|
||||||
// Reset old capability list
|
// Reset old capability list
|
||||||
MapItem* item = NULL;
|
for (std::map<int, VideoCaptureCapability*>::iterator it =
|
||||||
while (item = _captureCapabilities.Last())
|
_captureCapabilities.begin();
|
||||||
{
|
it != _captureCapabilities.end();
|
||||||
VideoCaptureCapabilityWindows* cap =
|
++it) {
|
||||||
static_cast<VideoCaptureCapabilityWindows*> (item->GetItem());
|
delete it->second;
|
||||||
delete cap;
|
|
||||||
_captureCapabilities.Erase(item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_captureCapabilities.clear();
|
||||||
|
|
||||||
const int32_t deviceUniqueIdUTF8Length =
|
const int32_t deviceUniqueIdUTF8Length =
|
||||||
(int32_t) strlen((char*) deviceUniqueIdUTF8);
|
(int32_t) strlen((char*) deviceUniqueIdUTF8);
|
||||||
if (deviceUniqueIdUTF8Length > kVideoCaptureUniqueNameLength)
|
if (deviceUniqueIdUTF8Length > kVideoCaptureUniqueNameLength)
|
||||||
@ -678,7 +673,7 @@ int32_t DeviceInfoDS::CreateCapabilityMap(
|
|||||||
productId,
|
productId,
|
||||||
capability->width,
|
capability->width,
|
||||||
capability->height);
|
capability->height);
|
||||||
_captureCapabilities.Insert(index++, capability);
|
_captureCapabilities[index++] = capability;
|
||||||
WEBRTC_TRACE( webrtc::kTraceInfo, webrtc::kTraceVideoCapture, _id,
|
WEBRTC_TRACE( webrtc::kTraceInfo, webrtc::kTraceVideoCapture, _id,
|
||||||
"Camera capability, width:%d height:%d type:%d fps:%d",
|
"Camera capability, width:%d height:%d type:%d fps:%d",
|
||||||
capability->width, capability->height,
|
capability->width, capability->height,
|
||||||
@ -699,9 +694,9 @@ int32_t DeviceInfoDS::CreateCapabilityMap(
|
|||||||
+ 1);
|
+ 1);
|
||||||
memcpy(_lastUsedDeviceName, deviceUniqueIdUTF8, _lastUsedDeviceNameLength+ 1);
|
memcpy(_lastUsedDeviceName, deviceUniqueIdUTF8, _lastUsedDeviceNameLength+ 1);
|
||||||
WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideoCapture, _id,
|
WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideoCapture, _id,
|
||||||
"CreateCapabilityMap %d", _captureCapabilities.Size());
|
"CreateCapabilityMap %d", _captureCapabilities.size());
|
||||||
|
|
||||||
return _captureCapabilities.Size();
|
return static_cast<int32_t>(_captureCapabilities.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Constructs a product ID from the Windows DevicePath. on a USB device the devicePath contains product id and vendor id.
|
/* Constructs a product ID from the Windows DevicePath. on a USB device the devicePath contains product id and vendor id.
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
|
|
||||||
#include "webrtc/modules/video_capture/device_info_impl.h"
|
#include "webrtc/modules/video_capture/device_info_impl.h"
|
||||||
#include "webrtc/modules/video_capture/video_capture_impl.h"
|
#include "webrtc/modules/video_capture/video_capture_impl.h"
|
||||||
#include "webrtc/system_wrappers/interface/map_wrapper.h"
|
|
||||||
|
|
||||||
#include <Dshow.h>
|
#include <Dshow.h>
|
||||||
|
|
||||||
|
@ -46,7 +46,6 @@ VideoRenderAndroid::VideoRenderAndroid(
|
|||||||
_critSect(*CriticalSectionWrapper::CreateCriticalSection()),
|
_critSect(*CriticalSectionWrapper::CreateCriticalSection()),
|
||||||
_renderType(videoRenderType),
|
_renderType(videoRenderType),
|
||||||
_ptrWindow((jobject)(window)),
|
_ptrWindow((jobject)(window)),
|
||||||
_streamsMap(),
|
|
||||||
_javaShutDownFlag(false),
|
_javaShutDownFlag(false),
|
||||||
_javaShutdownEvent(*EventWrapper::Create()),
|
_javaShutdownEvent(*EventWrapper::Create()),
|
||||||
_javaRenderEvent(*EventWrapper::Create()),
|
_javaRenderEvent(*EventWrapper::Create()),
|
||||||
@ -62,9 +61,10 @@ VideoRenderAndroid::~VideoRenderAndroid() {
|
|||||||
if (_javaRenderThread)
|
if (_javaRenderThread)
|
||||||
StopRender();
|
StopRender();
|
||||||
|
|
||||||
for (MapItem* item = _streamsMap.First(); item != NULL; item
|
for (AndroidStreamMap::iterator it = _streamsMap.begin();
|
||||||
= _streamsMap.Next(item)) { // Delete streams
|
it != _streamsMap.end();
|
||||||
delete static_cast<AndroidStream*> (item->GetItem());
|
++it) {
|
||||||
|
delete it->second;
|
||||||
}
|
}
|
||||||
delete &_javaShutdownEvent;
|
delete &_javaShutdownEvent;
|
||||||
delete &_javaRenderEvent;
|
delete &_javaRenderEvent;
|
||||||
@ -91,20 +91,20 @@ VideoRenderAndroid::AddIncomingRenderStream(const uint32_t streamId,
|
|||||||
CriticalSectionScoped cs(&_critSect);
|
CriticalSectionScoped cs(&_critSect);
|
||||||
|
|
||||||
AndroidStream* renderStream = NULL;
|
AndroidStream* renderStream = NULL;
|
||||||
MapItem* item = _streamsMap.Find(streamId);
|
AndroidStreamMap::iterator item = _streamsMap.find(streamId);
|
||||||
if (item) {
|
if (item != _streamsMap.end() && item->second != NULL) {
|
||||||
renderStream = (AndroidStream*) (item->GetItem());
|
WEBRTC_TRACE(kTraceInfo,
|
||||||
if (NULL != renderStream) {
|
kTraceVideoRenderer,
|
||||||
WEBRTC_TRACE(kTraceInfo, kTraceVideoRenderer, -1,
|
-1,
|
||||||
"%s: Render stream already exists", __FUNCTION__);
|
"%s: Render stream already exists",
|
||||||
return renderStream;
|
__FUNCTION__);
|
||||||
}
|
return renderStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
renderStream = CreateAndroidRenderChannel(streamId, zOrder, left, top,
|
renderStream = CreateAndroidRenderChannel(streamId, zOrder, left, top,
|
||||||
right, bottom, *this);
|
right, bottom, *this);
|
||||||
if (renderStream) {
|
if (renderStream) {
|
||||||
_streamsMap.Insert(streamId, renderStream);
|
_streamsMap[streamId] = renderStream;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id,
|
WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id,
|
||||||
@ -118,16 +118,14 @@ int32_t VideoRenderAndroid::DeleteIncomingRenderStream(
|
|||||||
const uint32_t streamId) {
|
const uint32_t streamId) {
|
||||||
CriticalSectionScoped cs(&_critSect);
|
CriticalSectionScoped cs(&_critSect);
|
||||||
|
|
||||||
MapItem* item = _streamsMap.Find(streamId);
|
AndroidStreamMap::iterator item = _streamsMap.find(streamId);
|
||||||
if (item) {
|
if (item == _streamsMap.end()) {
|
||||||
delete (AndroidStream*) item->GetItem();
|
|
||||||
_streamsMap.Erase(streamId);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id,
|
WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id,
|
||||||
"(%s:%d): renderStream is NULL", __FUNCTION__, __LINE__);
|
"(%s:%d): renderStream is NULL", __FUNCTION__, __LINE__);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
delete item->second;
|
||||||
|
_streamsMap.erase(item);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,10 +232,10 @@ bool VideoRenderAndroid::JavaRenderThreadProcess()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (MapItem* item = _streamsMap.First(); item != NULL;
|
for (AndroidStreamMap::iterator it = _streamsMap.begin();
|
||||||
item = _streamsMap.Next(item)) {
|
it != _streamsMap.end();
|
||||||
static_cast<AndroidStream*> (item->GetItem())->DeliverFrame(
|
++it) {
|
||||||
_javaRenderJniEnv);
|
it->second->DeliverFrame(_javaRenderJniEnv);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_javaShutDownFlag) {
|
if (_javaShutDownFlag) {
|
||||||
|
@ -12,8 +12,10 @@
|
|||||||
#define WEBRTC_MODULES_VIDEO_RENDER_MAIN_SOURCE_ANDROID_VIDEO_RENDER_ANDROID_IMPL_H_
|
#define WEBRTC_MODULES_VIDEO_RENDER_MAIN_SOURCE_ANDROID_VIDEO_RENDER_ANDROID_IMPL_H_
|
||||||
|
|
||||||
#include <jni.h>
|
#include <jni.h>
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
#include "webrtc/modules/video_render/i_video_render.h"
|
#include "webrtc/modules/video_render/i_video_render.h"
|
||||||
#include "webrtc/system_wrappers/interface/map_wrapper.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
@ -136,7 +138,8 @@ class VideoRenderAndroid: IVideoRender {
|
|||||||
bool JavaRenderThreadProcess();
|
bool JavaRenderThreadProcess();
|
||||||
|
|
||||||
// Map with streams to render.
|
// Map with streams to render.
|
||||||
MapWrapper _streamsMap;
|
typedef std::map<int32_t, AndroidStream*> AndroidStreamMap;
|
||||||
|
AndroidStreamMap _streamsMap;
|
||||||
// True if the _javaRenderThread thread shall be detached from the JVM.
|
// True if the _javaRenderThread thread shall be detached from the JVM.
|
||||||
bool _javaShutDownFlag;
|
bool _javaShutDownFlag;
|
||||||
EventWrapper& _javaShutdownEvent;
|
EventWrapper& _javaShutdownEvent;
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
#include "webrtc/modules/video_render//video_render_frames.h"
|
#include "webrtc/modules/video_render//video_render_frames.h"
|
||||||
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
||||||
#include "webrtc/system_wrappers/interface/event_wrapper.h"
|
#include "webrtc/system_wrappers/interface/event_wrapper.h"
|
||||||
#include "webrtc/system_wrappers/interface/map_wrapper.h"
|
|
||||||
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
||||||
#include "webrtc/system_wrappers/interface/tick_util.h"
|
#include "webrtc/system_wrappers/interface/tick_util.h"
|
||||||
#include "webrtc/system_wrappers/interface/trace.h"
|
#include "webrtc/system_wrappers/interface/trace.h"
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
#define WEBRTC_MODULES_VIDEO_RENDER_MAIN_SOURCE_INCOMING_VIDEO_STREAM_H_
|
#define WEBRTC_MODULES_VIDEO_RENDER_MAIN_SOURCE_INCOMING_VIDEO_STREAM_H_
|
||||||
|
|
||||||
#include "webrtc/modules/video_render/include/video_render.h"
|
#include "webrtc/modules/video_render/include/video_render.h"
|
||||||
#include "webrtc/system_wrappers/interface/map_wrapper.h"
|
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
class CriticalSectionWrapper;
|
class CriticalSectionWrapper;
|
||||||
|
@ -96,8 +96,7 @@ ModuleVideoRenderImpl::ModuleVideoRenderImpl(
|
|||||||
void* window,
|
void* window,
|
||||||
const bool fullscreen) :
|
const bool fullscreen) :
|
||||||
_id(id), _moduleCrit(*CriticalSectionWrapper::CreateCriticalSection()),
|
_id(id), _moduleCrit(*CriticalSectionWrapper::CreateCriticalSection()),
|
||||||
_ptrWindow(window), _fullScreen(fullscreen), _ptrRenderer(NULL),
|
_ptrWindow(window), _fullScreen(fullscreen), _ptrRenderer(NULL)
|
||||||
_streamRenderMap(*(new MapWrapper()))
|
|
||||||
{
|
{
|
||||||
|
|
||||||
// Create platform specific renderer
|
// Create platform specific renderer
|
||||||
@ -222,16 +221,11 @@ ModuleVideoRenderImpl::~ModuleVideoRenderImpl()
|
|||||||
{
|
{
|
||||||
delete &_moduleCrit;
|
delete &_moduleCrit;
|
||||||
|
|
||||||
while (_streamRenderMap.Size() > 0)
|
for (IncomingVideoStreamMap::iterator it = _streamRenderMap.begin();
|
||||||
{
|
it != _streamRenderMap.end();
|
||||||
MapItem* item = _streamRenderMap.First();
|
++it) {
|
||||||
IncomingVideoStream* ptrIncomingStream =
|
delete it->second;
|
||||||
static_cast<IncomingVideoStream*> (item->GetItem());
|
|
||||||
assert(ptrIncomingStream != NULL);
|
|
||||||
delete ptrIncomingStream;
|
|
||||||
_streamRenderMap.Erase(item);
|
|
||||||
}
|
}
|
||||||
delete &_streamRenderMap;
|
|
||||||
|
|
||||||
// Delete platform specific renderer
|
// Delete platform specific renderer
|
||||||
if (_ptrRenderer)
|
if (_ptrRenderer)
|
||||||
@ -410,29 +404,22 @@ int32_t ModuleVideoRenderImpl::Id()
|
|||||||
return _id;
|
return _id;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t ModuleVideoRenderImpl::GetIncomingFrameRate(
|
uint32_t ModuleVideoRenderImpl::GetIncomingFrameRate(const uint32_t streamId) {
|
||||||
const uint32_t streamId)
|
CriticalSectionScoped cs(&_moduleCrit);
|
||||||
{
|
|
||||||
CriticalSectionScoped cs(&_moduleCrit);
|
|
||||||
|
|
||||||
MapItem* mapItem = _streamRenderMap.Find(streamId);
|
IncomingVideoStreamMap::iterator it = _streamRenderMap.find(streamId);
|
||||||
if (mapItem == NULL)
|
|
||||||
{
|
if (it == _streamRenderMap.end()) {
|
||||||
// This stream doesn't exist
|
// This stream doesn't exist
|
||||||
WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id,
|
WEBRTC_TRACE(kTraceError,
|
||||||
"%s: stream doesn't exist", __FUNCTION__);
|
kTraceVideoRenderer,
|
||||||
return 0;
|
_id,
|
||||||
}
|
"%s: stream doesn't exist",
|
||||||
IncomingVideoStream* incomingStream =
|
__FUNCTION__);
|
||||||
static_cast<IncomingVideoStream*> (mapItem->GetItem());
|
return 0;
|
||||||
if (incomingStream == NULL)
|
}
|
||||||
{
|
assert(it->second != NULL);
|
||||||
// This should never happen
|
return it->second->IncomingRate();
|
||||||
assert(false);
|
|
||||||
_streamRenderMap.Erase(mapItem);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return incomingStream->IncomingRate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoRenderCallback*
|
VideoRenderCallback*
|
||||||
@ -452,8 +439,7 @@ ModuleVideoRenderImpl::AddIncomingRenderStream(const uint32_t streamId,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_streamRenderMap.Find(streamId) != NULL)
|
if (_streamRenderMap.find(streamId) != _streamRenderMap.end()) {
|
||||||
{
|
|
||||||
// The stream already exists...
|
// The stream already exists...
|
||||||
WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id,
|
WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id,
|
||||||
"%s: stream already exists", __FUNCTION__);
|
"%s: stream already exists", __FUNCTION__);
|
||||||
@ -495,7 +481,7 @@ ModuleVideoRenderImpl::AddIncomingRenderStream(const uint32_t streamId,
|
|||||||
ptrIncomingStream->ModuleCallback();
|
ptrIncomingStream->ModuleCallback();
|
||||||
|
|
||||||
// Store the stream
|
// Store the stream
|
||||||
_streamRenderMap.Insert(streamId, ptrIncomingStream);
|
_streamRenderMap[streamId] = ptrIncomingStream;
|
||||||
|
|
||||||
return moduleCallback;
|
return moduleCallback;
|
||||||
}
|
}
|
||||||
@ -512,56 +498,52 @@ int32_t ModuleVideoRenderImpl::DeleteIncomingRenderStream(
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
MapItem* mapItem = _streamRenderMap.Find(streamId);
|
IncomingVideoStreamMap::iterator item = _streamRenderMap.find(streamId);
|
||||||
if (!mapItem)
|
if (item == _streamRenderMap.end())
|
||||||
{
|
{
|
||||||
WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id,
|
WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id,
|
||||||
"%s: stream doesn't exist", __FUNCTION__);
|
"%s: stream doesn't exist", __FUNCTION__);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
IncomingVideoStream* ptrIncomingStream =
|
delete item->second;
|
||||||
static_cast<IncomingVideoStream*> (mapItem->GetItem());
|
|
||||||
delete ptrIncomingStream;
|
|
||||||
ptrIncomingStream = NULL;
|
|
||||||
_ptrRenderer->DeleteIncomingRenderStream(streamId);
|
_ptrRenderer->DeleteIncomingRenderStream(streamId);
|
||||||
_streamRenderMap.Erase(mapItem);
|
|
||||||
|
_streamRenderMap.erase(item);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ModuleVideoRenderImpl::AddExternalRenderCallback(
|
int32_t ModuleVideoRenderImpl::AddExternalRenderCallback(
|
||||||
const uint32_t streamId,
|
const uint32_t streamId,
|
||||||
VideoRenderCallback* renderObject)
|
VideoRenderCallback* renderObject) {
|
||||||
{
|
|
||||||
CriticalSectionScoped cs(&_moduleCrit);
|
CriticalSectionScoped cs(&_moduleCrit);
|
||||||
|
|
||||||
MapItem* mapItem = _streamRenderMap.Find(streamId);
|
IncomingVideoStreamMap::iterator item = _streamRenderMap.find(streamId);
|
||||||
if (!mapItem)
|
|
||||||
|
if (item == _streamRenderMap.end())
|
||||||
{
|
{
|
||||||
WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id,
|
WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id,
|
||||||
"%s: stream doesn't exist", __FUNCTION__);
|
"%s: stream doesn't exist", __FUNCTION__);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
IncomingVideoStream* ptrIncomingStream =
|
if (item->second == NULL) {
|
||||||
static_cast<IncomingVideoStream*> (mapItem->GetItem());
|
|
||||||
if (!ptrIncomingStream) {
|
|
||||||
WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id,
|
WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id,
|
||||||
"%s: could not get stream", __FUNCTION__);
|
"%s: could not get stream", __FUNCTION__);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return ptrIncomingStream->SetExternalCallback(renderObject);
|
return item->second->SetExternalCallback(renderObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ModuleVideoRenderImpl::GetIncomingRenderStreamProperties(
|
int32_t ModuleVideoRenderImpl::GetIncomingRenderStreamProperties(
|
||||||
const uint32_t streamId,
|
const uint32_t streamId,
|
||||||
uint32_t& zOrder,
|
uint32_t& zOrder,
|
||||||
float& left,
|
float& left,
|
||||||
float& top,
|
float& top,
|
||||||
float& right,
|
float& right,
|
||||||
float& bottom) const
|
float& bottom) const {
|
||||||
{
|
|
||||||
CriticalSectionScoped cs(&_moduleCrit);
|
CriticalSectionScoped cs(&_moduleCrit);
|
||||||
|
|
||||||
if (!_ptrRenderer)
|
if (!_ptrRenderer)
|
||||||
@ -580,27 +562,20 @@ uint32_t ModuleVideoRenderImpl::GetNumIncomingRenderStreams() const
|
|||||||
{
|
{
|
||||||
CriticalSectionScoped cs(&_moduleCrit);
|
CriticalSectionScoped cs(&_moduleCrit);
|
||||||
|
|
||||||
return (uint32_t) _streamRenderMap.Size();
|
return static_cast<uint32_t>(_streamRenderMap.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ModuleVideoRenderImpl::HasIncomingRenderStream(
|
bool ModuleVideoRenderImpl::HasIncomingRenderStream(
|
||||||
const uint32_t streamId) const
|
const uint32_t streamId) const {
|
||||||
{
|
CriticalSectionScoped cs(&_moduleCrit);
|
||||||
CriticalSectionScoped cs(&_moduleCrit);
|
|
||||||
|
|
||||||
bool hasStream = false;
|
return _streamRenderMap.find(streamId) != _streamRenderMap.end();
|
||||||
if (_streamRenderMap.Find(streamId) != NULL)
|
|
||||||
{
|
|
||||||
hasStream = true;
|
|
||||||
}
|
|
||||||
return hasStream;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ModuleVideoRenderImpl::RegisterRawFrameCallback(
|
int32_t ModuleVideoRenderImpl::RegisterRawFrameCallback(
|
||||||
const uint32_t streamId,
|
const uint32_t streamId,
|
||||||
VideoRenderCallback* callbackObj)
|
VideoRenderCallback* callbackObj) {
|
||||||
{
|
return -1;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ModuleVideoRenderImpl::StartRender(const uint32_t streamId)
|
int32_t ModuleVideoRenderImpl::StartRender(const uint32_t streamId)
|
||||||
@ -615,15 +590,14 @@ int32_t ModuleVideoRenderImpl::StartRender(const uint32_t streamId)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Start the stream
|
// Start the stream
|
||||||
MapItem* item = _streamRenderMap.Find(streamId);
|
IncomingVideoStreamMap::iterator item = _streamRenderMap.find(streamId);
|
||||||
if (item == NULL)
|
|
||||||
|
if (item == _streamRenderMap.end())
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
IncomingVideoStream* incomingStream =
|
if (item->second->Start() == -1)
|
||||||
static_cast<IncomingVideoStream*> (item->GetItem());
|
|
||||||
if (incomingStream->Start() == -1)
|
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -648,15 +622,14 @@ int32_t ModuleVideoRenderImpl::StopRender(const uint32_t streamId)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Stop the incoming stream
|
// Stop the incoming stream
|
||||||
MapItem* item = _streamRenderMap.Find(streamId);
|
IncomingVideoStreamMap::iterator item = _streamRenderMap.find(streamId);
|
||||||
if (item == NULL)
|
|
||||||
|
if (item == _streamRenderMap.end())
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
IncomingVideoStream* incomingStream =
|
if (item->second->Stop() == -1)
|
||||||
static_cast<IncomingVideoStream*> (item->GetItem());
|
|
||||||
if (incomingStream->Stop() == -1)
|
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -668,21 +641,15 @@ int32_t ModuleVideoRenderImpl::ResetRender()
|
|||||||
{
|
{
|
||||||
CriticalSectionScoped cs(&_moduleCrit);
|
CriticalSectionScoped cs(&_moduleCrit);
|
||||||
|
|
||||||
int32_t error = 0;
|
int32_t ret = 0;
|
||||||
|
// Loop through all incoming streams and reset them
|
||||||
// Loop through all incoming streams and stop them
|
for (IncomingVideoStreamMap::iterator it = _streamRenderMap.begin();
|
||||||
MapItem* item = _streamRenderMap.First();
|
it != _streamRenderMap.end();
|
||||||
while (item)
|
++it) {
|
||||||
{
|
if (it->second->Reset() == -1)
|
||||||
IncomingVideoStream* incomingStream =
|
ret = -1;
|
||||||
static_cast<IncomingVideoStream*> (item->GetItem());
|
|
||||||
if (incomingStream->Reset() == -1)
|
|
||||||
{
|
|
||||||
error = -1;
|
|
||||||
}
|
|
||||||
item = _streamRenderMap.Next(item);
|
|
||||||
}
|
}
|
||||||
return error;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
RawVideoType ModuleVideoRenderImpl::PreferredVideoType() const
|
RawVideoType ModuleVideoRenderImpl::PreferredVideoType() const
|
||||||
@ -830,24 +797,18 @@ int32_t ModuleVideoRenderImpl::GetLastRenderedFrame(
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
MapItem *item = _streamRenderMap.Find(streamId);
|
IncomingVideoStreamMap::const_iterator item =
|
||||||
if (item == NULL)
|
_streamRenderMap.find(streamId);
|
||||||
|
if (item == _streamRenderMap.end())
|
||||||
{
|
{
|
||||||
// This stream doesn't exist
|
// This stream doesn't exist
|
||||||
WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id,
|
WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id,
|
||||||
"%s: stream doesn't exist", __FUNCTION__);
|
"%s: stream doesn't exist", __FUNCTION__);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
IncomingVideoStream* incomingStream =
|
|
||||||
static_cast<IncomingVideoStream*> (item->GetItem());
|
assert(item->second != NULL);
|
||||||
if (incomingStream == NULL)
|
return item->second->GetLastRenderedFrame(frame);
|
||||||
{
|
|
||||||
// This should never happen
|
|
||||||
assert(false);
|
|
||||||
_streamRenderMap.Erase(item);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return incomingStream->GetLastRenderedFrame(frame);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ModuleVideoRenderImpl::SetExpectedRenderDelay(
|
int32_t ModuleVideoRenderImpl::SetExpectedRenderDelay(
|
||||||
@ -860,8 +821,9 @@ int32_t ModuleVideoRenderImpl::SetExpectedRenderDelay(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
MapItem *item = _streamRenderMap.Find(stream_id);
|
IncomingVideoStreamMap::const_iterator item =
|
||||||
if (item == NULL) {
|
_streamRenderMap.find(stream_id);
|
||||||
|
if (item == _streamRenderMap.end()) {
|
||||||
// This stream doesn't exist
|
// This stream doesn't exist
|
||||||
WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id,
|
WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id,
|
||||||
"%s(%u, %d): stream doesn't exist", __FUNCTION__, stream_id,
|
"%s(%u, %d): stream doesn't exist", __FUNCTION__, stream_id,
|
||||||
@ -869,16 +831,8 @@ int32_t ModuleVideoRenderImpl::SetExpectedRenderDelay(
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
IncomingVideoStream* incoming_stream =
|
assert(item->second != NULL);
|
||||||
static_cast<IncomingVideoStream*> (item->GetItem());
|
return item->second->SetExpectedRenderDelay(delay_ms);
|
||||||
if (incoming_stream == NULL) {
|
|
||||||
// This should never happen
|
|
||||||
assert(false);
|
|
||||||
_streamRenderMap.Erase(item);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return incoming_stream->SetExpectedRenderDelay(delay_ms);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ModuleVideoRenderImpl::ConfigureRenderer(
|
int32_t ModuleVideoRenderImpl::ConfigureRenderer(
|
||||||
@ -914,24 +868,17 @@ int32_t ModuleVideoRenderImpl::SetStartImage(
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
MapItem *item = _streamRenderMap.Find(streamId);
|
IncomingVideoStreamMap::const_iterator item =
|
||||||
if (item == NULL)
|
_streamRenderMap.find(streamId);
|
||||||
|
if (item == _streamRenderMap.end())
|
||||||
{
|
{
|
||||||
// This stream doesn't exist
|
// This stream doesn't exist
|
||||||
WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id,
|
WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id,
|
||||||
"%s: stream doesn't exist", __FUNCTION__);
|
"%s: stream doesn't exist", __FUNCTION__);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
IncomingVideoStream* incomingStream =
|
assert (item->second != NULL);
|
||||||
static_cast<IncomingVideoStream*> (item->GetItem());
|
return item->second->SetStartImage(videoFrame);
|
||||||
if (incomingStream == NULL)
|
|
||||||
{
|
|
||||||
// This should never happen
|
|
||||||
assert(false);
|
|
||||||
_streamRenderMap.Erase(item);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return incomingStream->SetStartImage(videoFrame);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -949,24 +896,17 @@ int32_t ModuleVideoRenderImpl::SetTimeoutImage(
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
MapItem *item = _streamRenderMap.Find(streamId);
|
IncomingVideoStreamMap::const_iterator item =
|
||||||
if (item == NULL)
|
_streamRenderMap.find(streamId);
|
||||||
|
if (item == _streamRenderMap.end())
|
||||||
{
|
{
|
||||||
// This stream doesn't exist
|
// This stream doesn't exist
|
||||||
WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id,
|
WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id,
|
||||||
"%s: stream doesn't exist", __FUNCTION__);
|
"%s: stream doesn't exist", __FUNCTION__);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
IncomingVideoStream* incomingStream =
|
assert(item->second != NULL);
|
||||||
static_cast<IncomingVideoStream*> (item->GetItem());
|
return item->second->SetTimeoutImage(videoFrame, timeout);
|
||||||
if (incomingStream == NULL)
|
|
||||||
{
|
|
||||||
// This should never happen
|
|
||||||
assert(false);
|
|
||||||
_streamRenderMap.Erase(item);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return incomingStream->SetTimeoutImage(videoFrame, timeout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ModuleVideoRenderImpl::MirrorRenderStream(const int renderId,
|
int32_t ModuleVideoRenderImpl::MirrorRenderStream(const int renderId,
|
||||||
@ -983,25 +923,18 @@ int32_t ModuleVideoRenderImpl::MirrorRenderStream(const int renderId,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
MapItem *item = _streamRenderMap.Find(renderId);
|
IncomingVideoStreamMap::const_iterator item =
|
||||||
if (item == NULL)
|
_streamRenderMap.find(renderId);
|
||||||
|
if (item == _streamRenderMap.end())
|
||||||
{
|
{
|
||||||
// This stream doesn't exist
|
// This stream doesn't exist
|
||||||
WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id,
|
WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id,
|
||||||
"%s: stream doesn't exist", __FUNCTION__);
|
"%s: stream doesn't exist", __FUNCTION__);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
IncomingVideoStream* incomingStream =
|
assert(item->second != NULL);
|
||||||
static_cast<IncomingVideoStream*> (item->GetItem());
|
|
||||||
if (incomingStream == NULL)
|
|
||||||
{
|
|
||||||
// This should never happen
|
|
||||||
assert(false);
|
|
||||||
_streamRenderMap.Erase(item);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return incomingStream->EnableMirroring(enable, mirrorXAxis, mirrorYAxis);
|
return item->second->EnableMirroring(enable, mirrorXAxis, mirrorYAxis);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
@ -11,15 +11,15 @@
|
|||||||
#ifndef WEBRTC_MODULES_VIDEO_RENDER_MAIN_SOURCE_VIDEO_RENDER_IMPL_H_
|
#ifndef WEBRTC_MODULES_VIDEO_RENDER_MAIN_SOURCE_VIDEO_RENDER_IMPL_H_
|
||||||
#define WEBRTC_MODULES_VIDEO_RENDER_MAIN_SOURCE_VIDEO_RENDER_IMPL_H_
|
#define WEBRTC_MODULES_VIDEO_RENDER_MAIN_SOURCE_VIDEO_RENDER_IMPL_H_
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
#include "webrtc/engine_configurations.h"
|
#include "webrtc/engine_configurations.h"
|
||||||
#include "webrtc/modules/video_render/include/video_render.h"
|
#include "webrtc/modules/video_render/include/video_render.h"
|
||||||
#include "webrtc/system_wrappers/interface/map_wrapper.h"
|
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
class CriticalSectionWrapper;
|
class CriticalSectionWrapper;
|
||||||
class IncomingVideoStream;
|
class IncomingVideoStream;
|
||||||
class IVideoRender;
|
class IVideoRender;
|
||||||
class MapWrapper;
|
|
||||||
|
|
||||||
// Class definitions
|
// Class definitions
|
||||||
class ModuleVideoRenderImpl: public VideoRender
|
class ModuleVideoRenderImpl: public VideoRender
|
||||||
@ -219,7 +219,8 @@ private:
|
|||||||
bool _fullScreen;
|
bool _fullScreen;
|
||||||
|
|
||||||
IVideoRender* _ptrRenderer;
|
IVideoRender* _ptrRenderer;
|
||||||
MapWrapper& _streamRenderMap;
|
typedef std::map<uint32_t, IncomingVideoStream*> IncomingVideoStreamMap;
|
||||||
|
IncomingVideoStreamMap _streamRenderMap;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
@ -1,75 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use of this source code is governed by a BSD-style license
|
|
||||||
* that can be found in the LICENSE file in the root of the source
|
|
||||||
* tree. An additional intellectual property rights grant can be found
|
|
||||||
* in the file PATENTS. All contributing project authors may
|
|
||||||
* be found in the AUTHORS file in the root of the source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef WEBRTC_SYSTEM_WRAPPERS_INTERFACE_MAP_WRAPPER_H_
|
|
||||||
#define WEBRTC_SYSTEM_WRAPPERS_INTERFACE_MAP_WRAPPER_H_
|
|
||||||
|
|
||||||
#include <map>
|
|
||||||
|
|
||||||
#include "webrtc/system_wrappers/interface/constructor_magic.h"
|
|
||||||
|
|
||||||
namespace webrtc {
|
|
||||||
|
|
||||||
class MapItem {
|
|
||||||
public:
|
|
||||||
MapItem(int id, void* ptr);
|
|
||||||
virtual ~MapItem();
|
|
||||||
void* GetItem();
|
|
||||||
int GetId();
|
|
||||||
unsigned int GetUnsignedId();
|
|
||||||
void SetItem(void* ptr);
|
|
||||||
|
|
||||||
private:
|
|
||||||
friend class MapWrapper;
|
|
||||||
|
|
||||||
int item_id_;
|
|
||||||
void* item_pointer_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class MapWrapper {
|
|
||||||
public:
|
|
||||||
MapWrapper();
|
|
||||||
~MapWrapper();
|
|
||||||
|
|
||||||
// Puts a pointer to anything in the map and associates it with id. Note, id
|
|
||||||
// needs to be unique for all items in the map.
|
|
||||||
int Insert(int id, void* ptr);
|
|
||||||
|
|
||||||
// Removes item from map.
|
|
||||||
int Erase(MapItem* item);
|
|
||||||
|
|
||||||
// Finds item with associated with id and removes it from the map.
|
|
||||||
int Erase(int id);
|
|
||||||
|
|
||||||
// Returns the number of elements stored in the map.
|
|
||||||
int Size() const;
|
|
||||||
|
|
||||||
// Returns a pointer to the first MapItem in the map.
|
|
||||||
MapItem* First() const;
|
|
||||||
|
|
||||||
// Returns a pointer to the last MapItem in the map.
|
|
||||||
MapItem* Last() const;
|
|
||||||
|
|
||||||
// Returns a pointer to the MapItem stored after item in the map.
|
|
||||||
MapItem* Next(MapItem* item) const;
|
|
||||||
|
|
||||||
// Returns a pointer to the MapItem stored before item in the map.
|
|
||||||
MapItem* Previous(MapItem* item) const;
|
|
||||||
|
|
||||||
// Returns a pointer to the MapItem associated with id from the map.
|
|
||||||
MapItem* Find(int id) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::map<int, MapItem*> map_;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace webrtc
|
|
||||||
|
|
||||||
#endif // WEBRTC_SYSTEM_WRAPPERS_INTERFACE_MAP_WRAPPER_H_
|
|
@ -19,7 +19,6 @@ LOCAL_CPP_EXTENSION := .cc
|
|||||||
LOCAL_SRC_FILES := \
|
LOCAL_SRC_FILES := \
|
||||||
android/cpu-features.c \
|
android/cpu-features.c \
|
||||||
cpu_features_android.c \
|
cpu_features_android.c \
|
||||||
map.cc \
|
|
||||||
sort.cc \
|
sort.cc \
|
||||||
aligned_malloc.cc \
|
aligned_malloc.cc \
|
||||||
atomic32_posix.cc \
|
atomic32_posix.cc \
|
||||||
|
@ -1,141 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use of this source code is governed by a BSD-style license
|
|
||||||
* that can be found in the LICENSE file in the root of the source
|
|
||||||
* tree. An additional intellectual property rights grant can be found
|
|
||||||
* in the file PATENTS. All contributing project authors may
|
|
||||||
* be found in the AUTHORS file in the root of the source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "webrtc/system_wrappers/interface/map_wrapper.h"
|
|
||||||
|
|
||||||
#include "webrtc/system_wrappers/interface/trace.h"
|
|
||||||
|
|
||||||
namespace webrtc {
|
|
||||||
|
|
||||||
MapItem::MapItem(int id, void* item)
|
|
||||||
: item_id_(id),
|
|
||||||
item_pointer_(item) {
|
|
||||||
}
|
|
||||||
|
|
||||||
MapItem::~MapItem() {
|
|
||||||
}
|
|
||||||
|
|
||||||
void* MapItem::GetItem() {
|
|
||||||
return item_pointer_;
|
|
||||||
}
|
|
||||||
|
|
||||||
int MapItem::GetId() {
|
|
||||||
return item_id_;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int MapItem::GetUnsignedId() {
|
|
||||||
return static_cast<unsigned int>(item_id_);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MapItem::SetItem(void* ptr) {
|
|
||||||
item_pointer_ = ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
MapWrapper::MapWrapper() : map_() {
|
|
||||||
}
|
|
||||||
|
|
||||||
MapWrapper::~MapWrapper() {
|
|
||||||
if (!map_.empty()) {
|
|
||||||
WEBRTC_TRACE(kTraceMemory, kTraceUtility, -1,
|
|
||||||
"Potential memory leak in MapWrapper");
|
|
||||||
// Remove all map items. Please note that std::map::clear() can't be
|
|
||||||
// used because each item has some dynamically allocated memory
|
|
||||||
// associated with it (i.e. using std::map::clear would introduce a
|
|
||||||
// memory leak).
|
|
||||||
while (Erase(First()) == 0)
|
|
||||||
{}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int MapWrapper::Size() const {
|
|
||||||
return (int)map_.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
int MapWrapper::Insert(int id, void* ptr) {
|
|
||||||
map_[id] = new MapItem(id, ptr);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
MapItem* MapWrapper::First() const {
|
|
||||||
std::map<int, MapItem*>::const_iterator it = map_.begin();
|
|
||||||
if (it != map_.end()) {
|
|
||||||
return it->second;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
MapItem* MapWrapper::Last() const {
|
|
||||||
std::map<int, MapItem*>::const_reverse_iterator it = map_.rbegin();
|
|
||||||
if (it != map_.rend()) {
|
|
||||||
return it->second;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
MapItem* MapWrapper::Next(MapItem* item) const {
|
|
||||||
if (item == 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
std::map<int, MapItem*>::const_iterator it = map_.find(item->item_id_);
|
|
||||||
if (it != map_.end()) {
|
|
||||||
it++;
|
|
||||||
if (it != map_.end()) {
|
|
||||||
return it->second;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
MapItem* MapWrapper::Previous(MapItem* item) const {
|
|
||||||
if (item == 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::map<int, MapItem*>::const_iterator it = map_.find(item->item_id_);
|
|
||||||
if ((it != map_.end()) &&
|
|
||||||
(it != map_.begin())) {
|
|
||||||
--it;
|
|
||||||
return it->second;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
MapItem* MapWrapper::Find(int id) const {
|
|
||||||
std::map<int, MapItem*>::const_iterator it = map_.find(id);
|
|
||||||
if (it != map_.end()) {
|
|
||||||
return it->second;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int MapWrapper::Erase(MapItem* item) {
|
|
||||||
if (item == 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
std::map<int, MapItem*>::iterator it = map_.find(item->item_id_);
|
|
||||||
if (it != map_.end()) {
|
|
||||||
delete it->second;
|
|
||||||
map_.erase(it);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int MapWrapper::Erase(const int id) {
|
|
||||||
std::map<int, MapItem*>::iterator it = map_.find(id);
|
|
||||||
if (it != map_.end()) {
|
|
||||||
delete it->second;
|
|
||||||
map_.erase(it);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace webrtc
|
|
@ -1,180 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use of this source code is governed by a BSD-style license
|
|
||||||
* that can be found in the LICENSE file in the root of the source
|
|
||||||
* tree. An additional intellectual property rights grant can be found
|
|
||||||
* in the file PATENTS. All contributing project authors may
|
|
||||||
* be found in the AUTHORS file in the root of the source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "webrtc/system_wrappers/source/map_no_stl.h"
|
|
||||||
|
|
||||||
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
|
||||||
#include "webrtc/system_wrappers/interface/trace.h"
|
|
||||||
|
|
||||||
namespace webrtc {
|
|
||||||
|
|
||||||
MapNoStlItem::MapNoStlItem(int id, void* item)
|
|
||||||
: next_(0),
|
|
||||||
prev_(0),
|
|
||||||
item_id_(id),
|
|
||||||
item_ptr_(item) {
|
|
||||||
}
|
|
||||||
|
|
||||||
MapNoStlItem::~MapNoStlItem() {
|
|
||||||
}
|
|
||||||
|
|
||||||
void* MapNoStlItem::GetItem() {
|
|
||||||
return item_ptr_;
|
|
||||||
}
|
|
||||||
|
|
||||||
int MapNoStlItem::GetId() {
|
|
||||||
return item_id_;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int MapNoStlItem::GetUnsignedId() {
|
|
||||||
return static_cast<unsigned int>(item_id_);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MapNoStlItem::SetItem(void* ptr) {
|
|
||||||
item_ptr_ = ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
MapNoStl::MapNoStl()
|
|
||||||
: critical_section_(CriticalSectionWrapper::CreateCriticalSection()),
|
|
||||||
first_(0),
|
|
||||||
last_(0),
|
|
||||||
size_(0) {
|
|
||||||
}
|
|
||||||
|
|
||||||
MapNoStl::~MapNoStl() {
|
|
||||||
if (First()) {
|
|
||||||
WEBRTC_TRACE(kTraceMemory, kTraceUtility, -1,
|
|
||||||
"Potential memory leak in MapNoStl");
|
|
||||||
while (Erase(First()) == 0)
|
|
||||||
{}
|
|
||||||
}
|
|
||||||
delete critical_section_;
|
|
||||||
}
|
|
||||||
|
|
||||||
int MapNoStl::Size() const {
|
|
||||||
return size_;
|
|
||||||
}
|
|
||||||
|
|
||||||
int MapNoStl::Insert(int id, void* ptr) {
|
|
||||||
MapNoStlItem* new_item = new MapNoStlItem(id, ptr);
|
|
||||||
|
|
||||||
CriticalSectionScoped lock(critical_section_);
|
|
||||||
MapNoStlItem* item = first_;
|
|
||||||
size_++;
|
|
||||||
if (!item) {
|
|
||||||
first_ = new_item;
|
|
||||||
last_ = new_item;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
while (item->next_) {
|
|
||||||
// Three scenarios
|
|
||||||
// 1. Item should be inserted first.
|
|
||||||
// 2. Item should be inserted between two items
|
|
||||||
// 3. Item should be inserted last
|
|
||||||
if (item->GetId() > id) {
|
|
||||||
new_item->next_ = item;
|
|
||||||
item->prev_ = new_item;
|
|
||||||
if (item == first_) {
|
|
||||||
first_ = new_item;
|
|
||||||
} else {
|
|
||||||
new_item->prev_ = item->prev_;
|
|
||||||
new_item->prev_->next_ = new_item;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
item = item->next_;
|
|
||||||
}
|
|
||||||
// 3
|
|
||||||
item->next_ = new_item;
|
|
||||||
new_item->prev_ = item;
|
|
||||||
last_ = new_item;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
MapNoStlItem* MapNoStl::First() const {
|
|
||||||
return first_;
|
|
||||||
}
|
|
||||||
|
|
||||||
MapNoStlItem* MapNoStl::Last() const {
|
|
||||||
return last_;
|
|
||||||
}
|
|
||||||
|
|
||||||
MapNoStlItem* MapNoStl::Next(MapNoStlItem* item) const {
|
|
||||||
if (!item) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return item->next_;
|
|
||||||
}
|
|
||||||
|
|
||||||
MapNoStlItem* MapNoStl::Previous(MapNoStlItem* item) const {
|
|
||||||
if (!item) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return item->prev_;
|
|
||||||
}
|
|
||||||
|
|
||||||
MapNoStlItem* MapNoStl::Find(int id) const {
|
|
||||||
CriticalSectionScoped lock(critical_section_);
|
|
||||||
MapNoStlItem* item = Locate(id);
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
int MapNoStl::Erase(MapNoStlItem* item) {
|
|
||||||
if (!item) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
CriticalSectionScoped lock(critical_section_);
|
|
||||||
return Remove(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
int MapNoStl::Erase(const int id) {
|
|
||||||
CriticalSectionScoped lock(critical_section_);
|
|
||||||
MapNoStlItem* item = Locate(id);
|
|
||||||
if (!item) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return Remove(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
MapNoStlItem* MapNoStl::Locate(int id) const {
|
|
||||||
MapNoStlItem* item = first_;
|
|
||||||
while (item) {
|
|
||||||
if (item->GetId() == id) {
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
item = item->next_;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int MapNoStl::Remove(MapNoStlItem* item) {
|
|
||||||
if (!item) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
size_--;
|
|
||||||
MapNoStlItem* previous_item = item->prev_;
|
|
||||||
MapNoStlItem* next_item = item->next_;
|
|
||||||
if (!previous_item) {
|
|
||||||
next_item->prev_ = 0;
|
|
||||||
first_ = next_item;
|
|
||||||
} else {
|
|
||||||
previous_item->next_ = next_item;
|
|
||||||
}
|
|
||||||
if (!next_item) {
|
|
||||||
previous_item->next_ = 0;
|
|
||||||
last_ = previous_item;
|
|
||||||
} else {
|
|
||||||
next_item->prev_ = previous_item;
|
|
||||||
}
|
|
||||||
delete item;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace webrtc
|
|
@ -1,70 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use of this source code is governed by a BSD-style license
|
|
||||||
* that can be found in the LICENSE file in the root of the source
|
|
||||||
* tree. An additional intellectual property rights grant can be found
|
|
||||||
* in the file PATENTS. All contributing project authors may
|
|
||||||
* be found in the AUTHORS file in the root of the source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef WEBRTC_SYSTEM_WRAPPERS_SOURCE_MAP_NO_STL_H_
|
|
||||||
#define WEBRTC_SYSTEM_WRAPPERS_SOURCE_MAP_NO_STL_H_
|
|
||||||
|
|
||||||
#include "webrtc/system_wrappers/interface/constructor_magic.h"
|
|
||||||
|
|
||||||
namespace webrtc {
|
|
||||||
|
|
||||||
class CriticalSectionWrapper;
|
|
||||||
|
|
||||||
class MapNoStlItem {
|
|
||||||
friend class Map;
|
|
||||||
|
|
||||||
public:
|
|
||||||
MapNoStlItem(int id, void* ptr);
|
|
||||||
virtual ~MapNoStlItem();
|
|
||||||
void* GetItem();
|
|
||||||
int GetId();
|
|
||||||
unsigned int GetUnsignedId();
|
|
||||||
void SetItem(void* ptr);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
MapNoStlItem* next_;
|
|
||||||
MapNoStlItem* prev_;
|
|
||||||
|
|
||||||
private:
|
|
||||||
int item_id_;
|
|
||||||
void* item_ptr_;
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(MapNoStlItem);
|
|
||||||
};
|
|
||||||
|
|
||||||
class MapNoStl {
|
|
||||||
public:
|
|
||||||
MapNoStl();
|
|
||||||
virtual ~MapNoStl();
|
|
||||||
|
|
||||||
// MapWrapper functions.
|
|
||||||
int Insert(int id, void* ptr);
|
|
||||||
int Erase(MapNoStlItem* item);
|
|
||||||
int Erase(int id);
|
|
||||||
int Size() const;
|
|
||||||
MapNoStlItem* First() const;
|
|
||||||
MapNoStlItem* Last() const;
|
|
||||||
MapNoStlItem* Next(MapNoStlItem* item) const;
|
|
||||||
MapNoStlItem* Previous(MapNoStlItem* item) const;
|
|
||||||
MapNoStlItem* Find(int id) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
MapNoStlItem* Locate(int id) const;
|
|
||||||
int Remove(MapNoStlItem* item);
|
|
||||||
|
|
||||||
CriticalSection* critical_section_;
|
|
||||||
MapNoStlItem* first_;
|
|
||||||
MapNoStlItem* last_;
|
|
||||||
int size_;
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(MapNoStl);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace webrtc
|
|
||||||
|
|
||||||
#endif // WEBRTC_SYSTEM_WRAPPERS_SOURCE_MAP_NO_STL_H_
|
|
@ -1,232 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use of this source code is governed by a BSD-style license
|
|
||||||
* that can be found in the LICENSE file in the root of the source
|
|
||||||
* tree. An additional intellectual property rights grant can be found
|
|
||||||
* in the file PATENTS. All contributing project authors may
|
|
||||||
* be found in the AUTHORS file in the root of the source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "webrtc/system_wrappers/interface/map_wrapper.h"
|
|
||||||
|
|
||||||
#include "testing/gtest/include/gtest/gtest.h"
|
|
||||||
|
|
||||||
using ::webrtc::MapWrapper;
|
|
||||||
using ::webrtc::MapItem;
|
|
||||||
|
|
||||||
const int kNumberOfElements = 10;
|
|
||||||
|
|
||||||
int* ItemPointer(MapItem* item) {
|
|
||||||
if (item == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return reinterpret_cast<int*>(item->GetItem());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DeleteItemContent(MapItem* item) {
|
|
||||||
if (item == NULL) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
int* value_ptr = ItemPointer(item);
|
|
||||||
delete value_ptr;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ItemValue(MapItem* item) {
|
|
||||||
if (item == NULL) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
const int* value_ptr = ItemPointer(item);
|
|
||||||
if (value_ptr == 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return *value_ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PrintToConsole(const char* message, bool supress) {
|
|
||||||
if (supress) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
printf("%s", message);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CreateAscendingMap(MapWrapper* ascending_map) {
|
|
||||||
int* insert_value = NULL;
|
|
||||||
for (int i = 0; i < kNumberOfElements; ++i) {
|
|
||||||
insert_value = new int;
|
|
||||||
if (insert_value == NULL) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
*insert_value = i;
|
|
||||||
if (0 != ascending_map->Insert(
|
|
||||||
i,
|
|
||||||
reinterpret_cast<void*>(insert_value))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ClearMap(MapWrapper* clear_map) {
|
|
||||||
bool success = true;
|
|
||||||
while (clear_map->Size() != 0) {
|
|
||||||
MapItem* remove_item = clear_map->First();
|
|
||||||
if (remove_item == NULL) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!DeleteItemContent(remove_item)) {
|
|
||||||
success = false;
|
|
||||||
}
|
|
||||||
if (clear_map->Erase(remove_item) != 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PrintMapItem(MapItem* item, bool supress) {
|
|
||||||
const int id = item->GetId();
|
|
||||||
const int value = ItemValue(item);
|
|
||||||
char print_buffer[16];
|
|
||||||
sprintf(print_buffer, "(%3i,%3i) ", id, value);
|
|
||||||
PrintToConsole(print_buffer, supress);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Succeeds only if all the items were printed.
|
|
||||||
bool PrintMap(const MapWrapper& print_map, bool supress) {
|
|
||||||
const int elements_to_print = print_map.Size();
|
|
||||||
int elements_printed = 0;
|
|
||||||
MapItem* item = print_map.First();
|
|
||||||
PrintToConsole("[", supress);
|
|
||||||
while (item != NULL) {
|
|
||||||
PrintMapItem(item, supress);
|
|
||||||
++elements_printed;
|
|
||||||
item = print_map.Next(item);
|
|
||||||
}
|
|
||||||
PrintToConsole("]\n", supress);
|
|
||||||
return elements_printed == elements_to_print;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Succeeds only if all the items were printed.
|
|
||||||
bool ReversePrintMap(const MapWrapper& print_map, bool supress) {
|
|
||||||
const int elements_to_print = print_map.Size();
|
|
||||||
int elements_printed = 0;
|
|
||||||
MapItem* item = print_map.Last();
|
|
||||||
PrintToConsole("[", supress);
|
|
||||||
while (item != NULL) {
|
|
||||||
PrintMapItem(item, supress);
|
|
||||||
++elements_printed;
|
|
||||||
item = print_map.Previous(item);
|
|
||||||
}
|
|
||||||
PrintToConsole("]\n", supress);
|
|
||||||
return elements_printed == elements_to_print;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns true if the map items contain the same item.
|
|
||||||
bool CompareItems(MapItem* lhs_item, MapItem* rhs_item) {
|
|
||||||
if ((lhs_item == NULL) || (rhs_item == NULL)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (lhs_item->GetId() != rhs_item->GetId()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return lhs_item->GetItem() == rhs_item->GetItem();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns true if the map contains the same items.
|
|
||||||
bool CompareMaps(const MapWrapper& lhs, const MapWrapper& rhs) {
|
|
||||||
const int map_size = lhs.Size();
|
|
||||||
if (map_size != rhs.Size()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
int item_count = 0;
|
|
||||||
MapItem* lhs_item = lhs.First();
|
|
||||||
while (lhs_item != NULL) {
|
|
||||||
MapItem* rhs_item = rhs.Find(lhs_item->GetId());
|
|
||||||
if (rhs_item == NULL) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!CompareItems(lhs_item, rhs_item)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
++item_count;
|
|
||||||
lhs_item = lhs.Next(lhs_item);
|
|
||||||
}
|
|
||||||
return item_count == map_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
class MapWrapperTest : public ::testing::Test {
|
|
||||||
protected:
|
|
||||||
virtual void SetUp() {
|
|
||||||
ASSERT_TRUE(CreateAscendingMap(&ascending_map_));
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void TearDown() {
|
|
||||||
EXPECT_TRUE(ClearMap(&ascending_map_));
|
|
||||||
}
|
|
||||||
MapWrapper ascending_map_;
|
|
||||||
};
|
|
||||||
|
|
||||||
TEST_F(MapWrapperTest, RemoveTest) {
|
|
||||||
// Erase using int id
|
|
||||||
{
|
|
||||||
// Create local scope to avoid accidental re-use
|
|
||||||
MapItem* item_first = ascending_map_.First();
|
|
||||||
ASSERT_FALSE(item_first == NULL);
|
|
||||||
const int first_value_id = item_first->GetId();
|
|
||||||
const int first_value = ItemValue(item_first);
|
|
||||||
EXPECT_TRUE(first_value == 0);
|
|
||||||
EXPECT_EQ(first_value_id, first_value);
|
|
||||||
EXPECT_FALSE(NULL == ascending_map_.Find(first_value_id));
|
|
||||||
EXPECT_TRUE(DeleteItemContent(item_first));
|
|
||||||
ascending_map_.Erase(first_value_id);
|
|
||||||
EXPECT_TRUE(NULL == ascending_map_.Find(first_value_id));
|
|
||||||
EXPECT_EQ(kNumberOfElements - 1, ascending_map_.Size());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Erase using MapItem* item
|
|
||||||
MapItem* item_last = ascending_map_.Last();
|
|
||||||
ASSERT_FALSE(item_last == NULL);
|
|
||||||
const int last_value_id = item_last->GetId();
|
|
||||||
const int last_value = ItemValue(item_last);
|
|
||||||
EXPECT_TRUE(last_value == kNumberOfElements - 1);
|
|
||||||
EXPECT_EQ(last_value_id, last_value);
|
|
||||||
EXPECT_FALSE(NULL == ascending_map_.Find(last_value_id));
|
|
||||||
EXPECT_TRUE(DeleteItemContent(item_last));
|
|
||||||
ascending_map_.Erase(last_value_id);
|
|
||||||
EXPECT_TRUE(NULL == ascending_map_.Find(last_value_id));
|
|
||||||
EXPECT_EQ(kNumberOfElements - 2, ascending_map_.Size());
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(MapWrapperTest, PrintTest) {
|
|
||||||
const bool supress = true; // Don't spam the console
|
|
||||||
|
|
||||||
EXPECT_TRUE(PrintMap(ascending_map_, supress));
|
|
||||||
EXPECT_TRUE(ReversePrintMap(ascending_map_, supress));
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(MapWrapperTest, CopyTest) {
|
|
||||||
MapWrapper compare_map;
|
|
||||||
ASSERT_TRUE(CreateAscendingMap(&compare_map));
|
|
||||||
const int map_size = compare_map.Size();
|
|
||||||
ASSERT_EQ(ascending_map_.Size(), map_size);
|
|
||||||
// CompareMaps compare the pointers not value of the pointers.
|
|
||||||
// (the values are the same since both are ascending maps).
|
|
||||||
EXPECT_FALSE(CompareMaps(compare_map, ascending_map_));
|
|
||||||
|
|
||||||
int copy_count = 0;
|
|
||||||
MapItem* ascend_item = ascending_map_.First();
|
|
||||||
while (ascend_item != NULL) {
|
|
||||||
MapItem* compare_item = compare_map.Find(ascend_item->GetId());
|
|
||||||
ASSERT_FALSE(compare_item == NULL);
|
|
||||||
DeleteItemContent(compare_item);
|
|
||||||
compare_item->SetItem(ascend_item->GetItem());
|
|
||||||
ascend_item = ascending_map_.Next(ascend_item);
|
|
||||||
++copy_count;
|
|
||||||
}
|
|
||||||
EXPECT_TRUE(CompareMaps(compare_map, ascending_map_));
|
|
||||||
while (compare_map.Erase(compare_map.First()) == 0) {
|
|
||||||
}
|
|
||||||
EXPECT_EQ(map_size, copy_count);
|
|
||||||
}
|
|
@ -39,7 +39,6 @@
|
|||||||
'../interface/fix_interlocked_exchange_pointer_win.h',
|
'../interface/fix_interlocked_exchange_pointer_win.h',
|
||||||
'../interface/list_wrapper.h',
|
'../interface/list_wrapper.h',
|
||||||
'../interface/logging.h',
|
'../interface/logging.h',
|
||||||
'../interface/map_wrapper.h',
|
|
||||||
'../interface/ref_count.h',
|
'../interface/ref_count.h',
|
||||||
'../interface/rw_lock_wrapper.h',
|
'../interface/rw_lock_wrapper.h',
|
||||||
'../interface/scoped_ptr.h',
|
'../interface/scoped_ptr.h',
|
||||||
@ -85,7 +84,6 @@
|
|||||||
'list_no_stl.cc',
|
'list_no_stl.cc',
|
||||||
'logging.cc',
|
'logging.cc',
|
||||||
'logging_no_op.cc',
|
'logging_no_op.cc',
|
||||||
'map.cc',
|
|
||||||
'rw_lock.cc',
|
'rw_lock.cc',
|
||||||
'rw_lock_generic.cc',
|
'rw_lock_generic.cc',
|
||||||
'rw_lock_generic.h',
|
'rw_lock_generic.h',
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
'event_tracer_unittest.cc',
|
'event_tracer_unittest.cc',
|
||||||
'list_unittest.cc',
|
'list_unittest.cc',
|
||||||
'logging_unittest.cc',
|
'logging_unittest.cc',
|
||||||
'map_unittest.cc',
|
|
||||||
'data_log_unittest.cc',
|
'data_log_unittest.cc',
|
||||||
'data_log_unittest_disabled.cc',
|
'data_log_unittest_disabled.cc',
|
||||||
'data_log_helpers_unittest.cc',
|
'data_log_helpers_unittest.cc',
|
||||||
|
@ -1,112 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use of this source code is governed by a BSD-style license
|
|
||||||
* that can be found in the LICENSE file in the root of the source
|
|
||||||
* tree. An additional intellectual property rights grant can be found
|
|
||||||
* in the file PATENTS. All contributing project authors may
|
|
||||||
* be found in the AUTHORS file in the root of the source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "webrtc/system_wrappers/interface/map_wrapper.h"
|
|
||||||
|
|
||||||
const int kNumberOfElements = 10;
|
|
||||||
|
|
||||||
void FailTest(bool failed)
|
|
||||||
{
|
|
||||||
if (failed)
|
|
||||||
{
|
|
||||||
printf("Test failed!\n");
|
|
||||||
printf("Press enter to continue:");
|
|
||||||
getchar();
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int GetStoredIntegerValue(MapItem* map_item)
|
|
||||||
{
|
|
||||||
void* map_item_pointer = map_item->GetItem();
|
|
||||||
if (map_item_pointer != NULL)
|
|
||||||
{
|
|
||||||
return *(reinterpret_cast<int*>(map_item_pointer));
|
|
||||||
}
|
|
||||||
return static_cast<int>(map_item->GetUnsignedId());
|
|
||||||
}
|
|
||||||
|
|
||||||
void PrintMap(MapWrapper& map)
|
|
||||||
{
|
|
||||||
MapItem* map_item = map.First();
|
|
||||||
printf("Map: ");
|
|
||||||
while (map_item != NULL)
|
|
||||||
{
|
|
||||||
int item_value = GetStoredIntegerValue(map_item);
|
|
||||||
FailTest(item_value < 0);
|
|
||||||
printf(" %d",item_value);
|
|
||||||
map_item = map.Next(map_item);
|
|
||||||
}
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int /*argc*/, char* /*argv*/[])
|
|
||||||
{
|
|
||||||
int element_array[kNumberOfElements];
|
|
||||||
for (int i = 0; i < kNumberOfElements; i++)
|
|
||||||
{
|
|
||||||
element_array[i] = i;
|
|
||||||
}
|
|
||||||
// Test insert
|
|
||||||
MapWrapper test_map;
|
|
||||||
for (int i = 0; i < kNumberOfElements; i++)
|
|
||||||
{
|
|
||||||
test_map.Insert(i,(void*)&element_array[i]);
|
|
||||||
}
|
|
||||||
// Test Erase1
|
|
||||||
MapItem* remove_item = test_map.Find(2);
|
|
||||||
FailTest(remove_item == NULL);
|
|
||||||
FailTest(test_map.Erase(remove_item) != 0);
|
|
||||||
FailTest(test_map.Find(2) != NULL);
|
|
||||||
remove_item = NULL;
|
|
||||||
FailTest(test_map.Erase(remove_item) != -1);
|
|
||||||
// Test Erase2
|
|
||||||
FailTest(test_map.Erase(1) != 0);
|
|
||||||
FailTest(test_map.Find(1) != NULL);
|
|
||||||
FailTest(test_map.Erase(1) != -1);
|
|
||||||
// Test Size
|
|
||||||
FailTest(test_map.Size() != kNumberOfElements - 2);
|
|
||||||
PrintMap(test_map);
|
|
||||||
// Test First
|
|
||||||
MapItem* first_item = test_map.First();
|
|
||||||
FailTest(first_item == NULL);
|
|
||||||
FailTest(GetStoredIntegerValue(first_item) != 0);
|
|
||||||
// Test Last
|
|
||||||
MapItem* last_item = test_map.Last();
|
|
||||||
FailTest(last_item == NULL);
|
|
||||||
FailTest(GetStoredIntegerValue(last_item) != 9);
|
|
||||||
// Test Next
|
|
||||||
MapItem* second_item = test_map.Next(first_item);
|
|
||||||
FailTest(second_item == NULL);
|
|
||||||
FailTest(GetStoredIntegerValue(second_item) != 3);
|
|
||||||
FailTest(test_map.Next(last_item) != NULL);
|
|
||||||
// Test Previous
|
|
||||||
MapItem* second_to_last_item = test_map.Previous(last_item);
|
|
||||||
FailTest(second_to_last_item == NULL);
|
|
||||||
FailTest(GetStoredIntegerValue(second_to_last_item) != 8);
|
|
||||||
FailTest(test_map.Previous(first_item) != NULL);
|
|
||||||
// Test Find (only improper usage untested)
|
|
||||||
FailTest(test_map.Find(kNumberOfElements + 2) != NULL);
|
|
||||||
// Test GetId
|
|
||||||
FailTest(*(reinterpret_cast<int*>(second_to_last_item->GetItem())) !=
|
|
||||||
second_to_last_item->GetId());
|
|
||||||
FailTest(second_to_last_item->GetUnsignedId() !=
|
|
||||||
static_cast<unsigned int>(second_to_last_item->GetId()));
|
|
||||||
// Test SetItem
|
|
||||||
int swapped_item = kNumberOfElements;
|
|
||||||
last_item->SetItem(reinterpret_cast<void*>(&swapped_item));
|
|
||||||
FailTest(GetStoredIntegerValue(last_item) !=
|
|
||||||
swapped_item);
|
|
||||||
|
|
||||||
printf("Tests passed successfully!\n");
|
|
||||||
}
|
|
@ -214,15 +214,13 @@ UdpSocketManagerPosixImpl::~UdpSocketManagerPosixImpl()
|
|||||||
UpdateSocketMap();
|
UpdateSocketMap();
|
||||||
|
|
||||||
_critSectList->Enter();
|
_critSectList->Enter();
|
||||||
|
for (std::map<SOCKET, UdpSocketPosix*>::iterator it =
|
||||||
MapItem* item = _socketMap.First();
|
_socketMap.begin();
|
||||||
while(item)
|
it != _socketMap.end();
|
||||||
{
|
++it) {
|
||||||
UdpSocketPosix* s = static_cast<UdpSocketPosix*>(item->GetItem());
|
delete it->second;
|
||||||
_socketMap.Erase(item);
|
|
||||||
item = _socketMap.First();
|
|
||||||
delete s;
|
|
||||||
}
|
}
|
||||||
|
_socketMap.clear();
|
||||||
_critSectList->Leave();
|
_critSectList->Leave();
|
||||||
|
|
||||||
delete _critSectList;
|
delete _critSectList;
|
||||||
@ -264,18 +262,19 @@ bool UdpSocketManagerPosixImpl::Process()
|
|||||||
struct timeval timeout;
|
struct timeval timeout;
|
||||||
timeout.tv_sec = 0;
|
timeout.tv_sec = 0;
|
||||||
timeout.tv_usec = 10000;
|
timeout.tv_usec = 10000;
|
||||||
MapItem* it;
|
|
||||||
|
|
||||||
FD_ZERO(&_readFds);
|
FD_ZERO(&_readFds);
|
||||||
|
|
||||||
UpdateSocketMap();
|
UpdateSocketMap();
|
||||||
|
|
||||||
unsigned int maxFd = 0;
|
SOCKET maxFd = 0;
|
||||||
for (it = _socketMap.First(); it != NULL; it=_socketMap.Next(it))
|
for (std::map<SOCKET, UdpSocketPosix*>::iterator it = _socketMap.begin();
|
||||||
{
|
it != _socketMap.end();
|
||||||
doSelect = true;
|
++it) {
|
||||||
maxFd = maxFd > it->GetUnsignedId() ? maxFd : it->GetUnsignedId();
|
doSelect = true;
|
||||||
FD_SET(it->GetUnsignedId(), &_readFds);
|
if (it->first > maxFd)
|
||||||
|
maxFd = it->first;
|
||||||
|
FD_SET(it->first, &_readFds);
|
||||||
}
|
}
|
||||||
|
|
||||||
int num = 0;
|
int num = 0;
|
||||||
@ -296,16 +295,15 @@ bool UdpSocketManagerPosixImpl::Process()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (it = _socketMap.First(); it != NULL && num > 0;
|
for (std::map<SOCKET, UdpSocketPosix*>::iterator it = _socketMap.begin();
|
||||||
it = _socketMap.Next(it))
|
it != _socketMap.end();
|
||||||
{
|
++it) {
|
||||||
UdpSocketPosix* s = static_cast<UdpSocketPosix*>(it->GetItem());
|
if (FD_ISSET(it->first, &_readFds)) {
|
||||||
if (FD_ISSET(it->GetUnsignedId(), &_readFds))
|
it->second->HasIncoming();
|
||||||
{
|
--num;
|
||||||
s->HasIncoming();
|
}
|
||||||
num--;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -352,11 +350,11 @@ bool UdpSocketManagerPosixImpl::RemoveSocket(UdpSocketWrapper* s)
|
|||||||
|
|
||||||
// Checking the socket map is safe since all Erase and Insert calls to this
|
// Checking the socket map is safe since all Erase and Insert calls to this
|
||||||
// map are also protected by _critSectList.
|
// map are also protected by _critSectList.
|
||||||
if(_socketMap.Find(static_cast<UdpSocketPosix*>(s)->GetFd()) != NULL)
|
if (_socketMap.find(static_cast<UdpSocketPosix*>(s)->GetFd()) !=
|
||||||
{
|
_socketMap.end()) {
|
||||||
_removeList.PushBack(static_cast<UdpSocketPosix*>(s)->GetFd());
|
_removeList.PushBack(static_cast<UdpSocketPosix*>(s)->GetFd());
|
||||||
_critSectList->Leave();
|
_critSectList->Leave();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
_critSectList->Leave();
|
_critSectList->Leave();
|
||||||
return false;
|
return false;
|
||||||
@ -369,7 +367,7 @@ void UdpSocketManagerPosixImpl::UpdateSocketMap()
|
|||||||
while(!_removeList.Empty())
|
while(!_removeList.Empty())
|
||||||
{
|
{
|
||||||
UdpSocketPosix* deleteSocket = NULL;
|
UdpSocketPosix* deleteSocket = NULL;
|
||||||
unsigned int removeFD = _removeList.First()->GetUnsignedItem();
|
SOCKET removeFD = _removeList.First()->GetUnsignedItem();
|
||||||
|
|
||||||
// If the socket is in the add list it hasn't been added to the socket
|
// If the socket is in the add list it hasn't been added to the socket
|
||||||
// map yet. Just remove the socket from the add list.
|
// map yet. Just remove the socket from the add list.
|
||||||
@ -377,7 +375,7 @@ void UdpSocketManagerPosixImpl::UpdateSocketMap()
|
|||||||
while(addListItem)
|
while(addListItem)
|
||||||
{
|
{
|
||||||
UdpSocketPosix* addSocket = (UdpSocketPosix*)addListItem->GetItem();
|
UdpSocketPosix* addSocket = (UdpSocketPosix*)addListItem->GetItem();
|
||||||
unsigned int addFD = addSocket->GetFd();
|
SOCKET addFD = addSocket->GetFd();
|
||||||
if(removeFD == addFD)
|
if(removeFD == addFD)
|
||||||
{
|
{
|
||||||
deleteSocket = addSocket;
|
deleteSocket = addSocket;
|
||||||
@ -388,16 +386,12 @@ void UdpSocketManagerPosixImpl::UpdateSocketMap()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Find and remove socket from _socketMap.
|
// Find and remove socket from _socketMap.
|
||||||
MapItem* it = _socketMap.Find(removeFD);
|
std::map<SOCKET, UdpSocketPosix*>::iterator it =
|
||||||
if(it != NULL)
|
_socketMap.find(removeFD);
|
||||||
|
if(it != _socketMap.end())
|
||||||
{
|
{
|
||||||
UdpSocketPosix* socket =
|
deleteSocket = it->second;
|
||||||
static_cast<UdpSocketPosix*>(it->GetItem());
|
_socketMap.erase(it);
|
||||||
if(socket)
|
|
||||||
{
|
|
||||||
deleteSocket = socket;
|
|
||||||
}
|
|
||||||
_socketMap.Erase(it);
|
|
||||||
}
|
}
|
||||||
if(deleteSocket)
|
if(deleteSocket)
|
||||||
{
|
{
|
||||||
@ -412,9 +406,8 @@ void UdpSocketManagerPosixImpl::UpdateSocketMap()
|
|||||||
{
|
{
|
||||||
UdpSocketPosix* s =
|
UdpSocketPosix* s =
|
||||||
static_cast<UdpSocketPosix*>(_addList.First()->GetItem());
|
static_cast<UdpSocketPosix*>(_addList.First()->GetItem());
|
||||||
if(s)
|
if(s) {
|
||||||
{
|
_socketMap[s->GetFd()] = s;
|
||||||
_socketMap.Insert(s->GetFd(), s);
|
|
||||||
}
|
}
|
||||||
_addList.PopFront();
|
_addList.PopFront();
|
||||||
}
|
}
|
||||||
|
@ -14,9 +14,10 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
||||||
#include "webrtc/system_wrappers/interface/list_wrapper.h"
|
#include "webrtc/system_wrappers/interface/list_wrapper.h"
|
||||||
#include "webrtc/system_wrappers/interface/map_wrapper.h"
|
|
||||||
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
||||||
#include "webrtc/test/channel_transport/udp_socket_manager_wrapper.h"
|
#include "webrtc/test/channel_transport/udp_socket_manager_wrapper.h"
|
||||||
#include "webrtc/test/channel_transport/udp_socket_wrapper.h"
|
#include "webrtc/test/channel_transport/udp_socket_wrapper.h"
|
||||||
@ -27,6 +28,7 @@ class ConditionVariableWrapper;
|
|||||||
|
|
||||||
namespace test {
|
namespace test {
|
||||||
|
|
||||||
|
class UdpSocketPosix;
|
||||||
class UdpSocketManagerPosixImpl;
|
class UdpSocketManagerPosixImpl;
|
||||||
#define MAX_NUMBER_OF_SOCKET_MANAGERS_LINUX 8
|
#define MAX_NUMBER_OF_SOCKET_MANAGERS_LINUX 8
|
||||||
|
|
||||||
@ -77,7 +79,7 @@ private:
|
|||||||
|
|
||||||
fd_set _readFds;
|
fd_set _readFds;
|
||||||
|
|
||||||
MapWrapper _socketMap;
|
std::map<SOCKET, UdpSocketPosix*> _socketMap;
|
||||||
ListWrapper _addList;
|
ListWrapper _addList;
|
||||||
ListWrapper _removeList;
|
ListWrapper _removeList;
|
||||||
};
|
};
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h"
|
#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h"
|
||||||
#include "webrtc/modules/utility/interface/process_thread.h"
|
#include "webrtc/modules/utility/interface/process_thread.h"
|
||||||
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
|
||||||
#include "webrtc/system_wrappers/interface/map_wrapper.h"
|
|
||||||
#include "webrtc/system_wrappers/interface/trace.h"
|
#include "webrtc/system_wrappers/interface/trace.h"
|
||||||
#include "webrtc/video_engine/call_stats.h"
|
#include "webrtc/video_engine/call_stats.h"
|
||||||
#include "webrtc/video_engine/encoder_state_feedback.h"
|
#include "webrtc/video_engine/encoder_state_feedback.h"
|
||||||
|
@ -27,7 +27,6 @@ namespace webrtc {
|
|||||||
|
|
||||||
class Config;
|
class Config;
|
||||||
class CriticalSectionWrapper;
|
class CriticalSectionWrapper;
|
||||||
class MapWrapper;
|
|
||||||
class ProcessThread;
|
class ProcessThread;
|
||||||
class RtcpRttObserver;
|
class RtcpRttObserver;
|
||||||
class ViEChannel;
|
class ViEChannel;
|
||||||
|
@ -44,19 +44,13 @@ ViEInputManager::ViEInputManager(const int engine_id, const Config& config)
|
|||||||
ViEInputManager::~ViEInputManager() {
|
ViEInputManager::~ViEInputManager() {
|
||||||
WEBRTC_TRACE(webrtc::kTraceMemory, webrtc::kTraceVideo, ViEId(engine_id_),
|
WEBRTC_TRACE(webrtc::kTraceMemory, webrtc::kTraceVideo, ViEId(engine_id_),
|
||||||
"%s", __FUNCTION__);
|
"%s", __FUNCTION__);
|
||||||
while (vie_frame_provider_map_.Size() != 0) {
|
for (FrameProviderMap::iterator it = vie_frame_provider_map_.begin();
|
||||||
MapItem* item = vie_frame_provider_map_.First();
|
it != vie_frame_provider_map_.end();
|
||||||
assert(item);
|
++it) {
|
||||||
ViEFrameProviderBase* frame_provider =
|
delete it->second;
|
||||||
static_cast<ViEFrameProviderBase*>(item->GetItem());
|
|
||||||
vie_frame_provider_map_.Erase(item);
|
|
||||||
delete frame_provider;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (capture_device_info_) {
|
delete capture_device_info_;
|
||||||
delete capture_device_info_;
|
|
||||||
capture_device_info_ = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
void ViEInputManager::SetModuleProcessThread(
|
void ViEInputManager::SetModuleProcessThread(
|
||||||
ProcessThread* module_process_thread) {
|
ProcessThread* module_process_thread) {
|
||||||
@ -191,18 +185,17 @@ int ViEInputManager::CreateCaptureDevice(
|
|||||||
CriticalSectionScoped cs(map_cs_.get());
|
CriticalSectionScoped cs(map_cs_.get());
|
||||||
|
|
||||||
// Make sure the device is not already allocated.
|
// Make sure the device is not already allocated.
|
||||||
for (MapItem* item = vie_frame_provider_map_.First(); item != NULL;
|
for (FrameProviderMap::iterator it = vie_frame_provider_map_.begin();
|
||||||
item = vie_frame_provider_map_.Next(item)) {
|
it != vie_frame_provider_map_.end();
|
||||||
|
++it) {
|
||||||
// Make sure this is a capture device.
|
// Make sure this is a capture device.
|
||||||
if (item->GetId() >= kViECaptureIdBase &&
|
if (it->first >= kViECaptureIdBase && it->first <= kViECaptureIdMax) {
|
||||||
item->GetId() <= kViECaptureIdMax) {
|
ViECapturer* vie_capture = static_cast<ViECapturer*>(it->second);
|
||||||
ViECapturer* vie_capture = static_cast<ViECapturer*>(item->GetItem());
|
|
||||||
assert(vie_capture);
|
assert(vie_capture);
|
||||||
// TODO(mflodman) Can we change input to avoid this cast?
|
// TODO(mflodman) Can we change input to avoid this cast?
|
||||||
const char* device_name =
|
const char* device_name =
|
||||||
reinterpret_cast<const char*>(vie_capture->CurrentDeviceName());
|
reinterpret_cast<const char*>(vie_capture->CurrentDeviceName());
|
||||||
if (strncmp(device_name,
|
if (strncmp(device_name, device_unique_idUTF8,
|
||||||
reinterpret_cast<const char*>(device_unique_idUTF8),
|
|
||||||
strlen(device_name)) == 0) {
|
strlen(device_name)) == 0) {
|
||||||
return kViECaptureDeviceAlreadyAllocated;
|
return kViECaptureDeviceAlreadyAllocated;
|
||||||
}
|
}
|
||||||
@ -266,13 +259,7 @@ int ViEInputManager::CreateCaptureDevice(
|
|||||||
return kViECaptureDeviceUnknownError;
|
return kViECaptureDeviceUnknownError;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vie_frame_provider_map_.Insert(newcapture_id, vie_capture) != 0) {
|
vie_frame_provider_map_[newcapture_id] = vie_capture;
|
||||||
ReturnCaptureId(newcapture_id);
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(engine_id_),
|
|
||||||
"%s: Could not insert capture module for %s", __FUNCTION__,
|
|
||||||
device_unique_idUTF8);
|
|
||||||
return kViECaptureDeviceUnknownError;
|
|
||||||
}
|
|
||||||
capture_id = newcapture_id;
|
capture_id = newcapture_id;
|
||||||
WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideo, ViEId(engine_id_),
|
WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideo, ViEId(engine_id_),
|
||||||
"%s(device_unique_id: %s, capture_id: %d)", __FUNCTION__,
|
"%s(device_unique_id: %s, capture_id: %d)", __FUNCTION__,
|
||||||
@ -303,12 +290,7 @@ int ViEInputManager::CreateCaptureDevice(VideoCaptureModule* capture_module,
|
|||||||
"%s: Could attach capture module.", __FUNCTION__);
|
"%s: Could attach capture module.", __FUNCTION__);
|
||||||
return kViECaptureDeviceUnknownError;
|
return kViECaptureDeviceUnknownError;
|
||||||
}
|
}
|
||||||
if (vie_frame_provider_map_.Insert(newcapture_id, vie_capture) != 0) {
|
vie_frame_provider_map_[newcapture_id] = vie_capture;
|
||||||
ReturnCaptureId(newcapture_id);
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(engine_id_),
|
|
||||||
"%s: Could not insert capture module", __FUNCTION__);
|
|
||||||
return kViECaptureDeviceUnknownError;
|
|
||||||
}
|
|
||||||
capture_id = newcapture_id;
|
capture_id = newcapture_id;
|
||||||
WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideo, ViEId(engine_id_),
|
WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideo, ViEId(engine_id_),
|
||||||
"%s, capture_id: %d", __FUNCTION__, capture_id);
|
"%s, capture_id: %d", __FUNCTION__, capture_id);
|
||||||
@ -340,7 +322,7 @@ int ViEInputManager::DestroyCaptureDevice(const int capture_id) {
|
|||||||
"callbacks when destroying capture device",
|
"callbacks when destroying capture device",
|
||||||
__FUNCTION__, capture_id, num_callbacks);
|
__FUNCTION__, capture_id, num_callbacks);
|
||||||
}
|
}
|
||||||
vie_frame_provider_map_.Erase(capture_id);
|
vie_frame_provider_map_.erase(capture_id);
|
||||||
ReturnCaptureId(capture_id);
|
ReturnCaptureId(capture_id);
|
||||||
// Leave cs before deleting the capture object. This is because deleting the
|
// Leave cs before deleting the capture object. This is because deleting the
|
||||||
// object might cause deletions of renderers so we prefer to not have a lock
|
// object might cause deletions of renderers so we prefer to not have a lock
|
||||||
@ -375,13 +357,7 @@ int ViEInputManager::CreateExternalCaptureDevice(
|
|||||||
return kViECaptureDeviceUnknownError;
|
return kViECaptureDeviceUnknownError;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vie_frame_provider_map_.Insert(newcapture_id, vie_capture) != 0) {
|
vie_frame_provider_map_[newcapture_id] = vie_capture;
|
||||||
ReturnCaptureId(newcapture_id);
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(engine_id_),
|
|
||||||
"%s: Could not insert capture module for external capture.",
|
|
||||||
__FUNCTION__);
|
|
||||||
return kViECaptureDeviceUnknownError;
|
|
||||||
}
|
|
||||||
capture_id = newcapture_id;
|
capture_id = newcapture_id;
|
||||||
external_capture = vie_capture;
|
external_capture = vie_capture;
|
||||||
WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideo, ViEId(engine_id_),
|
WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideo, ViEId(engine_id_),
|
||||||
@ -421,30 +397,25 @@ ViEFrameProviderBase* ViEInputManager::ViEFrameProvider(
|
|||||||
assert(capture_observer);
|
assert(capture_observer);
|
||||||
CriticalSectionScoped cs(map_cs_.get());
|
CriticalSectionScoped cs(map_cs_.get());
|
||||||
|
|
||||||
for (MapItem* provider_item = vie_frame_provider_map_.First(); provider_item
|
for (FrameProviderMap::const_iterator it = vie_frame_provider_map_.begin();
|
||||||
!= NULL; provider_item = vie_frame_provider_map_.Next(provider_item)) {
|
it != vie_frame_provider_map_.end();
|
||||||
ViEFrameProviderBase* vie_frame_provider =
|
++it) {
|
||||||
static_cast<ViEFrameProviderBase*>(provider_item->GetItem());
|
if (it->second->IsFrameCallbackRegistered(capture_observer))
|
||||||
assert(vie_frame_provider != NULL);
|
return it->second;
|
||||||
|
|
||||||
if (vie_frame_provider->IsFrameCallbackRegistered(capture_observer)) {
|
|
||||||
// We found it.
|
|
||||||
return vie_frame_provider;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// No capture device set for this channel.
|
// No capture device set for this channel.
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ViEFrameProviderBase* ViEInputManager::ViEFrameProvider(int provider_id) const {
|
ViEFrameProviderBase* ViEInputManager::ViEFrameProvider(int provider_id) const {
|
||||||
CriticalSectionScoped cs(map_cs_.get());
|
CriticalSectionScoped cs(map_cs_.get());
|
||||||
MapItem* map_item = vie_frame_provider_map_.Find(provider_id);
|
|
||||||
if (!map_item) {
|
FrameProviderMap::const_iterator it =
|
||||||
|
vie_frame_provider_map_.find(provider_id);
|
||||||
|
if (it == vie_frame_provider_map_.end())
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
return it->second;
|
||||||
ViEFrameProviderBase* vie_frame_provider =
|
|
||||||
static_cast<ViEFrameProviderBase*>(map_item->GetItem());
|
|
||||||
return vie_frame_provider;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ViECapturer* ViEInputManager::ViECapturePtr(int capture_id) const {
|
ViECapturer* ViEInputManager::ViECapturePtr(int capture_id) const {
|
||||||
@ -452,13 +423,7 @@ ViECapturer* ViEInputManager::ViECapturePtr(int capture_id) const {
|
|||||||
capture_id <= kViECaptureIdBase + kViEMaxCaptureDevices))
|
capture_id <= kViECaptureIdBase + kViEMaxCaptureDevices))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
CriticalSectionScoped cs(map_cs_.get());
|
return static_cast<ViECapturer*>(ViEFrameProvider(capture_id));
|
||||||
MapItem* map_item = vie_frame_provider_map_.Find(capture_id);
|
|
||||||
if (!map_item) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
ViECapturer* vie_capture = static_cast<ViECapturer*>(map_item->GetItem());
|
|
||||||
return vie_capture;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ViEInputManagerScoped::ViEInputManagerScoped(
|
ViEInputManagerScoped::ViEInputManagerScoped(
|
||||||
|
@ -11,8 +11,9 @@
|
|||||||
#ifndef WEBRTC_VIDEO_ENGINE_VIE_INPUT_MANAGER_H_
|
#ifndef WEBRTC_VIDEO_ENGINE_VIE_INPUT_MANAGER_H_
|
||||||
#define WEBRTC_VIDEO_ENGINE_VIE_INPUT_MANAGER_H_
|
#define WEBRTC_VIDEO_ENGINE_VIE_INPUT_MANAGER_H_
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
#include "webrtc/modules/video_capture/include/video_capture.h"
|
#include "webrtc/modules/video_capture/include/video_capture.h"
|
||||||
#include "webrtc/system_wrappers/interface/map_wrapper.h"
|
|
||||||
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
|
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
|
||||||
#include "webrtc/typedefs.h"
|
#include "webrtc/typedefs.h"
|
||||||
#include "webrtc/video_engine/include/vie_capture.h"
|
#include "webrtc/video_engine/include/vie_capture.h"
|
||||||
@ -98,7 +99,9 @@ class ViEInputManager : private ViEManagerBase {
|
|||||||
int engine_id_;
|
int engine_id_;
|
||||||
scoped_ptr<CriticalSectionWrapper> map_cs_;
|
scoped_ptr<CriticalSectionWrapper> map_cs_;
|
||||||
scoped_ptr<CriticalSectionWrapper> device_info_cs_;
|
scoped_ptr<CriticalSectionWrapper> device_info_cs_;
|
||||||
MapWrapper vie_frame_provider_map_;
|
|
||||||
|
typedef std::map<int, ViEFrameProviderBase*> FrameProviderMap;
|
||||||
|
FrameProviderMap vie_frame_provider_map_;
|
||||||
|
|
||||||
// Capture devices.
|
// Capture devices.
|
||||||
VideoCaptureModule::DeviceInfo* capture_device_info_;
|
VideoCaptureModule::DeviceInfo* capture_device_info_;
|
||||||
|
@ -43,14 +43,11 @@ ViERenderManager::ViERenderManager(int32_t engine_id)
|
|||||||
ViERenderManager::~ViERenderManager() {
|
ViERenderManager::~ViERenderManager() {
|
||||||
WEBRTC_TRACE(webrtc::kTraceMemory, webrtc::kTraceVideo, ViEId(engine_id_),
|
WEBRTC_TRACE(webrtc::kTraceMemory, webrtc::kTraceVideo, ViEId(engine_id_),
|
||||||
"ViERenderManager Destructor, engine_id: %d", engine_id_);
|
"ViERenderManager Destructor, engine_id: %d", engine_id_);
|
||||||
|
for (RendererMap::iterator it = stream_to_vie_renderer_.begin();
|
||||||
while (stream_to_vie_renderer_.Size() != 0) {
|
it != stream_to_vie_renderer_.end();
|
||||||
MapItem* item = stream_to_vie_renderer_.First();
|
++it) {
|
||||||
assert(item);
|
// The renderer is deleted in RemoveRenderStream.
|
||||||
const int32_t render_id = item->GetId();
|
RemoveRenderStream(it->first);
|
||||||
// The renderer is delete in RemoveRenderStream.
|
|
||||||
item = NULL;
|
|
||||||
RemoveRenderStream(render_id);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,7 +110,8 @@ ViERenderer* ViERenderManager::AddRenderStream(const int32_t render_id,
|
|||||||
const float bottom) {
|
const float bottom) {
|
||||||
CriticalSectionScoped cs(list_cs_.get());
|
CriticalSectionScoped cs(list_cs_.get());
|
||||||
|
|
||||||
if (stream_to_vie_renderer_.Find(render_id) != NULL) {
|
if (stream_to_vie_renderer_.find(render_id) !=
|
||||||
|
stream_to_vie_renderer_.end()) {
|
||||||
// This stream is already added to a renderer, not allowed!
|
// This stream is already added to a renderer, not allowed!
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(engine_id_),
|
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(engine_id_),
|
||||||
"Render stream already exists");
|
"Render stream already exists");
|
||||||
@ -146,7 +144,7 @@ ViERenderer* ViERenderManager::AddRenderStream(const int32_t render_id,
|
|||||||
"Could not create new render stream");
|
"Could not create new render stream");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
stream_to_vie_renderer_.Insert(render_id, vie_renderer);
|
stream_to_vie_renderer_[render_id] = vie_renderer;
|
||||||
return vie_renderer;
|
return vie_renderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,28 +153,24 @@ int32_t ViERenderManager::RemoveRenderStream(
|
|||||||
// We need exclusive right to the items in the render manager to delete a
|
// We need exclusive right to the items in the render manager to delete a
|
||||||
// stream.
|
// stream.
|
||||||
ViEManagerWriteScoped scope(this);
|
ViEManagerWriteScoped scope(this);
|
||||||
|
|
||||||
CriticalSectionScoped cs(list_cs_.get());
|
CriticalSectionScoped cs(list_cs_.get());
|
||||||
MapItem* map_item = stream_to_vie_renderer_.Find(render_id);
|
RendererMap::iterator it = stream_to_vie_renderer_.find(render_id);
|
||||||
if (!map_item) {
|
if (it == stream_to_vie_renderer_.end()) {
|
||||||
// No such stream
|
// No such stream
|
||||||
WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceVideo, ViEId(engine_id_),
|
WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceVideo, ViEId(engine_id_),
|
||||||
"No renderer for this stream found, channel_id");
|
"No renderer for this stream found, channel_id");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ViERenderer* vie_renderer = static_cast<ViERenderer*>(map_item->GetItem());
|
|
||||||
assert(vie_renderer);
|
|
||||||
|
|
||||||
// Get the render module pointer for this vie_render object.
|
// Get the render module pointer for this vie_render object.
|
||||||
VideoRender& renderer = vie_renderer->RenderModule();
|
VideoRender& renderer = it->second->RenderModule();
|
||||||
|
|
||||||
// Delete the vie_render.
|
// Delete the vie_render.
|
||||||
// This deletes the stream in the render module.
|
// This deletes the stream in the render module.
|
||||||
delete vie_renderer;
|
delete it->second;
|
||||||
|
|
||||||
// Remove from the stream map.
|
// Remove from the stream map.
|
||||||
stream_to_vie_renderer_.Erase(map_item);
|
stream_to_vie_renderer_.erase(it);
|
||||||
|
|
||||||
// Check if there are other streams in the module.
|
// Check if there are other streams in the module.
|
||||||
if (!use_external_render_module_ &&
|
if (!use_external_render_module_ &&
|
||||||
@ -216,15 +210,11 @@ VideoRender* ViERenderManager::FindRenderModule(void* window) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ViERenderer* ViERenderManager::ViERenderPtr(int32_t render_id) const {
|
ViERenderer* ViERenderManager::ViERenderPtr(int32_t render_id) const {
|
||||||
ViERenderer* renderer = NULL;
|
RendererMap::const_iterator it = stream_to_vie_renderer_.find(render_id);
|
||||||
MapItem* map_item = stream_to_vie_renderer_.Find(render_id);
|
if (it == stream_to_vie_renderer_.end())
|
||||||
if (!map_item) {
|
|
||||||
// No such stream in any renderer.
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
renderer = static_cast<ViERenderer*>(map_item->GetItem());
|
|
||||||
|
|
||||||
return renderer;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
@ -11,11 +11,11 @@
|
|||||||
#ifndef WEBRTC_VIDEO_ENGINE_VIE_RENDER_MANAGER_H_
|
#ifndef WEBRTC_VIDEO_ENGINE_VIE_RENDER_MANAGER_H_
|
||||||
#define WEBRTC_VIDEO_ENGINE_VIE_RENDER_MANAGER_H_
|
#define WEBRTC_VIDEO_ENGINE_VIE_RENDER_MANAGER_H_
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
#include "webrtc/system_wrappers/interface/list_wrapper.h"
|
#include "webrtc/system_wrappers/interface/list_wrapper.h"
|
||||||
#include "webrtc/system_wrappers/interface/map_wrapper.h"
|
|
||||||
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
|
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
|
||||||
#include "webrtc/typedefs.h"
|
#include "webrtc/typedefs.h"
|
||||||
|
|
||||||
#include "webrtc/video_engine/vie_manager_base.h"
|
#include "webrtc/video_engine/vie_manager_base.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
@ -55,7 +55,10 @@ class ViERenderManager : private ViEManagerBase {
|
|||||||
|
|
||||||
scoped_ptr<CriticalSectionWrapper> list_cs_;
|
scoped_ptr<CriticalSectionWrapper> list_cs_;
|
||||||
int32_t engine_id_;
|
int32_t engine_id_;
|
||||||
MapWrapper stream_to_vie_renderer_; // Protected by ViEManagerBase.
|
// Protected by ViEManagerBase.
|
||||||
|
typedef std::map<int32_t, ViERenderer*> RendererMap;
|
||||||
|
RendererMap stream_to_vie_renderer_;
|
||||||
|
|
||||||
ListWrapper render_list_;
|
ListWrapper render_list_;
|
||||||
bool use_external_render_module_;
|
bool use_external_render_module_;
|
||||||
};
|
};
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
#define WEBRTC_VIDEO_ENGINE_VIE_RENDERER_H_
|
#define WEBRTC_VIDEO_ENGINE_VIE_RENDERER_H_
|
||||||
|
|
||||||
#include "webrtc/modules/video_render/include/video_render_defines.h"
|
#include "webrtc/modules/video_render/include/video_render_defines.h"
|
||||||
#include "webrtc/system_wrappers/interface/map_wrapper.h"
|
|
||||||
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
|
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
|
||||||
#include "webrtc/video_engine/include/vie_render.h"
|
#include "webrtc/video_engine/include/vie_render.h"
|
||||||
#include "webrtc/video_engine/vie_frame_provider_base.h"
|
#include "webrtc/video_engine/vie_frame_provider_base.h"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user