Skip to content

Commit

Permalink
Remove RTP data implementation
Browse files Browse the repository at this point in the history
Bug: webrtc:6625
Change-Id: Ie68d7a938d8b7be95a01cca74a176104e4e44e1b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/215321
Reviewed-by: Henrik Boström <[email protected]>
Commit-Queue: Harald Alvestrand <[email protected]>
Cr-Commit-Position: refs/heads/master@{#33759}
  • Loading branch information
Harald Alvestrand authored and Commit Bot committed Apr 16, 2021
1 parent f981cb3 commit 7af57c6
Show file tree
Hide file tree
Showing 41 changed files with 87 additions and 3,487 deletions.
3 changes: 0 additions & 3 deletions media/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,6 @@ rtc_library("rtc_media_base") {
"base/media_engine.h",
"base/rid_description.cc",
"base/rid_description.h",
"base/rtp_data_engine.cc",
"base/rtp_data_engine.h",
"base/rtp_utils.cc",
"base/rtp_utils.h",
"base/stream_params.cc",
Expand Down Expand Up @@ -628,7 +626,6 @@ if (rtc_include_tests) {
sources = [
"base/codec_unittest.cc",
"base/media_engine_unittest.cc",
"base/rtp_data_engine_unittest.cc",
"base/rtp_utils_unittest.cc",
"base/sdp_fmtp_utils_unittest.cc",
"base/stream_params_unittest.cc",
Expand Down
105 changes: 0 additions & 105 deletions media/base/fake_media_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -422,93 +422,6 @@ void FakeVideoMediaChannel::ClearRecordableEncodedFrameCallback(uint32_t ssrc) {

void FakeVideoMediaChannel::GenerateKeyFrame(uint32_t ssrc) {}

FakeDataMediaChannel::FakeDataMediaChannel(void* unused,
const DataOptions& options)
: send_blocked_(false), max_bps_(-1) {}
FakeDataMediaChannel::~FakeDataMediaChannel() {}
const std::vector<DataCodec>& FakeDataMediaChannel::recv_codecs() const {
return recv_codecs_;
}
const std::vector<DataCodec>& FakeDataMediaChannel::send_codecs() const {
return send_codecs_;
}
const std::vector<DataCodec>& FakeDataMediaChannel::codecs() const {
return send_codecs();
}
int FakeDataMediaChannel::max_bps() const {
return max_bps_;
}
bool FakeDataMediaChannel::SetSendParameters(const DataSendParameters& params) {
set_send_rtcp_parameters(params.rtcp);
return (SetSendCodecs(params.codecs) &&
SetMaxSendBandwidth(params.max_bandwidth_bps));
}
bool FakeDataMediaChannel::SetRecvParameters(const DataRecvParameters& params) {
set_recv_rtcp_parameters(params.rtcp);
return SetRecvCodecs(params.codecs);
}
bool FakeDataMediaChannel::SetSend(bool send) {
return set_sending(send);
}
bool FakeDataMediaChannel::SetReceive(bool receive) {
set_playout(receive);
return true;
}
bool FakeDataMediaChannel::AddRecvStream(const StreamParams& sp) {
if (!RtpHelper<DataMediaChannel>::AddRecvStream(sp))
return false;
return true;
}
bool FakeDataMediaChannel::RemoveRecvStream(uint32_t ssrc) {
if (!RtpHelper<DataMediaChannel>::RemoveRecvStream(ssrc))
return false;
return true;
}
bool FakeDataMediaChannel::SendData(const SendDataParams& params,
const rtc::CopyOnWriteBuffer& payload,
SendDataResult* result) {
if (send_blocked_) {
*result = SDR_BLOCK;
return false;
} else {
last_sent_data_params_ = params;
last_sent_data_ = std::string(payload.data<char>(), payload.size());
return true;
}
}
SendDataParams FakeDataMediaChannel::last_sent_data_params() {
return last_sent_data_params_;
}
std::string FakeDataMediaChannel::last_sent_data() {
return last_sent_data_;
}
bool FakeDataMediaChannel::is_send_blocked() {
return send_blocked_;
}
void FakeDataMediaChannel::set_send_blocked(bool blocked) {
send_blocked_ = blocked;
}
bool FakeDataMediaChannel::SetRecvCodecs(const std::vector<DataCodec>& codecs) {
if (fail_set_recv_codecs()) {
// Fake the failure in SetRecvCodecs.
return false;
}
recv_codecs_ = codecs;
return true;
}
bool FakeDataMediaChannel::SetSendCodecs(const std::vector<DataCodec>& codecs) {
if (fail_set_send_codecs()) {
// Fake the failure in SetSendCodecs.
return false;
}
send_codecs_ = codecs;
return true;
}
bool FakeDataMediaChannel::SetMaxSendBandwidth(int bps) {
max_bps_ = bps;
return true;
}

FakeVoiceEngine::FakeVoiceEngine() : fail_create_channel_(false) {
// Add a fake audio codec. Note that the name must not be "" as there are
// sanity checks against that.
Expand Down Expand Up @@ -668,22 +581,4 @@ void FakeMediaEngine::set_fail_create_channel(bool fail) {
video_->fail_create_channel_ = fail;
}

DataMediaChannel* FakeDataEngine::CreateChannel(const MediaConfig& config) {
FakeDataMediaChannel* ch = new FakeDataMediaChannel(this, DataOptions());
channels_.push_back(ch);
return ch;
}
FakeDataMediaChannel* FakeDataEngine::GetChannel(size_t index) {
return (channels_.size() > index) ? channels_[index] : NULL;
}
void FakeDataEngine::UnregisterChannel(DataMediaChannel* channel) {
channels_.erase(absl::c_find(channels_, channel));
}
void FakeDataEngine::SetDataCodecs(const std::vector<DataCodec>& data_codecs) {
data_codecs_ = data_codecs;
}
const std::vector<DataCodec>& FakeDataEngine::data_codecs() {
return data_codecs_;
}

} // namespace cricket
61 changes: 0 additions & 61 deletions media/base/fake_media_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -472,48 +472,6 @@ class FakeVideoMediaChannel : public RtpHelper<VideoMediaChannel> {
int max_bps_;
};

// Dummy option class, needed for the DataTraits abstraction in
// channel_unittest.c.
class DataOptions {};

class FakeDataMediaChannel : public RtpHelper<DataMediaChannel> {
public:
explicit FakeDataMediaChannel(void* unused, const DataOptions& options);
~FakeDataMediaChannel();
const std::vector<DataCodec>& recv_codecs() const;
const std::vector<DataCodec>& send_codecs() const;
const std::vector<DataCodec>& codecs() const;
int max_bps() const;

bool SetSendParameters(const DataSendParameters& params) override;
bool SetRecvParameters(const DataRecvParameters& params) override;
bool SetSend(bool send) override;
bool SetReceive(bool receive) override;
bool AddRecvStream(const StreamParams& sp) override;
bool RemoveRecvStream(uint32_t ssrc) override;

bool SendData(const SendDataParams& params,
const rtc::CopyOnWriteBuffer& payload,
SendDataResult* result) override;

SendDataParams last_sent_data_params();
std::string last_sent_data();
bool is_send_blocked();
void set_send_blocked(bool blocked);

private:
bool SetRecvCodecs(const std::vector<DataCodec>& codecs);
bool SetSendCodecs(const std::vector<DataCodec>& codecs);
bool SetMaxSendBandwidth(int bps);

std::vector<DataCodec> recv_codecs_;
std::vector<DataCodec> send_codecs_;
SendDataParams last_sent_data_params_;
std::string last_sent_data_;
bool send_blocked_;
int max_bps_;
};

class FakeVoiceEngine : public VoiceEngineInterface {
public:
FakeVoiceEngine();
Expand Down Expand Up @@ -609,25 +567,6 @@ class FakeMediaEngine : public CompositeMediaEngine {
FakeVideoEngine* const video_;
};

// Have to come afterwards due to declaration order

class FakeDataEngine : public DataEngineInterface {
public:
DataMediaChannel* CreateChannel(const MediaConfig& config) override;

FakeDataMediaChannel* GetChannel(size_t index);

void UnregisterChannel(DataMediaChannel* channel);

void SetDataCodecs(const std::vector<DataCodec>& data_codecs);

const std::vector<DataCodec>& data_codecs() override;

private:
std::vector<FakeDataMediaChannel*> channels_;
std::vector<DataCodec> data_codecs_;
};

} // namespace cricket

#endif // MEDIA_BASE_FAKE_MEDIA_ENGINE_H_
13 changes: 3 additions & 10 deletions media/base/media_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -955,11 +955,8 @@ enum DataMessageType {
// signal fires, on up the chain.
struct ReceiveDataParams {
// The in-packet stream indentifier.
// RTP data channels use SSRCs, SCTP data channels use SIDs.
union {
uint32_t ssrc;
int sid = 0;
};
// SCTP data channels use SIDs.
int sid = 0;
// The type of message (binary, text, or control).
DataMessageType type = DMT_TEXT;
// A per-stream value incremented per packet in the stream.
Expand All @@ -970,11 +967,7 @@ struct ReceiveDataParams {

struct SendDataParams {
// The in-packet stream indentifier.
// RTP data channels use SSRCs, SCTP data channels use SIDs.
union {
uint32_t ssrc;
int sid = 0;
};
int sid = 0;
// The type of message (binary, text, or control).
DataMessageType type = DMT_TEXT;

Expand Down
8 changes: 0 additions & 8 deletions media/base/media_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,17 +158,9 @@ class CompositeMediaEngine : public MediaEngineInterface {

enum DataChannelType {
DCT_NONE = 0,
DCT_RTP = 1,
DCT_SCTP = 2,
};

class DataEngineInterface {
public:
virtual ~DataEngineInterface() {}
virtual DataMediaChannel* CreateChannel(const MediaConfig& config) = 0;
virtual const std::vector<DataCodec>& data_codecs() = 0;
};

webrtc::RtpParameters CreateRtpParametersWithOneEncoding();
webrtc::RtpParameters CreateRtpParametersWithEncodings(StreamParams sp);

Expand Down
Loading

0 comments on commit 7af57c6

Please sign in to comment.