Use preprocessor to strip H264 implementation.

This CL makes it more flexible and easier to include/exclude H264 code
when using other build systems because it delegates the decision to
remove the code to the preprocessor instead of GN.

This CL should be a noop, and for WebRTC/Chromium the GN param
`rtc_use_h264` will still be the only thing to change in order to
include/exclude H264.

Moving code that requires ffmpeg or h264 out of the #ifdef/#endif
part should break the build since dependencies are only added if
`rtc_use_h264=true`.

Bug: webrtc:9213
Change-Id: Ibc04edc2f6b9e51489ffe638d5be4b32959cdca0
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/137430
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28055}
This commit is contained in:
Mirko Bonadei
2019-05-24 12:17:59 +02:00
committed by Commit Bot
parent 5c18a5ff5e
commit 815b1a6f53
7 changed files with 61 additions and 11 deletions

View File

@ -8,6 +8,11 @@
* be found in the AUTHORS file in the root of the source tree.
*/
// Everything declared/defined in this header is only required when WebRTC is
// build with H264 support, please do not move anything out of the
// #ifdef unless needed and tested.
#ifdef WEBRTC_USE_H264
#include "modules/video_coding/codecs/h264/h264_color_space.h"
namespace webrtc {
@ -169,3 +174,5 @@ ColorSpace ExtractH264ColorSpace(AVCodecContext* codec) {
}
} // namespace webrtc
#endif // WEBRTC_USE_H264

View File

@ -11,6 +11,15 @@
#ifndef MODULES_VIDEO_CODING_CODECS_H264_H264_COLOR_SPACE_H_
#define MODULES_VIDEO_CODING_CODECS_H264_H264_COLOR_SPACE_H_
// Everything declared in this header is only required when WebRTC is
// build with H264 support, please do not move anything out of the
// #ifdef unless needed and tested.
#ifdef WEBRTC_USE_H264
#if defined(WEBRTC_WIN) && !defined(__clang__)
#error "See: bugs.webrtc.org/9213#c13."
#endif
#include "api/video/color_space.h"
extern "C" {
@ -24,4 +33,6 @@ ColorSpace ExtractH264ColorSpace(AVCodecContext* codec);
} // namespace webrtc
#endif // WEBRTC_USE_H264
#endif // MODULES_VIDEO_CODING_CODECS_H264_H264_COLOR_SPACE_H_

View File

@ -9,6 +9,11 @@
*
*/
// Everything declared/defined in this header is only required when WebRTC is
// build with H264 support, please do not move anything out of the
// #ifdef unless needed and tested.
#ifdef WEBRTC_USE_H264
#include "modules/video_coding/codecs/h264/h264_decoder_impl.h"
#include <algorithm>
@ -380,3 +385,5 @@ void H264DecoderImpl::ReportError() {
}
} // namespace webrtc
#endif // WEBRTC_USE_H264

View File

@ -12,6 +12,15 @@
#ifndef MODULES_VIDEO_CODING_CODECS_H264_H264_DECODER_IMPL_H_
#define MODULES_VIDEO_CODING_CODECS_H264_H264_DECODER_IMPL_H_
// Everything declared in this header is only required when WebRTC is
// build with H264 support, please do not move anything out of the
// #ifdef unless needed and tested.
#ifdef WEBRTC_USE_H264
#if defined(WEBRTC_WIN) && !defined(__clang__)
#error "See: bugs.webrtc.org/9213#c13."
#endif
#include <memory>
#include "modules/video_coding/codecs/h264/include/h264.h"
@ -98,4 +107,6 @@ class H264DecoderImpl : public H264Decoder {
} // namespace webrtc
#endif // WEBRTC_USE_H264
#endif // MODULES_VIDEO_CODING_CODECS_H264_H264_DECODER_IMPL_H_

View File

@ -9,6 +9,11 @@
*
*/
// Everything declared/defined in this header is only required when WebRTC is
// build with H264 support, please do not move anything out of the
// #ifdef unless needed and tested.
#ifdef WEBRTC_USE_H264
#include "modules/video_coding/codecs/h264/h264_encoder_impl.h"
#include <limits>
@ -659,3 +664,5 @@ void H264EncoderImpl::LayerConfig::SetStreamState(bool send_stream) {
}
} // namespace webrtc
#endif // WEBRTC_USE_H264

View File

@ -12,6 +12,15 @@
#ifndef MODULES_VIDEO_CODING_CODECS_H264_H264_ENCODER_IMPL_H_
#define MODULES_VIDEO_CODING_CODECS_H264_H264_ENCODER_IMPL_H_
// Everything declared in this header is only required when WebRTC is
// build with H264 support, please do not move anything out of the
// #ifdef unless needed and tested.
#ifdef WEBRTC_USE_H264
#if defined(WEBRTC_WIN) && !defined(__clang__)
#error "See: bugs.webrtc.org/9213#c13."
#endif
#include <memory>
#include <vector>
@ -104,4 +113,6 @@ class H264EncoderImpl : public H264Encoder {
} // namespace webrtc
#endif // WEBRTC_USE_H264
#endif // MODULES_VIDEO_CODING_CODECS_H264_H264_ENCODER_IMPL_H_