Remove ViE external encryption API.
BUG= R=mflodman@webrtc.org Review URL: https://webrtc-codereview.appspot.com/8079005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@5525 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
82ebb463fd
commit
fc320466d1
@ -102,7 +102,6 @@
|
||||
|
||||
#define WEBRTC_VIDEO_ENGINE_CAPTURE_API
|
||||
#define WEBRTC_VIDEO_ENGINE_CODEC_API
|
||||
#define WEBRTC_VIDEO_ENGINE_ENCRYPTION_API
|
||||
#define WEBRTC_VIDEO_ENGINE_IMAGE_PROCESS_API
|
||||
#define WEBRTC_VIDEO_ENGINE_RENDER_API
|
||||
#define WEBRTC_VIDEO_ENGINE_RTP_RTCP_API
|
||||
|
@ -20,7 +20,6 @@ LOCAL_SRC_FILES := \
|
||||
vie_base_impl.cc \
|
||||
vie_capture_impl.cc \
|
||||
vie_codec_impl.cc \
|
||||
vie_encryption_impl.cc \
|
||||
vie_external_codec_impl.cc \
|
||||
vie_file_impl.cc \
|
||||
vie_image_process_impl.cc \
|
||||
|
@ -1,51 +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.
|
||||
*/
|
||||
|
||||
// This sub-API supports the following functionalities:
|
||||
// - External encryption and decryption.
|
||||
|
||||
#ifndef WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_ENCRYPTION_H_
|
||||
#define WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_ENCRYPTION_H_
|
||||
|
||||
#include "webrtc/common_types.h"
|
||||
|
||||
namespace webrtc {
|
||||
class VideoEngine;
|
||||
|
||||
class WEBRTC_DLLEXPORT ViEEncryption {
|
||||
public:
|
||||
// Factory for the ViEEncryption sub‐API and increases an internal reference
|
||||
// counter if successful. Returns NULL if the API is not supported or if
|
||||
// construction fails.
|
||||
static ViEEncryption* GetInterface(VideoEngine* video_engine);
|
||||
|
||||
// Releases the ViEEncryption sub-API and decreases an internal reference
|
||||
// counter.
|
||||
// Returns the new reference count. This value should be zero
|
||||
// for all sub-API:s before the VideoEngine object can be safely deleted.
|
||||
virtual int Release() = 0;
|
||||
|
||||
// This function registers a encryption derived instance and enables
|
||||
// external encryption for the specified channel.
|
||||
virtual int RegisterExternalEncryption(const int video_channel,
|
||||
Encryption& encryption) = 0;
|
||||
|
||||
// This function deregisters a registered encryption derived instance
|
||||
// and disables external encryption.
|
||||
virtual int DeregisterExternalEncryption(const int video_channel) = 0;
|
||||
|
||||
protected:
|
||||
ViEEncryption() {}
|
||||
virtual ~ViEEncryption() {}
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_ENCRYPTION_H_
|
@ -98,12 +98,6 @@ enum ViEErrors {
|
||||
kViERtpRtcpObserverNotRegistered, // No observer registered.
|
||||
kViERtpRtcpUnknownError, // An unknown error has occurred. Check the log file.
|
||||
|
||||
// ViEEncryption.
|
||||
kViEEncryptionInvalidChannelId = 12700, // Channel id does not exist.
|
||||
kViEEncryptionInvalidSrtpParameter, // DEPRECATED
|
||||
kViEEncryptionSrtpNotSupported, // DEPRECATED
|
||||
kViEEncryptionUnknownError, // An unknown error has occurred. Check the log file.
|
||||
|
||||
// ViEImageProcess.
|
||||
kViEImageProcessInvalidChannelId = 12800, // No Channel exist with the provided channel id.
|
||||
kViEImageProcessInvalidCaptureId, // No capture device exist with the provided capture id.
|
||||
|
@ -24,7 +24,6 @@ LOCAL_SRC_FILES := \
|
||||
../../source/vie_autotest_base.cc \
|
||||
../../source/vie_autotest_capture.cc \
|
||||
../../source/vie_autotest_codec.cc \
|
||||
../../source/vie_autotest_encryption.cc \
|
||||
../../source/vie_autotest_file.cc \
|
||||
../../source/vie_autotest_image_process.cc \
|
||||
../../source/vie_autotest_loopback.cc \
|
||||
@ -35,7 +34,7 @@ LOCAL_SRC_FILES := \
|
||||
../../source/tb_capture_device.cc \
|
||||
../../source/tb_external_transport.cc \
|
||||
../../source/tb_interfaces.cc \
|
||||
../../source/tb_video_channel.cc
|
||||
../../source/tb_video_channel.cc
|
||||
|
||||
LOCAL_CFLAGS := \
|
||||
'-DWEBRTC_TARGET_PC' \
|
||||
@ -57,7 +56,7 @@ LOCAL_C_INCLUDES := \
|
||||
$(LOCAL_PATH)/../../../../../modules/video_coding/codecs/interface \
|
||||
$(LOCAL_PATH)/../../../../../modules/video_render/main/interface \
|
||||
$(LOCAL_PATH)/../../../../../voice_engine/include \
|
||||
$(LOCAL_PATH)/../../../../../system_wrappers/interface
|
||||
$(LOCAL_PATH)/../../../../../system_wrappers/interface
|
||||
|
||||
LOCAL_PRELINK_MODULE := false
|
||||
|
||||
@ -69,7 +68,7 @@ LOCAL_SHARED_LIBRARIES := \
|
||||
libGLESv2
|
||||
|
||||
# the following line is for NDK build
|
||||
LOCAL_LDLIBS := $(LIBS_PATH)/VideoEngine_android_gcc.a -llog -lgcc
|
||||
LOCAL_LDLIBS := $(LIBS_PATH)/VideoEngine_android_gcc.a -llog -lgcc
|
||||
|
||||
ifndef NDK_ROOT
|
||||
include external/stlport/libstlport.mk
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
|
||||
<string name="app_name">ViEAutotest</string>
|
||||
<string name="TitleName">ViEAutotest</string>
|
||||
<string name="run_button">Run Test</string>
|
||||
|
@ -34,11 +34,6 @@ TEST_F(DISABLED_ON_MAC(ViEApiIntegrationTest), RunsCodecTestWithoutErrors) {
|
||||
tests_->ViECodecAPITest();
|
||||
}
|
||||
|
||||
TEST_F(DISABLED_ON_MAC(ViEApiIntegrationTest),
|
||||
RunsEncryptionTestWithoutErrors) {
|
||||
tests_->ViEEncryptionAPITest();
|
||||
}
|
||||
|
||||
TEST_F(DISABLED_ON_MAC(ViEApiIntegrationTest),
|
||||
RunsImageProcessTestWithoutErrors) {
|
||||
tests_->ViEImageProcessAPITest();
|
||||
|
@ -42,11 +42,6 @@ TEST_F(DISABLED_ON_MAC(ViEExtendedIntegrationTest),
|
||||
tests_->ViECodecExtendedTest();
|
||||
}
|
||||
|
||||
TEST_F(DISABLED_ON_MAC(ViEExtendedIntegrationTest),
|
||||
RunsEncryptionTestWithoutErrors) {
|
||||
tests_->ViEEncryptionExtendedTest();
|
||||
}
|
||||
|
||||
TEST_F(DISABLED_ON_MAC(ViEExtendedIntegrationTest),
|
||||
RunsImageProcessTestWithoutErrors) {
|
||||
tests_->ViEImageProcessExtendedTest();
|
||||
|
@ -1,150 +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 <time.h>
|
||||
|
||||
#include "gflags/gflags.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "webrtc/test/libtest/include/bit_flip_encryption.h"
|
||||
#include "webrtc/test/libtest/include/random_encryption.h"
|
||||
#include "webrtc/video_engine/test/auto_test/automated/two_windows_fixture.h"
|
||||
#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_window_manager_interface.h"
|
||||
#include "webrtc/video_engine/test/auto_test/interface/vie_window_creator.h"
|
||||
#include "webrtc/video_engine/test/auto_test/primitives/general_primitives.h"
|
||||
#include "webrtc/video_engine/test/libvietest/include/tb_capture_device.h"
|
||||
#include "webrtc/video_engine/test/libvietest/include/tb_interfaces.h"
|
||||
#include "webrtc/video_engine/test/libvietest/include/tb_video_channel.h"
|
||||
|
||||
namespace {
|
||||
|
||||
DEFINE_int32(rtp_fuzz_test_rand_seed, 0, "The rand seed to use for "
|
||||
"the RTP fuzz test. Defaults to time(). 0 cannot be specified.");
|
||||
|
||||
class ViERtpFuzzTest : public TwoWindowsFixture {
|
||||
protected:
|
||||
TbVideoChannel* video_channel_;
|
||||
TbInterfaces* video_engine_;
|
||||
TbCaptureDevice* capture_device_;
|
||||
|
||||
void SetUp() {
|
||||
video_engine_ = new TbInterfaces(
|
||||
"ViERtpTryInjectingRandomPacketsIntoRtpStream");
|
||||
video_channel_ = new TbVideoChannel(
|
||||
*video_engine_, webrtc::kVideoCodecVP8);
|
||||
capture_device_ = new TbCaptureDevice(*video_engine_);
|
||||
|
||||
capture_device_->ConnectTo(video_channel_->videoChannel);
|
||||
|
||||
// Enable PLI RTCP, which will allow the video engine to recover better.
|
||||
video_engine_->rtp_rtcp->SetKeyFrameRequestMethod(
|
||||
video_channel_->videoChannel, webrtc::kViEKeyFrameRequestPliRtcp);
|
||||
|
||||
video_channel_->StartReceive();
|
||||
video_channel_->StartSend();
|
||||
|
||||
RenderInWindow(
|
||||
video_engine_->render, capture_device_->captureId, window_1_, 0);
|
||||
RenderInWindow(
|
||||
video_engine_->render, video_channel_->videoChannel, window_2_, 1);
|
||||
}
|
||||
|
||||
void TearDown() {
|
||||
delete capture_device_;
|
||||
delete video_channel_;
|
||||
delete video_engine_;
|
||||
}
|
||||
|
||||
unsigned int FetchRandSeed() {
|
||||
if (FLAGS_rtp_fuzz_test_rand_seed != 0) {
|
||||
return FLAGS_rtp_fuzz_test_rand_seed;
|
||||
}
|
||||
return time(NULL);
|
||||
}
|
||||
|
||||
// Pass in a number [0, 1] which will be the bit flip probability per byte.
|
||||
void BitFlipFuzzTest(float flip_probability) {
|
||||
unsigned int rand_seed = FetchRandSeed();
|
||||
ViETest::Log("Running test with rand seed %d.", rand_seed);
|
||||
|
||||
ViETest::Log("Running as usual. You should see video output.");
|
||||
AutoTestSleep(2000);
|
||||
|
||||
ViETest::Log("Starting to flip bits in packets (%f%% chance per byte).",
|
||||
flip_probability * 100);
|
||||
BitFlipEncryption bit_flip_encryption(rand_seed, flip_probability);
|
||||
video_engine_->encryption->RegisterExternalEncryption(
|
||||
video_channel_->videoChannel, bit_flip_encryption);
|
||||
|
||||
AutoTestSleep(5000);
|
||||
|
||||
ViETest::Log("Back to normal. Flipped %d bits.",
|
||||
bit_flip_encryption.flip_count());
|
||||
video_engine_->encryption->DeregisterExternalEncryption(
|
||||
video_channel_->videoChannel);
|
||||
|
||||
AutoTestSleep(5000);
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(ViERtpFuzzTest, VideoEngineDealsWithASmallNumberOfTamperedPackets) {
|
||||
// Try 0.005% bit flip chance per byte.
|
||||
BitFlipFuzzTest(0.00005f);
|
||||
}
|
||||
|
||||
TEST_F(ViERtpFuzzTest, VideoEngineDealsWithAMediumNumberOfTamperedPackets) {
|
||||
// Try 0.05% bit flip chance per byte.
|
||||
BitFlipFuzzTest(0.0005f);
|
||||
}
|
||||
|
||||
TEST_F(ViERtpFuzzTest, VideoEngineDealsWithALargeNumberOfTamperedPackets) {
|
||||
// Try 0.5% bit flip chance per byte.
|
||||
BitFlipFuzzTest(0.005f);
|
||||
}
|
||||
|
||||
TEST_F(ViERtpFuzzTest, VideoEngineDealsWithAVeryLargeNumberOfTamperedPackets) {
|
||||
// Try 5% bit flip chance per byte.
|
||||
BitFlipFuzzTest(0.05f);
|
||||
}
|
||||
|
||||
TEST_F(ViERtpFuzzTest,
|
||||
VideoEngineDealsWithAExtremelyLargeNumberOfTamperedPackets) {
|
||||
// Try 25% bit flip chance per byte (madness!)
|
||||
BitFlipFuzzTest(0.25f);
|
||||
}
|
||||
|
||||
TEST_F(ViERtpFuzzTest, VideoEngineDealsWithSeveralPeriodsOfTamperedPackets) {
|
||||
// Try 0.05% bit flip chance per byte.
|
||||
BitFlipFuzzTest(0.0005f);
|
||||
BitFlipFuzzTest(0.0005f);
|
||||
BitFlipFuzzTest(0.0005f);
|
||||
}
|
||||
|
||||
TEST_F(ViERtpFuzzTest, VideoEngineRecoversAfterSomeCompletelyRandomPackets) {
|
||||
unsigned int rand_seed = FetchRandSeed();
|
||||
ViETest::Log("Running test with rand seed %d.", rand_seed);
|
||||
|
||||
ViETest::Log("Running as usual. You should see video output.");
|
||||
AutoTestSleep(2000);
|
||||
|
||||
ViETest::Log("Injecting completely random packets...");
|
||||
RandomEncryption random_encryption(rand_seed);
|
||||
video_engine_->encryption->RegisterExternalEncryption(
|
||||
video_channel_->videoChannel, random_encryption);
|
||||
|
||||
AutoTestSleep(5000);
|
||||
|
||||
ViETest::Log("Back to normal.");
|
||||
video_engine_->encryption->DeregisterExternalEncryption(
|
||||
video_channel_->videoChannel);
|
||||
|
||||
AutoTestSleep(5000);
|
||||
}
|
||||
|
||||
}
|
@ -43,10 +43,6 @@ TEST_F(ViEStandardIntegrationTest, RunsCaptureTestWithoutErrors) {
|
||||
tests_->ViECaptureStandardTest();
|
||||
}
|
||||
|
||||
TEST_F(ViEStandardIntegrationTest, RunsEncryptionTestWithoutErrors) {
|
||||
tests_->ViEEncryptionStandardTest();
|
||||
}
|
||||
|
||||
TEST_F(ViEStandardIntegrationTest, RunsImageProcessTestWithoutErrors) {
|
||||
tests_->ViEImageProcessStandardTest();
|
||||
}
|
||||
|
@ -83,11 +83,6 @@ public:
|
||||
void ViECodecExternalCodecTest();
|
||||
void ViECodecAPITest();
|
||||
|
||||
// vie_autotest_encryption.cc
|
||||
void ViEEncryptionStandardTest();
|
||||
void ViEEncryptionExtendedTest();
|
||||
void ViEEncryptionAPITest();
|
||||
|
||||
// vie_autotest_image_process.cc
|
||||
void ViEImageProcessStandardTest();
|
||||
void ViEImageProcessExtendedTest();
|
||||
@ -108,9 +103,6 @@ public:
|
||||
void ViERtpRtcpExtendedTest();
|
||||
void ViERtpRtcpAPITest();
|
||||
|
||||
// vie_autotest_rtp_fuzz.cc
|
||||
void ViERtpTryInjectingRandomPacketsIntoRtpStream(long rand_seed);
|
||||
|
||||
private:
|
||||
void PrintAudioCodec(const webrtc::CodecInst audioCodec);
|
||||
void PrintVideoCodec(const webrtc::VideoCodec videoCodec);
|
||||
|
@ -22,7 +22,6 @@ LOCAL_SRC_FILES:= \
|
||||
vie_autotest_base.cc \
|
||||
vie_autotest_capture.cc \
|
||||
vie_autotest_codec.cc \
|
||||
vie_autotest_encryption.cc \
|
||||
vie_autotest_file.cc \
|
||||
vie_autotest_image_process.cc \
|
||||
vie_autotest_loopback.cc \
|
||||
|
@ -64,7 +64,6 @@ void ViEAutoTest::ViEStandardTest()
|
||||
ViEBaseStandardTest();
|
||||
ViECaptureStandardTest();
|
||||
ViECodecStandardTest();
|
||||
ViEEncryptionStandardTest();
|
||||
ViEImageProcessStandardTest();
|
||||
ViERenderStandardTest();
|
||||
ViERtpRtcpStandardTest();
|
||||
@ -75,7 +74,6 @@ void ViEAutoTest::ViEExtendedTest()
|
||||
ViEBaseExtendedTest();
|
||||
ViECaptureExtendedTest();
|
||||
ViECodecExtendedTest();
|
||||
ViEEncryptionExtendedTest();
|
||||
ViEImageProcessExtendedTest();
|
||||
ViERenderExtendedTest();
|
||||
ViERtpRtcpExtendedTest();
|
||||
@ -86,7 +84,6 @@ void ViEAutoTest::ViEAPITest()
|
||||
ViEBaseAPITest();
|
||||
ViECaptureAPITest();
|
||||
ViECodecAPITest();
|
||||
ViEEncryptionAPITest();
|
||||
ViEImageProcessAPITest();
|
||||
ViERenderAPITest();
|
||||
ViERtpRtcpAPITest();
|
||||
|
@ -62,10 +62,6 @@ int ViEAutoTestAndroid::RunAutotest(int testSelection, int subTestSelection,
|
||||
vieAutoTest.ViECodecStandardTest();
|
||||
break;
|
||||
|
||||
case 5: //encryption
|
||||
vieAutoTest.ViEEncryptionStandardTest();
|
||||
break;
|
||||
|
||||
case 6: // image process
|
||||
vieAutoTest.ViEImageProcessStandardTest();
|
||||
break;
|
||||
@ -101,10 +97,6 @@ int ViEAutoTestAndroid::RunAutotest(int testSelection, int subTestSelection,
|
||||
vieAutoTest.ViECodecAPITest();
|
||||
break;
|
||||
|
||||
case 5: //encryption
|
||||
vieAutoTest.ViEEncryptionAPITest();
|
||||
break;
|
||||
|
||||
case 6: // image process
|
||||
vieAutoTest.ViEImageProcessAPITest();
|
||||
break;
|
||||
@ -142,10 +134,6 @@ int ViEAutoTestAndroid::RunAutotest(int testSelection, int subTestSelection,
|
||||
vieAutoTest.ViECodecExtendedTest();
|
||||
break;
|
||||
|
||||
case 5: //encryption
|
||||
vieAutoTest.ViEEncryptionExtendedTest();
|
||||
break;
|
||||
|
||||
case 6: // image process
|
||||
vieAutoTest.ViEImageProcessExtendedTest();
|
||||
break;
|
||||
|
@ -1,203 +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.
|
||||
*/
|
||||
|
||||
//
|
||||
// vie_autotest_encryption.cc
|
||||
//
|
||||
|
||||
#include "webrtc/engine_configurations.h"
|
||||
#include "webrtc/video_engine/test/auto_test/interface/vie_autotest.h"
|
||||
#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_defines.h"
|
||||
|
||||
#include "webrtc/video_engine/test/libvietest/include/tb_capture_device.h"
|
||||
#include "webrtc/video_engine/test/libvietest/include/tb_external_transport.h"
|
||||
#include "webrtc/video_engine/test/libvietest/include/tb_interfaces.h"
|
||||
#include "webrtc/video_engine/test/libvietest/include/tb_video_channel.h"
|
||||
|
||||
class ViEAutotestEncryption: public webrtc::Encryption
|
||||
{
|
||||
public:
|
||||
ViEAutotestEncryption()
|
||||
{
|
||||
}
|
||||
~ViEAutotestEncryption()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void encrypt(int channel_no, unsigned char* in_data,
|
||||
unsigned char* out_data, int bytes_in, int* bytes_out)
|
||||
{
|
||||
for (int i = 0; i < bytes_in; i++)
|
||||
{
|
||||
out_data[i] = ~in_data[i];
|
||||
}
|
||||
assert(*bytes_out >= bytes_in + 2);
|
||||
*bytes_out = bytes_in + 2;
|
||||
out_data[bytes_in] = 'a';
|
||||
out_data[bytes_in + 1] = 'b';
|
||||
}
|
||||
|
||||
virtual void decrypt(int channel_no, unsigned char* in_data,
|
||||
unsigned char* out_data, int bytes_in, int* bytes_out)
|
||||
{
|
||||
for (int i = 0; i < bytes_in - 2; i++)
|
||||
{
|
||||
out_data[i] = ~in_data[i];
|
||||
}
|
||||
assert(*bytes_out >= bytes_in - 2);
|
||||
*bytes_out = bytes_in - 2;
|
||||
}
|
||||
|
||||
virtual void encrypt_rtcp(int channel_no, unsigned char* in_data,
|
||||
unsigned char* out_data, int bytes_in,
|
||||
int* bytes_out)
|
||||
{
|
||||
for (int i = 0; i < bytes_in; i++)
|
||||
{
|
||||
out_data[i] = ~in_data[i];
|
||||
}
|
||||
assert(*bytes_out >= bytes_in + 2);
|
||||
*bytes_out = bytes_in + 2;
|
||||
out_data[bytes_in] = 'a';
|
||||
out_data[bytes_in + 1] = 'b';
|
||||
}
|
||||
|
||||
virtual void decrypt_rtcp(int channel_no, unsigned char* in_data,
|
||||
unsigned char* out_data, int bytes_in,
|
||||
int* bytes_out)
|
||||
{
|
||||
for (int i = 0; i < bytes_in - 2; i++)
|
||||
{
|
||||
out_data[i] = ~in_data[i];
|
||||
}
|
||||
assert(*bytes_out >= bytes_in - 2);
|
||||
*bytes_out = bytes_in - 2;
|
||||
}
|
||||
};
|
||||
|
||||
void ViEAutoTest::ViEEncryptionStandardTest()
|
||||
{
|
||||
//***************************************************************
|
||||
// Begin create/initialize WebRTC Video Engine for testing
|
||||
//***************************************************************
|
||||
|
||||
// Create VIE
|
||||
TbInterfaces ViE("ViEEncryptionStandardTest");
|
||||
// Create a video channel
|
||||
TbVideoChannel tbChannel(ViE, webrtc::kVideoCodecVP8);
|
||||
|
||||
// Create a capture device
|
||||
TbCaptureDevice tbCapture(ViE);
|
||||
tbCapture.ConnectTo(tbChannel.videoChannel);
|
||||
|
||||
tbChannel.StartReceive();
|
||||
|
||||
tbChannel.StartSend();
|
||||
|
||||
RenderCaptureDeviceAndOutputStream(&ViE, &tbChannel, &tbCapture);
|
||||
|
||||
//
|
||||
// External encryption
|
||||
//
|
||||
ViEAutotestEncryption testEncryption;
|
||||
// Note(qhogpat): StartSend fails, not sure if this is intentional.
|
||||
EXPECT_NE(0, ViE.base->StartSend(tbChannel.videoChannel));
|
||||
EXPECT_EQ(0, ViE.encryption->RegisterExternalEncryption(
|
||||
tbChannel.videoChannel, testEncryption));
|
||||
ViETest::Log(
|
||||
"External encryption/decryption added, you should still see video");
|
||||
AutoTestSleep(kAutoTestSleepTimeMs);
|
||||
EXPECT_EQ(0, ViE.encryption->DeregisterExternalEncryption(
|
||||
tbChannel.videoChannel));
|
||||
|
||||
//***************************************************************
|
||||
// Testing finished. Tear down Video Engine
|
||||
//***************************************************************
|
||||
}
|
||||
|
||||
void ViEAutoTest::ViEEncryptionExtendedTest()
|
||||
{
|
||||
//***************************************************************
|
||||
// Begin create/initialize WebRTC Video Engine for testing
|
||||
//***************************************************************
|
||||
|
||||
// Create VIE
|
||||
TbInterfaces ViE("ViEEncryptionExtendedTest");
|
||||
// Create a video channel
|
||||
TbVideoChannel tbChannel(ViE, webrtc::kVideoCodecVP8);
|
||||
|
||||
// Create a capture device
|
||||
TbCaptureDevice tbCapture(ViE);
|
||||
tbCapture.ConnectTo(tbChannel.videoChannel);
|
||||
|
||||
tbChannel.StartReceive();
|
||||
tbChannel.StartSend();
|
||||
|
||||
RenderCaptureDeviceAndOutputStream(&ViE, &tbChannel, &tbCapture);
|
||||
|
||||
//***************************************************************
|
||||
// Engine ready. Begin testing class
|
||||
//***************************************************************
|
||||
|
||||
//
|
||||
// External encryption
|
||||
//
|
||||
ViEAutotestEncryption testEncryption;
|
||||
EXPECT_EQ(0, ViE.encryption->RegisterExternalEncryption(
|
||||
tbChannel.videoChannel, testEncryption));
|
||||
ViETest::Log(
|
||||
"External encryption/decryption added, you should still see video");
|
||||
AutoTestSleep(kAutoTestSleepTimeMs);
|
||||
EXPECT_EQ(0, ViE.encryption->DeregisterExternalEncryption(
|
||||
tbChannel.videoChannel));
|
||||
|
||||
//***************************************************************
|
||||
// Testing finished. Tear down Video Engine
|
||||
//***************************************************************
|
||||
}
|
||||
|
||||
void ViEAutoTest::ViEEncryptionAPITest()
|
||||
{
|
||||
//***************************************************************
|
||||
// Begin create/initialize WebRTC Video Engine for testing
|
||||
//***************************************************************
|
||||
|
||||
//***************************************************************
|
||||
// Engine ready. Begin testing class
|
||||
//***************************************************************
|
||||
|
||||
// Create VIE
|
||||
TbInterfaces ViE("ViEEncryptionAPITest");
|
||||
// Create a video channel
|
||||
TbVideoChannel tbChannel(ViE, webrtc::kVideoCodecVP8);
|
||||
|
||||
// Create a capture device
|
||||
TbCaptureDevice tbCapture(ViE);
|
||||
// Connect to channel
|
||||
tbCapture.ConnectTo(tbChannel.videoChannel);
|
||||
|
||||
//
|
||||
// External encryption
|
||||
//
|
||||
|
||||
ViEAutotestEncryption testEncryption;
|
||||
EXPECT_EQ(0, ViE.encryption->RegisterExternalEncryption(
|
||||
tbChannel.videoChannel, testEncryption));
|
||||
EXPECT_NE(0, ViE.encryption->RegisterExternalEncryption(
|
||||
tbChannel.videoChannel, testEncryption));
|
||||
EXPECT_EQ(0, ViE.encryption->DeregisterExternalEncryption(
|
||||
tbChannel.videoChannel));
|
||||
EXPECT_EQ(0, ViE.encryption->DeregisterExternalEncryption(
|
||||
tbChannel.videoChannel));
|
||||
|
||||
//***************************************************************
|
||||
// Testing finished. Tear down Video Engine
|
||||
//***************************************************************
|
||||
}
|
@ -29,7 +29,7 @@ ViEAutoTestMain::ViEAutoTestMain() {
|
||||
index_to_test_method_map_[1] = "RunsBaseTestWithoutErrors";
|
||||
index_to_test_method_map_[2] = "RunsCaptureTestWithoutErrors";
|
||||
index_to_test_method_map_[3] = "RunsCodecTestWithoutErrors";
|
||||
index_to_test_method_map_[4] = "RunsEncryptionTestWithoutErrors";
|
||||
index_to_test_method_map_[4] = "[unused]";
|
||||
index_to_test_method_map_[5] = "RunsImageProcessTestWithoutErrors";
|
||||
index_to_test_method_map_[6] = "RunsNetworkTestWithoutErrors";
|
||||
index_to_test_method_map_[7] = "RunsRenderTestWithoutErrors";
|
||||
|
@ -42,7 +42,6 @@
|
||||
'automated/two_windows_fixture.cc',
|
||||
'automated/vie_api_integration_test.cc',
|
||||
'automated/vie_extended_integration_test.cc',
|
||||
'automated/vie_rtp_fuzz_test.cc',
|
||||
'automated/vie_standard_integration_test.cc',
|
||||
'automated/vie_video_verification_test.cc',
|
||||
|
||||
@ -68,7 +67,6 @@
|
||||
'source/vie_autotest_base.cc',
|
||||
'source/vie_autotest_capture.cc',
|
||||
'source/vie_autotest_codec.cc',
|
||||
'source/vie_autotest_encryption.cc',
|
||||
'source/vie_autotest_image_process.cc',
|
||||
'source/vie_autotest_loopback.cc',
|
||||
'source/vie_autotest_main.cc',
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include "webrtc/video_engine/include/vie_base.h"
|
||||
#include "webrtc/video_engine/include/vie_capture.h"
|
||||
#include "webrtc/video_engine/include/vie_codec.h"
|
||||
#include "webrtc/video_engine/include/vie_encryption.h"
|
||||
#include "webrtc/video_engine/include/vie_image_process.h"
|
||||
#include "webrtc/video_engine/include/vie_network.h"
|
||||
#include "webrtc/video_engine/include/vie_render.h"
|
||||
@ -43,7 +42,6 @@ public:
|
||||
webrtc::ViECodec* codec;
|
||||
webrtc::ViENetwork* network;
|
||||
webrtc::ViEImageProcess* image_process;
|
||||
webrtc::ViEEncryption* encryption;
|
||||
|
||||
int LastError() {
|
||||
return base->LastError();
|
||||
|
@ -21,8 +21,7 @@ TbInterfaces::TbInterfaces(const std::string& test_name) :
|
||||
rtp_rtcp(NULL),
|
||||
codec(NULL),
|
||||
network(NULL),
|
||||
image_process(NULL),
|
||||
encryption(NULL)
|
||||
image_process(NULL)
|
||||
{
|
||||
std::string complete_path =
|
||||
webrtc::test::OutputPath() + test_name + "_trace.txt";
|
||||
@ -55,15 +54,10 @@ TbInterfaces::TbInterfaces(const std::string& test_name) :
|
||||
|
||||
image_process = webrtc::ViEImageProcess::GetInterface(video_engine);
|
||||
EXPECT_TRUE(image_process != NULL);
|
||||
|
||||
encryption = webrtc::ViEEncryption::GetInterface(video_engine);
|
||||
EXPECT_TRUE(encryption != NULL);
|
||||
}
|
||||
|
||||
TbInterfaces::~TbInterfaces(void)
|
||||
{
|
||||
EXPECT_EQ(0, encryption->Release());
|
||||
encryption = NULL;
|
||||
EXPECT_EQ(0, image_process->Release());
|
||||
image_process = NULL;
|
||||
EXPECT_EQ(0, codec->Release());
|
||||
|
@ -38,7 +38,6 @@
|
||||
'include/vie_base.h',
|
||||
'include/vie_capture.h',
|
||||
'include/vie_codec.h',
|
||||
'include/vie_encryption.h',
|
||||
'include/vie_errors.h',
|
||||
'include/vie_external_codec.h',
|
||||
'include/vie_image_process.h',
|
||||
@ -55,7 +54,6 @@
|
||||
'vie_capture_impl.h',
|
||||
'vie_codec_impl.h',
|
||||
'vie_defines.h',
|
||||
'vie_encryption_impl.h',
|
||||
'vie_external_codec_impl.h',
|
||||
'vie_image_process_impl.h',
|
||||
'vie_impl.h',
|
||||
@ -88,7 +86,6 @@
|
||||
'vie_base_impl.cc',
|
||||
'vie_capture_impl.cc',
|
||||
'vie_codec_impl.cc',
|
||||
'vie_encryption_impl.cc',
|
||||
'vie_external_codec_impl.cc',
|
||||
'vie_image_process_impl.cc',
|
||||
'vie_impl.cc',
|
||||
|
@ -96,7 +96,6 @@ ViEChannel::ViEChannel(int32_t channel_id,
|
||||
decoder_reset_(true),
|
||||
wait_for_key_frame_(false),
|
||||
decode_thread_(NULL),
|
||||
external_encryption_(NULL),
|
||||
effect_filter_(NULL),
|
||||
color_enhancement_(false),
|
||||
mtu_(0),
|
||||
@ -1883,48 +1882,6 @@ int32_t ViEChannel::StopDecodeThread() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t ViEChannel::RegisterExternalEncryption(Encryption* encryption) {
|
||||
WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(engine_id_, channel_id_), "%s",
|
||||
__FUNCTION__);
|
||||
|
||||
CriticalSectionScoped cs(callback_cs_.get());
|
||||
if (external_encryption_) {
|
||||
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(engine_id_, channel_id_),
|
||||
"%s: external encryption already registered", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
external_encryption_ = encryption;
|
||||
|
||||
vie_receiver_.RegisterExternalDecryption(encryption);
|
||||
vie_sender_.RegisterExternalEncryption(encryption);
|
||||
|
||||
WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(engine_id_, channel_id_),
|
||||
"%s", "external encryption object registerd with channel=%d",
|
||||
channel_id_);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t ViEChannel::DeRegisterExternalEncryption() {
|
||||
WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(engine_id_, channel_id_), "%s",
|
||||
__FUNCTION__);
|
||||
|
||||
CriticalSectionScoped cs(callback_cs_.get());
|
||||
if (!external_encryption_) {
|
||||
WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(engine_id_, channel_id_),
|
||||
"%s: external encryption is not registered", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
external_transport_ = NULL;
|
||||
vie_receiver_.DeregisterExternalDecryption();
|
||||
vie_sender_.DeregisterExternalEncryption();
|
||||
WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(engine_id_, channel_id_),
|
||||
"%s external encryption object de-registerd with channel=%d",
|
||||
__FUNCTION__, channel_id_);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t ViEChannel::SetVoiceChannel(int32_t ve_channel_id,
|
||||
VoEVideoSync* ve_sync_interface) {
|
||||
WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(engine_id_, channel_id_),
|
||||
|
@ -34,7 +34,6 @@ class ChannelStatsObserver;
|
||||
class Config;
|
||||
class CriticalSectionWrapper;
|
||||
class EncodedImageCallback;
|
||||
class Encryption;
|
||||
class I420FrameCallback;
|
||||
class PacedSender;
|
||||
class ProcessThread;
|
||||
@ -333,9 +332,6 @@ class ViEChannel
|
||||
virtual int32_t ResendPackets(const uint16_t* sequence_numbers,
|
||||
uint16_t length);
|
||||
|
||||
int32_t RegisterExternalEncryption(Encryption* encryption);
|
||||
int32_t DeRegisterExternalEncryption();
|
||||
|
||||
int32_t SetVoiceChannel(int32_t ve_channel_id,
|
||||
VoEVideoSync* ve_sync_interface);
|
||||
int32_t VoiceChannel();
|
||||
@ -415,8 +411,6 @@ class ViEChannel
|
||||
bool wait_for_key_frame_;
|
||||
ThreadWrapper* decode_thread_;
|
||||
|
||||
Encryption* external_encryption_;
|
||||
|
||||
ViEEffectFilter* effect_filter_;
|
||||
bool color_enhancement_;
|
||||
|
||||
|
@ -51,14 +51,6 @@ enum { kViEMaxCodecHeight = 3072 };
|
||||
enum { kViEMaxCodecFramerate = 60 };
|
||||
enum { kViEMinCodecBitrate = 30 };
|
||||
|
||||
// ViEEncryption
|
||||
enum { kViEMaxSrtpKeyLength = 30 };
|
||||
enum { kViEMinSrtpEncryptLength = 16 };
|
||||
enum { kViEMaxSrtpEncryptLength = 256 };
|
||||
enum { kViEMaxSrtpAuthSh1Length = 20 };
|
||||
enum { kViEMaxSrtpTagAuthNullLength = 12 };
|
||||
enum { kViEMaxSrtpKeyAuthNullLength = 256 };
|
||||
|
||||
// ViENetwork
|
||||
enum { kViEMaxMtu = 1500 };
|
||||
enum { kViESocketThreads = 1 };
|
||||
|
@ -1,111 +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/video_engine/vie_encryption_impl.h"
|
||||
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
#include "webrtc/video_engine/include/vie_errors.h"
|
||||
#include "webrtc/video_engine/vie_channel.h"
|
||||
#include "webrtc/video_engine/vie_channel_manager.h"
|
||||
#include "webrtc/video_engine/vie_defines.h"
|
||||
#include "webrtc/video_engine/vie_impl.h"
|
||||
#include "webrtc/video_engine/vie_shared_data.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
ViEEncryption* ViEEncryption::GetInterface(VideoEngine* video_engine) {
|
||||
#ifdef WEBRTC_VIDEO_ENGINE_ENCRYPTION_API
|
||||
if (video_engine == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
VideoEngineImpl* vie_impl = static_cast<VideoEngineImpl*>(video_engine);
|
||||
ViEEncryptionImpl* vie_encryption_impl = vie_impl;
|
||||
// Increase ref count.
|
||||
(*vie_encryption_impl)++;
|
||||
return vie_encryption_impl;
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
int ViEEncryptionImpl::Release() {
|
||||
WEBRTC_TRACE(kTraceApiCall, kTraceVideo, shared_data_->instance_id(),
|
||||
"ViEEncryptionImpl::Release()");
|
||||
// Decrease ref count.
|
||||
(*this)--;
|
||||
|
||||
int32_t ref_count = GetCount();
|
||||
if (ref_count < 0) {
|
||||
WEBRTC_TRACE(kTraceWarning, kTraceVideo, shared_data_->instance_id(),
|
||||
"ViEEncryptionImpl release too many times");
|
||||
shared_data_->SetLastError(kViEAPIDoesNotExist);
|
||||
return -1;
|
||||
}
|
||||
WEBRTC_TRACE(kTraceInfo, kTraceVideo, shared_data_->instance_id(),
|
||||
"ViEEncryptionImpl reference count: %d", ref_count);
|
||||
return ref_count;
|
||||
}
|
||||
|
||||
ViEEncryptionImpl::ViEEncryptionImpl(ViESharedData* shared_data)
|
||||
: shared_data_(shared_data) {
|
||||
WEBRTC_TRACE(kTraceMemory, kTraceVideo, shared_data_->instance_id(),
|
||||
"ViEEncryptionImpl::ViEEncryptionImpl() Ctor");
|
||||
}
|
||||
|
||||
ViEEncryptionImpl::~ViEEncryptionImpl() {
|
||||
WEBRTC_TRACE(kTraceMemory, kTraceVideo, shared_data_->instance_id(),
|
||||
"ViEEncryptionImpl::~ViEEncryptionImpl() Dtor");
|
||||
}
|
||||
|
||||
int ViEEncryptionImpl::RegisterExternalEncryption(const int video_channel,
|
||||
Encryption& encryption) {
|
||||
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
|
||||
ViEId(shared_data_->instance_id(), video_channel),
|
||||
"RegisterExternalEncryption(video_channel=%d)", video_channel);
|
||||
|
||||
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
|
||||
ViEChannel* vie_channel = cs.Channel(video_channel);
|
||||
if (vie_channel == NULL) {
|
||||
WEBRTC_TRACE(kTraceError, kTraceVideo,
|
||||
ViEId(shared_data_->instance_id(), video_channel),
|
||||
"%s: No channel %d", __FUNCTION__, video_channel);
|
||||
shared_data_->SetLastError(kViEEncryptionInvalidChannelId);
|
||||
return -1;
|
||||
}
|
||||
if (vie_channel->RegisterExternalEncryption(&encryption) != 0) {
|
||||
shared_data_->SetLastError(kViEEncryptionUnknownError);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ViEEncryptionImpl::DeregisterExternalEncryption(const int video_channel) {
|
||||
WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
|
||||
ViEId(shared_data_->instance_id(), video_channel),
|
||||
"RegisterExternalEncryption(video_channel=%d)", video_channel);
|
||||
|
||||
ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
|
||||
ViEChannel* vie_channel = cs.Channel(video_channel);
|
||||
if (vie_channel == NULL) {
|
||||
WEBRTC_TRACE(kTraceError, kTraceVideo,
|
||||
ViEId(shared_data_->instance_id(), video_channel),
|
||||
"%s: No channel %d", __FUNCTION__, video_channel);
|
||||
shared_data_->SetLastError(kViEEncryptionInvalidChannelId);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (vie_channel->DeRegisterExternalEncryption() != 0) {
|
||||
shared_data_->SetLastError(kViEEncryptionUnknownError);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
@ -1,43 +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 WEBRTC_VIDEO_ENGINE_VIE_ENCRYPTION_IMPL_H_
|
||||
#define WEBRTC_VIDEO_ENGINE_VIE_ENCRYPTION_IMPL_H_
|
||||
|
||||
#include "webrtc/typedefs.h"
|
||||
#include "webrtc/video_engine/include/vie_encryption.h"
|
||||
#include "webrtc/video_engine/vie_ref_count.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class ViESharedData;
|
||||
|
||||
class ViEEncryptionImpl
|
||||
: public ViEEncryption,
|
||||
public ViERefCount {
|
||||
public:
|
||||
virtual int Release();
|
||||
|
||||
// Implements ViEEncryption.
|
||||
virtual int RegisterExternalEncryption(const int video_channel,
|
||||
Encryption& encryption);
|
||||
virtual int DeregisterExternalEncryption(const int video_channel);
|
||||
|
||||
protected:
|
||||
explicit ViEEncryptionImpl(ViESharedData* shared_data);
|
||||
virtual ~ViEEncryptionImpl();
|
||||
|
||||
private:
|
||||
ViESharedData* shared_data_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_VIDEO_ENGINE_VIE_ENCRYPTION_IMPL_H_
|
@ -63,19 +63,11 @@ bool VideoEngine::Delete(VideoEngine*& video_engine) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
#ifdef WEBRTC_VIDEO_ENGINE_ENCRYPTION_API
|
||||
ViEEncryptionImpl* vie_encryption = vie_impl;
|
||||
if (vie_encryption->GetCount() > 0) {
|
||||
WEBRTC_TRACE(kTraceError, kTraceVideo, kModuleId,
|
||||
"ViEEncryption ref count: %d", vie_encryption->GetCount());
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
#ifdef WEBRTC_VIDEO_ENGINE_EXTERNAL_CODEC_API
|
||||
ViEExternalCodecImpl* vie_external_codec = vie_impl;
|
||||
if (vie_external_codec->GetCount() > 0) {
|
||||
WEBRTC_TRACE(kTraceError, kTraceVideo, kModuleId,
|
||||
"ViEEncryption ref count: %d", vie_encryption->GetCount());
|
||||
"ViEExternalCodec ref count: %d", vie_external_codec->GetCount());
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
@ -24,9 +24,6 @@
|
||||
#ifdef WEBRTC_VIDEO_ENGINE_CODEC_API
|
||||
#include "webrtc/video_engine/vie_codec_impl.h"
|
||||
#endif
|
||||
#ifdef WEBRTC_VIDEO_ENGINE_ENCRYPTION_API
|
||||
#include "webrtc/video_engine/vie_encryption_impl.h"
|
||||
#endif
|
||||
#ifdef WEBRTC_VIDEO_ENGINE_FILE_API
|
||||
#include "webrtc/video_engine/vie_file_impl.h"
|
||||
#endif
|
||||
@ -54,9 +51,6 @@ class VideoEngineImpl
|
||||
#ifdef WEBRTC_VIDEO_ENGINE_CAPTURE_API
|
||||
public ViECaptureImpl,
|
||||
#endif
|
||||
#ifdef WEBRTC_VIDEO_ENGINE_ENCRYPTION_API
|
||||
public ViEEncryptionImpl,
|
||||
#endif
|
||||
#ifdef WEBRTC_VIDEO_ENGINE_FILE_API
|
||||
public ViEFileImpl,
|
||||
#endif
|
||||
@ -84,9 +78,6 @@ class VideoEngineImpl
|
||||
#ifdef WEBRTC_VIDEO_ENGINE_CAPTURE_API
|
||||
ViECaptureImpl(ViEBaseImpl::shared_data()),
|
||||
#endif
|
||||
#ifdef WEBRTC_VIDEO_ENGINE_ENCRYPTION_API
|
||||
ViEEncryptionImpl(ViEBaseImpl::shared_data()),
|
||||
#endif
|
||||
#ifdef WEBRTC_VIDEO_ENGINE_FILE_API
|
||||
ViEFileImpl(ViEBaseImpl::shared_data()),
|
||||
#endif
|
||||
|
@ -45,8 +45,6 @@ ViEReceiver::ViEReceiver(const int32_t channel_id,
|
||||
rtp_rtcp_(NULL),
|
||||
vcm_(module_vcm),
|
||||
remote_bitrate_estimator_(remote_bitrate_estimator),
|
||||
external_decryption_(NULL),
|
||||
decryption_buffer_(NULL),
|
||||
rtp_dump_(NULL),
|
||||
receiving_(false),
|
||||
restored_packet_in_use_(false) {
|
||||
@ -54,10 +52,6 @@ ViEReceiver::ViEReceiver(const int32_t channel_id,
|
||||
}
|
||||
|
||||
ViEReceiver::~ViEReceiver() {
|
||||
if (decryption_buffer_) {
|
||||
delete[] decryption_buffer_;
|
||||
decryption_buffer_ = NULL;
|
||||
}
|
||||
if (rtp_dump_) {
|
||||
rtp_dump_->Stop();
|
||||
RtpDump::DestroyRtpDump(rtp_dump_);
|
||||
@ -114,28 +108,6 @@ int ViEReceiver::GetCsrcs(uint32_t* csrcs) const {
|
||||
return rtp_receiver_->CSRCs(csrcs);
|
||||
}
|
||||
|
||||
int ViEReceiver::RegisterExternalDecryption(Encryption* decryption) {
|
||||
CriticalSectionScoped cs(receive_cs_.get());
|
||||
if (external_decryption_) {
|
||||
return -1;
|
||||
}
|
||||
decryption_buffer_ = new uint8_t[kViEMaxMtu];
|
||||
if (decryption_buffer_ == NULL) {
|
||||
return -1;
|
||||
}
|
||||
external_decryption_ = decryption;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ViEReceiver::DeregisterExternalDecryption() {
|
||||
CriticalSectionScoped cs(receive_cs_.get());
|
||||
if (external_decryption_ == NULL) {
|
||||
return -1;
|
||||
}
|
||||
external_decryption_ = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ViEReceiver::SetRtpRtcpModule(RtpRtcp* module) {
|
||||
rtp_rtcp_ = module;
|
||||
}
|
||||
@ -179,13 +151,13 @@ bool ViEReceiver::SetReceiveAbsoluteSendTimeStatus(bool enable, int id) {
|
||||
int ViEReceiver::ReceivedRTPPacket(const void* rtp_packet,
|
||||
int rtp_packet_length,
|
||||
const PacketTime& packet_time) {
|
||||
return InsertRTPPacket(static_cast<const int8_t*>(rtp_packet),
|
||||
return InsertRTPPacket(static_cast<const uint8_t*>(rtp_packet),
|
||||
rtp_packet_length, packet_time);
|
||||
}
|
||||
|
||||
int ViEReceiver::ReceivedRTCPPacket(const void* rtcp_packet,
|
||||
int rtcp_packet_length) {
|
||||
return InsertRTCPPacket(static_cast<const int8_t*>(rtcp_packet),
|
||||
return InsertRTCPPacket(static_cast<const uint8_t*>(rtcp_packet),
|
||||
rtcp_packet_length);
|
||||
}
|
||||
|
||||
@ -211,53 +183,28 @@ bool ViEReceiver::OnRecoveredPacket(const uint8_t* rtp_packet,
|
||||
return ReceivePacket(rtp_packet, rtp_packet_length, header, false);
|
||||
}
|
||||
|
||||
int ViEReceiver::InsertRTPPacket(const int8_t* rtp_packet,
|
||||
int ViEReceiver::InsertRTPPacket(const uint8_t* rtp_packet,
|
||||
int rtp_packet_length,
|
||||
const PacketTime& packet_time) {
|
||||
// TODO(mflodman) Change decrypt to get rid of this cast.
|
||||
int8_t* tmp_ptr = const_cast<int8_t*>(rtp_packet);
|
||||
unsigned char* received_packet = reinterpret_cast<unsigned char*>(tmp_ptr);
|
||||
int received_packet_length = rtp_packet_length;
|
||||
|
||||
{
|
||||
CriticalSectionScoped cs(receive_cs_.get());
|
||||
if (!receiving_) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (external_decryption_) {
|
||||
int decrypted_length = kViEMaxMtu;
|
||||
external_decryption_->decrypt(channel_id_, received_packet,
|
||||
decryption_buffer_, received_packet_length,
|
||||
&decrypted_length);
|
||||
if (decrypted_length <= 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, channel_id_,
|
||||
"RTP decryption failed");
|
||||
return -1;
|
||||
} else if (decrypted_length > kViEMaxMtu) {
|
||||
WEBRTC_TRACE(webrtc::kTraceCritical, webrtc::kTraceVideo, channel_id_,
|
||||
"InsertRTPPacket: %d bytes is allocated as RTP decrytption"
|
||||
" output, external decryption used %d bytes. => memory is "
|
||||
" now corrupted", kViEMaxMtu, decrypted_length);
|
||||
return -1;
|
||||
}
|
||||
received_packet = decryption_buffer_;
|
||||
received_packet_length = decrypted_length;
|
||||
}
|
||||
|
||||
if (rtp_dump_) {
|
||||
rtp_dump_->DumpPacket(received_packet,
|
||||
static_cast<uint16_t>(received_packet_length));
|
||||
rtp_dump_->DumpPacket(rtp_packet,
|
||||
static_cast<uint16_t>(rtp_packet_length));
|
||||
}
|
||||
}
|
||||
|
||||
RTPHeader header;
|
||||
if (!rtp_header_parser_->Parse(received_packet, received_packet_length,
|
||||
if (!rtp_header_parser_->Parse(rtp_packet, rtp_packet_length,
|
||||
&header)) {
|
||||
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceVideo, channel_id_,
|
||||
"Incoming packet: Invalid RTP header");
|
||||
return -1;
|
||||
}
|
||||
int payload_length = received_packet_length - header.headerLength;
|
||||
int payload_length = rtp_packet_length - header.headerLength;
|
||||
int64_t arrival_time_ms;
|
||||
if (packet_time.timestamp != -1)
|
||||
arrival_time_ms = (packet_time.timestamp + 500) / 1000;
|
||||
@ -270,12 +217,11 @@ int ViEReceiver::InsertRTPPacket(const int8_t* rtp_packet,
|
||||
|
||||
bool in_order = IsPacketInOrder(header);
|
||||
rtp_receive_statistics_->IncomingPacket(
|
||||
header, received_packet_length, IsPacketRetransmitted(header, in_order));
|
||||
header, rtp_packet_length, IsPacketRetransmitted(header, in_order));
|
||||
rtp_payload_registry_->SetIncomingPayloadType(header);
|
||||
return ReceivePacket(
|
||||
received_packet, received_packet_length, header, in_order)
|
||||
? 0
|
||||
: -1;
|
||||
return ReceivePacket(rtp_packet, rtp_packet_length, header, in_order)
|
||||
? 0
|
||||
: -1;
|
||||
}
|
||||
|
||||
bool ViEReceiver::ReceivePacket(const uint8_t* packet,
|
||||
@ -339,55 +285,27 @@ bool ViEReceiver::ParseAndHandleEncapsulatingHeader(const uint8_t* packet,
|
||||
return false;
|
||||
}
|
||||
|
||||
int ViEReceiver::InsertRTCPPacket(const int8_t* rtcp_packet,
|
||||
int ViEReceiver::InsertRTCPPacket(const uint8_t* rtcp_packet,
|
||||
int rtcp_packet_length) {
|
||||
// TODO(mflodman) Change decrypt to get rid of this cast.
|
||||
int8_t* tmp_ptr = const_cast<int8_t*>(rtcp_packet);
|
||||
unsigned char* received_packet = reinterpret_cast<unsigned char*>(tmp_ptr);
|
||||
int received_packet_length = rtcp_packet_length;
|
||||
{
|
||||
CriticalSectionScoped cs(receive_cs_.get());
|
||||
if (!receiving_) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (external_decryption_) {
|
||||
int decrypted_length = kViEMaxMtu;
|
||||
external_decryption_->decrypt_rtcp(channel_id_, received_packet,
|
||||
decryption_buffer_,
|
||||
received_packet_length,
|
||||
&decrypted_length);
|
||||
if (decrypted_length <= 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, channel_id_,
|
||||
"RTP decryption failed");
|
||||
return -1;
|
||||
} else if (decrypted_length > kViEMaxMtu) {
|
||||
WEBRTC_TRACE(webrtc::kTraceCritical, webrtc::kTraceVideo, channel_id_,
|
||||
"InsertRTCPPacket: %d bytes is allocated as RTP "
|
||||
" decrytption output, external decryption used %d bytes. "
|
||||
" => memory is now corrupted",
|
||||
kViEMaxMtu, decrypted_length);
|
||||
return -1;
|
||||
}
|
||||
received_packet = decryption_buffer_;
|
||||
received_packet_length = decrypted_length;
|
||||
}
|
||||
|
||||
if (rtp_dump_) {
|
||||
rtp_dump_->DumpPacket(
|
||||
received_packet, static_cast<uint16_t>(received_packet_length));
|
||||
rtcp_packet, static_cast<uint16_t>(rtcp_packet_length));
|
||||
}
|
||||
}
|
||||
{
|
||||
CriticalSectionScoped cs(receive_cs_.get());
|
||||
|
||||
std::list<RtpRtcp*>::iterator it = rtp_rtcp_simulcast_.begin();
|
||||
while (it != rtp_rtcp_simulcast_.end()) {
|
||||
RtpRtcp* rtp_rtcp = *it++;
|
||||
rtp_rtcp->IncomingRtcpPacket(received_packet, received_packet_length);
|
||||
rtp_rtcp->IncomingRtcpPacket(rtcp_packet, rtcp_packet_length);
|
||||
}
|
||||
}
|
||||
assert(rtp_rtcp_); // Should be set by owner at construction time.
|
||||
return rtp_rtcp_->IncomingRtcpPacket(received_packet, received_packet_length);
|
||||
return rtp_rtcp_->IncomingRtcpPacket(rtcp_packet, rtcp_packet_length);
|
||||
}
|
||||
|
||||
void ViEReceiver::StartReceive() {
|
||||
|
@ -24,7 +24,6 @@
|
||||
namespace webrtc {
|
||||
|
||||
class CriticalSectionWrapper;
|
||||
class Encryption;
|
||||
class FecReceiver;
|
||||
class ReceiveStatistics;
|
||||
class RemoteBitrateEstimator;
|
||||
@ -53,9 +52,6 @@ class ViEReceiver : public RtpData {
|
||||
uint32_t GetRemoteSsrc() const;
|
||||
int GetCsrcs(uint32_t* csrcs) const;
|
||||
|
||||
int RegisterExternalDecryption(Encryption* decryption);
|
||||
int DeregisterExternalDecryption();
|
||||
|
||||
void SetRtpRtcpModule(RtpRtcp* module);
|
||||
|
||||
RtpReceiver* GetRtpReceiver() const;
|
||||
@ -92,7 +88,7 @@ class ViEReceiver : public RtpData {
|
||||
ReceiveStatistics* GetReceiveStatistics() const;
|
||||
|
||||
private:
|
||||
int InsertRTPPacket(const int8_t* rtp_packet, int rtp_packet_length,
|
||||
int InsertRTPPacket(const uint8_t* rtp_packet, int rtp_packet_length,
|
||||
const PacketTime& packet_time);
|
||||
bool ReceivePacket(const uint8_t* packet,
|
||||
int packet_length,
|
||||
@ -103,7 +99,7 @@ class ViEReceiver : public RtpData {
|
||||
bool ParseAndHandleEncapsulatingHeader(const uint8_t* packet,
|
||||
int packet_length,
|
||||
const RTPHeader& header);
|
||||
int InsertRTCPPacket(const int8_t* rtcp_packet, int rtcp_packet_length);
|
||||
int InsertRTCPPacket(const uint8_t* rtcp_packet, int rtcp_packet_length);
|
||||
bool IsPacketInOrder(const RTPHeader& header) const;
|
||||
bool IsPacketRetransmitted(const RTPHeader& header, bool in_order) const;
|
||||
|
||||
@ -119,8 +115,6 @@ class ViEReceiver : public RtpData {
|
||||
VideoCodingModule* vcm_;
|
||||
RemoteBitrateEstimator* remote_bitrate_estimator_;
|
||||
|
||||
Encryption* external_decryption_;
|
||||
uint8_t* decryption_buffer_;
|
||||
RtpDump* rtp_dump_;
|
||||
bool receiving_;
|
||||
uint8_t restored_packet_[kViEMaxMtu];
|
||||
|
@ -21,18 +21,11 @@ namespace webrtc {
|
||||
ViESender::ViESender(int channel_id)
|
||||
: channel_id_(channel_id),
|
||||
critsect_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
external_encryption_(NULL),
|
||||
encryption_buffer_(NULL),
|
||||
transport_(NULL),
|
||||
rtp_dump_(NULL) {
|
||||
}
|
||||
|
||||
ViESender::~ViESender() {
|
||||
if (encryption_buffer_) {
|
||||
delete[] encryption_buffer_;
|
||||
encryption_buffer_ = NULL;
|
||||
}
|
||||
|
||||
if (rtp_dump_) {
|
||||
rtp_dump_->Stop();
|
||||
RtpDump::DestroyRtpDump(rtp_dump_);
|
||||
@ -40,32 +33,6 @@ ViESender::~ViESender() {
|
||||
}
|
||||
}
|
||||
|
||||
int ViESender::RegisterExternalEncryption(Encryption* encryption) {
|
||||
CriticalSectionScoped cs(critsect_.get());
|
||||
if (external_encryption_) {
|
||||
return -1;
|
||||
}
|
||||
encryption_buffer_ = new uint8_t[kViEMaxMtu];
|
||||
if (encryption_buffer_ == NULL) {
|
||||
return -1;
|
||||
}
|
||||
external_encryption_ = encryption;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ViESender::DeregisterExternalEncryption() {
|
||||
CriticalSectionScoped cs(critsect_.get());
|
||||
if (external_encryption_ == NULL) {
|
||||
return -1;
|
||||
}
|
||||
if (encryption_buffer_) {
|
||||
delete[] encryption_buffer_;
|
||||
encryption_buffer_ = NULL;
|
||||
}
|
||||
external_encryption_ = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ViESender::RegisterSendTransport(Transport* transport) {
|
||||
CriticalSectionScoped cs(critsect_.get());
|
||||
if (transport_) {
|
||||
@ -134,29 +101,13 @@ int ViESender::SendPacket(int vie_id, const void* data, int len) {
|
||||
}
|
||||
assert(ChannelId(vie_id) == channel_id_);
|
||||
|
||||
// TODO(mflodman) Change decrypt to get rid of this cast.
|
||||
void* tmp_ptr = const_cast<void*>(data);
|
||||
unsigned char* send_packet = static_cast<unsigned char*>(tmp_ptr);
|
||||
|
||||
// Data length for packets sent to possible encryption and to the transport.
|
||||
int send_packet_length = len;
|
||||
|
||||
if (rtp_dump_) {
|
||||
rtp_dump_->DumpPacket(send_packet, send_packet_length);
|
||||
rtp_dump_->DumpPacket(static_cast<const uint8_t*>(data),
|
||||
static_cast<uint16_t>(len));
|
||||
}
|
||||
|
||||
if (external_encryption_) {
|
||||
// Encryption buffer size.
|
||||
int encrypted_packet_length = kViEMaxMtu;
|
||||
|
||||
external_encryption_->encrypt(channel_id_, send_packet, encryption_buffer_,
|
||||
send_packet_length, &encrypted_packet_length);
|
||||
send_packet = encryption_buffer_;
|
||||
send_packet_length = encrypted_packet_length;
|
||||
}
|
||||
const int bytes_sent = transport_->SendPacket(channel_id_, send_packet,
|
||||
send_packet_length);
|
||||
if (bytes_sent != send_packet_length) {
|
||||
const int bytes_sent = transport_->SendPacket(channel_id_, data, len);
|
||||
if (bytes_sent != len) {
|
||||
WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceVideo, channel_id_,
|
||||
"ViESender::SendPacket - Transport failed to send RTP packet");
|
||||
}
|
||||
@ -165,43 +116,22 @@ int ViESender::SendPacket(int vie_id, const void* data, int len) {
|
||||
|
||||
int ViESender::SendRTCPPacket(int vie_id, const void* data, int len) {
|
||||
CriticalSectionScoped cs(critsect_.get());
|
||||
|
||||
if (!transport_) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
assert(ChannelId(vie_id) == channel_id_);
|
||||
|
||||
// Prepare for possible encryption and sending.
|
||||
// TODO(mflodman) Change decrypt to get rid of this cast.
|
||||
void* tmp_ptr = const_cast<void*>(data);
|
||||
unsigned char* send_packet = static_cast<unsigned char*>(tmp_ptr);
|
||||
|
||||
// Data length for packets sent to possible encryption and to the transport.
|
||||
int send_packet_length = len;
|
||||
|
||||
if (rtp_dump_) {
|
||||
rtp_dump_->DumpPacket(send_packet, send_packet_length);
|
||||
rtp_dump_->DumpPacket(static_cast<const uint8_t*>(data),
|
||||
static_cast<uint16_t>(len));
|
||||
}
|
||||
|
||||
if (external_encryption_) {
|
||||
// Encryption buffer size.
|
||||
int encrypted_packet_length = kViEMaxMtu;
|
||||
|
||||
external_encryption_->encrypt_rtcp(
|
||||
channel_id_, send_packet, encryption_buffer_, send_packet_length,
|
||||
&encrypted_packet_length);
|
||||
send_packet = encryption_buffer_;
|
||||
send_packet_length = encrypted_packet_length;
|
||||
}
|
||||
|
||||
const int bytes_sent = transport_->SendRTCPPacket(channel_id_, send_packet,
|
||||
send_packet_length);
|
||||
if (bytes_sent != send_packet_length) {
|
||||
const int bytes_sent = transport_->SendRTCPPacket(channel_id_, data, len);
|
||||
if (bytes_sent != len) {
|
||||
WEBRTC_TRACE(
|
||||
webrtc::kTraceWarning, webrtc::kTraceVideo, channel_id_,
|
||||
"ViESender::SendRTCPPacket - Transport failed to send RTCP packet"
|
||||
" (%d vs %d)", bytes_sent, send_packet_length);
|
||||
" (%d vs %d)", bytes_sent, len);
|
||||
}
|
||||
return bytes_sent;
|
||||
}
|
||||
|
@ -8,8 +8,7 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
// ViESender is responsible for encrypting, if enabled, packets and send to
|
||||
// network.
|
||||
// ViESender is responsible for sending packets to network.
|
||||
|
||||
#ifndef WEBRTC_VIDEO_ENGINE_VIE_SENDER_H_
|
||||
#define WEBRTC_VIDEO_ENGINE_VIE_SENDER_H_
|
||||
@ -32,10 +31,6 @@ class ViESender: public Transport {
|
||||
explicit ViESender(const int32_t channel_id);
|
||||
~ViESender();
|
||||
|
||||
// Registers an encryption class to use before sending packets.
|
||||
int RegisterExternalEncryption(Encryption* encryption);
|
||||
int DeregisterExternalEncryption();
|
||||
|
||||
// Registers transport to use for sending RTP and RTCP.
|
||||
int RegisterSendTransport(Transport* transport);
|
||||
int DeregisterSendTransport();
|
||||
@ -53,8 +48,6 @@ class ViESender: public Transport {
|
||||
|
||||
scoped_ptr<CriticalSectionWrapper> critsect_;
|
||||
|
||||
Encryption* external_encryption_;
|
||||
uint8_t* encryption_buffer_;
|
||||
Transport* transport_;
|
||||
RtpDump* rtp_dump_;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user