h264.h (2957B)
1 /* 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 * 10 */ 11 12 #ifndef MODULES_VIDEO_CODING_CODECS_H264_INCLUDE_H264_H_ 13 #define MODULES_VIDEO_CODING_CODECS_H264_INCLUDE_H264_H_ 14 15 #include <memory> 16 #include <string> 17 #include <vector> 18 19 #include "absl/base/nullability.h" 20 #include "api/environment/environment.h" 21 #include "api/video_codecs/h264_profile_level_id.h" 22 #include "api/video_codecs/scalability_mode.h" 23 #include "api/video_codecs/sdp_video_format.h" 24 #include "api/video_codecs/video_decoder.h" 25 #include "api/video_codecs/video_encoder.h" 26 #include "modules/video_coding/codecs/h264/include/h264_globals.h" 27 #include "rtc_base/system/rtc_export.h" 28 29 namespace webrtc { 30 31 // Creates an H264 SdpVideoFormat entry with specified paramters. 32 RTC_EXPORT SdpVideoFormat 33 CreateH264Format(H264Profile profile, 34 H264Level level, 35 const std::string& packetization_mode, 36 bool add_scalability_modes = false); 37 38 // Set to disable the H.264 encoder/decoder implementations that are provided if 39 // `rtc_use_h264` build flag is true (if false, this function does nothing). 40 // This function should only be called before or during WebRTC initialization 41 // and is not thread-safe. 42 RTC_EXPORT void DisableRtcUseH264(); 43 44 // Returns a vector with all supported internal H264 encode profiles that we can 45 // negotiate in SDP, in order of preference. 46 std::vector<SdpVideoFormat> SupportedH264Codecs( 47 bool add_scalability_modes = false); 48 49 // Returns a vector with all supported internal H264 decode profiles that we can 50 // negotiate in SDP, in order of preference. This will be available for receive 51 // only connections. 52 std::vector<SdpVideoFormat> SupportedH264DecoderCodecs(); 53 54 class RTC_EXPORT H264Encoder { 55 public: 56 // If H.264 is supported (any implementation). 57 static bool IsSupported(); 58 static bool SupportsScalabilityMode(ScalabilityMode scalability_mode); 59 }; 60 61 struct H264EncoderSettings { 62 // Use factory function rather than constructor to allow to create 63 // `H264EncoderSettings` with designated initializers. 64 static H264EncoderSettings Parse(const SdpVideoFormat& format); 65 66 H264PacketizationMode packetization_mode = 67 H264PacketizationMode::NonInterleaved; 68 }; 69 absl_nonnull std::unique_ptr<VideoEncoder> CreateH264Encoder( 70 const Environment& env, 71 H264EncoderSettings settings = {}); 72 73 class RTC_EXPORT H264Decoder : public VideoDecoder { 74 public: 75 static std::unique_ptr<H264Decoder> Create(); 76 static bool IsSupported(); 77 78 ~H264Decoder() override {} 79 }; 80 81 } // namespace webrtc 82 83 #endif // MODULES_VIDEO_CODING_CODECS_H264_INCLUDE_H264_H_