client side handle codec format

This commit is contained in:
csf
2022-07-05 22:17:34 +08:00
parent 6c9e601c59
commit 5bd08bf0a7
10 changed files with 68 additions and 81 deletions

View File

@@ -3,7 +3,7 @@
// https://github.com/rust-av/vpx-rs/blob/master/src/decoder.rs
use hbb_common::anyhow::{anyhow, Context};
use hbb_common::message_proto::{test_delay, Message, VP9s, VideoFrame, VP9};
use hbb_common::message_proto::{Message, VP9s, VideoFrame, VP9};
use hbb_common::ResultType;
use crate::codec::EncoderApi;
@@ -27,7 +27,6 @@ impl Default for VpxVideoCodecId {
pub struct VpxEncoder {
ctx: vpx_codec_ctx_t,
format: VpxVideoCodecId,
width: usize,
height: usize,
}
@@ -97,17 +96,14 @@ impl EncoderApi for VpxEncoder {
{
match cfg {
crate::codec::EncoderCfg::VPX(config) => {
let format;
let i;
if cfg!(feature = "VP8") {
i = match config.codec {
VpxVideoCodecId::VP8 => call_vpx_ptr!(vpx_codec_vp8_cx()),
VpxVideoCodecId::VP9 => call_vpx_ptr!(vpx_codec_vp9_cx()),
};
format = config.codec;
} else {
i = call_vpx_ptr!(vpx_codec_vp9_cx());
format = VpxVideoCodecId::VP9;
}
let mut c = unsafe { std::mem::MaybeUninit::zeroed().assume_init() };
call_vpx!(vpx_codec_enc_config_default(i, &mut c, 0));
@@ -194,7 +190,6 @@ impl EncoderApi for VpxEncoder {
Ok(Self {
ctx,
format,
width: config.width as _,
height: config.height as _,
})
@@ -233,13 +228,6 @@ impl EncoderApi for VpxEncoder {
call_vpx!(vpx_codec_enc_config_set(&mut self.ctx, &new_enc_cfg));
return Ok(());
}
fn get_codec_format(&self) -> test_delay::CodecFormat {
match self.format {
VpxVideoCodecId::VP8 => test_delay::CodecFormat::VP8,
VpxVideoCodecId::VP9 => test_delay::CodecFormat::VP9,
}
}
}
impl VpxEncoder {