diff options
author | Sho Amano <samano@xevo.com> | 2017-08-29 14:55:39 +0900 |
---|---|---|
committer | Sho Amano <samano@xevo.com> | 2017-08-29 17:25:06 +0900 |
commit | 33b5d07cf3f2cea665db06e6b8c5b8cc90af263e (patch) | |
tree | e03c0da6bfe03b271520d145e622a1ab2535d203 | |
parent | 97e022637e08dc716508ba82c45e01cd9d1aa60e (diff) | |
download | sdl_ios-33b5d07cf3f2cea665db06e6b8c5b8cc90af263e.tar.gz |
Update "pts" acronym to "presentationTimestamp"
Reflecting review comments.
-rw-r--r-- | SmartDeviceLink/SDLStreamingMediaLifecycleManager.h | 4 | ||||
-rw-r--r-- | SmartDeviceLink/SDLStreamingMediaLifecycleManager.m | 26 | ||||
-rw-r--r-- | SmartDeviceLink/SDLStreamingMediaManager.h | 4 | ||||
-rw-r--r-- | SmartDeviceLink/SDLStreamingMediaManager.m | 4 | ||||
-rw-r--r-- | SmartDeviceLink/SDLVideoEncoder.h | 2 | ||||
-rw-r--r-- | SmartDeviceLink/SDLVideoEncoder.m | 24 | ||||
-rw-r--r-- | SmartDeviceLinkTests/DevAPISpecs/SDLRTPH264PacketizerSpec.m | 12 |
7 files changed, 38 insertions, 38 deletions
diff --git a/SmartDeviceLink/SDLStreamingMediaLifecycleManager.h b/SmartDeviceLink/SDLStreamingMediaLifecycleManager.h index 4ca6ebea9..1dcbcd09f 100644 --- a/SmartDeviceLink/SDLStreamingMediaLifecycleManager.h +++ b/SmartDeviceLink/SDLStreamingMediaLifecycleManager.h @@ -149,11 +149,11 @@ extern SDLAudioStreamState *const SDLAudioStreamStateShuttingDown; * This method receives raw image data and will run iOS8+'s hardware video encoder to turn the data into a video stream, which will then be passed to the connected head unit. * * @param imageBuffer A CVImageBufferRef to be encoded by Video Toolbox - * @param pts A presentation timestamp for the frame, or kCMTimeInvalid if timestamp is unknown. If it's valid, it must be greater than the previous one. + * @param presentationTimestamp A presentation timestamp for the frame, or kCMTimeInvalid if timestamp is unknown. If it's valid, it must be greater than the previous one. * * @return Whether or not the data was successfully encoded and sent. */ -- (BOOL)sendVideoData:(CVImageBufferRef)imageBuffer pts:(CMTime)pts; +- (BOOL)sendVideoData:(CVImageBufferRef)imageBuffer presentationTimestamp:(CMTime)presentationTimestamp; /** * This method receives PCM audio data and will attempt to send that data across to the head unit for immediate playback diff --git a/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m b/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m index a2265e0e7..53a813551 100644 --- a/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m +++ b/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m @@ -64,7 +64,7 @@ static NSUInteger const SDLFramesToSendOnBackground = 30; @property (assign, nonatomic) CV_NULLABLE CVPixelBufferRef backgroundingPixelBuffer; -@property (assign, nonatomic) CMTime lastPTS; +@property (assign, nonatomic) CMTime lastPresentationTimestamp; @end @@ -116,7 +116,7 @@ static NSUInteger const SDLFramesToSendOnBackground = 30; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sdl_appStateDidUpdate:) name:UIApplicationDidBecomeActiveNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sdl_appStateDidUpdate:) name:UIApplicationWillResignActiveNotification object:nil]; - _lastPTS = kCMTimeInvalid; + _lastPresentationTimestamp = kCMTimeInvalid; return self; } @@ -140,10 +140,10 @@ static NSUInteger const SDLFramesToSendOnBackground = 30; } - (BOOL)sendVideoData:(CVImageBufferRef)imageBuffer { - return [self sendVideoData:imageBuffer pts:kCMTimeInvalid]; + return [self sendVideoData:imageBuffer presentationTimestamp:kCMTimeInvalid]; } -- (BOOL)sendVideoData:(CVImageBufferRef)imageBuffer pts:(CMTime)pts { +- (BOOL)sendVideoData:(CVImageBufferRef)imageBuffer presentationTimestamp:(CMTime)presentationTimestamp { if (!self.isVideoConnected) { SDLLogW(@"Attempted to send video data, but not connected"); return NO; @@ -157,17 +157,17 @@ static NSUInteger const SDLFramesToSendOnBackground = 30; /* * reject input image for following cases: - * - pts is not increasing + * - presentation timestamp is not increasing * - app tries to send images while background images are shown */ - if (CMTIME_IS_VALID(self.lastPTS) && CMTIME_IS_VALID(pts) - && CMTIME_COMPARE_INLINE(pts, <=, self.lastPTS)) { + if (CMTIME_IS_VALID(self.lastPresentationTimestamp) && CMTIME_IS_VALID(presentationTimestamp) + && CMTIME_COMPARE_INLINE(presentationTimestamp, <=, self.lastPresentationTimestamp)) { SDLLogW(@"The video data is out of date"); return NO; } - self.lastPTS = pts; + self.lastPresentationTimestamp = presentationTimestamp; - return [self.videoEncoder encodeFrame:imageBuffer pts:pts]; + return [self.videoEncoder encodeFrame:imageBuffer presentationTimestamp:presentationTimestamp]; } - (BOOL)sendAudioData:(NSData*)audioData { @@ -317,7 +317,7 @@ static NSUInteger const SDLFramesToSendOnBackground = 30; self.backgroundingPixelBuffer = backgroundingPixelBuffer; } - self.lastPTS = kCMTimeInvalid; + self.lastPresentationTimestamp = kCMTimeInvalid; } [[NSNotificationCenter defaultCenter] postNotificationName:SDLVideoStreamDidStartNotification object:nil]; @@ -540,9 +540,9 @@ static NSUInteger const SDLFramesToSendOnBackground = 30; const CMTime interval = CMTimeMake(1, 30); for (int frameCount = 0; frameCount < SDLFramesToSendOnBackground; frameCount++) { - if (CMTIME_IS_VALID(self.lastPTS)) { - self.lastPTS = CMTimeAdd(self.lastPTS, interval); - [self.videoEncoder encodeFrame:self.backgroundingPixelBuffer pts:self.lastPTS]; + if (CMTIME_IS_VALID(self.lastPresentationTimestamp)) { + self.lastPresentationTimestamp = CMTimeAdd(self.lastPresentationTimestamp, interval); + [self.videoEncoder encodeFrame:self.backgroundingPixelBuffer presentationTimestamp:self.lastPresentationTimestamp]; } else { [self.videoEncoder encodeFrame:self.backgroundingPixelBuffer]; } diff --git a/SmartDeviceLink/SDLStreamingMediaManager.h b/SmartDeviceLink/SDLStreamingMediaManager.h index e47beeecc..46169484b 100644 --- a/SmartDeviceLink/SDLStreamingMediaManager.h +++ b/SmartDeviceLink/SDLStreamingMediaManager.h @@ -117,11 +117,11 @@ NS_ASSUME_NONNULL_BEGIN * This method receives raw image data and will run iOS8+'s hardware video encoder to turn the data into a video stream, which will then be passed to the connected head unit. * * @param imageBuffer A CVImageBufferRef to be encoded by Video Toolbox - * @param pts A presentation timestamp for the frame, or kCMTimeInvalid if timestamp is unknown. If it's valid, it must be greater than the previous one. + * @param presentationTimestamp A presentation timestamp for the frame, or kCMTimeInvalid if timestamp is unknown. If it's valid, it must be greater than the previous one. * * @return Whether or not the data was successfully encoded and sent. */ -- (BOOL)sendVideoData:(CVImageBufferRef)imageBuffer pts:(CMTime)pts; +- (BOOL)sendVideoData:(CVImageBufferRef)imageBuffer presentationTimestamp:(CMTime)presentationTimestamp; /** * This method receives PCM audio data and will attempt to send that data across to the head unit for immediate playback diff --git a/SmartDeviceLink/SDLStreamingMediaManager.m b/SmartDeviceLink/SDLStreamingMediaManager.m index a3e98262a..72bbf9691 100644 --- a/SmartDeviceLink/SDLStreamingMediaManager.m +++ b/SmartDeviceLink/SDLStreamingMediaManager.m @@ -53,8 +53,8 @@ NS_ASSUME_NONNULL_BEGIN return [self.lifecycleManager sendVideoData:imageBuffer]; } -- (BOOL)sendVideoData:(CVImageBufferRef)imageBuffer pts:(CMTime)pts { - return [self.lifecycleManager sendVideoData:imageBuffer pts:pts]; +- (BOOL)sendVideoData:(CVImageBufferRef)imageBuffer presentationTimestamp:(CMTime)presentationTimestamp { + return [self.lifecycleManager sendVideoData:imageBuffer presentationTimestamp:presentationTimestamp]; } - (BOOL)sendAudioData:(NSData*)audioData { diff --git a/SmartDeviceLink/SDLVideoEncoder.h b/SmartDeviceLink/SDLVideoEncoder.h index 4cdaac87c..53816452b 100644 --- a/SmartDeviceLink/SDLVideoEncoder.h +++ b/SmartDeviceLink/SDLVideoEncoder.h @@ -60,7 +60,7 @@ extern NSString *const SDLErrorDomainVideoEncoder; - (BOOL)encodeFrame:(CVImageBufferRef)imageBuffer; -- (BOOL)encodeFrame:(CVImageBufferRef)imageBuffer pts:(CMTime)pts; +- (BOOL)encodeFrame:(CVImageBufferRef)imageBuffer presentationTimestamp:(CMTime)presentationTimestamp; /** * Creates a new pixel buffer using the pixelBufferPool property. diff --git a/SmartDeviceLink/SDLVideoEncoder.m b/SmartDeviceLink/SDLVideoEncoder.m index f4676c288..f3216d851 100644 --- a/SmartDeviceLink/SDLVideoEncoder.m +++ b/SmartDeviceLink/SDLVideoEncoder.m @@ -125,16 +125,16 @@ static NSDictionary<NSString *, id>* _defaultVideoEncoderSettings; } - (BOOL)encodeFrame:(CVImageBufferRef)imageBuffer { - return [self encodeFrame:imageBuffer pts:kCMTimeInvalid]; + return [self encodeFrame:imageBuffer presentationTimestamp:kCMTimeInvalid]; } -- (BOOL)encodeFrame:(CVImageBufferRef)imageBuffer pts:(CMTime)pts { - if (!CMTIME_IS_VALID(pts)) { - pts = CMTimeMake(self.currentFrameNumber, 30); +- (BOOL)encodeFrame:(CVImageBufferRef)imageBuffer presentationTimestamp:(CMTime)presentationTimestamp { + if (!CMTIME_IS_VALID(presentationTimestamp)) { + presentationTimestamp = CMTimeMake(self.currentFrameNumber, 30); } self.currentFrameNumber++; - OSStatus status = VTCompressionSessionEncodeFrame(_compressionSession, imageBuffer, pts, kCMTimeInvalid, NULL, (__bridge void *)self, NULL); + OSStatus status = VTCompressionSessionEncodeFrame(_compressionSession, imageBuffer, presentationTimestamp, kCMTimeInvalid, NULL, (__bridge void *)self, NULL); return (status == noErr); } @@ -178,18 +178,18 @@ void sdl_videoEncoderOutputCallback(void * CM_NULLABLE outputCallbackRefCon, voi SDLVideoEncoder *encoder = (__bridge SDLVideoEncoder *)sourceFrameRefCon; NSArray *nalUnits = [encoder.class sdl_extractNalUnitsFromSampleBuffer:sampleBuffer]; - const CMTime ptsInCMTime = CMSampleBufferGetPresentationTimeStamp(sampleBuffer); - double pts = 0.0; - if (CMTIME_IS_VALID(ptsInCMTime)) { - pts = CMTimeGetSeconds(ptsInCMTime); + const CMTime presentationTimestampInCMTime = CMSampleBufferGetPresentationTimeStamp(sampleBuffer); + double presentationTimestamp = 0.0; + if (CMTIME_IS_VALID(presentationTimestampInCMTime)) { + presentationTimestamp = CMTimeGetSeconds(presentationTimestampInCMTime); } if (encoder.timestampOffset == 0.0) { - // remember this first PTS as the offset - encoder.timestampOffset = pts; + // remember this first timestamp as the offset + encoder.timestampOffset = presentationTimestamp; } NSArray *packets = [encoder.packetizer createPackets:nalUnits - presentationTimestamp:(pts - encoder.timestampOffset)]; + presentationTimestamp:(presentationTimestamp - encoder.timestampOffset)]; if ([encoder.delegate respondsToSelector:@selector(videoEncoder:hasEncodedFrame:)]) { for (NSData *packet in packets) { diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLRTPH264PacketizerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLRTPH264PacketizerSpec.m index cb70cfdbc..c7c4e5158 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLRTPH264PacketizerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLRTPH264PacketizerSpec.m @@ -205,21 +205,21 @@ describe(@"a RTP H264 packetizer", ^{ it(@"then increases in 90 kHz clock value", ^{ NSArray *nalUnits = @[iframe]; - UInt32 initialPTS = 0; + UInt32 initialPresentationTimestamp = 0; for (NSUInteger i = 0; i <= 100; i++) { // the timestamp increases by 1/30 seconds NSArray *results = [packetizer createPackets:nalUnits presentationTimestamp:i/30.0]; const UInt8 *header = [results[0] bytes]; - UInt32 pts = readLongInNBO(&header[FRAME_LENGTH_LEN+4]); + UInt32 presentationTimestamp = readLongInNBO(&header[FRAME_LENGTH_LEN+4]); if (i == 0) { - initialPTS = pts; + initialPresentationTimestamp = presentationTimestamp; } else { - UInt32 expectedPTS = initialPTS + i / 30.0 * CLOCK_RATE; + UInt32 expectedPresentationTimestamp = initialPresentationTimestamp + i / 30.0 * CLOCK_RATE; // accept calculation error (+-1) - expect(@(pts)).to(beGreaterThanOrEqualTo(@(expectedPTS - 1))); - expect(@(pts)).to(beLessThanOrEqualTo(@(expectedPTS + 1))); + expect(@(presentationTimestamp)).to(beGreaterThanOrEqualTo(@(expectedPresentationTimestamp - 1))); + expect(@(presentationTimestamp)).to(beLessThanOrEqualTo(@(expectedPresentationTimestamp + 1))); } } }); |