mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-23 03:10:04 +08:00
整理rtp相关代码
This commit is contained in:
parent
0045d405a5
commit
a69d7d0f71
@ -157,7 +157,11 @@ void SdpAttr::load(const string &sdp) {
|
||||
}
|
||||
}
|
||||
|
||||
SdpTrack::Ptr SdpAttr::getTrack(TrackType type) {
|
||||
bool SdpAttr::available() const {
|
||||
return getTrack(TrackAudio) || getTrack(TrackVideo);
|
||||
}
|
||||
|
||||
SdpTrack::Ptr SdpAttr::getTrack(TrackType type) const {
|
||||
for (auto &pr : _track_map){
|
||||
if(pr.second->_type == type){
|
||||
return pr.second;
|
||||
@ -218,24 +222,5 @@ static onceToken s_token([](){
|
||||
SdpAttr attr(str);
|
||||
track[0].inited=true;
|
||||
});
|
||||
bool MakeNalu(uint8_t in, NALU &nal) {
|
||||
nal.forbidden_zero_bit = in >> 7;
|
||||
if (nal.forbidden_zero_bit) {
|
||||
return false;
|
||||
}
|
||||
nal.nal_ref_idc = (in & 0x60) >> 5;
|
||||
nal.type = in & 0x1f;
|
||||
return true;
|
||||
}
|
||||
bool MakeFU(uint8_t in, FU &fu) {
|
||||
fu.S = in >> 7;
|
||||
fu.E = (in >> 6) & 0x01;
|
||||
fu.R = (in >> 5) & 0x01;
|
||||
fu.type = in & 0x1f;
|
||||
if (fu.R != 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -71,7 +71,8 @@ public:
|
||||
~SdpAttr(){}
|
||||
|
||||
void load(const string &sdp);
|
||||
SdpTrack::Ptr getTrack(TrackType type);
|
||||
SdpTrack::Ptr getTrack(TrackType type) const;
|
||||
bool available() const ;
|
||||
private:
|
||||
map<string,SdpTrack::Ptr> _track_map;
|
||||
};
|
||||
@ -218,21 +219,6 @@ private:
|
||||
mutable StrCaseMap _mapUrlArgs;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
unsigned forbidden_zero_bit :1;
|
||||
unsigned nal_ref_idc :2;
|
||||
unsigned type :5;
|
||||
} NALU;
|
||||
|
||||
typedef struct {
|
||||
unsigned S :1;
|
||||
unsigned E :1;
|
||||
unsigned R :1;
|
||||
unsigned type :5;
|
||||
} FU;
|
||||
|
||||
bool MakeNalu(uint8_t in, NALU &nal) ;
|
||||
bool MakeFU(uint8_t in, FU &fu) ;
|
||||
|
||||
|
||||
#endif //RTSP_RTSP_H_
|
||||
|
@ -28,6 +28,41 @@
|
||||
|
||||
namespace mediakit{
|
||||
|
||||
|
||||
typedef struct {
|
||||
unsigned forbidden_zero_bit :1;
|
||||
unsigned nal_ref_idc :2;
|
||||
unsigned type :5;
|
||||
} NALU;
|
||||
|
||||
typedef struct {
|
||||
unsigned S :1;
|
||||
unsigned E :1;
|
||||
unsigned R :1;
|
||||
unsigned type :5;
|
||||
} FU;
|
||||
|
||||
bool MakeNalu(uint8_t in, NALU &nal) {
|
||||
nal.forbidden_zero_bit = in >> 7;
|
||||
if (nal.forbidden_zero_bit) {
|
||||
return false;
|
||||
}
|
||||
nal.nal_ref_idc = (in & 0x60) >> 5;
|
||||
nal.type = in & 0x1f;
|
||||
return true;
|
||||
}
|
||||
bool MakeFU(uint8_t in, FU &fu) {
|
||||
fu.S = in >> 7;
|
||||
fu.E = (in >> 6) & 0x01;
|
||||
fu.R = (in >> 5) & 0x01;
|
||||
fu.type = in & 0x1f;
|
||||
if (fu.R != 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
H264RtpDecoder::H264RtpDecoder() {
|
||||
_h264frame = obtainFrame();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user