Adding test for relaying all simulcast streams to different receive channels.
BUG= Review URL: https://webrtc-codereview.appspot.com/776007 git-svn-id: http://webrtc.googlecode.com/svn/trunk@2726 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
deaf685b66
commit
e37ecc6f81
@ -126,7 +126,8 @@ void TestFullStack(const TbInterfaces& interfaces,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Configure External transport to simulate network interference:
|
// Configure External transport to simulate network interference:
|
||||||
TbExternalTransport external_transport(*interfaces.network);
|
TbExternalTransport external_transport(*interfaces.network, video_channel,
|
||||||
|
NULL);
|
||||||
external_transport.SetPacketLoss(packet_loss_percent);
|
external_transport.SetPacketLoss(packet_loss_percent);
|
||||||
external_transport.SetNetworkDelay(network_delay_ms);
|
external_transport.SetNetworkDelay(network_delay_ms);
|
||||||
|
|
||||||
|
@ -443,7 +443,7 @@ int VideoEngineSampleCode(void* window1, void* window2)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Setting External transport
|
// Setting External transport
|
||||||
TbExternalTransport extTransport(*(ptrViENetwork));
|
TbExternalTransport extTransport(*(ptrViENetwork), videoChannel, NULL);
|
||||||
|
|
||||||
int testMode = 0;
|
int testMode = 0;
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
@ -61,7 +61,8 @@ void ViEAutoTest::ViENetworkStandardTest()
|
|||||||
//
|
//
|
||||||
// Transport
|
// Transport
|
||||||
//
|
//
|
||||||
TbExternalTransport testTransport(*ViE.network);
|
TbExternalTransport testTransport(*ViE.network, tbChannel.videoChannel,
|
||||||
|
NULL);
|
||||||
EXPECT_EQ(0, ViE.network->RegisterSendTransport(
|
EXPECT_EQ(0, ViE.network->RegisterSendTransport(
|
||||||
tbChannel.videoChannel, testTransport));
|
tbChannel.videoChannel, testTransport));
|
||||||
EXPECT_EQ(0, ViE.base->StartReceive(tbChannel.videoChannel));
|
EXPECT_EQ(0, ViE.base->StartReceive(tbChannel.videoChannel));
|
||||||
@ -225,7 +226,8 @@ void ViEAutoTest::ViENetworkAPITest()
|
|||||||
//
|
//
|
||||||
// External transport
|
// External transport
|
||||||
//
|
//
|
||||||
TbExternalTransport testTransport(*ViE.network);
|
TbExternalTransport testTransport(*ViE.network, tbChannel.videoChannel,
|
||||||
|
NULL);
|
||||||
EXPECT_EQ(0, ViE.network->RegisterSendTransport(
|
EXPECT_EQ(0, ViE.network->RegisterSendTransport(
|
||||||
tbChannel.videoChannel, testTransport));
|
tbChannel.videoChannel, testTransport));
|
||||||
EXPECT_NE(0, ViE.network->RegisterSendTransport(
|
EXPECT_NE(0, ViE.network->RegisterSendTransport(
|
||||||
|
@ -354,7 +354,7 @@ int VideoEngineSampleRecordCode(void* window1, void* window2) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Setting External transport
|
// Setting External transport
|
||||||
TbExternalTransport extTransport(*(ptrViENetwork));
|
TbExternalTransport extTransport(*(ptrViENetwork), videoChannel, NULL);
|
||||||
error = ptrViENetwork->SetLocalReceiver(videoChannel, rtpPort);
|
error = ptrViENetwork->SetLocalReceiver(videoChannel, rtpPort);
|
||||||
if (error == -1) {
|
if (error == -1) {
|
||||||
printf("ERROR in ViENetwork::SetLocalReceiver\n");
|
printf("ERROR in ViENetwork::SetLocalReceiver\n");
|
||||||
|
@ -104,7 +104,8 @@ void ViEAutoTest::ViERtpRtcpStandardTest()
|
|||||||
tbCapture.ConnectTo(tbChannel.videoChannel);
|
tbCapture.ConnectTo(tbChannel.videoChannel);
|
||||||
|
|
||||||
ViETest::Log("\n");
|
ViETest::Log("\n");
|
||||||
TbExternalTransport myTransport(*(ViE.network));
|
TbExternalTransport myTransport(*(ViE.network), tbChannel.videoChannel,
|
||||||
|
NULL);
|
||||||
|
|
||||||
EXPECT_EQ(0, ViE.network->RegisterSendTransport(
|
EXPECT_EQ(0, ViE.network->RegisterSendTransport(
|
||||||
tbChannel.videoChannel, myTransport));
|
tbChannel.videoChannel, myTransport));
|
||||||
@ -375,7 +376,8 @@ void ViEAutoTest::ViERtpRtcpExtendedTest()
|
|||||||
|
|
||||||
//tbChannel.StartReceive(rtpPort);
|
//tbChannel.StartReceive(rtpPort);
|
||||||
//tbChannel.StartSend(rtpPort);
|
//tbChannel.StartSend(rtpPort);
|
||||||
TbExternalTransport myTransport(*(ViE.network));
|
TbExternalTransport myTransport(*(ViE.network), tbChannel.videoChannel,
|
||||||
|
NULL);
|
||||||
|
|
||||||
EXPECT_EQ(0, ViE.network->RegisterSendTransport(
|
EXPECT_EQ(0, ViE.network->RegisterSendTransport(
|
||||||
tbChannel.videoChannel, myTransport));
|
tbChannel.videoChannel, myTransport));
|
||||||
|
@ -22,9 +22,16 @@
|
|||||||
#include "vie_render.h"
|
#include "vie_render.h"
|
||||||
#include "vie_rtp_rtcp.h"
|
#include "vie_rtp_rtcp.h"
|
||||||
|
|
||||||
|
enum RelayMode {
|
||||||
|
kRelayOneStream = 1,
|
||||||
|
kRelayAllStreams = 2
|
||||||
|
};
|
||||||
|
|
||||||
#define VCM_RED_PAYLOAD_TYPE 96
|
#define VCM_RED_PAYLOAD_TYPE 96
|
||||||
#define VCM_ULPFEC_PAYLOAD_TYPE 97
|
#define VCM_ULPFEC_PAYLOAD_TYPE 97
|
||||||
|
|
||||||
|
const int kNumStreams = 3;
|
||||||
|
|
||||||
void InitialSingleStreamSettings(webrtc::VideoCodec* video_codec) {
|
void InitialSingleStreamSettings(webrtc::VideoCodec* video_codec) {
|
||||||
video_codec->numberOfSimulcastStreams = 0;
|
video_codec->numberOfSimulcastStreams = 0;
|
||||||
video_codec->width = 1200;
|
video_codec->width = 1200;
|
||||||
@ -35,7 +42,7 @@ void SetSimulcastSettings(webrtc::VideoCodec* video_codec) {
|
|||||||
video_codec->width = 1280;
|
video_codec->width = 1280;
|
||||||
video_codec->height = 720;
|
video_codec->height = 720;
|
||||||
// simulcast settings
|
// simulcast settings
|
||||||
video_codec->numberOfSimulcastStreams = 3;
|
video_codec->numberOfSimulcastStreams = kNumStreams;
|
||||||
video_codec->simulcastStream[0].width = 320;
|
video_codec->simulcastStream[0].width = 320;
|
||||||
video_codec->simulcastStream[0].height = 180;
|
video_codec->simulcastStream[0].height = 180;
|
||||||
video_codec->simulcastStream[0].numberOfTemporalLayers = 0;
|
video_codec->simulcastStream[0].numberOfTemporalLayers = 0;
|
||||||
@ -59,7 +66,7 @@ void RuntimeSingleStreamSettings(webrtc::VideoCodec* video_codec) {
|
|||||||
SetSimulcastSettings(video_codec);
|
SetSimulcastSettings(video_codec);
|
||||||
video_codec->width = 1200;
|
video_codec->width = 1200;
|
||||||
video_codec->height = 800;
|
video_codec->height = 800;
|
||||||
video_codec->numberOfSimulcastStreams = 3;
|
video_codec->numberOfSimulcastStreams = kNumStreams;
|
||||||
video_codec->simulcastStream[0].maxBitrate = 0;
|
video_codec->simulcastStream[0].maxBitrate = 0;
|
||||||
video_codec->simulcastStream[1].maxBitrate = 0;
|
video_codec->simulcastStream[1].maxBitrate = 0;
|
||||||
video_codec->simulcastStream[2].maxBitrate = 0;
|
video_codec->simulcastStream[2].maxBitrate = 0;
|
||||||
@ -72,6 +79,7 @@ int VideoEngineSimulcastTest(void* window1, void* window2)
|
|||||||
//********************************************************
|
//********************************************************
|
||||||
|
|
||||||
int error = 0;
|
int error = 0;
|
||||||
|
int receive_channels[kNumStreams];
|
||||||
|
|
||||||
//
|
//
|
||||||
// Create a VideoEngine instance
|
// Create a VideoEngine instance
|
||||||
@ -118,6 +126,17 @@ int VideoEngineSimulcastTest(void* window1, void* window2)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RelayMode relay_mode = kRelayOneStream;
|
||||||
|
printf("Select relay mode:\n");
|
||||||
|
printf("\t1. Relay one stream\n");
|
||||||
|
printf("\t2. Relay all streams\n");
|
||||||
|
if (scanf("%d", reinterpret_cast<int*>(&relay_mode)) != 1)
|
||||||
|
{
|
||||||
|
printf("Error in scanf()\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
getchar();
|
||||||
|
|
||||||
int videoChannel = -1;
|
int videoChannel = -1;
|
||||||
error = ptrViEBase->CreateChannel(videoChannel);
|
error = ptrViEBase->CreateChannel(videoChannel);
|
||||||
if (error == -1)
|
if (error == -1)
|
||||||
@ -126,6 +145,17 @@ int VideoEngineSimulcastTest(void* window1, void* window2)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < kNumStreams; ++i) {
|
||||||
|
receive_channels[i] = -1;
|
||||||
|
error = ptrViEBase->CreateReceiveChannel(receive_channels[i],
|
||||||
|
videoChannel);
|
||||||
|
if (error == -1)
|
||||||
|
{
|
||||||
|
printf("ERROR in ViEBase::CreateChannel\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// List available capture devices, allocate and connect.
|
// List available capture devices, allocate and connect.
|
||||||
//
|
//
|
||||||
@ -227,6 +257,13 @@ int VideoEngineSimulcastTest(void* window1, void* window2)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ptrViERtpRtcp->SetRembStatus(videoChannel, true, false);
|
||||||
|
if (error == -1)
|
||||||
|
{
|
||||||
|
printf("ERROR in ViERTP_RTCP::SetRTCPStatus\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
error = ptrViERtpRtcp->SetKeyFrameRequestMethod(
|
error = ptrViERtpRtcp->SetKeyFrameRequestMethod(
|
||||||
videoChannel, webrtc::kViEKeyFrameRequestPliRtcp);
|
videoChannel, webrtc::kViEKeyFrameRequestPliRtcp);
|
||||||
if (error == -1)
|
if (error == -1)
|
||||||
@ -235,6 +272,31 @@ int VideoEngineSimulcastTest(void* window1, void* window2)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < kNumStreams; ++i) {
|
||||||
|
error = ptrViERtpRtcp->SetRTCPStatus(receive_channels[i],
|
||||||
|
webrtc::kRtcpCompound_RFC4585);
|
||||||
|
if (error == -1)
|
||||||
|
{
|
||||||
|
printf("ERROR in ViERTP_RTCP::SetRTCPStatus\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ptrViERtpRtcp->SetRembStatus(receive_channels[i], false, true);
|
||||||
|
if (error == -1)
|
||||||
|
{
|
||||||
|
printf("ERROR in ViERTP_RTCP::SetRTCPStatus\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
error = ptrViERtpRtcp->SetKeyFrameRequestMethod(
|
||||||
|
receive_channels[i], webrtc::kViEKeyFrameRequestPliRtcp);
|
||||||
|
if (error == -1)
|
||||||
|
{
|
||||||
|
printf("ERROR in ViERTP_RTCP::SetKeyFrameRequestMethod\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Set up rendering
|
// Set up rendering
|
||||||
//
|
//
|
||||||
@ -260,15 +322,20 @@ int VideoEngineSimulcastTest(void* window1, void* window2)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
error = ptrViERender->AddRenderer(videoChannel, window2, 1, 0.0, 0.0, 1.0,
|
// Only rendering the thumbnail.
|
||||||
1.0);
|
int channel_to_render = videoChannel;
|
||||||
|
if (relay_mode == kRelayAllStreams) {
|
||||||
|
channel_to_render = receive_channels[0];
|
||||||
|
}
|
||||||
|
error = ptrViERender->AddRenderer(channel_to_render, window2, 1, 0.0,
|
||||||
|
0.0, 1.0, 1.0);
|
||||||
if (error == -1)
|
if (error == -1)
|
||||||
{
|
{
|
||||||
printf("ERROR in ViERender::AddRenderer\n");
|
printf("ERROR in ViERender::AddRenderer\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
error = ptrViERender->StartRender(videoChannel);
|
error = ptrViERender->StartRender(channel_to_render);
|
||||||
if (error == -1)
|
if (error == -1)
|
||||||
{
|
{
|
||||||
printf("ERROR in ViERender::StartRender\n");
|
printf("ERROR in ViERender::StartRender\n");
|
||||||
@ -303,11 +370,13 @@ int VideoEngineSimulcastTest(void* window1, void* window2)
|
|||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
error = ptrViECodec->SetReceiveCodec(videoChannel, videoCodec);
|
for (int i = 0; i < kNumStreams; ++i) {
|
||||||
if (error == -1)
|
error = ptrViECodec->SetReceiveCodec(receive_channels[i], videoCodec);
|
||||||
{
|
if (error == -1)
|
||||||
|
{
|
||||||
printf("ERROR in ViECodec::SetReceiveCodec\n");
|
printf("ERROR in ViECodec::SetReceiveCodec\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (videoCodec.codecType != webrtc::kVideoCodecRED
|
if (videoCodec.codecType != webrtc::kVideoCodecRED
|
||||||
&& videoCodec.codecType != webrtc::kVideoCodecULPFEC)
|
&& videoCodec.codecType != webrtc::kVideoCodecULPFEC)
|
||||||
@ -362,8 +431,31 @@ int VideoEngineSimulcastTest(void* window1, void* window2)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TbExternalTransport::SsrcChannelMap ssrc_channel_map;
|
||||||
|
for (int idx = 0; idx < num_streams; idx++)
|
||||||
|
{
|
||||||
|
error = ptrViERtpRtcp->SetLocalSSRC(
|
||||||
|
videoChannel,
|
||||||
|
idx+1, // SSRC
|
||||||
|
webrtc::kViEStreamTypeNormal,
|
||||||
|
idx);
|
||||||
|
ssrc_channel_map[idx + 1] = receive_channels[idx];
|
||||||
|
if (error == -1)
|
||||||
|
{
|
||||||
|
printf("ERROR in ViERTP_RTCP::SetLocalSSRC(idx:%d)\n",
|
||||||
|
idx);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TbExternalTransport::SsrcChannelMap* channel_map_ptr = &ssrc_channel_map;
|
||||||
|
if (relay_mode == kRelayOneStream) {
|
||||||
|
channel_map_ptr = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// Setting External transport
|
// Setting External transport
|
||||||
TbExternalTransport extTransport(*(ptrViENetwork));
|
TbExternalTransport extTransport(*(ptrViENetwork), videoChannel,
|
||||||
|
channel_map_ptr);
|
||||||
|
|
||||||
error = ptrViENetwork->RegisterSendTransport(videoChannel,
|
error = ptrViENetwork->RegisterSendTransport(videoChannel,
|
||||||
extTransport);
|
extTransport);
|
||||||
@ -373,32 +465,23 @@ int VideoEngineSimulcastTest(void* window1, void* window2)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < kNumStreams; ++i) {
|
||||||
|
error = ptrViENetwork->RegisterSendTransport(receive_channels[i],
|
||||||
|
extTransport);
|
||||||
|
if (error == -1)
|
||||||
|
{
|
||||||
|
printf("ERROR in ViECodec::RegisterSendTransport \n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
extTransport.SetPacketLoss(0);
|
extTransport.SetPacketLoss(0);
|
||||||
|
|
||||||
// Set network delay value
|
// Set network delay value
|
||||||
extTransport.SetNetworkDelay(10);
|
extTransport.SetNetworkDelay(10);
|
||||||
|
|
||||||
for (int idx = 0; idx < num_streams; idx++)
|
if (relay_mode == kRelayOneStream) {
|
||||||
{
|
extTransport.SetSSRCFilter(num_streams);
|
||||||
error = ptrViERtpRtcp->SetLocalSSRC(
|
|
||||||
videoChannel,
|
|
||||||
idx+1, // SSRC
|
|
||||||
webrtc::kViEStreamTypeNormal,
|
|
||||||
idx);
|
|
||||||
if (error == -1)
|
|
||||||
{
|
|
||||||
printf("ERROR in ViERTP_RTCP::SetLocalSSRC(idx:%d)\n",
|
|
||||||
idx);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
extTransport.SetSSRCFilter(num_streams);
|
|
||||||
|
|
||||||
error = ptrViEBase->StartReceive(videoChannel);
|
|
||||||
if (error == -1)
|
|
||||||
{
|
|
||||||
printf("ERROR in ViENetwork::StartReceive\n");
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
error = ptrViEBase->StartSend(videoChannel);
|
error = ptrViEBase->StartSend(videoChannel);
|
||||||
@ -407,6 +490,21 @@ int VideoEngineSimulcastTest(void* window1, void* window2)
|
|||||||
printf("ERROR in ViENetwork::StartSend\n");
|
printf("ERROR in ViENetwork::StartSend\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
error = ptrViEBase->StartReceive(videoChannel);
|
||||||
|
if (error == -1)
|
||||||
|
{
|
||||||
|
printf("ERROR in ViENetwork::StartReceive\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < kNumStreams; ++i) {
|
||||||
|
error = ptrViEBase->StartReceive(receive_channels[i]);
|
||||||
|
if (error == -1)
|
||||||
|
{
|
||||||
|
printf("ERROR in ViENetwork::StartReceive\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Create a receive channel to verify that it doesn't mess up toggling
|
// Create a receive channel to verify that it doesn't mess up toggling
|
||||||
// between single stream and simulcast.
|
// between single stream and simulcast.
|
||||||
@ -463,10 +561,14 @@ int VideoEngineSimulcastTest(void* window1, void* window2)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
extTransport.SetSSRCFilter(num_streams);
|
if (relay_mode == kRelayOneStream) {
|
||||||
|
extTransport.SetSSRCFilter(num_streams);
|
||||||
|
}
|
||||||
} else if (ssrc > 0 && ssrc < 4)
|
} else if (ssrc > 0 && ssrc < 4)
|
||||||
{
|
{
|
||||||
|
if (relay_mode == kRelayOneStream) {
|
||||||
extTransport.SetSSRCFilter(ssrc);
|
extTransport.SetSSRCFilter(ssrc);
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
printf("Invalid SSRC\n");
|
printf("Invalid SSRC\n");
|
||||||
@ -488,6 +590,15 @@ int VideoEngineSimulcastTest(void* window1, void* window2)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < kNumStreams; ++i) {
|
||||||
|
error = ptrViEBase->StopReceive(receive_channels[i]);
|
||||||
|
if (error == -1)
|
||||||
|
{
|
||||||
|
printf("ERROR in ViEBase::StopReceive\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
error = ptrViEBase->StopReceive(videoChannel);
|
error = ptrViEBase->StopReceive(videoChannel);
|
||||||
if (error == -1)
|
if (error == -1)
|
||||||
{
|
{
|
||||||
@ -516,14 +627,14 @@ int VideoEngineSimulcastTest(void* window1, void* window2)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
error = ptrViERender->StopRender(videoChannel);
|
error = ptrViERender->StopRender(channel_to_render);
|
||||||
if (error == -1)
|
if (error == -1)
|
||||||
{
|
{
|
||||||
printf("ERROR in ViERender::StopRender\n");
|
printf("ERROR in ViERender::StopRender\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
error = ptrViERender->RemoveRenderer(videoChannel);
|
error = ptrViERender->RemoveRenderer(channel_to_render);
|
||||||
if (error == -1)
|
if (error == -1)
|
||||||
{
|
{
|
||||||
printf("ERROR in ViERender::RemoveRenderer\n");
|
printf("ERROR in ViERender::RemoveRenderer\n");
|
||||||
@ -551,6 +662,15 @@ int VideoEngineSimulcastTest(void* window1, void* window2)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < kNumStreams; ++i) {
|
||||||
|
error = ptrViEBase->DeleteChannel(receive_channels[i]);
|
||||||
|
if (error == -1)
|
||||||
|
{
|
||||||
|
printf("ERROR in ViEBase::DeleteChannel\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
error = ptrViEBase->DeleteChannel(videoChannel);
|
error = ptrViEBase->DeleteChannel(videoChannel);
|
||||||
if (error == -1)
|
if (error == -1)
|
||||||
{
|
{
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#define WEBRTC_VIDEO_ENGINE_TEST_AUTOTEST_INTERFACE_TB_EXTERNAL_TRANSPORT_H_
|
#define WEBRTC_VIDEO_ENGINE_TEST_AUTOTEST_INTERFACE_TB_EXTERNAL_TRANSPORT_H_
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
#include "common_types.h"
|
#include "common_types.h"
|
||||||
|
|
||||||
@ -61,7 +62,11 @@ protected:
|
|||||||
class TbExternalTransport : public webrtc::Transport
|
class TbExternalTransport : public webrtc::Transport
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TbExternalTransport(webrtc::ViENetwork& vieNetwork);
|
typedef std::map<unsigned int, unsigned int> SsrcChannelMap;
|
||||||
|
|
||||||
|
TbExternalTransport(webrtc::ViENetwork& vieNetwork,
|
||||||
|
int sender_channel,
|
||||||
|
TbExternalTransport::SsrcChannelMap* receive_channels);
|
||||||
~TbExternalTransport(void);
|
~TbExternalTransport(void);
|
||||||
|
|
||||||
virtual int SendPacket(int channel, const void *data, int len);
|
virtual int SendPacket(int channel, const void *data, int len);
|
||||||
@ -115,6 +120,8 @@ private:
|
|||||||
WebRtc_Word64 receiveTime;
|
WebRtc_Word64 receiveTime;
|
||||||
} VideoPacket;
|
} VideoPacket;
|
||||||
|
|
||||||
|
int sender_channel_;
|
||||||
|
SsrcChannelMap* receive_channels_;
|
||||||
webrtc::ViENetwork& _vieNetwork;
|
webrtc::ViENetwork& _vieNetwork;
|
||||||
webrtc::ThreadWrapper& _thread;
|
webrtc::ThreadWrapper& _thread;
|
||||||
webrtc::EventWrapper& _event;
|
webrtc::EventWrapper& _event;
|
||||||
|
@ -31,39 +31,48 @@
|
|||||||
#pragma warning(disable: 4355) // 'this' : used in base member initializer list
|
#pragma warning(disable: 4355) // 'this' : used in base member initializer list
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
TbExternalTransport::TbExternalTransport(webrtc::ViENetwork& vieNetwork) :
|
const uint8_t kSenderReportPayloadType = 200;
|
||||||
_vieNetwork(vieNetwork),
|
const uint8_t kReceiverReportPayloadType = 201;
|
||||||
_thread(*webrtc::ThreadWrapper::CreateThread(
|
|
||||||
ViEExternalTransportRun, this, webrtc::kHighPriority,
|
TbExternalTransport::TbExternalTransport(
|
||||||
"AutotestTransport")),
|
webrtc::ViENetwork& vieNetwork,
|
||||||
_event(*webrtc::EventWrapper::Create()),
|
int sender_channel,
|
||||||
_crit(*webrtc::CriticalSectionWrapper::CreateCriticalSection()),
|
TbExternalTransport::SsrcChannelMap* receive_channels)
|
||||||
_statCrit(*webrtc::CriticalSectionWrapper::CreateCriticalSection()),
|
:
|
||||||
_lossRate(0),
|
sender_channel_(sender_channel),
|
||||||
_networkDelayMs(0),
|
receive_channels_(receive_channels),
|
||||||
_rtpCount(0),
|
_vieNetwork(vieNetwork),
|
||||||
_rtcpCount(0),
|
_thread(*webrtc::ThreadWrapper::CreateThread(
|
||||||
_dropCount(0),
|
ViEExternalTransportRun, this, webrtc::kHighPriority,
|
||||||
_rtpPackets(),
|
"AutotestTransport")),
|
||||||
_rtcpPackets(),
|
_event(*webrtc::EventWrapper::Create()),
|
||||||
_send_frame_callback(NULL),
|
_crit(*webrtc::CriticalSectionWrapper::CreateCriticalSection()),
|
||||||
_receive_frame_callback(NULL),
|
_statCrit(*webrtc::CriticalSectionWrapper::CreateCriticalSection()),
|
||||||
_temporalLayers(0),
|
_lossRate(0),
|
||||||
_seqNum(0),
|
_networkDelayMs(0),
|
||||||
_sendPID(0),
|
_rtpCount(0),
|
||||||
_receivedPID(0),
|
_rtcpCount(0),
|
||||||
_switchLayer(false),
|
_dropCount(0),
|
||||||
_currentRelayLayer(0),
|
_rtpPackets(),
|
||||||
_lastTimeMs(webrtc::TickTime::MillisecondTimestamp()),
|
_rtcpPackets(),
|
||||||
_checkSSRC(false),
|
_send_frame_callback(NULL),
|
||||||
_lastSSRC(0),
|
_receive_frame_callback(NULL),
|
||||||
_filterSSRC(false),
|
_temporalLayers(0),
|
||||||
_SSRC(0),
|
_seqNum(0),
|
||||||
_checkSequenceNumber(0),
|
_sendPID(0),
|
||||||
_firstSequenceNumber(0),
|
_receivedPID(0),
|
||||||
_firstRTPTimestamp(0),
|
_switchLayer(false),
|
||||||
_lastSendRTPTimestamp(0),
|
_currentRelayLayer(0),
|
||||||
_lastReceiveRTPTimestamp(0)
|
_lastTimeMs(webrtc::TickTime::MillisecondTimestamp()),
|
||||||
|
_checkSSRC(false),
|
||||||
|
_lastSSRC(0),
|
||||||
|
_filterSSRC(false),
|
||||||
|
_SSRC(0),
|
||||||
|
_checkSequenceNumber(0),
|
||||||
|
_firstSequenceNumber(0),
|
||||||
|
_firstRTPTimestamp(0),
|
||||||
|
_lastSendRTPTimestamp(0),
|
||||||
|
_lastReceiveRTPTimestamp(0)
|
||||||
{
|
{
|
||||||
srand((int) webrtc::TickTime::MicrosecondTimestamp());
|
srand((int) webrtc::TickTime::MicrosecondTimestamp());
|
||||||
unsigned int tId = 0;
|
unsigned int tId = 0;
|
||||||
@ -360,8 +369,13 @@ bool TbExternalTransport::ViEExternalTransportProcess()
|
|||||||
// Send to ViE
|
// Send to ViE
|
||||||
if (packet)
|
if (packet)
|
||||||
{
|
{
|
||||||
|
unsigned int ssrc = 0;
|
||||||
{
|
{
|
||||||
webrtc::CriticalSectionScoped cs(_statCrit);
|
webrtc::CriticalSectionScoped cs(_statCrit);
|
||||||
|
ssrc = ((packet->packetBuffer[8]) << 24);
|
||||||
|
ssrc += (packet->packetBuffer[9] << 16);
|
||||||
|
ssrc += (packet->packetBuffer[10] << 8);
|
||||||
|
ssrc += packet->packetBuffer[11];
|
||||||
if (_checkSSRC)
|
if (_checkSSRC)
|
||||||
{
|
{
|
||||||
_lastSSRC = ((packet->packetBuffer[8]) << 24);
|
_lastSSRC = ((packet->packetBuffer[8]) << 24);
|
||||||
@ -390,9 +404,17 @@ bool TbExternalTransport::ViEExternalTransportProcess()
|
|||||||
_receive_frame_callback->FrameReceived(rtp_timestamp);
|
_receive_frame_callback->FrameReceived(rtp_timestamp);
|
||||||
}
|
}
|
||||||
_lastReceiveRTPTimestamp = rtp_timestamp;
|
_lastReceiveRTPTimestamp = rtp_timestamp;
|
||||||
|
int destination_channel = sender_channel_;
|
||||||
_vieNetwork.ReceivedRTPPacket(packet->channel,
|
if (receive_channels_) {
|
||||||
packet->packetBuffer, packet->length);
|
SsrcChannelMap::iterator it = receive_channels_->find(ssrc);
|
||||||
|
if (it == receive_channels_->end()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
destination_channel = it->second;
|
||||||
|
}
|
||||||
|
_vieNetwork.ReceivedRTPPacket(destination_channel,
|
||||||
|
packet->packetBuffer,
|
||||||
|
packet->length);
|
||||||
delete packet;
|
delete packet;
|
||||||
packet = NULL;
|
packet = NULL;
|
||||||
}
|
}
|
||||||
@ -428,9 +450,27 @@ bool TbExternalTransport::ViEExternalTransportProcess()
|
|||||||
// Send to ViE
|
// Send to ViE
|
||||||
if (packet)
|
if (packet)
|
||||||
{
|
{
|
||||||
_vieNetwork.ReceivedRTCPPacket(
|
uint8_t pltype = static_cast<uint8_t>(packet->packetBuffer[1]);
|
||||||
packet->channel,
|
if (pltype == kSenderReportPayloadType) {
|
||||||
packet->packetBuffer, packet->length);
|
// Sender report.
|
||||||
|
if (receive_channels_) {
|
||||||
|
for (SsrcChannelMap::iterator it = receive_channels_->begin();
|
||||||
|
it != receive_channels_->end(); ++it) {
|
||||||
|
_vieNetwork.ReceivedRTCPPacket(it->second,
|
||||||
|
packet->packetBuffer,
|
||||||
|
packet->length);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_vieNetwork.ReceivedRTCPPacket(sender_channel_,
|
||||||
|
packet->packetBuffer,
|
||||||
|
packet->length);
|
||||||
|
}
|
||||||
|
} else if (pltype == kReceiverReportPayloadType) {
|
||||||
|
// Receiver report.
|
||||||
|
_vieNetwork.ReceivedRTCPPacket(sender_channel_,
|
||||||
|
packet->packetBuffer,
|
||||||
|
packet->length);
|
||||||
|
}
|
||||||
delete packet;
|
delete packet;
|
||||||
packet = NULL;
|
packet = NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user