2021-05-07 11:19:12 +08:00
|
|
|
|
/*
|
2021-05-06 16:25:18 +08:00
|
|
|
|
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by MIT license that can be found in the
|
|
|
|
|
* LICENSE file in the root of the source tree. All contributing project authors
|
|
|
|
|
* may be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef ZLMEDIAKIT_RTPEXT_H
|
|
|
|
|
#define ZLMEDIAKIT_RTPEXT_H
|
|
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <map>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include "Common/macros.h"
|
|
|
|
|
#include "Rtsp/Rtsp.h"
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
using namespace mediakit;
|
|
|
|
|
|
2021-05-07 12:00:26 +08:00
|
|
|
|
enum class RtpExtType : uint8_t {
|
|
|
|
|
padding = 0,
|
|
|
|
|
ssrc_audio_level = 1,
|
|
|
|
|
abs_send_time = 2,
|
|
|
|
|
transport_cc = 3,
|
|
|
|
|
sdes_mid = 4,
|
|
|
|
|
sdes_rtp_stream_id = 5,
|
|
|
|
|
sdes_repaired_rtp_stream_id = 6,
|
|
|
|
|
video_timing = 7,
|
|
|
|
|
color_space = 8,
|
2021-05-07 17:47:53 +08:00
|
|
|
|
//for firefox
|
|
|
|
|
csrc_audio_level = 9,
|
|
|
|
|
//svc ?
|
|
|
|
|
framemarking = 10,
|
2021-05-07 12:00:26 +08:00
|
|
|
|
video_content_type = 11,
|
|
|
|
|
playout_delay = 12,
|
|
|
|
|
video_orientation = 13,
|
|
|
|
|
toffset = 14,
|
|
|
|
|
reserved = 15,
|
2021-05-07 17:47:53 +08:00
|
|
|
|
// e2e ?
|
2021-05-07 18:33:45 +08:00
|
|
|
|
encrypt = reserved
|
2021-05-07 12:00:26 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class RtcMedia;
|
|
|
|
|
|
|
|
|
|
class RtpExt : public std::string {
|
2021-05-06 16:25:18 +08:00
|
|
|
|
public:
|
2021-05-07 18:33:45 +08:00
|
|
|
|
template<typename Type>
|
|
|
|
|
friend void appendExt(map<RtpExtType, RtpExt> &ret, const RtcMedia &media, uint8_t *ptr, const uint8_t *end);
|
|
|
|
|
|
2021-05-07 12:00:26 +08:00
|
|
|
|
~RtpExt() = default;
|
2021-05-07 14:56:01 +08:00
|
|
|
|
|
|
|
|
|
static map<RtpExtType/*type*/, RtpExt/*data*/> getExtValue(const RtpHeader *header, const RtcMedia &media);
|
2021-05-07 14:01:24 +08:00
|
|
|
|
static RtpExtType getExtType(const string &url);
|
|
|
|
|
static const string& getExtUrl(RtpExtType type);
|
2021-05-07 14:56:01 +08:00
|
|
|
|
static const char *getExtName(RtpExtType type);
|
2021-05-07 12:00:26 +08:00
|
|
|
|
|
2021-05-07 14:56:01 +08:00
|
|
|
|
string dumpString() const;
|
2021-05-07 12:00:26 +08:00
|
|
|
|
|
2021-05-07 17:47:53 +08:00
|
|
|
|
uint8_t getAudioLevel(bool *vad) const;
|
|
|
|
|
uint32_t getAbsSendTime() const;
|
|
|
|
|
uint16_t getTransportCCSeq() const;
|
|
|
|
|
const string& getSdesMid() const;
|
|
|
|
|
string getRtpStreamId() const;
|
|
|
|
|
string getRepairedRtpStreamId() const;
|
|
|
|
|
|
|
|
|
|
void getVideoTiming(uint8_t &flags,
|
|
|
|
|
uint16_t &encode_start,
|
|
|
|
|
uint16_t &encode_finish,
|
|
|
|
|
uint16_t &packetization_complete,
|
|
|
|
|
uint16_t &last_pkt_left_pacer,
|
|
|
|
|
uint16_t &reserved_net0,
|
|
|
|
|
uint16_t &reserved_net1) const;
|
|
|
|
|
|
|
|
|
|
uint8_t getVideoContentType() const;
|
|
|
|
|
|
|
|
|
|
void getVideoOrientation(bool &camera_bit,
|
|
|
|
|
bool &flip_bit,
|
|
|
|
|
bool &first_rotation,
|
|
|
|
|
bool &second_rotation) const;
|
|
|
|
|
|
|
|
|
|
void getPlayoutDelay(uint16_t &min_delay, uint16_t &max_delay) const;
|
|
|
|
|
|
|
|
|
|
uint32_t getTransmissionOffset() const;
|
|
|
|
|
|
|
|
|
|
uint8_t getFramemarkingTID() const;
|
|
|
|
|
|
2021-05-07 18:33:45 +08:00
|
|
|
|
//危险函数,必须保证关联的RtpHeader对象有效
|
|
|
|
|
void setExtId(uint8_t ext_id);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
RtpExt(void *ptr, bool one_byte_ext, RtpExtType type, const char *str, size_t size);
|
|
|
|
|
|
2021-05-07 12:00:26 +08:00
|
|
|
|
private:
|
2021-05-07 18:33:45 +08:00
|
|
|
|
void *_ptr = nullptr;
|
|
|
|
|
bool _one_byte_ext = true;
|
2021-05-07 12:00:26 +08:00
|
|
|
|
RtpExtType _type;
|
2021-05-06 16:25:18 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif //ZLMEDIAKIT_RTPEXT_H
|