ZLMediaKit/src/Rtsp/RtspSplitter.h
2021-01-17 18:31:50 +08:00

67 lines
1.6 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* 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_RTSPSPLITTER_H
#define ZLMEDIAKIT_RTSPSPLITTER_H
#include "Common/Parser.h"
#include "Http/HttpRequestSplitter.h"
namespace mediakit{
class RtspSplitter : public HttpRequestSplitter{
public:
RtspSplitter(){}
virtual ~RtspSplitter(){}
/**
* 是否允许接收rtp包
* @param enable
*/
void enableRecvRtp(bool enable);
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;
/**
* 从rtsp头中获取Content长度
* @param parser
* @return
*/
virtual size_t getContentLength(Parser &parser);
protected:
const char *onSearchPacketTail(const char *data,size_t len) override ;
const char *onSearchPacketTail_l(const char *data,size_t len) ;
size_t onRecvHeader(const char *data,size_t len) override;
void onRecvContent(const char *data,size_t len) override;
private:
bool _enableRecvRtp = false;
bool _isRtpPacket = false;
Parser _parser;
};
}//namespace mediakit
#endif //ZLMEDIAKIT_RTSPSPLITTER_H