Skip to content

Commit

Permalink
feat: add svc codecs
Browse files Browse the repository at this point in the history
  • Loading branch information
theomonnom committed Dec 8, 2023
1 parent d3d7800 commit 8bb0ed6
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 9 deletions.
1 change: 1 addition & 0 deletions webrtc-sys/libwebrtc/build_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ args="is_debug=$debug \
rtc_build_tools=false \
rtc_build_examples=false \
rtc_libvpx_build_vp9=true \
enable_libaom=true \
is_component_build=false \
enable_stripping=true \
use_goma=false \
Expand Down
2 changes: 1 addition & 1 deletion webrtc-sys/libwebrtc/build_macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ gn gen "$OUTPUT_DIR" --root="src" \
rtc_build_examples=false \
rtc_build_tools=false \
rtc_libvpx_build_vp9=true \
enable_libaom=true \
is_component_build=false \
enable_stripping=true \
rtc_enable_symbol_export=true \
rtc_enable_objc_symbol_export=false \
enable_libaom = true \
rtc_include_dav1d_in_internal_decoder_factory = true \
rtc_use_h264=true \
use_custom_libcxx=false \
Expand Down
2 changes: 1 addition & 1 deletion webrtc-sys/libwebrtc/build_windows.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ if "!profile!" == "debug" (

rem generate ninja for release
call gn.bat gen %OUTPUT_DIR% --root="src" ^
--args="is_debug=!debug! is_clang=true target_cpu=\"!arch!\" use_custom_libcxx=false rtc_disable_check_msg=true rtc_include_tests=false rtc_build_examples=false rtc_build_tools=false is_component_build=false rtc_enable_protobuf=false rtc_use_h264=true ffmpeg_branding=\"Chrome\" symbol_level=0 enable_iterator_debugging=false"
--args="is_debug=!debug! is_clang=true target_cpu=\"!arch!\" use_custom_libcxx=false rtc_libvpx_build_vp9=true enable_libaom=true rtc_disable_check_msg=true rtc_include_tests=false rtc_build_examples=false rtc_build_tools=false is_component_build=false rtc_enable_protobuf=false rtc_use_h264=true ffmpeg_branding=\"Chrome\" symbol_level=0 enable_iterator_debugging=false"

rem build
ninja.exe -C %OUTPUT_DIR% :default
Expand Down
27 changes: 27 additions & 0 deletions webrtc-sys/src/video_decoder_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,19 @@

#include "livekit/video_decoder_factory.h"

#include "api/video_codecs/av1_profile.h"
#include "api/video_codecs/sdp_video_format.h"
#include "livekit/objc_video_factory.h"
#include "media/base/media_constants.h"
#include "modules/video_coding/codecs/h264/include/h264.h"
#include "modules/video_coding/codecs/vp8/include/vp8.h"
#include "modules/video_coding/codecs/vp9/include/vp9.h"
#include "rtc_base/logging.h"

#if defined(RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY)
#include "modules/video_coding/codecs/av1/dav1d_decoder.h" // nogncheck
#endif

#ifdef WEBRTC_ANDROID
#include "livekit/android.h"
#endif
Expand Down Expand Up @@ -52,10 +58,21 @@ std::vector<webrtc::SdpVideoFormat> VideoDecoderFactory::GetSupportedFormats()
}

formats.push_back(webrtc::SdpVideoFormat(cricket::kVp8CodecName));
for (const webrtc::SdpVideoFormat& format :
webrtc::SupportedVP9DecoderCodecs())
formats.push_back(format);
for (const webrtc::SdpVideoFormat& h264_format :
webrtc::SupportedH264DecoderCodecs())
formats.push_back(h264_format);

#if defined(RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY)
formats.push_back(webrtc::SdpVideoFormat(cricket::kAv1CodecName));
formats.push_back(webrtc::SdpVideoFormat(
cricket::kAv1CodecName,
{{webrtc::kAV1FmtpProfile,
AV1ProfileToString(webrtc::AV1Profile::kProfile1).data()}}));
#endif

return formats;
}

Expand Down Expand Up @@ -86,9 +103,19 @@ std::unique_ptr<webrtc::VideoDecoder> VideoDecoderFactory::CreateVideoDecoder(

if (absl::EqualsIgnoreCase(format.name, cricket::kVp8CodecName))
return webrtc::VP8Decoder::Create();
if (absl::EqualsIgnoreCase(format.name, cricket::kVp9CodecName))
return webrtc::VP9Decoder::Create();
if (absl::EqualsIgnoreCase(format.name, cricket::kH264CodecName))
return webrtc::H264Decoder::Create();


#if defined(RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY)
if (absl::EqualsIgnoreCase(format.name, cricket::kAv1CodecName)) {
return webrtc::CreateDav1dDecoder();
}
#endif


RTC_LOG(LS_ERROR) << "No VideoDecoder found for " << format.name;
return nullptr;
}
Expand Down
19 changes: 12 additions & 7 deletions webrtc-sys/src/video_encoder_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,34 @@
#include "api/video_codecs/sdp_video_format.h"
#include "api/video_codecs/video_encoder.h"
#include "api/video_codecs/video_encoder_factory_template.h"
#include "api/video_codecs/video_encoder_factory_template_libvpx_vp8_adapter.h"
#include "livekit/objc_video_factory.h"
#include "media/base/media_constants.h"
#include "media/engine/simulcast_encoder_adapter.h"
#include "rtc_base/logging.h"

#if defined(RTC_USE_LIBAOM_AV1_ENCODER)
#include "api/video_codecs/video_encoder_factory_template_libaom_av1_adapter.h"
#endif
#if defined(WEBRTC_USE_H264)
#include "api/video_codecs/video_encoder_factory_template_open_h264_adapter.h"
#endif
#include "api/video_codecs/video_encoder_factory_template_libvpx_vp8_adapter.h"
#include "api/video_codecs/video_encoder_factory_template_libvpx_vp9_adapter.h"

#ifdef WEBRTC_ANDROID
#include "livekit/android.h"
#endif

namespace livekit {

using Factory =
webrtc::VideoEncoderFactoryTemplate<webrtc::LibvpxVp8EncoderTemplateAdapter
using Factory = webrtc::VideoEncoderFactoryTemplate<
webrtc::LibvpxVp8EncoderTemplateAdapter,
#if defined(WEBRTC_USE_H264)
,
webrtc::OpenH264EncoderTemplateAdapter
webrtc::OpenH264EncoderTemplateAdapter,
#endif
#if defined(RTC_USE_LIBAOM_AV1_ENCODER)
webrtc::LibaomAv1EncoderTemplateAdapter,
#endif
>;
webrtc::LibvpxVp9EncoderTemplateAdapter>;

VideoEncoderFactory::InternalFactory::InternalFactory() {
#ifdef __APPLE__
Expand Down

0 comments on commit 8bb0ed6

Please sign in to comment.