diff options
-rw-r--r-- | SmartDeviceLink/SDLH264ByteStreamPacketizer.h | 19 | ||||
-rw-r--r-- | SmartDeviceLink/SDLH264ByteStreamPacketizer.m | 7 | ||||
-rw-r--r-- | SmartDeviceLink/SDLH264Packetizer.h | 12 | ||||
-rw-r--r-- | SmartDeviceLink/SDLRTPH264Packetizer.h | 19 | ||||
-rw-r--r-- | SmartDeviceLink/SDLRTPH264Packetizer.m | 9 | ||||
-rw-r--r-- | SmartDeviceLink/SDLVideoEncoder.m | 3 |
6 files changed, 19 insertions, 50 deletions
diff --git a/SmartDeviceLink/SDLH264ByteStreamPacketizer.h b/SmartDeviceLink/SDLH264ByteStreamPacketizer.h index ee3a671b7..5b6d57928 100644 --- a/SmartDeviceLink/SDLH264ByteStreamPacketizer.h +++ b/SmartDeviceLink/SDLH264ByteStreamPacketizer.h @@ -12,25 +12,6 @@ NS_ASSUME_NONNULL_BEGIN @interface SDLH264ByteStreamPacketizer : NSObject <SDLH264Packetizer> - -/** - * Initializer. - */ -- (instancetype)init; - -/** - * Creates H.264 byte-stream by appending start codes in front of every NAL units. - * - * @param nalUnits List of NAL units to create the stream - * @param pts Ignored; presentation timestamp in seconds. - * - * @return List of NSData, containing H.264 byte-stream - * - * @note This packetizer consolidates all NAL units into one NSData object - * to keep compatibility with previous implementation. - */ -- (nullable NSArray *)createPackets:(NSArray *)nalUnits pts:(double)pts; - @end NS_ASSUME_NONNULL_END diff --git a/SmartDeviceLink/SDLH264ByteStreamPacketizer.m b/SmartDeviceLink/SDLH264ByteStreamPacketizer.m index bd237fd71..60b868e5c 100644 --- a/SmartDeviceLink/SDLH264ByteStreamPacketizer.m +++ b/SmartDeviceLink/SDLH264ByteStreamPacketizer.m @@ -11,7 +11,7 @@ NS_ASSUME_NONNULL_BEGIN -@interface SDLH264ByteStreamPacketizer () <SDLH264Packetizer> +@interface SDLH264ByteStreamPacketizer () @property (nonatomic) NSData *startCode; @end @@ -27,11 +27,14 @@ NS_ASSUME_NONNULL_BEGIN return self; } -- (nullable NSArray *)createPackets:(NSArray *)nalUnits pts:(double)pts { +- (nullable NSArray<NSData *> *)createPackets:(NSArray<NSData *> *)nalUnits + presentationTimestamp:(double)presentationTimestamp { NSMutableArray *array = [NSMutableArray arrayWithCapacity:1]; NSMutableData *elementaryStream = [NSMutableData data]; + // Note: this packetizer consolidates all NAL units into one NSData object + // to keep compatibility with previous implementation. for (NSData *nalUnit in nalUnits) { [elementaryStream appendData:self.startCode]; [elementaryStream appendData:nalUnit]; diff --git a/SmartDeviceLink/SDLH264Packetizer.h b/SmartDeviceLink/SDLH264Packetizer.h index 8635cdd16..45c5e8d5c 100644 --- a/SmartDeviceLink/SDLH264Packetizer.h +++ b/SmartDeviceLink/SDLH264Packetizer.h @@ -16,15 +16,17 @@ NS_ASSUME_NONNULL_BEGIN * Creates packets from given H.264 NAL units and presentation timestamp. * * @param nalUnits List of NAL units to create packets. - * @param pts Presentation timestamp associated to the NAL units, in seconds. + * @param presentationTimestamp Presentation timestamp associated to + * the NAL units, in seconds. * * @return List of NSData. Each NSData holds a packet. * - * @note This method cannot be called more than once with same pts value. - * All NAL units that belongs to a frame should be included in - * nalUnits array. + * @warning This method cannot be called more than once with same pts value. + * All NAL units that belongs to a frame should be included in + * nalUnits array. */ -- (nullable NSArray *)createPackets:(NSArray *)nalUnits pts:(double)pts; +- (nullable NSArray<NSData *> *)createPackets:(NSArray<NSData *> *)nalUnits + presentationTimestamp:(double)presentationTimestamp; @end diff --git a/SmartDeviceLink/SDLRTPH264Packetizer.h b/SmartDeviceLink/SDLRTPH264Packetizer.h index b851e95a9..ca9fed938 100644 --- a/SmartDeviceLink/SDLRTPH264Packetizer.h +++ b/SmartDeviceLink/SDLRTPH264Packetizer.h @@ -27,25 +27,6 @@ NS_ASSUME_NONNULL_BEGIN */ @property (assign, nonatomic) UInt32 ssrc; -/** - * Initializer. - */ -- (instancetype)init; - -/** - * Creates RTP packets from given H.264 NAL units and presentation timestamp. - * - * @param nalUnits List of NAL units to create packets. - * @param pts Presentation timestamp associated to the NAL units, in seconds. - * - * @return List of NSData. Each NSData holds a RTP packet. - * - * @note This method cannot be called more than once with same pts value. - * All NAL units that belongs to a frame should be included in - * nalUnits array. - */ -- (nullable NSArray *)createPackets:(NSArray *)nalUnits pts:(double)pts; - @end NS_ASSUME_NONNULL_END diff --git a/SmartDeviceLink/SDLRTPH264Packetizer.m b/SmartDeviceLink/SDLRTPH264Packetizer.m index ca44b9207..8c14c6b9e 100644 --- a/SmartDeviceLink/SDLRTPH264Packetizer.m +++ b/SmartDeviceLink/SDLRTPH264Packetizer.m @@ -44,7 +44,7 @@ static inline void writeLongInNBO(UInt8 *p, UInt32 value) { NS_ASSUME_NONNULL_BEGIN -@interface SDLRTPH264Packetizer () <SDLH264Packetizer> +@interface SDLRTPH264Packetizer () @property (assign, nonatomic) UInt32 initialTimestamp; @property (assign, nonatomic) UInt16 sequenceNum; @end @@ -71,7 +71,8 @@ NS_ASSUME_NONNULL_BEGIN } } -- (nullable NSArray *)createPackets:(NSArray *)nalUnits pts:(double)pts { +- (nullable NSArray<NSData *> *)createPackets:(NSArray<NSData *> *)nalUnits + presentationTimestamp:(double)presentationTimestamp { NSMutableArray *rtpFrames = [NSMutableArray array]; NSUInteger nalUnitsCount = [nalUnits count]; @@ -105,7 +106,7 @@ NS_ASSUME_NONNULL_BEGIN UInt8 *p = buffer; p += [self writeFrameHeader:p packetSize:packetSize]; - p += [self writeRTPHeader:p marker:isLast pts:pts]; + p += [self writeRTPHeader:p marker:isLast pts:presentationTimestamp]; // FU indicator *p++ = (firstByte & 0xE0) | TYPE_FU_A; @@ -133,7 +134,7 @@ NS_ASSUME_NONNULL_BEGIN UInt8 *p = buffer; p += [self writeFrameHeader:p packetSize:packetSize]; - p += [self writeRTPHeader:p marker:isLast pts:pts]; + p += [self writeRTPHeader:p marker:isLast pts:presentationTimestamp]; [nalUnit getBytes:p length:nalUnitLength]; NSData *rtpFrame = [NSData dataWithBytesNoCopy:buffer length:frameSize]; diff --git a/SmartDeviceLink/SDLVideoEncoder.m b/SmartDeviceLink/SDLVideoEncoder.m index 57e266a64..f4676c288 100644 --- a/SmartDeviceLink/SDLVideoEncoder.m +++ b/SmartDeviceLink/SDLVideoEncoder.m @@ -188,7 +188,8 @@ void sdl_videoEncoderOutputCallback(void * CM_NULLABLE outputCallbackRefCon, voi encoder.timestampOffset = pts; } - NSArray *packets = [encoder.packetizer createPackets:nalUnits pts:(pts - encoder.timestampOffset)]; + NSArray *packets = [encoder.packetizer createPackets:nalUnits + presentationTimestamp:(pts - encoder.timestampOffset)]; if ([encoder.delegate respondsToSelector:@selector(videoEncoder:hasEncodedFrame:)]) { for (NSData *packet in packets) { |