Skip to content
This repository was archived by the owner on Oct 23, 2024. It is now read-only.

Commit 1b51c04

Browse files
authored
Enable AV1 stream forwarding (#1085)
1 parent 73d7ef3 commit 1b51c04

File tree

7 files changed

+39
-7
lines changed

7 files changed

+39
-7
lines changed

source/agent/conference/conference.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const {
6060
* }
6161
*
6262
* object(VideoFormat):: {
63-
* codec: 'h264' | 'vp8' | 'h265' | 'vp9',
63+
* codec: 'h264' | 'vp8' | 'h265' | 'vp9' | 'av1x',
6464
* profile: 'constrained-baseline' | 'baseline' | 'main' | 'high' | undefined
6565
* }
6666
*

source/agent/video/videoCapability.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ const isHWAccAppliable = () => {
2020
module.exports.detected = (requireHWAcc) => {
2121
/*FIXME: should be double checked whether hardware acceleration is actually running*/
2222
var useHW = false;
23+
// TODO: support av1x.
2324
var codecs = {
24-
decode: ['vp8', 'vp9', 'h264', 'h265'],
25-
encode: ['vp8', 'vp9']
25+
decode: ['vp8', 'vp9', 'h264', 'h265', 'av1x'],
26+
encode: ['vp8', 'vp9', 'av1x']
2627
};
2728

2829
if (requireHWAcc && isHWAccAppliable()) {

source/core/common/rtputils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ struct redheader {
6969
#define VP9_90000_PT 101 // VP9 Video Codec
7070
#define H264_90000_PT 127 // H264 Video Codec
7171
#define H265_90000_PT 121 // H265 Video Codec
72+
#define AV1_90000_PT 35 // AV1X Video Codec
7273
#define RED_90000_PT 116 // REDundancy (RFC 2198)
7374
#define ULP_90000_PT 117 // ULP/FEC
7475
#define ISAC_16000_PT 103 // ISAC Audio Codec

source/core/owt_base/MediaFramePipeline.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ enum FrameFormat {
2222
FRAME_FORMAT_VP9,
2323
FRAME_FORMAT_H264,
2424
FRAME_FORMAT_H265,
25+
FRAME_FORMAT_AV1,
2526

2627
FRAME_FORMAT_MSDK = 300,
2728

@@ -104,6 +105,8 @@ inline FrameFormat getFormat(const std::string& codec) {
104105
return owt_base::FRAME_FORMAT_VP9;
105106
} else if (codec == "h265") {
106107
return owt_base::FRAME_FORMAT_H265;
108+
} else if (codec == "av1x") {
109+
return owt_base::FRAME_FORMAT_AV1;
107110
} else if (codec == "pcm_48000_2" || codec == "pcm_raw") {
108111
return owt_base::FRAME_FORMAT_PCM_48000_2;
109112
} else if (codec == "pcmu") {
@@ -152,6 +155,8 @@ inline const char *getFormatStr(const FrameFormat &format) {
152155
return "H264";
153156
case FRAME_FORMAT_H265:
154157
return "H265";
158+
case FRAME_FORMAT_AV1:
159+
return "AV1X";
155160
case FRAME_FORMAT_PCM_48000_2:
156161
return "PCM_48000_2";
157162
case FRAME_FORMAT_PCMU:
@@ -205,7 +210,8 @@ inline bool isVideoFrame(const Frame& frame) {
205210
|| frame.format == FRAME_FORMAT_VP8
206211
|| frame.format == FRAME_FORMAT_VP9
207212
|| frame.format == FRAME_FORMAT_H264
208-
|| frame.format == FRAME_FORMAT_H265;
213+
|| frame.format == FRAME_FORMAT_H265
214+
|| frame.format == FRAME_FORMAT_AV1;
209215
}
210216

211217
inline bool isDataFrame(const Frame& frame) {

source/core/rtc_adapter/VideoReceiveAdapter.cc

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ int32_t VideoReceiveAdapterImpl::AdapterDecoder::Decode(const webrtc::EncodedIma
7777
case webrtc::VideoCodecType::kVideoCodecH265:
7878
format = FRAME_FORMAT_H265;
7979
break;
80+
case webrtc::VideoCodecType::kVideoCodecAV1:
81+
format = FRAME_FORMAT_AV1;
82+
break;
8083
default:
8184
RTC_LOG(LS_WARNING) << "Unknown FORMAT";
8285
return 0;
@@ -242,6 +245,12 @@ void VideoReceiveAdapterImpl::CreateReceiveVideo()
242245
webrtc::CodecTypeToPayloadString(webrtc::VideoCodecType::kVideoCodecH265));
243246
RTC_DLOG(LS_INFO) << "Config add decoder:" << decoder.ToString();
244247
video_recv_config.decoders.push_back(decoder);
248+
// Add AV1 decoder
249+
decoder.payload_type = AV1_90000_PT;
250+
decoder.video_format = webrtc::SdpVideoFormat(
251+
webrtc::CodecTypeToPayloadString(webrtc::VideoCodecType::kVideoCodecAV1));
252+
RTC_DLOG(LS_INFO) << "Config add decoder:" << decoder.ToString();
253+
video_recv_config.decoders.push_back(decoder);
245254

246255
RTC_DLOG(LS_INFO) << "VideoReceiveStream::Config " << video_recv_config.ToString();
247256
m_videoRecvStream = call()->CreateVideoReceiveStream(std::move(video_recv_config));
@@ -267,7 +276,9 @@ std::vector<webrtc::SdpVideoFormat> VideoReceiveAdapterImpl::GetSupportedFormats
267276
webrtc::SdpVideoFormat(
268277
webrtc::CodecTypeToPayloadString(webrtc::VideoCodecType::kVideoCodecH264)),
269278
webrtc::SdpVideoFormat(
270-
webrtc::CodecTypeToPayloadString(webrtc::VideoCodecType::kVideoCodecH265))
279+
webrtc::CodecTypeToPayloadString(webrtc::VideoCodecType::kVideoCodecH265)),
280+
webrtc::SdpVideoFormat(
281+
webrtc::CodecTypeToPayloadString(webrtc::VideoCodecType::kVideoCodecAV1))
271282
};
272283
}
273284

source/core/rtc_adapter/VideoSendAdapter.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,18 @@ void VideoSendAdapterImpl::onFrame(const Frame& frame)
397397
m_rtpRtcp->ExpectedRetransmissionTimeMs(),
398398
0);
399399
}
400+
} else if (frame.format == FRAME_FORMAT_AV1) {
401+
h.codec = webrtc::VideoCodecType::kVideoCodecAV1;
402+
boost::shared_lock<boost::shared_mutex> lock(m_rtpRtcpMutex);
403+
m_senderVideo->SendVideo(
404+
AV1_90000_PT,
405+
webrtc::kVideoCodecAV1,
406+
timeStamp,
407+
timeStamp,
408+
rtc::ArrayView<const uint8_t>(frame.payload, frame.length),
409+
h,
410+
m_rtpRtcp->ExpectedRetransmissionTimeMs(),
411+
0);
400412
}
401413
}
402414

source/management_console/public/js/App.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,7 @@ class RoomModal extends React.Component {
604604
'h265': {codec: 'h265'},
605605
'vp8': {codec: 'vp8'},
606606
'vp9': {codec: 'vp9'},
607+
'av1x': {codec: 'av1x'},
607608
// audio
608609
'opus': {codec: 'opus', sampleRate: 48000, channelNum: 2},
609610
'isac-16000': {codec: 'isac', sampleRate: 16000},
@@ -702,7 +703,7 @@ class RoomModal extends React.Component {
702703
return mediaCheckBox(name, 'mediaIn.audio');
703704
});
704705

705-
const videoNames = ['h264', 'h265', 'vp8', 'vp9'];
706+
const videoNames = ['h264', 'h265', 'vp8', 'vp9', 'av1x'];
706707
const videoCheckBoxes = videoNames.map((name) => {
707708
return mediaCheckBox(name, 'mediaIn.video');
708709
});
@@ -748,7 +749,7 @@ class RoomModal extends React.Component {
748749
'h264-baseline',
749750
'h264-main',
750751
'h264-high',
751-
'h265', 'vp8', 'vp9'
752+
'h265', 'vp8', 'vp9', 'av1x',
752753
];
753754
const videoCheckBoxes = videoNames.map((name) => {
754755
return mediaCheckBox(name, 'mediaOut.video.format');

0 commit comments

Comments
 (0)