mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-26 04:31:37 +08:00
Optimize Decoder inheritance relationship (#1760)
This commit is contained in:
parent
07982b7243
commit
28350c0d05
@ -24,6 +24,15 @@
|
||||
using namespace toolkit;
|
||||
|
||||
namespace mediakit {
|
||||
|
||||
void Decoder::setOnDecode(Decoder::onDecode cb) {
|
||||
_on_decode = std::move(cb);
|
||||
}
|
||||
|
||||
void Decoder::setOnStream(Decoder::onStream cb) {
|
||||
_on_stream = std::move(cb);
|
||||
}
|
||||
|
||||
static Decoder::Ptr createDecoder_l(DecoderImp::Type type) {
|
||||
switch (type){
|
||||
case DecoderImp::decoder_ps:
|
||||
|
@ -25,12 +25,16 @@ public:
|
||||
typedef std::function<void(int stream, int codecid, const void *extra, size_t bytes, int finish)> onStream;
|
||||
|
||||
virtual ssize_t input(const uint8_t *data, size_t bytes) = 0;
|
||||
virtual void setOnDecode(onDecode cb) = 0;
|
||||
virtual void setOnStream(onStream cb) = 0;
|
||||
void setOnDecode(onDecode cb);
|
||||
void setOnStream(onStream cb);
|
||||
|
||||
protected:
|
||||
Decoder() = default;
|
||||
virtual ~Decoder() = default;
|
||||
|
||||
protected:
|
||||
onDecode _on_decode;
|
||||
onStream _on_stream;
|
||||
};
|
||||
|
||||
class DecoderImp{
|
||||
|
@ -53,14 +53,6 @@ ssize_t PSDecoder::input(const uint8_t *data, size_t bytes) {
|
||||
return bytes;
|
||||
}
|
||||
|
||||
void PSDecoder::setOnDecode(Decoder::onDecode cb) {
|
||||
_on_decode = std::move(cb);
|
||||
}
|
||||
|
||||
void PSDecoder::setOnStream(Decoder::onStream cb) {
|
||||
_on_stream = std::move(cb);
|
||||
}
|
||||
|
||||
const char *PSDecoder::onSearchPacketTail(const char *data, size_t len) {
|
||||
try {
|
||||
auto ret = ps_demuxer_input(static_cast<struct ps_demuxer_t *>(_ps_demuxer), reinterpret_cast<const uint8_t *>(data), len);
|
||||
@ -81,4 +73,4 @@ const char *PSDecoder::onSearchPacketTail(const char *data, size_t len) {
|
||||
}
|
||||
|
||||
}//namespace mediakit
|
||||
#endif//#if defined(ENABLE_RTPPROXY)
|
||||
#endif//#if defined(ENABLE_RTPPROXY)
|
||||
|
@ -25,8 +25,6 @@ public:
|
||||
~PSDecoder();
|
||||
|
||||
ssize_t input(const uint8_t* data, size_t bytes) override;
|
||||
void setOnDecode(onDecode cb) override;
|
||||
void setOnStream(onStream cb) override;
|
||||
|
||||
// HttpRequestSplitter interface
|
||||
private:
|
||||
@ -36,8 +34,6 @@ private:
|
||||
|
||||
private:
|
||||
void *_ps_demuxer = nullptr;
|
||||
onDecode _on_decode;
|
||||
onStream _on_stream;
|
||||
};
|
||||
|
||||
}//namespace mediakit
|
||||
|
@ -101,14 +101,6 @@ ssize_t TSDecoder::input(const uint8_t *data, size_t bytes) {
|
||||
return bytes;
|
||||
}
|
||||
|
||||
void TSDecoder::setOnDecode(Decoder::onDecode cb) {
|
||||
_on_decode = std::move(cb);
|
||||
}
|
||||
|
||||
void TSDecoder::setOnStream(Decoder::onStream cb) {
|
||||
_on_stream = std::move(cb);
|
||||
}
|
||||
|
||||
#endif//defined(ENABLE_HLS)
|
||||
|
||||
}//namespace mediakit
|
||||
|
@ -45,14 +45,10 @@ public:
|
||||
TSDecoder();
|
||||
~TSDecoder();
|
||||
ssize_t input(const uint8_t* data, size_t bytes) override ;
|
||||
void setOnDecode(onDecode cb) override;
|
||||
void setOnStream(onStream cb) override;
|
||||
|
||||
private:
|
||||
TSSegment _ts_segment;
|
||||
struct ts_demuxer_t* _demuxer_ctx = nullptr;
|
||||
onDecode _on_decode;
|
||||
onStream _on_stream;
|
||||
};
|
||||
#endif//defined(ENABLE_HLS)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user