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
|
|
|
|
*
|
2021-01-17 18:31:50 +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
|
|
|
|
|
*/
|
2021-01-17 18:31:50 +08:00
|
|
|
|
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-17 18:31:50 +08:00
|
|
|
|
virtual size_t getContentLength(Parser &parser);
|
|
|
|
|
|
2018-10-30 10:31:27 +08:00
|
|
|
|
protected:
|
2021-01-17 18:31:50 +08:00
|
|
|
|
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;
|
|
|
|
|
|
2018-10-30 10:31:27 +08:00
|
|
|
|
private:
|
|
|
|
|
bool _enableRecvRtp = false;
|
|
|
|
|
bool _isRtpPacket = false;
|
|
|
|
|
Parser _parser;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}//namespace mediakit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif //ZLMEDIAKIT_RTSPSPLITTER_H
|