Reason for revert:
I'm really sorry for having to revert this but it seems this hit an unexpected compile error downstream:
webrtc/media/sctp/sctpdataengine.cc: In function 'void cricket::VerboseLogPacket(const void*, size_t, int)':
webrtc/media/sctp/sctpdataengine.cc:172:37: error: invalid conversion from 'const void*' to 'void*' [-fpermissive]
data, length, direction)) != NULL) {
^
In file included from webrtc/media/sctp/sctpdataengine.cc:20:0:
third_party/usrsctp/usrsctplib/usrsctp.h:964:1: error: initializing argument 1 of 'char* usrsctp_dumppacket(void*, size_t, int)' [-fpermissive]
usrsctp_dumppacket(void *, size_t, int);
^
I'm sure you can fix this easily and just re-land this CL, while I'm going to look into how to add this warning at the public bots (on Monday).
Original issue's description:
> Use CopyOnWriteBuffer instead of Buffer to avoid unnecessary copies.
>
> This CL removes copy and assign support from Buffer and changes various
> parameters from Buffer to CopyOnWriteBuffer so they can be passed along
> and copied without actually copying the underlying data.
>
> With this changed some parameters to be "const" and fixed an issue when
> creating a CopyOnWriteBuffer with empty data.
>
> BUG=webrtc:5155
>
> Committed: https://crrev.com/944c39006f1c52aee20919676002dac7a42b1c05
> Cr-Commit-Position: refs/heads/master@{#12058}
TBR=kwiberg@webrtc.org,tkchin@webrtc.org,tommi@webrtc.org,pthatcher@webrtc.org,jbauch@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:5155
Review URL: https://codereview.webrtc.org/1817753003
Cr-Commit-Position: refs/heads/master@{#12060}
126 lines
3.8 KiB
C++
126 lines
3.8 KiB
C++
/*
|
|
* 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_MEDIA_BASE_RTPDATAENGINE_H_
|
|
#define WEBRTC_MEDIA_BASE_RTPDATAENGINE_H_
|
|
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "webrtc/base/timing.h"
|
|
#include "webrtc/media/base/mediachannel.h"
|
|
#include "webrtc/media/base/mediaconstants.h"
|
|
#include "webrtc/media/base/mediaengine.h"
|
|
|
|
namespace cricket {
|
|
|
|
struct DataCodec;
|
|
|
|
class RtpDataEngine : public DataEngineInterface {
|
|
public:
|
|
RtpDataEngine();
|
|
|
|
virtual DataMediaChannel* CreateChannel(DataChannelType data_channel_type);
|
|
|
|
virtual const std::vector<DataCodec>& data_codecs() {
|
|
return data_codecs_;
|
|
}
|
|
|
|
// Mostly for testing with a fake clock. Ownership is passed in.
|
|
void SetTiming(rtc::Timing* timing) {
|
|
timing_.reset(timing);
|
|
}
|
|
|
|
private:
|
|
std::vector<DataCodec> data_codecs_;
|
|
std::unique_ptr<rtc::Timing> timing_;
|
|
};
|
|
|
|
// Keep track of sequence number and timestamp of an RTP stream. The
|
|
// sequence number starts with a "random" value and increments. The
|
|
// timestamp starts with a "random" value and increases monotonically
|
|
// according to the clockrate.
|
|
class RtpClock {
|
|
public:
|
|
RtpClock(int clockrate, uint16_t first_seq_num, uint32_t timestamp_offset)
|
|
: clockrate_(clockrate),
|
|
last_seq_num_(first_seq_num),
|
|
timestamp_offset_(timestamp_offset) {}
|
|
|
|
// Given the current time (in number of seconds which must be
|
|
// monotonically increasing), Return the next sequence number and
|
|
// timestamp.
|
|
void Tick(double now, int* seq_num, uint32_t* timestamp);
|
|
|
|
private:
|
|
int clockrate_;
|
|
uint16_t last_seq_num_;
|
|
uint32_t timestamp_offset_;
|
|
};
|
|
|
|
class RtpDataMediaChannel : public DataMediaChannel {
|
|
public:
|
|
// Timing* Used for the RtpClock
|
|
explicit RtpDataMediaChannel(rtc::Timing* timing);
|
|
// Sets Timing == NULL, so you'll need to call set_timer() before
|
|
// using it. This is needed by FakeMediaEngine.
|
|
RtpDataMediaChannel();
|
|
virtual ~RtpDataMediaChannel();
|
|
|
|
void set_timing(rtc::Timing* timing) {
|
|
timing_ = timing;
|
|
}
|
|
|
|
virtual bool SetSendParameters(const DataSendParameters& params);
|
|
virtual bool SetRecvParameters(const DataRecvParameters& params);
|
|
virtual bool AddSendStream(const StreamParams& sp);
|
|
virtual bool RemoveSendStream(uint32_t ssrc);
|
|
virtual bool AddRecvStream(const StreamParams& sp);
|
|
virtual bool RemoveRecvStream(uint32_t ssrc);
|
|
virtual bool SetSend(bool send) {
|
|
sending_ = send;
|
|
return true;
|
|
}
|
|
virtual bool SetReceive(bool receive) {
|
|
receiving_ = receive;
|
|
return true;
|
|
}
|
|
virtual void OnPacketReceived(rtc::Buffer* packet,
|
|
const rtc::PacketTime& packet_time);
|
|
virtual void OnRtcpReceived(rtc::Buffer* packet,
|
|
const rtc::PacketTime& packet_time) {}
|
|
virtual void OnReadyToSend(bool ready) {}
|
|
virtual bool SendData(
|
|
const SendDataParams& params,
|
|
const rtc::Buffer& payload,
|
|
SendDataResult* result);
|
|
|
|
private:
|
|
void Construct(rtc::Timing* timing);
|
|
bool SetMaxSendBandwidth(int bps);
|
|
bool SetSendCodecs(const std::vector<DataCodec>& codecs);
|
|
bool SetRecvCodecs(const std::vector<DataCodec>& codecs);
|
|
|
|
bool sending_;
|
|
bool receiving_;
|
|
rtc::Timing* timing_;
|
|
std::vector<DataCodec> send_codecs_;
|
|
std::vector<DataCodec> recv_codecs_;
|
|
std::vector<StreamParams> send_streams_;
|
|
std::vector<StreamParams> recv_streams_;
|
|
std::map<uint32_t, RtpClock*> rtp_clock_by_send_ssrc_;
|
|
std::unique_ptr<rtc::RateLimiter> send_limiter_;
|
|
};
|
|
|
|
} // namespace cricket
|
|
|
|
#endif // WEBRTC_MEDIA_BASE_RTPDATAENGINE_H_
|