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

Commit

Permalink
Reenable HEVC on iOS.
Browse files Browse the repository at this point in the history
This change applies #243912b03f7d089b1cdda31197baf05a2e37cb70 on m76
branch. It also fixes compile issues on iOS introduced by
\#6c5fb0208451b8fbfc15087465ea8c3dc9421c92.
  • Loading branch information
jianjunz committed Aug 28, 2019
1 parent 6c5fb02 commit adf5efc
Show file tree
Hide file tree
Showing 10 changed files with 1,308 additions and 2 deletions.
1 change: 0 additions & 1 deletion api/video_codecs/video_codec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ static const char* kPayloadNameH264 = "H264";
#ifndef DISABLE_H265
static const char* kPayloadNameH265 = "H265";
#endif
static const char* kPayloadNameI420 = "I420";
static const char* kPayloadNameGeneric = "Generic";
static const char* kPayloadNameMultiplex = "Multiplex";

Expand Down
3 changes: 3 additions & 0 deletions call/rtp_payload_params.cc
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,9 @@ void RtpPayloadParams::SetGeneric(const CodecSpecificInfo* codec_specific_info,
return;
case VideoCodecType::kVideoCodecH264:
// TODO(philipel): Implement H264 to new generic descriptor.
#ifndef DISABLE_H265
case VideoCodecType::kVideoCodecH265:
#endif
case VideoCodecType::kVideoCodecMultiplex:
return;
}
Expand Down
2 changes: 1 addition & 1 deletion modules/rtp_rtcp/source/rtp_format_h265.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ bool RtpPacketizerH265::GeneratePackets(
// For HEVC we follow non-interleaved mode for the packetization,
// and don't support single-nalu mode at present.
for (size_t i = 0; i < input_fragments_.size();) {
size_t fragment_len = input_fragments_[i].length;
int fragment_len = input_fragments_[i].length;
int single_packet_capacity = limits_.max_payload_len;
if (input_fragments_.size() == 1)
single_packet_capacity -= limits_.single_packet_reduction_len;
Expand Down
5 changes: 5 additions & 0 deletions sdk/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -1631,6 +1631,11 @@ if (is_ios || is_mac) {
"objc/components/video_codec/RTCVideoEncoderFactoryH264.m",
"objc/components/video_codec/RTCVideoEncoderH264.h",
"objc/components/video_codec/RTCVideoEncoderH264.mm",
"objc/Framework/Headers/WebRTC/RTCVideoCodecH265.h",
"objc/components/video_codec/RTCVideoEncoderH265.mm",
"objc/components/video_codec/RTCVideoCodecH265.mm",
"objc/components/video_codec/RTCVideoDecoderH265.h",
"objc/components/video_codec/RTCVideoDecoderH265.mm",
]

configs += [
Expand Down
48 changes: 48 additions & 0 deletions sdk/objc/Framework/Headers/WebRTC/RTCVideoCodecH265.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright 2018 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/

/* This file is borrowed from webrtc/sdk/objc/Framework/Headers/WebRTC/RTCVideoCodecH264.h */

#import <Foundation/Foundation.h>

#import <WebRTC/RTCMacros.h>
#import <WebRTC/RTCVideoCodecFactory.h>

RTC_OBJC_EXPORT
API_AVAILABLE(ios(11.0))
@interface RTCCodecSpecificInfoH265 : NSObject <RTCCodecSpecificInfo>
@end

/** Encoder. */
RTC_OBJC_EXPORT
API_AVAILABLE(ios(11.0))
@interface RTCVideoEncoderH265 : NSObject<RTCVideoEncoder>

- (instancetype)initWithCodecInfo:(RTCVideoCodecInfo *)codecInfo;

@end

/** Decoder. */
RTC_OBJC_EXPORT
API_AVAILABLE(ios(11.0))
@interface RTCVideoDecoderH265 : NSObject<RTCVideoDecoder>
@end

/** Encoder factory. */
RTC_OBJC_EXPORT
API_AVAILABLE(ios(11.0))
@interface RTCVideoEncoderFactoryH265 : NSObject<RTCVideoEncoderFactory>
@end

/** Decoder factory. */
RTC_OBJC_EXPORT
API_AVAILABLE(ios(11.0))
@interface RTCVideoDecoderFactoryH265 : NSObject<RTCVideoDecoderFactory>
@end
67 changes: 67 additions & 0 deletions sdk/objc/components/video_codec/RTCVideoCodecH265.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Copyright 2018 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/

/* This file is borrowed from
* webrtc/sdk/objc/Framework/Classes/PeerConnection/RTCVideoCodecH265.mm */

#import "WebRTC/RTCVideoCodecH265.h"

#include <vector>

#import "WebRTC/RTCVideoCodec.h"

#include "rtc_base/time_utils.h"
#include "system_wrappers/include/field_trial.h"

static NSString* kH265CodecName = @"H265";
// TODO(jianjunz): This is value is not correct.
static NSString* kLevel31Main = @"4d001f";

@implementation RTCCodecSpecificInfoH265
@end

// Encoder factory.
@implementation RTCVideoEncoderFactoryH265

- (NSArray<RTCVideoCodecInfo*>*)supportedCodecs {
NSMutableArray<RTCVideoCodecInfo*>* codecs = [NSMutableArray array];
NSString* codecName = kH265CodecName;

NSDictionary<NSString*, NSString*>* mainParams = @{
@"profile-level-id" : kLevel31Main,
@"level-asymmetry-allowed" : @"1",
@"packetization-mode" : @"1",
};
RTCVideoCodecInfo* constrainedBaselineInfo =
[[RTCVideoCodecInfo alloc] initWithName:codecName parameters:mainParams];
[codecs addObject:constrainedBaselineInfo];

return [codecs copy];
}

- (id<RTCVideoEncoder>)createEncoder:(RTCVideoCodecInfo*)info {
return [[RTCVideoEncoderH265 alloc] initWithCodecInfo:info];
}

@end

// Decoder factory.
@implementation RTCVideoDecoderFactoryH265

- (id<RTCVideoDecoder>)createDecoder:(RTCVideoCodecInfo*)info {
return [[RTCVideoDecoderH265 alloc] init];
}

- (NSArray<RTCVideoCodecInfo*>*)supportedCodecs {
NSString* codecName = kH265CodecName;
return @[ [[RTCVideoCodecInfo alloc] initWithName:codecName parameters:nil] ];
}

@end
Loading

0 comments on commit adf5efc

Please sign in to comment.