mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-16 21:42:43 +00:00
feat: generic camera stream support for http snapshot and rtsp
This commit is contained in:
@@ -45,6 +45,25 @@ int AVVideoDecoder::open(Bambu_StreamInfo const &info)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int AVVideoDecoder::open(AVCodecParameters const ¶meters)
|
||||
{
|
||||
if (avcodec_parameters_to_context(codec_ctx_, ¶meters) < 0)
|
||||
return -1;
|
||||
|
||||
auto codec = avcodec_find_decoder(codec_ctx_->codec_id);
|
||||
if (codec == nullptr) {
|
||||
fprintf(stderr, "AVVideoDecoder: unsupported codec!\n");
|
||||
return -1;
|
||||
}
|
||||
if (avcodec_open2(codec_ctx_, codec, nullptr) < 0) {
|
||||
fprintf(stderr, "AVVideoDecoder: could not open codec\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
frame_ = av_frame_alloc();
|
||||
return frame_ == nullptr ? -1 : 0;
|
||||
}
|
||||
|
||||
int AVVideoDecoder::decode(const Bambu_Sample &sample)
|
||||
{
|
||||
int ret = -1;
|
||||
@@ -71,6 +90,14 @@ int AVVideoDecoder::decode(const Bambu_Sample &sample)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int AVVideoDecoder::decode(const AVPacket &packet)
|
||||
{
|
||||
int ret = avcodec_send_packet(codec_ctx_, &packet);
|
||||
if (ret == 0)
|
||||
got_frame_ = avcodec_receive_frame(codec_ctx_, frame_) == 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int AVVideoDecoder::flush()
|
||||
{
|
||||
int ret = avcodec_send_packet(codec_ctx_, nullptr);
|
||||
|
||||
Reference in New Issue
Block a user