2015-02-06 13:10:19 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2015 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef VIDEO_PAYLOAD_ROUTER_H_
|
|
|
|
|
#define VIDEO_PAYLOAD_ROUTER_H_
|
2015-02-06 13:10:19 +00:00
|
|
|
|
2017-10-06 10:04:04 +02:00
|
|
|
#include <map>
|
2015-02-06 13:10:19 +00:00
|
|
|
#include <vector>
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "api/video_codecs/video_encoder.h"
|
2017-09-15 13:58:09 +02:00
|
|
|
#include "common_types.h" // NOLINT(build/include)
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "rtc_base/constructormagic.h"
|
|
|
|
|
#include "rtc_base/criticalsection.h"
|
|
|
|
|
#include "rtc_base/thread_annotations.h"
|
2015-02-06 13:10:19 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
class RTPFragmentationHeader;
|
|
|
|
|
class RtpRtcp;
|
|
|
|
|
struct RTPVideoHeader;
|
|
|
|
|
|
|
|
|
|
// PayloadRouter routes outgoing data to the correct sending RTP module, based
|
|
|
|
|
// on the simulcast layer in RTPVideoHeader.
|
2016-04-20 05:05:54 -07:00
|
|
|
class PayloadRouter : public EncodedImageCallback {
|
2015-02-06 13:10:19 +00:00
|
|
|
public:
|
2016-04-15 14:59:13 +02:00
|
|
|
// Rtp modules are assumed to be sorted in simulcast index order.
|
2016-08-02 17:46:41 -07:00
|
|
|
PayloadRouter(const std::vector<RtpRtcp*>& rtp_modules,
|
2017-10-06 10:04:04 +02:00
|
|
|
const std::vector<uint32_t>& ssrcs,
|
|
|
|
|
int payload_type,
|
|
|
|
|
const std::map<uint32_t, RtpPayloadState>& states);
|
2015-02-06 13:10:19 +00:00
|
|
|
~PayloadRouter();
|
|
|
|
|
|
|
|
|
|
// PayloadRouter will only route packets if being active, all packets will be
|
|
|
|
|
// dropped otherwise.
|
2016-12-01 06:34:11 -08:00
|
|
|
void SetActive(bool active);
|
|
|
|
|
bool IsActive();
|
2015-02-06 13:10:19 +00:00
|
|
|
|
2017-10-06 10:04:04 +02:00
|
|
|
std::map<uint32_t, RtpPayloadState> GetRtpPayloadStates() const;
|
|
|
|
|
|
2016-04-20 05:05:54 -07:00
|
|
|
// Implements EncodedImageCallback.
|
|
|
|
|
// Returns 0 if the packet was routed / sent, -1 otherwise.
|
2016-08-02 17:46:41 -07:00
|
|
|
EncodedImageCallback::Result OnEncodedImage(
|
|
|
|
|
const EncodedImage& encoded_image,
|
|
|
|
|
const CodecSpecificInfo* codec_specific_info,
|
|
|
|
|
const RTPFragmentationHeader* fragmentation) override;
|
2015-02-06 13:10:19 +00:00
|
|
|
|
2016-12-01 06:34:11 -08:00
|
|
|
void OnBitrateAllocationUpdated(const BitrateAllocation& bitrate);
|
|
|
|
|
|
2015-02-06 13:10:19 +00:00
|
|
|
private:
|
2017-10-06 10:04:04 +02:00
|
|
|
class RtpPayloadParams;
|
|
|
|
|
|
2017-09-09 04:17:22 -07:00
|
|
|
void UpdateModuleSendingState() RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_);
|
2015-02-06 13:10:19 +00:00
|
|
|
|
2016-02-26 16:31:37 +01:00
|
|
|
rtc::CriticalSection crit_;
|
2017-09-09 04:17:22 -07:00
|
|
|
bool active_ RTC_GUARDED_BY(crit_);
|
2015-02-20 12:45:40 +00:00
|
|
|
|
2016-04-15 14:59:13 +02:00
|
|
|
// Rtp modules are assumed to be sorted in simulcast index order. Not owned.
|
|
|
|
|
const std::vector<RtpRtcp*> rtp_modules_;
|
2016-04-20 05:05:54 -07:00
|
|
|
const int payload_type_;
|
2016-04-15 14:59:13 +02:00
|
|
|
|
2017-10-06 10:04:04 +02:00
|
|
|
const bool forced_fallback_enabled_;
|
|
|
|
|
std::vector<RtpPayloadParams> params_ RTC_GUARDED_BY(crit_);
|
|
|
|
|
|
2015-09-16 05:37:44 -07:00
|
|
|
RTC_DISALLOW_COPY_AND_ASSIGN(PayloadRouter);
|
2015-02-06 13:10:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // VIDEO_PAYLOAD_ROUTER_H_
|