RtpSplitter.cpp 1.05 KB
Newer Older
Gemfield committed
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
 */
Gemfield committed
10

11
#if defined(ENABLE_RTPPROXY)
Gemfield committed
12
#include "RtpSplitter.h"
13
namespace mediakit{
Gemfield committed
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38

RtpSplitter::RtpSplitter() {
}

RtpSplitter::~RtpSplitter() {
}

const char *RtpSplitter::onSearchPacketTail(const char *data, int len) {
    //这是rtp包
    if(len < 2){
        //数据不够
        return nullptr;
    }
    uint16_t length = (((uint8_t *)data)[0] << 8) | ((uint8_t *)data)[1];
    if(len < length + 2){
        //数据不够
        return nullptr;
    }
    //返回rtp包末尾
    return data + 2 + length;
}

int64_t RtpSplitter::onRecvHeader(const char *data, uint64_t len) {
    onRtpPacket(data,len);
    return 0;
39 40 41 42
}

}//namespace mediakit
#endif//defined(ENABLE_RTPPROXY)