Switching to stl instead of WebRTC wrappers.
BUG=C-10436, C-10437, C-10438 Review URL: https://webrtc-codereview.appspot.com/343012 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1468 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
8e50693736
commit
70111e69bf
@ -15,8 +15,9 @@
|
||||
#ifndef WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_TB_EXTERNAL_TRANSPORT_H_
|
||||
#define WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_TB_EXTERNAL_TRANSPORT_H_
|
||||
|
||||
#include <list>
|
||||
|
||||
#include "common_types.h"
|
||||
#include "list_wrapper.h"
|
||||
|
||||
namespace webrtc
|
||||
{
|
||||
@ -85,8 +86,8 @@ private:
|
||||
WebRtc_Word32 _rtcpCount;
|
||||
WebRtc_Word32 _dropCount;
|
||||
|
||||
webrtc::ListWrapper _rtpPackets;
|
||||
webrtc::ListWrapper _rtcpPackets;
|
||||
std::list<VideoPacket*> _rtpPackets;
|
||||
std::list<VideoPacket*> _rtcpPackets;
|
||||
|
||||
unsigned char _temporalLayers;
|
||||
unsigned short _seqNum;
|
||||
|
@ -48,8 +48,6 @@ TbExternalTransport::TbExternalTransport(webrtc::ViENetwork& vieNetwork) :
|
||||
_rtpCount(0),
|
||||
_rtcpCount(0),
|
||||
_dropCount(0),
|
||||
_rtpPackets(),
|
||||
_rtcpPackets(),
|
||||
_temporalLayers(0),
|
||||
_seqNum(0),
|
||||
_sendPID(0),
|
||||
@ -196,7 +194,7 @@ int TbExternalTransport::SendPacket(int channel, const void *data, int len)
|
||||
|
||||
_crit.Enter();
|
||||
newPacket->receiveTime = NowMs() + _networkDelayMs;
|
||||
_rtpPackets.PushBack(newPacket);
|
||||
_rtpPackets.push_back(newPacket);
|
||||
_event.Set();
|
||||
_crit.Leave();
|
||||
return len;
|
||||
@ -221,7 +219,7 @@ int TbExternalTransport::SendRTCPPacket(int channel, const void *data, int len)
|
||||
|
||||
_crit.Enter();
|
||||
newPacket->receiveTime = NowMs() + _networkDelayMs;
|
||||
_rtcpPackets.PushBack(newPacket);
|
||||
_rtcpPackets.push_back(newPacket);
|
||||
_event.Set();
|
||||
_crit.Leave();
|
||||
return len;
|
||||
@ -300,11 +298,11 @@ bool TbExternalTransport::ViEExternalTransportProcess()
|
||||
|
||||
VideoPacket* packet = NULL;
|
||||
|
||||
while (!_rtpPackets.Empty())
|
||||
while (!_rtpPackets.empty())
|
||||
{
|
||||
// Take first packet in queue
|
||||
_crit.Enter();
|
||||
packet = static_cast<VideoPacket*> ((_rtpPackets.First())->GetItem());
|
||||
packet = _rtpPackets.front();
|
||||
WebRtc_Word64 timeToReceive = packet->receiveTime - NowMs();
|
||||
if (timeToReceive > 0)
|
||||
{
|
||||
@ -316,7 +314,7 @@ bool TbExternalTransport::ViEExternalTransportProcess()
|
||||
_crit.Leave();
|
||||
break;
|
||||
}
|
||||
_rtpPackets.PopFront();
|
||||
_rtpPackets.pop_front();
|
||||
_crit.Leave();
|
||||
|
||||
// Send to ViE
|
||||
@ -347,11 +345,11 @@ bool TbExternalTransport::ViEExternalTransportProcess()
|
||||
packet = NULL;
|
||||
}
|
||||
}
|
||||
while (!_rtcpPackets.Empty())
|
||||
while (!_rtcpPackets.empty())
|
||||
{
|
||||
// Take first packet in queue
|
||||
_crit.Enter();
|
||||
packet = static_cast<VideoPacket*> ((_rtcpPackets.First())->GetItem());
|
||||
packet = _rtcpPackets.front();
|
||||
WebRtc_Word64 timeToReceive = packet->receiveTime - NowMs();
|
||||
if (timeToReceive > 0)
|
||||
{
|
||||
@ -363,7 +361,7 @@ bool TbExternalTransport::ViEExternalTransportProcess()
|
||||
_crit.Leave();
|
||||
break;
|
||||
}
|
||||
_rtcpPackets.PopFront();
|
||||
_rtcpPackets.pop_front();
|
||||
_crit.Leave();
|
||||
|
||||
// Send to ViE
|
||||
|
@ -270,8 +270,12 @@ int ViEFilePlayer::StopPlay() {
|
||||
|
||||
int ViEFilePlayer::StopPlayAudio() {
|
||||
// Stop sending audio.
|
||||
while (MapItem* audio_item = audio_channels_sending_.First()) {
|
||||
StopSendAudioOnChannel(audio_item->GetId());
|
||||
|
||||
std::set<int>::iterator it = audio_channels_sending_.begin();
|
||||
while (it != audio_channels_sending_.end()) {
|
||||
StopSendAudioOnChannel(*it);
|
||||
// StopSendAudioOnChannel erases the item from the map.
|
||||
it = audio_channels_sending_.begin();
|
||||
}
|
||||
|
||||
// Stop local audio playback.
|
||||
@ -279,10 +283,7 @@ int ViEFilePlayer::StopPlayAudio() {
|
||||
StopPlayAudioLocally(local_audio_channel_);
|
||||
}
|
||||
local_audio_channel_ = -1;
|
||||
while (audio_channel_buffers_.PopFront() != -1) {
|
||||
}
|
||||
while (audio_channels_sending_.Erase(audio_channels_sending_.First()) != -1) {
|
||||
}
|
||||
audio_channel_buffers_.clear();
|
||||
audio_clients_ = 0;
|
||||
return 0;
|
||||
}
|
||||
@ -300,8 +301,8 @@ int ViEFilePlayer::Read(void* buf, int len) {
|
||||
}
|
||||
// 2 bytes per sample.
|
||||
decoded_audio_length_ *= 2;
|
||||
if (buf != 0) {
|
||||
audio_channel_buffers_.PushBack(buf);
|
||||
if (buf) {
|
||||
audio_channel_buffers_.push_back(buf);
|
||||
}
|
||||
} else {
|
||||
// No need for new audiobuffer from file, ie the buffer read from file has
|
||||
@ -315,16 +316,16 @@ int ViEFilePlayer::Read(void* buf, int len) {
|
||||
|
||||
bool ViEFilePlayer::NeedsAudioFromFile(void* buf) {
|
||||
bool needs_new_audio = false;
|
||||
if (audio_channel_buffers_.GetSize() == 0) {
|
||||
if (audio_channel_buffers_.size() == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if we the buf already have read the current audio.
|
||||
for (ListItem* item = audio_channel_buffers_.First(); item != NULL;
|
||||
item = audio_channel_buffers_.Next(item)) {
|
||||
if (item->GetItem() == buf) {
|
||||
for (std::list<void*>::iterator it = audio_channel_buffers_.begin();
|
||||
it != audio_channel_buffers_.end(); ++it) {
|
||||
if (*it == buf) {
|
||||
needs_new_audio = true;
|
||||
audio_channel_buffers_.Erase(item);
|
||||
audio_channel_buffers_.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -381,7 +382,7 @@ int ViEFilePlayer::SendAudioOnChannel(const int audio_channel,
|
||||
audio_channel, mix_microphone, volume_scaling);
|
||||
return -1;
|
||||
}
|
||||
audio_channels_sending_.Insert(audio_channel, NULL);
|
||||
audio_channels_sending_.insert(audio_channel);
|
||||
|
||||
CriticalSectionScoped lock(*audio_cs_);
|
||||
audio_clients_++;
|
||||
@ -390,8 +391,8 @@ int ViEFilePlayer::SendAudioOnChannel(const int audio_channel,
|
||||
|
||||
int ViEFilePlayer::StopSendAudioOnChannel(const int audio_channel) {
|
||||
int result = 0;
|
||||
MapItem* audio_item = audio_channels_sending_.Find(audio_channel);
|
||||
if (!audio_item) {
|
||||
std::set<int>::iterator it = audio_channels_sending_.find(audio_channel);
|
||||
if (it == audio_channels_sending_.end()) {
|
||||
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(engine_id_, id_),
|
||||
"ViEFilePlayer::StopSendAudioOnChannel AudioChannel %d not "
|
||||
"sending", audio_channel);
|
||||
@ -404,7 +405,7 @@ int ViEFilePlayer::StopSendAudioOnChannel(const int audio_channel) {
|
||||
"VE_StopPlayingFileAsMicrophone failed. audio_channel %d",
|
||||
audio_channel);
|
||||
}
|
||||
audio_channels_sending_.Erase(audio_item);
|
||||
audio_channels_sending_.erase(audio_channel);
|
||||
CriticalSectionScoped lock(*audio_cs_);
|
||||
audio_clients_--;
|
||||
assert(audio_clients_ >= 0);
|
||||
|
@ -11,10 +11,12 @@
|
||||
#ifndef WEBRTC_VIDEO_ENGINE_VIE_FILE_PLAYER_H_
|
||||
#define WEBRTC_VIDEO_ENGINE_VIE_FILE_PLAYER_H_
|
||||
|
||||
#include <list>
|
||||
#include <set>
|
||||
|
||||
#include "common_types.h"
|
||||
#include "modules/media_file/interface/media_file_defines.h"
|
||||
#include "system_wrappers/interface/file_wrapper.h"
|
||||
#include "system_wrappers/interface/list_wrapper.h"
|
||||
#include "typedefs.h"
|
||||
#include "video_engine/vie_frame_provider_base.h"
|
||||
|
||||
@ -124,10 +126,10 @@ class ViEFilePlayer
|
||||
|
||||
// Trick - list containing VoE buffer reading this file. Used if multiple
|
||||
// audio channels are sending.
|
||||
ListWrapper audio_channel_buffers_;
|
||||
std::list<void*> audio_channel_buffers_;
|
||||
|
||||
// AudioChannels sending audio from this file.
|
||||
MapWrapper audio_channels_sending_;
|
||||
std::set<int> audio_channels_sending_;
|
||||
|
||||
// Frame receiving decoded video from file.
|
||||
VideoFrame decoded_video_;
|
||||
|
Loading…
x
Reference in New Issue
Block a user