PSDecoder.cpp 1.45 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 "PSDecoder.h"
13 14
#include "mpeg-ps.h"
namespace mediakit{
Gemfield committed
15 16 17 18 19 20 21 22 23 24 25

PSDecoder::PSDecoder() {
    _ps_demuxer = ps_demuxer_create([](void* param,
                                       int stream,
                                       int codecid,
                                       int flags,
                                       int64_t pts,
                                       int64_t dts,
                                       const void* data,
                                       size_t bytes){
        PSDecoder *thiz = (PSDecoder *)param;
xiongziliang committed
26 27 28
        if(thiz->_on_decode){
            thiz->_on_decode(stream, codecid, flags, pts, dts, data, bytes);
        }
Gemfield committed
29 30 31 32
    },this);
}

PSDecoder::~PSDecoder() {
33
    ps_demuxer_destroy((struct ps_demuxer_t*)_ps_demuxer);
Gemfield committed
34 35
}

xiongziliang committed
36
int PSDecoder::input(const uint8_t *data, int bytes) {
37
    return ps_demuxer_input((struct ps_demuxer_t*)_ps_demuxer,data,bytes);
Gemfield committed
38
}
39

xiongziliang committed
40 41 42
void PSDecoder::setOnDecode(const Decoder::onDecode &decode) {
    _on_decode = decode;
}
43

xiongziliang committed
44
}//namespace mediakit
45
#endif//#if defined(ENABLE_RTPPROXY)