ZLMediaKit/src/Rtsp/RtspSplitter.h

67 lines
1.6 KiB
C++
Raw Normal View History

2018-10-30 10:31:27 +08:00
/*
2020-04-04 20:30:09 +08:00
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
2018-10-30 10:31:27 +08:00
*
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
2018-10-30 10:31:27 +08:00
*
2020-04-04 20:30:09 +08:00
* 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.
2018-10-30 10:31:27 +08:00
*/
#ifndef ZLMEDIAKIT_RTSPSPLITTER_H
#define ZLMEDIAKIT_RTSPSPLITTER_H
2019-06-28 16:48:02 +08:00
#include "Common/Parser.h"
2018-10-30 10:31:27 +08:00
#include "Http/HttpRequestSplitter.h"
namespace mediakit{
class RtspSplitter : public HttpRequestSplitter{
public:
RtspSplitter(){}
virtual ~RtspSplitter(){}
2018-12-17 15:21:23 +08:00
/**
* rtp包
* @param enable
*/
void enableRecvRtp(bool enable);
2018-10-30 10:31:27 +08:00
protected:
/**
* rtsp包回调sdp等content数据
* @param parser rtsp包
*/
virtual void onWholeRtspPacket(Parser &parser) = 0;
/**
* rtp包回调
* @param data
* @param len
*/
virtual void onRtpPacket(const char *data,size_t len) = 0;
2018-10-30 10:31:27 +08:00
/**
2018-12-17 15:21:23 +08:00
* rtsp头中获取Content长度
* @param parser
* @return
2018-10-30 10:31:27 +08:00
*/
2021-01-19 16:05:38 +08:00
virtual ssize_t getContentLength(Parser &parser);
2018-10-30 10:31:27 +08:00
protected:
const char *onSearchPacketTail(const char *data,size_t len) override ;
const char *onSearchPacketTail_l(const char *data,size_t len) ;
2021-01-19 16:05:38 +08:00
ssize_t onRecvHeader(const char *data,size_t len) override;
void onRecvContent(const char *data,size_t len) override;
2018-10-30 10:31:27 +08:00
private:
bool _enableRecvRtp = false;
bool _isRtpPacket = false;
Parser _parser;
};
}//namespace mediakit
#endif //ZLMEDIAKIT_RTSPSPLITTER_H