2013-07-10 00:45:36 +00:00
|
|
|
/*
|
2016-02-07 20:46:45 -08:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2013-07-10 00:45:36 +00:00
|
|
|
*
|
2016-02-07 20:46:45 -08:00
|
|
|
* 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.
|
2013-07-10 00:45:36 +00:00
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef MEDIA_BASE_RTPDATAENGINE_H_
|
|
|
|
|
#define MEDIA_BASE_RTPDATAENGINE_H_
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2017-10-31 09:53:08 -07:00
|
|
|
#include <map>
|
2016-02-26 03:00:35 -08:00
|
|
|
#include <memory>
|
2013-07-10 00:45:36 +00:00
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "media/base/mediachannel.h"
|
|
|
|
|
#include "media/base/mediaconstants.h"
|
|
|
|
|
#include "media/base/mediaengine.h"
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
namespace cricket {
|
|
|
|
|
|
|
|
|
|
struct DataCodec;
|
|
|
|
|
|
|
|
|
|
class RtpDataEngine : public DataEngineInterface {
|
|
|
|
|
public:
|
|
|
|
|
RtpDataEngine();
|
|
|
|
|
|
2017-01-09 14:53:41 -08:00
|
|
|
virtual DataMediaChannel* CreateChannel(const MediaConfig& config);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
virtual const std::vector<DataCodec>& data_codecs() {
|
|
|
|
|
return data_codecs_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
std::vector<DataCodec> data_codecs_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 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:
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
RtpClock(int clockrate, uint16_t first_seq_num, uint32_t timestamp_offset)
|
2013-07-10 00:45:36 +00:00
|
|
|
: clockrate_(clockrate),
|
|
|
|
|
last_seq_num_(first_seq_num),
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
timestamp_offset_(timestamp_offset) {}
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
// Given the current time (in number of seconds which must be
|
|
|
|
|
// monotonically increasing), Return the next sequence number and
|
|
|
|
|
// timestamp.
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
void Tick(double now, int* seq_num, uint32_t* timestamp);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
int clockrate_;
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
uint16_t last_seq_num_;
|
|
|
|
|
uint32_t timestamp_offset_;
|
2013-07-10 00:45:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class RtpDataMediaChannel : public DataMediaChannel {
|
|
|
|
|
public:
|
2017-10-31 09:53:08 -07:00
|
|
|
explicit RtpDataMediaChannel(const MediaConfig& config);
|
2013-07-10 00:45:36 +00:00
|
|
|
virtual ~RtpDataMediaChannel();
|
|
|
|
|
|
2015-09-17 16:42:56 +02:00
|
|
|
virtual bool SetSendParameters(const DataSendParameters& params);
|
|
|
|
|
virtual bool SetRecvParameters(const DataRecvParameters& params);
|
2013-07-10 00:45:36 +00:00
|
|
|
virtual bool AddSendStream(const StreamParams& sp);
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
virtual bool RemoveSendStream(uint32_t ssrc);
|
2013-07-10 00:45:36 +00:00
|
|
|
virtual bool AddRecvStream(const StreamParams& sp);
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
virtual bool RemoveRecvStream(uint32_t ssrc);
|
2013-07-10 00:45:36 +00:00
|
|
|
virtual bool SetSend(bool send) {
|
|
|
|
|
sending_ = send;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
virtual bool SetReceive(bool receive) {
|
|
|
|
|
receiving_ = receive;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2016-03-20 06:15:43 -07:00
|
|
|
virtual void OnPacketReceived(rtc::CopyOnWriteBuffer* packet,
|
2014-07-29 17:36:52 +00:00
|
|
|
const rtc::PacketTime& packet_time);
|
2016-03-20 06:15:43 -07:00
|
|
|
virtual void OnRtcpReceived(rtc::CopyOnWriteBuffer* packet,
|
2014-07-29 17:36:52 +00:00
|
|
|
const rtc::PacketTime& packet_time) {}
|
2013-07-10 00:45:36 +00:00
|
|
|
virtual void OnReadyToSend(bool ready) {}
|
|
|
|
|
virtual bool SendData(
|
|
|
|
|
const SendDataParams& params,
|
2016-03-20 06:15:43 -07:00
|
|
|
const rtc::CopyOnWriteBuffer& payload,
|
2013-07-10 00:45:36 +00:00
|
|
|
SendDataResult* result);
|
2016-12-06 10:45:42 -08:00
|
|
|
virtual rtc::DiffServCodePoint PreferredDscp() const;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
private:
|
2016-09-13 23:41:47 -07:00
|
|
|
void Construct();
|
2015-09-17 16:42:56 +02:00
|
|
|
bool SetMaxSendBandwidth(int bps);
|
|
|
|
|
bool SetSendCodecs(const std::vector<DataCodec>& codecs);
|
|
|
|
|
bool SetRecvCodecs(const std::vector<DataCodec>& codecs);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
bool sending_;
|
|
|
|
|
bool receiving_;
|
|
|
|
|
std::vector<DataCodec> send_codecs_;
|
|
|
|
|
std::vector<DataCodec> recv_codecs_;
|
|
|
|
|
std::vector<StreamParams> send_streams_;
|
|
|
|
|
std::vector<StreamParams> recv_streams_;
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
std::map<uint32_t, RtpClock*> rtp_clock_by_send_ssrc_;
|
2016-02-26 03:00:35 -08:00
|
|
|
std::unique_ptr<rtc::RateLimiter> send_limiter_;
|
2013-07-10 00:45:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace cricket
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // MEDIA_BASE_RTPDATAENGINE_H_
|