2013-01-17 16:10:45 +00:00
|
|
|
/*
|
2013-02-04 13:23:07 +00:00
|
|
|
* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
|
2013-01-17 16:10:45 +00: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-16 19:25:04 +00:00
|
|
|
#ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_PAYLOAD_REGISTRY_H_
|
|
|
|
|
#define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_PAYLOAD_REGISTRY_H_
|
2013-01-17 16:10:45 +00:00
|
|
|
|
|
|
|
|
#include "webrtc/modules/rtp_rtcp/source/rtp_receiver_strategy.h"
|
|
|
|
|
#include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
|
2013-02-04 13:23:07 +00:00
|
|
|
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
|
2013-01-17 16:10:45 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
2013-02-04 13:23:07 +00:00
|
|
|
// This strategy deals with the audio/video-specific aspects
|
|
|
|
|
// of payload handling.
|
|
|
|
|
class RTPPayloadStrategy {
|
|
|
|
|
public:
|
2013-07-16 19:25:04 +00:00
|
|
|
virtual ~RTPPayloadStrategy() {};
|
2013-02-04 13:23:07 +00:00
|
|
|
|
|
|
|
|
virtual bool CodecsMustBeUnique() const = 0;
|
|
|
|
|
|
|
|
|
|
virtual bool PayloadIsCompatible(
|
|
|
|
|
const ModuleRTPUtility::Payload& payload,
|
2013-04-08 11:08:41 +00:00
|
|
|
const uint32_t frequency,
|
|
|
|
|
const uint8_t channels,
|
|
|
|
|
const uint32_t rate) const = 0;
|
2013-02-04 13:23:07 +00:00
|
|
|
|
|
|
|
|
virtual void UpdatePayloadRate(
|
|
|
|
|
ModuleRTPUtility::Payload* payload,
|
2013-04-08 11:08:41 +00:00
|
|
|
const uint32_t rate) const = 0;
|
2013-02-04 13:23:07 +00:00
|
|
|
|
|
|
|
|
virtual ModuleRTPUtility::Payload* CreatePayloadType(
|
|
|
|
|
const char payloadName[RTP_PAYLOAD_NAME_SIZE],
|
2013-04-08 11:08:41 +00:00
|
|
|
const int8_t payloadType,
|
|
|
|
|
const uint32_t frequency,
|
|
|
|
|
const uint8_t channels,
|
|
|
|
|
const uint32_t rate) const = 0;
|
2013-02-04 13:23:07 +00:00
|
|
|
|
|
|
|
|
static RTPPayloadStrategy* CreateStrategy(const bool handling_audio);
|
|
|
|
|
|
|
|
|
|
protected:
|
2013-07-16 19:25:04 +00:00
|
|
|
RTPPayloadStrategy() {};
|
2013-02-04 13:23:07 +00:00
|
|
|
};
|
|
|
|
|
|
2013-01-17 16:10:45 +00:00
|
|
|
class RTPPayloadRegistry {
|
|
|
|
|
public:
|
2013-02-04 13:23:07 +00:00
|
|
|
// The registry takes ownership of the strategy.
|
2013-04-08 11:08:41 +00:00
|
|
|
RTPPayloadRegistry(const int32_t id,
|
2013-02-04 13:23:07 +00:00
|
|
|
RTPPayloadStrategy* rtp_payload_strategy);
|
2013-01-17 16:10:45 +00:00
|
|
|
~RTPPayloadRegistry();
|
|
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
int32_t RegisterReceivePayload(
|
2013-01-17 16:10:45 +00:00
|
|
|
const char payload_name[RTP_PAYLOAD_NAME_SIZE],
|
2013-04-08 11:08:41 +00:00
|
|
|
const int8_t payload_type,
|
|
|
|
|
const uint32_t frequency,
|
|
|
|
|
const uint8_t channels,
|
|
|
|
|
const uint32_t rate,
|
2013-02-04 13:23:07 +00:00
|
|
|
bool* created_new_payload_type);
|
2013-01-17 16:10:45 +00:00
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
int32_t DeRegisterReceivePayload(
|
|
|
|
|
const int8_t payload_type);
|
2013-01-17 16:10:45 +00:00
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
int32_t ReceivePayloadType(
|
2013-01-17 16:10:45 +00:00
|
|
|
const char payload_name[RTP_PAYLOAD_NAME_SIZE],
|
2013-04-08 11:08:41 +00:00
|
|
|
const uint32_t frequency,
|
|
|
|
|
const uint8_t channels,
|
|
|
|
|
const uint32_t rate,
|
|
|
|
|
int8_t* payload_type) const;
|
2013-01-17 16:10:45 +00:00
|
|
|
|
2013-07-16 19:25:04 +00:00
|
|
|
int32_t PayloadTypeToPayload(
|
2013-04-08 11:08:41 +00:00
|
|
|
const uint8_t payload_type,
|
2013-01-17 16:10:45 +00:00
|
|
|
ModuleRTPUtility::Payload*& payload) const;
|
|
|
|
|
|
|
|
|
|
void ResetLastReceivedPayloadTypes() {
|
|
|
|
|
last_received_payload_type_ = -1;
|
|
|
|
|
last_received_media_payload_type_ = -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Returns true if the new media payload type has not changed.
|
2013-04-08 11:08:41 +00:00
|
|
|
bool ReportMediaPayloadType(uint8_t media_payload_type);
|
2013-01-17 16:10:45 +00:00
|
|
|
|
2013-04-08 11:08:41 +00:00
|
|
|
int8_t red_payload_type() const { return red_payload_type_; }
|
|
|
|
|
int8_t last_received_payload_type() const {
|
2013-01-17 16:10:45 +00:00
|
|
|
return last_received_payload_type_;
|
|
|
|
|
}
|
2013-04-08 11:08:41 +00:00
|
|
|
void set_last_received_payload_type(int8_t last_received_payload_type) {
|
2013-01-17 16:10:45 +00:00
|
|
|
last_received_payload_type_ = last_received_payload_type;
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-12 14:55:46 +00:00
|
|
|
int8_t last_received_media_payload_type() const {
|
|
|
|
|
return last_received_media_payload_type_;
|
|
|
|
|
};
|
|
|
|
|
|
2013-01-17 16:10:45 +00:00
|
|
|
private:
|
2013-02-04 13:23:07 +00:00
|
|
|
// Prunes the payload type map of the specific payload type, if it exists.
|
|
|
|
|
void DeregisterAudioCodecOrRedTypeRegardlessOfPayloadType(
|
|
|
|
|
const char payload_name[RTP_PAYLOAD_NAME_SIZE],
|
|
|
|
|
const size_t payload_name_length,
|
2013-04-08 11:08:41 +00:00
|
|
|
const uint32_t frequency,
|
|
|
|
|
const uint8_t channels,
|
|
|
|
|
const uint32_t rate);
|
2013-02-04 13:23:07 +00:00
|
|
|
|
2013-01-17 16:10:45 +00:00
|
|
|
ModuleRTPUtility::PayloadTypeMap payload_type_map_;
|
2013-04-08 11:08:41 +00:00
|
|
|
int32_t id_;
|
2013-02-04 13:23:07 +00:00
|
|
|
scoped_ptr<RTPPayloadStrategy> rtp_payload_strategy_;
|
2013-04-08 11:08:41 +00:00
|
|
|
int8_t red_payload_type_;
|
|
|
|
|
int8_t last_received_payload_type_;
|
|
|
|
|
int8_t last_received_media_payload_type_;
|
2013-01-17 16:10:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2013-07-16 19:25:04 +00:00
|
|
|
#endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_PAYLOAD_REGISTRY_H_
|