RtspSplitter.h 1.63 KB
Newer Older
1
/*
xiongziliang committed
2
 * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
3 4 5
 *
 * This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
 *
xiongziliang committed
6 7 8
 * 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.
9 10 11 12 13
 */

#ifndef ZLMEDIAKIT_RTSPSPLITTER_H
#define ZLMEDIAKIT_RTSPSPLITTER_H

xiongziliang committed
14
#include "Common/Parser.h"
15 16 17 18 19 20 21 22
#include "Http/HttpRequestSplitter.h"

namespace mediakit{

class RtspSplitter : public HttpRequestSplitter{
public:
    RtspSplitter(){}
    virtual ~RtspSplitter(){}
xiongziliang committed
23 24 25 26 27 28

    /**
    * 是否允许接收rtp包
    * @param enable
    */
    void enableRecvRtp(bool enable);
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
protected:
    /**
     * 收到完整的rtsp包回调,包括sdp等content数据
     * @param parser rtsp包
     */
    virtual void onWholeRtspPacket(Parser &parser) = 0;

    /**
     * 收到rtp包回调
     * @param data
     * @param len
     */
    virtual void onRtpPacket(const char *data,uint64_t len) = 0;

    /**
xiongziliang committed
44 45 46
     * 从rtsp头中获取Content长度
     * @param parser
     * @return
47
     */
xiongziliang committed
48
    virtual int64_t getContentLength(Parser &parser);
49 50
protected:
    const char *onSearchPacketTail(const char *data,int len) override ;
51
    const char *onSearchPacketTail_l(const char *data,int len) ;
52 53 54 55 56 57 58 59 60 61 62 63 64
    int64_t onRecvHeader(const char *data,uint64_t len) override;
    void onRecvContent(const char *data,uint64_t len) override;
private:
    bool _enableRecvRtp = false;
    bool _isRtpPacket = false;
    Parser _parser;
};

}//namespace mediakit



#endif //ZLMEDIAKIT_RTSPSPLITTER_H