WebRTC支持H264笔记

环境 Ubuntu16.04 

版本 WebRTC m84 

1、修改代码

  vi  third_party/ffmpeg/chromium/config/Chromium/linux/x64/libavcodec/parser_list.c

static const AVCodecParser * const parser_list[] = {
    &ff_flac_parser,
    &ff_mpegaudio_parser,
    &ff_opus_parser,
    &ff_vorbis_parser,
    &ff_vp3_parser,
    &ff_vp8_parser,
    &ff_vp9_parser,
    &ff_h264_parser,
    NULL };

vi third_party/ffmpeg/chromium/config/Chromium/linux/x64/libavcodec/codec_list.c 

static const AVCodec * const codec_list[] = {
    &ff_theora_decoder,
    &ff_vp3_decoder,
    &ff_vp8_decoder,
    &ff_flac_decoder,
    &ff_mp3_decoder,
    &ff_vorbis_decoder,
    &ff_pcm_alaw_decoder,
    &ff_pcm_f32le_decoder,
    &ff_pcm_mulaw_decoder,
    &ff_pcm_s16be_decoder,
    &ff_pcm_s16le_decoder,
    &ff_pcm_s24be_decoder,
    &ff_pcm_s24le_decoder,
    &ff_pcm_s32le_decoder,
    &ff_pcm_u8_decoder,
    &ff_libopus_decoder,
    &ff_h264_decoder,
    NULL };

vi media/engine/internal_encoder_factory.cc 


std::vector InternalEncoderFactory::SupportedFormats() {
  std::vector supported_codecs;
  for (const webrtc::SdpVideoFormat& format : webrtc::SupportedH264Codecs())
    supported_codecs.push_back(format);
/*   supported_codecs.push_back(SdpVideoFormat(cricket::kVp8CodecName));
     for (const webrtc::SdpVideoFormat& format : webrtc::SupportedVP9Codecs())
     supported_codecs.push_back(format);
 if (kIsLibaomAv1EncoderSupported)
    supported_codecs.push_back(SdpVideoFormat(cricket::kAv1CodecName));*/
  return supported_codecs;
}

vi src/third_party/ffmpeg/chromium/config/Chrome/linux/x64/config.h

#define CONFIG_H264_DECODER 1

2、编译选项支持

gn gen out/h264Debug --args="proprietary_codecs=true rtc_use_h264=true use_openh264=true ffmpeg_branding=\"Chrome\""

3、调试结果

WebRTC支持H264笔记_第1张图片

你可能感兴趣的:(WebRTC,p2p,webrtc,音视频)