Remove some dead code.
WebRtcPassthroughRender has been dead since webrtcvideoengine.cc was removed, FakeExternalTransport has probably been unused for a long time. BUG=webrtc:1695 R=henrika@webrtc.org Review URL: https://codereview.webrtc.org/1343393003 . Cr-Commit-Position: refs/heads/master@{#9968}
This commit is contained in:
parent
e64fbce0d9
commit
f2bfc2b8ef
@ -499,8 +499,6 @@
|
||||
'media/webrtc/webrtcmediaengine.cc',
|
||||
'media/webrtc/webrtcmediaengine.h',
|
||||
'media/webrtc/webrtcmediaengine.cc',
|
||||
'media/webrtc/webrtcpassthroughrender.cc',
|
||||
'media/webrtc/webrtcpassthroughrender.h',
|
||||
'media/webrtc/webrtcvideocapturer.cc',
|
||||
'media/webrtc/webrtcvideocapturer.h',
|
||||
'media/webrtc/webrtcvideocapturerfactory.h',
|
||||
|
||||
@ -97,7 +97,6 @@
|
||||
'media/devices/filevideocapturer_unittest.cc',
|
||||
'media/sctp/sctpdataengine_unittest.cc',
|
||||
'media/webrtc/simulcast_unittest.cc',
|
||||
'media/webrtc/webrtcpassthroughrender_unittest.cc',
|
||||
'media/webrtc/webrtcvideocapturer_unittest.cc',
|
||||
'media/base/videoframe_unittest.h',
|
||||
'media/webrtc/webrtcvideoframe_unittest.cc',
|
||||
|
||||
@ -1,172 +0,0 @@
|
||||
/*
|
||||
* libjingle
|
||||
* Copyright 2004 Google Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "talk/media/webrtc/webrtcpassthroughrender.h"
|
||||
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
|
||||
namespace cricket {
|
||||
|
||||
#define LOG_FIND_STREAM_ERROR(func, id) LOG(LS_ERROR) \
|
||||
<< "" << func << " - Failed to find stream: " << id
|
||||
|
||||
class PassthroughStream: public webrtc::VideoRenderCallback {
|
||||
public:
|
||||
PassthroughStream() : running_(false) {}
|
||||
virtual ~PassthroughStream() {
|
||||
}
|
||||
virtual int32_t RenderFrame(const uint32_t stream_id,
|
||||
const webrtc::VideoFrame& videoFrame) {
|
||||
rtc::CritScope cs(&stream_critical_);
|
||||
// Send frame for rendering directly
|
||||
if (running_ && renderer_) {
|
||||
renderer_->RenderFrame(stream_id, videoFrame);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int32_t SetRenderer(VideoRenderCallback* renderer) {
|
||||
rtc::CritScope cs(&stream_critical_);
|
||||
renderer_ = renderer;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t StartRender() {
|
||||
rtc::CritScope cs(&stream_critical_);
|
||||
running_ = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t StopRender() {
|
||||
rtc::CritScope cs(&stream_critical_);
|
||||
running_ = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
private:
|
||||
VideoRenderCallback* renderer_;
|
||||
rtc::CriticalSection stream_critical_;
|
||||
bool running_;
|
||||
};
|
||||
|
||||
WebRtcPassthroughRender::WebRtcPassthroughRender()
|
||||
: window_(NULL) {
|
||||
}
|
||||
|
||||
WebRtcPassthroughRender::~WebRtcPassthroughRender() {
|
||||
while (!stream_render_map_.empty()) {
|
||||
PassthroughStream* stream = stream_render_map_.begin()->second;
|
||||
stream_render_map_.erase(stream_render_map_.begin());
|
||||
delete stream;
|
||||
}
|
||||
}
|
||||
|
||||
webrtc::VideoRenderCallback* WebRtcPassthroughRender::AddIncomingRenderStream(
|
||||
const uint32_t stream_id,
|
||||
const uint32_t zOrder,
|
||||
const float left, const float top,
|
||||
const float right, const float bottom) {
|
||||
rtc::CritScope cs(&render_critical_);
|
||||
// Stream already exist.
|
||||
if (FindStream(stream_id) != NULL) {
|
||||
LOG(LS_ERROR) << "AddIncomingRenderStream - Stream already exists: "
|
||||
<< stream_id;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PassthroughStream* stream = new PassthroughStream();
|
||||
// Store the stream
|
||||
stream_render_map_[stream_id] = stream;
|
||||
return stream;
|
||||
}
|
||||
|
||||
int32_t WebRtcPassthroughRender::DeleteIncomingRenderStream(
|
||||
const uint32_t stream_id) {
|
||||
rtc::CritScope cs(&render_critical_);
|
||||
PassthroughStream* stream = FindStream(stream_id);
|
||||
if (stream == NULL) {
|
||||
LOG_FIND_STREAM_ERROR("DeleteIncomingRenderStream", stream_id);
|
||||
return -1;
|
||||
}
|
||||
delete stream;
|
||||
stream_render_map_.erase(stream_id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t WebRtcPassthroughRender::AddExternalRenderCallback(
|
||||
const uint32_t stream_id,
|
||||
webrtc::VideoRenderCallback* render_object) {
|
||||
rtc::CritScope cs(&render_critical_);
|
||||
PassthroughStream* stream = FindStream(stream_id);
|
||||
if (stream == NULL) {
|
||||
LOG_FIND_STREAM_ERROR("AddExternalRenderCallback", stream_id);
|
||||
return -1;
|
||||
}
|
||||
return stream->SetRenderer(render_object);
|
||||
}
|
||||
|
||||
bool WebRtcPassthroughRender::HasIncomingRenderStream(
|
||||
const uint32_t stream_id) const {
|
||||
return (FindStream(stream_id) != NULL);
|
||||
}
|
||||
|
||||
webrtc::RawVideoType WebRtcPassthroughRender::PreferredVideoType() const {
|
||||
return webrtc::kVideoI420;
|
||||
}
|
||||
|
||||
int32_t WebRtcPassthroughRender::StartRender(const uint32_t stream_id) {
|
||||
rtc::CritScope cs(&render_critical_);
|
||||
PassthroughStream* stream = FindStream(stream_id);
|
||||
if (stream == NULL) {
|
||||
LOG_FIND_STREAM_ERROR("StartRender", stream_id);
|
||||
return -1;
|
||||
}
|
||||
return stream->StartRender();
|
||||
}
|
||||
|
||||
int32_t WebRtcPassthroughRender::StopRender(const uint32_t stream_id) {
|
||||
rtc::CritScope cs(&render_critical_);
|
||||
PassthroughStream* stream = FindStream(stream_id);
|
||||
if (stream == NULL) {
|
||||
LOG_FIND_STREAM_ERROR("StopRender", stream_id);
|
||||
return -1;
|
||||
}
|
||||
return stream->StopRender();
|
||||
}
|
||||
|
||||
// TODO(ronghuawu): Is it ok to return non-const pointer to PassthroughStream
|
||||
// from this const function FindStream.
|
||||
PassthroughStream* WebRtcPassthroughRender::FindStream(
|
||||
const uint32_t stream_id) const {
|
||||
StreamMap::const_iterator it = stream_render_map_.find(stream_id);
|
||||
if (it == stream_render_map_.end()) {
|
||||
return NULL;
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
|
||||
} // namespace cricket
|
||||
@ -1,185 +0,0 @@
|
||||
/*
|
||||
* libjingle
|
||||
* Copyright 2004 Google Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef TALK_MEDIA_WEBRTCPASSTHROUGHRENDER_H_
|
||||
#define TALK_MEDIA_WEBRTCPASSTHROUGHRENDER_H_
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "webrtc/base/criticalsection.h"
|
||||
#include "webrtc/modules/video_render/include/video_render.h"
|
||||
|
||||
namespace cricket {
|
||||
class PassthroughStream;
|
||||
|
||||
class WebRtcPassthroughRender : public webrtc::VideoRender {
|
||||
public:
|
||||
WebRtcPassthroughRender();
|
||||
virtual ~WebRtcPassthroughRender();
|
||||
|
||||
int64_t TimeUntilNextProcess() override { return 0; }
|
||||
|
||||
int32_t Process() override { return 0; }
|
||||
|
||||
void* Window() override {
|
||||
rtc::CritScope cs(&render_critical_);
|
||||
return window_;
|
||||
}
|
||||
|
||||
int32_t ChangeWindow(void* window) override {
|
||||
rtc::CritScope cs(&render_critical_);
|
||||
window_ = window;
|
||||
return 0;
|
||||
}
|
||||
|
||||
webrtc::VideoRenderCallback* AddIncomingRenderStream(
|
||||
const uint32_t stream_id,
|
||||
const uint32_t zOrder,
|
||||
const float left,
|
||||
const float top,
|
||||
const float right,
|
||||
const float bottom) override;
|
||||
|
||||
int32_t DeleteIncomingRenderStream(const uint32_t stream_id) override;
|
||||
|
||||
int32_t AddExternalRenderCallback(
|
||||
const uint32_t stream_id,
|
||||
webrtc::VideoRenderCallback* render_object) override;
|
||||
|
||||
int32_t GetIncomingRenderStreamProperties(const uint32_t stream_id,
|
||||
uint32_t& zOrder,
|
||||
float& left,
|
||||
float& top,
|
||||
float& right,
|
||||
float& bottom) const override {
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint32_t GetIncomingFrameRate(const uint32_t stream_id) override { return 0; }
|
||||
|
||||
uint32_t GetNumIncomingRenderStreams() const override {
|
||||
return static_cast<uint32_t>(stream_render_map_.size());
|
||||
}
|
||||
|
||||
bool HasIncomingRenderStream(const uint32_t stream_id) const override;
|
||||
|
||||
int32_t RegisterRawFrameCallback(
|
||||
const uint32_t stream_id,
|
||||
webrtc::VideoRenderCallback* callback_obj) override {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t StartRender(const uint32_t stream_id) override;
|
||||
|
||||
int32_t StopRender(const uint32_t stream_id) override;
|
||||
|
||||
int32_t ResetRender() override { return 0; }
|
||||
|
||||
webrtc::RawVideoType PreferredVideoType() const override;
|
||||
|
||||
bool IsFullScreen() override { return false; }
|
||||
|
||||
int32_t GetScreenResolution(uint32_t& screenWidth,
|
||||
uint32_t& screenHeight) const override {
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint32_t RenderFrameRate(const uint32_t stream_id) override { return 0; }
|
||||
|
||||
int32_t SetStreamCropping(const uint32_t stream_id,
|
||||
const float left,
|
||||
const float top,
|
||||
const float right,
|
||||
const float bottom) override {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t SetExpectedRenderDelay(uint32_t stream_id,
|
||||
int32_t delay_ms) override {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t ConfigureRenderer(const uint32_t stream_id,
|
||||
const unsigned int zOrder,
|
||||
const float left,
|
||||
const float top,
|
||||
const float right,
|
||||
const float bottom) override {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t SetTransparentBackground(const bool enable) override { return -1; }
|
||||
|
||||
int32_t FullScreenRender(void* window, const bool enable) override {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t SetBitmap(const void* bitMap,
|
||||
const uint8_t pictureId,
|
||||
const void* colorKey,
|
||||
const float left,
|
||||
const float top,
|
||||
const float right,
|
||||
const float bottom) override {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t SetText(const uint8_t textId,
|
||||
const uint8_t* text,
|
||||
const int32_t textLength,
|
||||
const uint32_t textColorRef,
|
||||
const uint32_t backgroundColorRef,
|
||||
const float left,
|
||||
const float top,
|
||||
const float right,
|
||||
const float bottom) override {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t SetStartImage(const uint32_t stream_id,
|
||||
const webrtc::VideoFrame& videoFrame) override {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t SetTimeoutImage(const uint32_t stream_id,
|
||||
const webrtc::VideoFrame& videoFrame,
|
||||
const uint32_t timeout) override {
|
||||
return -1;
|
||||
}
|
||||
|
||||
private:
|
||||
typedef std::map<uint32_t, PassthroughStream*> StreamMap;
|
||||
|
||||
PassthroughStream* FindStream(const uint32_t stream_id) const;
|
||||
|
||||
void* window_;
|
||||
StreamMap stream_render_map_;
|
||||
rtc::CriticalSection render_critical_;
|
||||
};
|
||||
} // namespace cricket
|
||||
|
||||
#endif // TALK_MEDIA_WEBRTCPASSTHROUGHRENDER_H_
|
||||
@ -1,172 +0,0 @@
|
||||
/*
|
||||
* libjingle
|
||||
* Copyright 2008 Google Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
// Author: Ronghua Wu (ronghuawu@google.com)
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "talk/media/base/testutils.h"
|
||||
#include "talk/media/webrtc/webrtcpassthroughrender.h"
|
||||
#include "webrtc/base/gunit.h"
|
||||
|
||||
class WebRtcPassthroughRenderTest : public testing::Test {
|
||||
public:
|
||||
class ExternalRenderer : public webrtc::VideoRenderCallback {
|
||||
public:
|
||||
ExternalRenderer() : frame_num_(0) {
|
||||
}
|
||||
|
||||
virtual ~ExternalRenderer() {
|
||||
}
|
||||
|
||||
virtual int32_t RenderFrame(const uint32_t stream_id,
|
||||
const webrtc::VideoFrame& videoFrame) {
|
||||
++frame_num_;
|
||||
LOG(INFO) << "RenderFrame stream_id: " << stream_id
|
||||
<< " frame_num: " << frame_num_;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int frame_num() const {
|
||||
return frame_num_;
|
||||
}
|
||||
|
||||
private:
|
||||
int frame_num_;
|
||||
};
|
||||
|
||||
WebRtcPassthroughRenderTest()
|
||||
: renderer_(new cricket::WebRtcPassthroughRender()) {
|
||||
}
|
||||
|
||||
~WebRtcPassthroughRenderTest() {
|
||||
}
|
||||
|
||||
webrtc::VideoRenderCallback* AddIncomingRenderStream(int stream_id) {
|
||||
return renderer_->AddIncomingRenderStream(stream_id, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
bool HasIncomingRenderStream(int stream_id) {
|
||||
return renderer_->HasIncomingRenderStream(stream_id);
|
||||
}
|
||||
|
||||
bool DeleteIncomingRenderStream(int stream_id) {
|
||||
return (renderer_->DeleteIncomingRenderStream(stream_id) == 0);
|
||||
}
|
||||
|
||||
bool AddExternalRenderCallback(int stream_id,
|
||||
webrtc::VideoRenderCallback* renderer) {
|
||||
return (renderer_->AddExternalRenderCallback(stream_id, renderer) == 0);
|
||||
}
|
||||
|
||||
bool StartRender(int stream_id) {
|
||||
return (renderer_->StartRender(stream_id) == 0);
|
||||
}
|
||||
|
||||
bool StopRender(int stream_id) {
|
||||
return (renderer_->StopRender(stream_id) == 0);
|
||||
}
|
||||
|
||||
private:
|
||||
rtc::scoped_ptr<cricket::WebRtcPassthroughRender> renderer_;
|
||||
};
|
||||
|
||||
TEST_F(WebRtcPassthroughRenderTest, Streams) {
|
||||
const int stream_id1 = 1234;
|
||||
const int stream_id2 = 5678;
|
||||
const int stream_id3 = 9012; // A stream that doesn't exist.
|
||||
webrtc::VideoRenderCallback* stream = NULL;
|
||||
// Add a new stream
|
||||
stream = AddIncomingRenderStream(stream_id1);
|
||||
EXPECT_TRUE(stream != NULL);
|
||||
EXPECT_TRUE(HasIncomingRenderStream(stream_id1));
|
||||
// Tried to add a already existed stream should return null
|
||||
stream =AddIncomingRenderStream(stream_id1);
|
||||
EXPECT_TRUE(stream == NULL);
|
||||
stream = AddIncomingRenderStream(stream_id2);
|
||||
EXPECT_TRUE(stream != NULL);
|
||||
EXPECT_TRUE(HasIncomingRenderStream(stream_id2));
|
||||
// Remove the stream
|
||||
EXPECT_FALSE(DeleteIncomingRenderStream(stream_id3));
|
||||
EXPECT_TRUE(DeleteIncomingRenderStream(stream_id2));
|
||||
EXPECT_TRUE(!HasIncomingRenderStream(stream_id2));
|
||||
// Add back the removed stream
|
||||
stream = AddIncomingRenderStream(stream_id2);
|
||||
EXPECT_TRUE(stream != NULL);
|
||||
EXPECT_TRUE(HasIncomingRenderStream(stream_id2));
|
||||
}
|
||||
|
||||
TEST_F(WebRtcPassthroughRenderTest, Renderer) {
|
||||
webrtc::VideoFrame frame;
|
||||
const int stream_id1 = 1234;
|
||||
const int stream_id2 = 5678;
|
||||
const int stream_id3 = 9012; // A stream that doesn't exist.
|
||||
webrtc::VideoRenderCallback* stream1 = NULL;
|
||||
webrtc::VideoRenderCallback* stream2 = NULL;
|
||||
// Add two new stream
|
||||
stream1 = AddIncomingRenderStream(stream_id1);
|
||||
EXPECT_TRUE(stream1 != NULL);
|
||||
EXPECT_TRUE(HasIncomingRenderStream(stream_id1));
|
||||
stream2 = AddIncomingRenderStream(stream_id2);
|
||||
EXPECT_TRUE(stream2 != NULL);
|
||||
EXPECT_TRUE(HasIncomingRenderStream(stream_id2));
|
||||
// Register the external renderer
|
||||
WebRtcPassthroughRenderTest::ExternalRenderer renderer1;
|
||||
WebRtcPassthroughRenderTest::ExternalRenderer renderer2;
|
||||
EXPECT_FALSE(AddExternalRenderCallback(stream_id3, &renderer1));
|
||||
EXPECT_TRUE(AddExternalRenderCallback(stream_id1, &renderer1));
|
||||
EXPECT_TRUE(AddExternalRenderCallback(stream_id2, &renderer2));
|
||||
int test_frame_num = 10;
|
||||
// RenderFrame without starting the render
|
||||
for (int i = 0; i < test_frame_num; ++i) {
|
||||
stream1->RenderFrame(stream_id1, frame);
|
||||
}
|
||||
EXPECT_EQ(0, renderer1.frame_num());
|
||||
// Start the render and test again.
|
||||
EXPECT_FALSE(StartRender(stream_id3));
|
||||
EXPECT_TRUE(StartRender(stream_id1));
|
||||
for (int i = 0; i < test_frame_num; ++i) {
|
||||
stream1->RenderFrame(stream_id1, frame);
|
||||
}
|
||||
EXPECT_EQ(test_frame_num, renderer1.frame_num());
|
||||
// Stop the render and test again.
|
||||
EXPECT_FALSE(StopRender(stream_id3));
|
||||
EXPECT_TRUE(StopRender(stream_id1));
|
||||
for (int i = 0; i < test_frame_num; ++i) {
|
||||
stream1->RenderFrame(stream_id1, frame);
|
||||
}
|
||||
// The frame number should not have changed.
|
||||
EXPECT_EQ(test_frame_num, renderer1.frame_num());
|
||||
|
||||
// Test on stream2 with a differnt number.
|
||||
EXPECT_TRUE(StartRender(stream_id2));
|
||||
test_frame_num = 30;
|
||||
for (int i = 0; i < test_frame_num; ++i) {
|
||||
stream2->RenderFrame(stream_id2, frame);
|
||||
}
|
||||
EXPECT_EQ(test_frame_num, renderer2.frame_num());
|
||||
}
|
||||
@ -1,96 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2012 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/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/event_wrapper.h"
|
||||
#include "webrtc/system_wrappers/interface/sleep.h"
|
||||
#include "webrtc/system_wrappers/interface/thread_wrapper.h"
|
||||
#include "webrtc/voice_engine/include/voe_network.h"
|
||||
#include "webrtc/voice_engine/test/auto_test/fakes/fake_external_transport.h"
|
||||
#include "webrtc/voice_engine/voice_engine_defines.h"
|
||||
|
||||
FakeExternalTransport::FakeExternalTransport(webrtc::VoENetwork* ptr)
|
||||
: my_network_(ptr),
|
||||
lock_(NULL),
|
||||
event_(NULL),
|
||||
length_(0),
|
||||
channel_(0),
|
||||
delay_is_enabled_(0),
|
||||
delay_time_in_ms_(0) {
|
||||
const char* thread_name = "external_thread";
|
||||
lock_ = webrtc::CriticalSectionWrapper::CreateCriticalSection();
|
||||
event_ = webrtc::EventWrapper::Create();
|
||||
thread_ = webrtc::ThreadWrapper::CreateThread(Run, this, thread_name);
|
||||
if (thread_) {
|
||||
thread_->Start();
|
||||
thread_->SetPriority(webrtc::kHighPriority);
|
||||
}
|
||||
}
|
||||
|
||||
FakeExternalTransport::~FakeExternalTransport() {
|
||||
if (thread_) {
|
||||
event_->Set();
|
||||
thread_->Stop();
|
||||
delete event_;
|
||||
event_ = NULL;
|
||||
delete lock_;
|
||||
lock_ = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool FakeExternalTransport::Run(void* ptr) {
|
||||
return static_cast<FakeExternalTransport*> (ptr)->Process();
|
||||
}
|
||||
|
||||
bool FakeExternalTransport::Process() {
|
||||
switch (event_->Wait(500)) {
|
||||
case webrtc::kEventSignaled:
|
||||
lock_->Enter();
|
||||
my_network_->ReceivedRTPPacket(channel_, packet_buffer_, length_,
|
||||
webrtc::PacketTime());
|
||||
lock_->Leave();
|
||||
return true;
|
||||
case webrtc::kEventTimeout:
|
||||
return true;
|
||||
case webrtc::kEventError:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int FakeExternalTransport::SendPacket(int channel,
|
||||
const void *data,
|
||||
size_t len) {
|
||||
lock_->Enter();
|
||||
if (len < 1612) {
|
||||
memcpy(packet_buffer_, (const unsigned char*) data, len);
|
||||
length_ = len;
|
||||
channel_ = channel;
|
||||
}
|
||||
lock_->Leave();
|
||||
event_->Set(); // Triggers ReceivedRTPPacket() from worker thread.
|
||||
return static_cast<int>(len);
|
||||
}
|
||||
|
||||
int FakeExternalTransport::SendRTCPPacket(int channel,
|
||||
const void *data,
|
||||
size_t len) {
|
||||
if (delay_is_enabled_) {
|
||||
webrtc::SleepMs(delay_time_in_ms_);
|
||||
}
|
||||
my_network_->ReceivedRTCPPacket(channel, data, len);
|
||||
return static_cast<int>(len);
|
||||
}
|
||||
|
||||
void FakeExternalTransport::SetDelayStatus(bool enable,
|
||||
unsigned int delayInMs) {
|
||||
delay_is_enabled_ = enable;
|
||||
delay_time_in_ms_ = delayInMs;
|
||||
}
|
||||
@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2012 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 VOICE_ENGINE_MAIN_TEST_AUTO_TEST_FAKES_FAKE_EXTERNAL_TRANSPORT_H_
|
||||
#define VOICE_ENGINE_MAIN_TEST_AUTO_TEST_FAKES_FAKE_EXTERNAL_TRANSPORT_H_
|
||||
|
||||
#include "webrtc/common_types.h"
|
||||
|
||||
namespace webrtc {
|
||||
class CriticalSectionWrapper;
|
||||
class EventWrapper;
|
||||
class ThreadWrapper;
|
||||
class VoENetwork;
|
||||
}
|
||||
|
||||
class FakeExternalTransport : public webrtc::Transport {
|
||||
public:
|
||||
explicit FakeExternalTransport(webrtc::VoENetwork* ptr);
|
||||
virtual ~FakeExternalTransport();
|
||||
int SendPacket(int channel, const void* data, size_t len) override;
|
||||
int SendRTCPPacket(int channel, const void* data, size_t len) override;
|
||||
void SetDelayStatus(bool enabled, unsigned int delayInMs = 100);
|
||||
|
||||
webrtc::VoENetwork* my_network_;
|
||||
private:
|
||||
static bool Run(void* ptr);
|
||||
bool Process();
|
||||
private:
|
||||
rtc::scoped_ptr<webrtc::ThreadWrapper> thread_;
|
||||
webrtc::CriticalSectionWrapper* lock_;
|
||||
webrtc::EventWrapper* event_;
|
||||
private:
|
||||
unsigned char packet_buffer_[1612];
|
||||
size_t length_;
|
||||
int channel_;
|
||||
bool delay_is_enabled_;
|
||||
int delay_time_in_ms_;
|
||||
};
|
||||
|
||||
#endif // VOICE_ENGINE_MAIN_TEST_AUTO_TEST_FAKES_FAKE_EXTERNAL_TRANSPORT_H_
|
||||
@ -162,8 +162,6 @@
|
||||
'test/auto_test/extended/ec_metrics_test.cc',
|
||||
'test/auto_test/fakes/conference_transport.cc',
|
||||
'test/auto_test/fakes/conference_transport.h',
|
||||
'test/auto_test/fakes/fake_external_transport.cc',
|
||||
'test/auto_test/fakes/fake_external_transport.h',
|
||||
'test/auto_test/fakes/loudest_filter.cc',
|
||||
'test/auto_test/fakes/loudest_filter.h',
|
||||
'test/auto_test/fixtures/after_initialization_fixture.cc',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user