2013-05-16 12:08:03 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2013 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.
|
|
|
|
|
*/
|
2015-12-09 12:13:30 +01:00
|
|
|
#ifndef WEBRTC_TEST_DIRECT_TRANSPORT_H_
|
|
|
|
|
#define WEBRTC_TEST_DIRECT_TRANSPORT_H_
|
2013-05-16 12:08:03 +00:00
|
|
|
|
2013-08-05 12:01:36 +00:00
|
|
|
#include <assert.h>
|
|
|
|
|
|
2013-08-12 12:59:04 +00:00
|
|
|
#include <deque>
|
|
|
|
|
|
2016-11-28 07:02:13 -08:00
|
|
|
#include "webrtc/api/call/transport.h"
|
Reland of Don't hardcode MediaType::ANY in FakeNetworkPipe. (patchset #1 id:1 of https://codereview.webrtc.org/2784543002/ )
Reason for revert:
Intend to fix perf failures and reland.
Original issue's description:
> Revert of Don't hardcode MediaType::ANY in FakeNetworkPipe. (patchset #4 id:60001 of https://codereview.webrtc.org/2774463003/ )
>
> Reason for revert:
> Reverting since this seems to break multiple WebRTC Perf buildbots
>
> Original issue's description:
> > Don't hardcode MediaType::ANY in FakeNetworkPipe.
> >
> > Instead let each test set the appropriate media type. This simplifies
> > demuxing in Call and later in RtpTransportController.
> >
> > BUG=webrtc:7135
> >
> > Review-Url: https://codereview.webrtc.org/2774463003
> > Cr-Commit-Position: refs/heads/master@{#17418}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/9c47b00e24da2941eb095df5a4459c6d98a8a88d
>
> TBR=stefan@webrtc.org,deadbeef@webrtc.org,solenberg@webrtc.org,pbos@webrtc.org,sprang@webrtc.org,nisse@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:7135
>
> Review-Url: https://codereview.webrtc.org/2784543002
> Cr-Commit-Position: refs/heads/master@{#17427}
> Committed: https://chromium.googlesource.com/external/webrtc/+/3a3bd5061089da5327fc549337a8430054d66057
TBR=stefan@webrtc.org,deadbeef@webrtc.org,solenberg@webrtc.org,pbos@webrtc.org,sprang@webrtc.org,lliuu@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:7135
Review-Url: https://codereview.webrtc.org/2783853002
Cr-Commit-Position: refs/heads/master@{#17459}
2017-03-29 23:57:43 -07:00
|
|
|
#include "webrtc/call/call.h"
|
2017-07-06 19:44:34 +02:00
|
|
|
#include "webrtc/rtc_base/criticalsection.h"
|
|
|
|
|
#include "webrtc/rtc_base/event.h"
|
|
|
|
|
#include "webrtc/rtc_base/platform_thread.h"
|
2013-12-18 20:28:25 +00:00
|
|
|
#include "webrtc/test/fake_network_pipe.h"
|
2013-05-16 12:08:03 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
2013-08-12 12:59:04 +00:00
|
|
|
|
2013-11-18 11:45:11 +00:00
|
|
|
class Clock;
|
2013-08-12 12:59:04 +00:00
|
|
|
class PacketReceiver;
|
|
|
|
|
|
2013-05-16 12:08:03 +00:00
|
|
|
namespace test {
|
|
|
|
|
|
2015-09-28 09:59:31 -07:00
|
|
|
class DirectTransport : public Transport {
|
2013-05-16 12:08:03 +00:00
|
|
|
public:
|
2017-04-10 16:57:57 -07:00
|
|
|
DirectTransport(Call* send_call,
|
|
|
|
|
const std::map<uint8_t, MediaType>& payload_type_map);
|
|
|
|
|
DirectTransport(const FakeNetworkPipe::Config& config,
|
|
|
|
|
Call* send_call,
|
|
|
|
|
const std::map<uint8_t, MediaType>& payload_type_map);
|
|
|
|
|
DirectTransport(const FakeNetworkPipe::Config& config,
|
|
|
|
|
Call* send_call,
|
|
|
|
|
std::unique_ptr<Demuxer> demuxer);
|
|
|
|
|
|
|
|
|
|
// These deprecated variants always use ForceDemuxer.
|
|
|
|
|
RTC_DEPRECATED DirectTransport(Call* send_call, MediaType media_type)
|
|
|
|
|
: DirectTransport(
|
|
|
|
|
FakeNetworkPipe::Config(),
|
|
|
|
|
send_call,
|
|
|
|
|
std::unique_ptr<Demuxer>(new ForceDemuxer(media_type))) {}
|
|
|
|
|
RTC_DEPRECATED DirectTransport(const FakeNetworkPipe::Config& config,
|
|
|
|
|
Call* send_call,
|
|
|
|
|
MediaType media_type)
|
|
|
|
|
: DirectTransport(
|
|
|
|
|
config,
|
|
|
|
|
send_call,
|
|
|
|
|
std::unique_ptr<Demuxer>(new ForceDemuxer(media_type))) {}
|
|
|
|
|
|
Reland of Don't hardcode MediaType::ANY in FakeNetworkPipe. (patchset #1 id:1 of https://codereview.webrtc.org/2784543002/ )
Reason for revert:
Intend to fix perf failures and reland.
Original issue's description:
> Revert of Don't hardcode MediaType::ANY in FakeNetworkPipe. (patchset #4 id:60001 of https://codereview.webrtc.org/2774463003/ )
>
> Reason for revert:
> Reverting since this seems to break multiple WebRTC Perf buildbots
>
> Original issue's description:
> > Don't hardcode MediaType::ANY in FakeNetworkPipe.
> >
> > Instead let each test set the appropriate media type. This simplifies
> > demuxing in Call and later in RtpTransportController.
> >
> > BUG=webrtc:7135
> >
> > Review-Url: https://codereview.webrtc.org/2774463003
> > Cr-Commit-Position: refs/heads/master@{#17418}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/9c47b00e24da2941eb095df5a4459c6d98a8a88d
>
> TBR=stefan@webrtc.org,deadbeef@webrtc.org,solenberg@webrtc.org,pbos@webrtc.org,sprang@webrtc.org,nisse@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:7135
>
> Review-Url: https://codereview.webrtc.org/2784543002
> Cr-Commit-Position: refs/heads/master@{#17427}
> Committed: https://chromium.googlesource.com/external/webrtc/+/3a3bd5061089da5327fc549337a8430054d66057
TBR=stefan@webrtc.org,deadbeef@webrtc.org,solenberg@webrtc.org,pbos@webrtc.org,sprang@webrtc.org,lliuu@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:7135
Review-Url: https://codereview.webrtc.org/2783853002
Cr-Commit-Position: refs/heads/master@{#17459}
2017-03-29 23:57:43 -07:00
|
|
|
// These deprecated variants always use MediaType::VIDEO.
|
|
|
|
|
RTC_DEPRECATED explicit DirectTransport(Call* send_call)
|
2017-04-10 16:57:57 -07:00
|
|
|
: DirectTransport(
|
|
|
|
|
FakeNetworkPipe::Config(),
|
|
|
|
|
send_call,
|
|
|
|
|
std::unique_ptr<Demuxer>(new ForceDemuxer(MediaType::VIDEO))) {}
|
Reland of Don't hardcode MediaType::ANY in FakeNetworkPipe. (patchset #1 id:1 of https://codereview.webrtc.org/2784543002/ )
Reason for revert:
Intend to fix perf failures and reland.
Original issue's description:
> Revert of Don't hardcode MediaType::ANY in FakeNetworkPipe. (patchset #4 id:60001 of https://codereview.webrtc.org/2774463003/ )
>
> Reason for revert:
> Reverting since this seems to break multiple WebRTC Perf buildbots
>
> Original issue's description:
> > Don't hardcode MediaType::ANY in FakeNetworkPipe.
> >
> > Instead let each test set the appropriate media type. This simplifies
> > demuxing in Call and later in RtpTransportController.
> >
> > BUG=webrtc:7135
> >
> > Review-Url: https://codereview.webrtc.org/2774463003
> > Cr-Commit-Position: refs/heads/master@{#17418}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/9c47b00e24da2941eb095df5a4459c6d98a8a88d
>
> TBR=stefan@webrtc.org,deadbeef@webrtc.org,solenberg@webrtc.org,pbos@webrtc.org,sprang@webrtc.org,nisse@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:7135
>
> Review-Url: https://codereview.webrtc.org/2784543002
> Cr-Commit-Position: refs/heads/master@{#17427}
> Committed: https://chromium.googlesource.com/external/webrtc/+/3a3bd5061089da5327fc549337a8430054d66057
TBR=stefan@webrtc.org,deadbeef@webrtc.org,solenberg@webrtc.org,pbos@webrtc.org,sprang@webrtc.org,lliuu@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:7135
Review-Url: https://codereview.webrtc.org/2783853002
Cr-Commit-Position: refs/heads/master@{#17459}
2017-03-29 23:57:43 -07:00
|
|
|
|
|
|
|
|
RTC_DEPRECATED DirectTransport(const FakeNetworkPipe::Config& config,
|
|
|
|
|
Call* send_call)
|
2017-04-10 16:57:57 -07:00
|
|
|
: DirectTransport(
|
|
|
|
|
config,
|
|
|
|
|
send_call,
|
|
|
|
|
std::unique_ptr<Demuxer>(new ForceDemuxer(MediaType::VIDEO))) {}
|
Reland of Don't hardcode MediaType::ANY in FakeNetworkPipe. (patchset #1 id:1 of https://codereview.webrtc.org/2784543002/ )
Reason for revert:
Intend to fix perf failures and reland.
Original issue's description:
> Revert of Don't hardcode MediaType::ANY in FakeNetworkPipe. (patchset #4 id:60001 of https://codereview.webrtc.org/2774463003/ )
>
> Reason for revert:
> Reverting since this seems to break multiple WebRTC Perf buildbots
>
> Original issue's description:
> > Don't hardcode MediaType::ANY in FakeNetworkPipe.
> >
> > Instead let each test set the appropriate media type. This simplifies
> > demuxing in Call and later in RtpTransportController.
> >
> > BUG=webrtc:7135
> >
> > Review-Url: https://codereview.webrtc.org/2774463003
> > Cr-Commit-Position: refs/heads/master@{#17418}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/9c47b00e24da2941eb095df5a4459c6d98a8a88d
>
> TBR=stefan@webrtc.org,deadbeef@webrtc.org,solenberg@webrtc.org,pbos@webrtc.org,sprang@webrtc.org,nisse@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:7135
>
> Review-Url: https://codereview.webrtc.org/2784543002
> Cr-Commit-Position: refs/heads/master@{#17427}
> Committed: https://chromium.googlesource.com/external/webrtc/+/3a3bd5061089da5327fc549337a8430054d66057
TBR=stefan@webrtc.org,deadbeef@webrtc.org,solenberg@webrtc.org,pbos@webrtc.org,sprang@webrtc.org,lliuu@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:7135
Review-Url: https://codereview.webrtc.org/2783853002
Cr-Commit-Position: refs/heads/master@{#17459}
2017-03-29 23:57:43 -07:00
|
|
|
|
2013-08-12 12:59:04 +00:00
|
|
|
~DirectTransport();
|
2013-05-16 12:08:03 +00:00
|
|
|
|
2014-02-26 13:34:52 +00:00
|
|
|
void SetConfig(const FakeNetworkPipe::Config& config);
|
|
|
|
|
|
2013-08-12 12:59:04 +00:00
|
|
|
virtual void StopSending();
|
2015-10-27 08:29:42 -07:00
|
|
|
// TODO(holmer): Look into moving this to the constructor.
|
2013-08-23 09:19:30 +00:00
|
|
|
virtual void SetReceiver(PacketReceiver* receiver);
|
2013-05-16 12:08:03 +00:00
|
|
|
|
2015-10-02 03:39:33 -07:00
|
|
|
bool SendRtp(const uint8_t* data,
|
|
|
|
|
size_t length,
|
|
|
|
|
const PacketOptions& options) override;
|
2015-03-04 12:58:35 +00:00
|
|
|
bool SendRtcp(const uint8_t* data, size_t length) override;
|
2013-05-16 12:08:03 +00:00
|
|
|
|
2016-01-14 10:00:21 +01:00
|
|
|
int GetAverageDelayMs();
|
|
|
|
|
|
2013-05-16 12:08:03 +00:00
|
|
|
private:
|
2017-04-10 16:57:57 -07:00
|
|
|
// TODO(minyue): remove when the deprecated ctors of DirectTransport that
|
|
|
|
|
// create ForceDemuxer are removed.
|
|
|
|
|
class ForceDemuxer : public Demuxer {
|
|
|
|
|
public:
|
|
|
|
|
explicit ForceDemuxer(MediaType media_type);
|
|
|
|
|
void SetReceiver(PacketReceiver* receiver) override;
|
|
|
|
|
void DeliverPacket(const NetworkPacket* packet,
|
|
|
|
|
const PacketTime& packet_time) override;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
const MediaType media_type_;
|
|
|
|
|
PacketReceiver* packet_receiver_;
|
|
|
|
|
RTC_DISALLOW_COPY_AND_ASSIGN(ForceDemuxer);
|
|
|
|
|
};
|
|
|
|
|
|
2013-08-12 12:59:04 +00:00
|
|
|
static bool NetworkProcess(void* transport);
|
|
|
|
|
bool SendPackets();
|
|
|
|
|
|
2015-05-01 13:00:41 +02:00
|
|
|
rtc::CriticalSection lock_;
|
2015-10-27 08:29:42 -07:00
|
|
|
Call* const send_call_;
|
2015-12-10 13:02:50 +01:00
|
|
|
rtc::Event packet_event_;
|
2015-11-26 17:45:47 +01:00
|
|
|
rtc::PlatformThread thread_;
|
2014-04-28 13:00:21 +00:00
|
|
|
Clock* const clock_;
|
2013-08-12 12:59:04 +00:00
|
|
|
|
2013-08-12 14:28:00 +00:00
|
|
|
bool shutting_down_;
|
|
|
|
|
|
2013-12-18 20:28:25 +00:00
|
|
|
FakeNetworkPipe fake_network_;
|
2013-05-16 12:08:03 +00:00
|
|
|
};
|
2013-08-12 12:59:04 +00:00
|
|
|
} // namespace test
|
|
|
|
|
} // namespace webrtc
|
2013-05-16 12:08:03 +00:00
|
|
|
|
2015-12-09 12:13:30 +01:00
|
|
|
#endif // WEBRTC_TEST_DIRECT_TRANSPORT_H_
|