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

#include "RtpCache.h"

13 14
#if defined(ENABLE_RTPPROXY)

夏楚 committed
15 16
using namespace toolkit;

xiongziliang committed
17 18 19 20 21
namespace mediakit{

RtpCache::RtpCache(onFlushed cb) {
    _cb = std::move(cb);
}
22 23

void RtpCache::onFlush(std::shared_ptr<List<Buffer::Ptr>> rtp_list, bool) {
xiongziliang committed
24 25 26
    _cb(std::move(rtp_list));
}

27
void RtpCache::input(uint64_t stamp, Buffer::Ptr buffer, bool is_key) {
28
    inputPacket(stamp, true, std::move(buffer), is_key);
xiongziliang committed
29 30
}

31 32 33 34 35 36
void RtpCachePS::flush() {
    PSEncoderImp::flush();
    RtpCache::flush();
}

void RtpCachePS::onRTP(Buffer::Ptr buffer, bool is_key) {
夏楚 committed
37
    auto rtp = std::static_pointer_cast<RtpPacket>(buffer);
xiongziliang committed
38
    auto stamp = rtp->getStampMS();
39 40 41 42 43 44
    input(stamp, std::move(buffer), is_key);
}

void RtpCacheRaw::flush() {
    RawEncoderImp::flush();
    RtpCache::flush();
xiongziliang committed
45 46
}

47
void RtpCacheRaw::onRTP(Buffer::Ptr buffer, bool is_key) {
48 49
    auto rtp = std::static_pointer_cast<RtpPacket>(buffer);
    auto stamp = rtp->getStampMS();
50
    input(stamp, std::move(buffer), is_key);
51 52
}

xiongziliang committed
53
}//namespace mediakit
54 55

#endif//#if defined(ENABLE_RTPPROXY)