ObjC EncodedImage: Use fixed width integer types
We currently use long for some variables, which causes warnings when
converting from int64_t. We should use fixed width integer types
instead.
BUG=b/65491700
Review-Url: https://codereview.webrtc.org/3009293002
Cr-Original-Commit-Position: refs/heads/master@{#19791}
Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: 43467b09c88533d7ecf2659bb7cd66ed423c7f7c
diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCEncodedImage.mm b/sdk/objc/Framework/Classes/PeerConnection/RTCEncodedImage.mm
index 3c39acb..1c8a27b 100644
--- a/sdk/objc/Framework/Classes/PeerConnection/RTCEncodedImage.mm
+++ b/sdk/objc/Framework/Classes/PeerConnection/RTCEncodedImage.mm
@@ -12,6 +12,8 @@
#import "RTCVideoCodec+Private.h"
+#include "webrtc/rtc_base/safe_conversions.h"
+
@implementation RTCEncodedImage
@synthesize buffer = _buffer;
@@ -35,16 +37,16 @@
_buffer = [NSData dataWithBytesNoCopy:encodedImage._buffer
length:encodedImage._length
freeWhenDone:NO];
- _encodedWidth = encodedImage._encodedWidth;
- _encodedHeight = encodedImage._encodedHeight;
+ _encodedWidth = rtc::dchecked_cast<int32_t>(encodedImage._encodedWidth);
+ _encodedHeight = rtc::dchecked_cast<int32_t>(encodedImage._encodedHeight);
_timeStamp = encodedImage._timeStamp;
_captureTimeMs = encodedImage.capture_time_ms_;
_ntpTimeMs = encodedImage.ntp_time_ms_;
_flags = encodedImage.timing_.flags;
_encodeStartMs = encodedImage.timing_.encode_start_ms;
_encodeFinishMs = encodedImage.timing_.encode_finish_ms;
- _frameType = (RTCFrameType)encodedImage._frameType;
- _rotation = encodedImage.rotation_;
+ _frameType = static_cast<RTCFrameType>(encodedImage._frameType);
+ _rotation = static_cast<RTCVideoRotation>(encodedImage.rotation_);
_completeFrame = encodedImage._completeFrame;
_qp = encodedImage.qp_ == -1 ? nil : @(encodedImage.qp_);
_contentType = (encodedImage.content_type_ == webrtc::VideoContentType::SCREENSHARE) ?
@@ -59,8 +61,8 @@
// Return the pointer without copying.
webrtc::EncodedImage encodedImage(
(uint8_t *)_buffer.bytes, (size_t)_buffer.length, (size_t)_buffer.length);
- encodedImage._encodedWidth = _encodedWidth;
- encodedImage._encodedHeight = _encodedHeight;
+ encodedImage._encodedWidth = rtc::dchecked_cast<uint32_t>(_encodedWidth);
+ encodedImage._encodedHeight = rtc::dchecked_cast<uint32_t>(_encodedHeight);
encodedImage._timeStamp = _timeStamp;
encodedImage.capture_time_ms_ = _captureTimeMs;
encodedImage.ntp_time_ms_ = _ntpTimeMs;
diff --git a/sdk/objc/Framework/Headers/WebRTC/RTCVideoCodec.h b/sdk/objc/Framework/Headers/WebRTC/RTCVideoCodec.h
index 657ec0c..2f287dd 100644
--- a/sdk/objc/Framework/Headers/WebRTC/RTCVideoCodec.h
+++ b/sdk/objc/Framework/Headers/WebRTC/RTCVideoCodec.h
@@ -11,8 +11,7 @@
#import <Foundation/Foundation.h>
#import <WebRTC/RTCMacros.h>
-
-@class RTCVideoFrame;
+#import <WebRTC/RTCVideoFrame.h>
NS_ASSUME_NONNULL_BEGIN
@@ -35,16 +34,16 @@
@interface RTCEncodedImage : NSObject
@property(nonatomic, strong) NSData *buffer;
-@property(nonatomic, assign) int encodedWidth;
-@property(nonatomic, assign) int encodedHeight;
+@property(nonatomic, assign) int32_t encodedWidth;
+@property(nonatomic, assign) int32_t encodedHeight;
@property(nonatomic, assign) uint32_t timeStamp;
-@property(nonatomic, assign) long captureTimeMs;
-@property(nonatomic, assign) long ntpTimeMs;
+@property(nonatomic, assign) int64_t captureTimeMs;
+@property(nonatomic, assign) int64_t ntpTimeMs;
@property(nonatomic, assign) uint8_t flags;
-@property(nonatomic, assign) long encodeStartMs;
-@property(nonatomic, assign) long encodeFinishMs;
+@property(nonatomic, assign) int64_t encodeStartMs;
+@property(nonatomic, assign) int64_t encodeFinishMs;
@property(nonatomic, assign) RTCFrameType frameType;
-@property(nonatomic, assign) int rotation;
+@property(nonatomic, assign) RTCVideoRotation rotation;
@property(nonatomic, assign) BOOL completeFrame;
@property(nonatomic, strong) NSNumber *qp;
@property(nonatomic, assign) RTCVideoContentType contentType;