Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed video/audio end services sometimes not being sent when secondary transport shuts down #1566

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
158 commits
Select commit Hold shift + click to select a range
1fb8081
video streaming manager stop method fixed
NicoleYarroch Jan 30, 2020
2fabda5
Added logs
NicoleYarroch Jan 30, 2020
21c3fb6
Fixed nil pixel buffer pool
NicoleYarroch Jan 30, 2020
e4d0a25
Added log to car window
NicoleYarroch Jan 30, 2020
0e1cd3f
Removed hmilevel check
NicoleYarroch Jan 30, 2020
630517c
Fixed documentation
NicoleYarroch Jan 30, 2020
cbf99f7
Removed hmi level check
NicoleYarroch Jan 30, 2020
92fd023
Fixed pragma markers
NicoleYarroch Jan 30, 2020
6919c06
Remove setting pool to nil
NicoleYarroch Jan 30, 2020
2174537
fixed video state for starting video when app is in bg
NicoleYarroch Jan 30, 2020
902e556
Added error handling to CarWindow
NicoleYarroch Jan 31, 2020
ba7627a
Added more detail to error messages
NicoleYarroch Jan 31, 2020
25ee756
Cleaned up serviceType check
NicoleYarroch Jan 31, 2020
cf15791
Removed reset
NicoleYarroch Feb 3, 2020
53121ae
Fixed SDL log messages
NicoleYarroch Feb 4, 2020
13562fb
Refactored compression session resetting
NicoleYarroch Feb 4, 2020
66138dd
Cleaned up documentation
NicoleYarroch Feb 4, 2020
0780c1e
Refactoring the video lifecycle manager
NicoleYarroch Feb 4, 2020
7ee19e2
Fixed returned value
NicoleYarroch Feb 4, 2020
28a06ec
Fixing audio state stop method
NicoleYarroch Feb 4, 2020
df13cf6
Added error message
NicoleYarroch Feb 4, 2020
56e793a
Cleaned up audio stream manager
NicoleYarroch Feb 4, 2020
618464d
Removed newlines
NicoleYarroch Feb 4, 2020
8c272fa
Added test cases for audio manager
NicoleYarroch Feb 4, 2020
106c0cd
Added test cases for stopping streaming
NicoleYarroch Feb 4, 2020
484f193
Fixed resetting the pixelBufferPool
NicoleYarroch Feb 4, 2020
e5b1543
connectedVehicleMake now reset on disconnect
NicoleYarroch Feb 4, 2020
7495445
Fix backgrounding breaking the compression session
NicoleYarroch Feb 17, 2020
af768ef
TCP transport only stopped after video stops
NicoleYarroch Feb 18, 2020
d62883c
Added background task and fixes
NicoleYarroch Feb 19, 2020
d3d6d7f
Fixed log message
NicoleYarroch Feb 19, 2020
0e49c5a
reset handler
NicoleYarroch Feb 19, 2020
1f97519
Added logs
NicoleYarroch Feb 19, 2020
f7e8107
Fix for video ack screen size being 0
NicoleYarroch Feb 19, 2020
eabd306
Removed duplicate saving video resolution
NicoleYarroch Feb 20, 2020
979e54a
Added documentation
NicoleYarroch Feb 21, 2020
977a27e
Refactored audioSLM method names
NicoleYarroch Feb 21, 2020
0ff5a35
Renamed vars & added documentation
NicoleYarroch Feb 21, 2020
16501d0
Merge branch 'develop' into bugfix/issue_1551_video_end_service_not_s…
NicoleYarroch Feb 21, 2020
9254ee6
Removed commented out code
NicoleYarroch Feb 21, 2020
372c11e
Added documentation for new method
NicoleYarroch Feb 21, 2020
f436c9e
Removed commented out logs
NicoleYarroch Feb 21, 2020
f655a4b
Added documentation to methods
NicoleYarroch Feb 21, 2020
8617155
Refactored the streaming media manager
NicoleYarroch Feb 21, 2020
0aeca6c
Cleaned up TCP transport classes and docs
NicoleYarroch Feb 21, 2020
c690aab
Refactored the transport updated code
NicoleYarroch Feb 24, 2020
2ed7147
Updated docs
NicoleYarroch Feb 24, 2020
3ebedfe
Fixed test cases
NicoleYarroch Feb 24, 2020
cba57a9
Fixed log level
NicoleYarroch Feb 24, 2020
7d50b53
Fixed audio manager not getting reset
NicoleYarroch Feb 24, 2020
f3bda0d
Refactored streaming managers
NicoleYarroch Feb 24, 2020
d1e8374
Added test cases for streaming managers
NicoleYarroch Feb 24, 2020
14e050a
Cleaning up docs in H264VideoEncoder class
NicoleYarroch Feb 24, 2020
6e1d5d7
Fixed formatting and logs
NicoleYarroch Feb 24, 2020
9ec0e9b
Merge branch 'develop' into bugfix/issue_1551_video_end_service_not_s…
NicoleYarroch Feb 25, 2020
9ef00f1
Fixed log
NicoleYarroch Feb 25, 2020
d78d99e
Attempting broken Travis test cases
NicoleYarroch Feb 25, 2020
86a411a
Attempting to fix Response Dispatcher tests
NicoleYarroch Feb 26, 2020
f5f59b5
Merge branch 'develop' into bugfix/issue_1551_video_end_service_not_s…
NicoleYarroch Feb 28, 2020
630b78c
Apply suggestions from code review
NicoleYarroch Feb 28, 2020
6b98b4e
Merge branch 'bugfix/issue_1551_video_end_service_not_sent_secondary_…
NicoleYarroch Feb 28, 2020
1afc4a5
Refactored error description in video encoder
NicoleYarroch Feb 28, 2020
9fdd058
Relocated func to streaming media manager
NicoleYarroch Mar 3, 2020
8cfa80f
Added weak/strong to blocks
NicoleYarroch Mar 3, 2020
7551276
Moved some video/audio to streaming media manager
NicoleYarroch Mar 3, 2020
d4d64cd
Fixed error log for NAK
NicoleYarroch Mar 3, 2020
ec454de
Fixed documentation formatting
NicoleYarroch Mar 3, 2020
1d86ebd
Refactored the secondary transport manager
NicoleYarroch Mar 3, 2020
87977bc
Renamed handlers
NicoleYarroch Mar 3, 2020
0fdf860
Renamed video/audio completion handlers
NicoleYarroch Mar 3, 2020
f3a3fd6
Removed redundant setting to `nil`
NicoleYarroch Mar 3, 2020
dc566e6
Cleaned up streaming log modules & logs
NicoleYarroch Mar 3, 2020
019bd97
Removed unnecessary methods
NicoleYarroch Mar 3, 2020
284ebf6
Fixed check for nil
NicoleYarroch Mar 3, 2020
25718ba
Fixed documentation for hmiLevel
NicoleYarroch Mar 3, 2020
0a91598
Refactored logs and docs
NicoleYarroch Mar 3, 2020
0fe7790
Removed unnecessary methods
NicoleYarroch Mar 3, 2020
472924f
Fixed documentation formatting
NicoleYarroch Mar 4, 2020
780115b
Fixed documentation
NicoleYarroch Mar 4, 2020
4ce0ef8
Removed typedef for completion handler
NicoleYarroch Mar 4, 2020
a7e811b
Added more logs to module map
NicoleYarroch Mar 5, 2020
ceae12e
Display link now stopped before end service sent
NicoleYarroch Mar 6, 2020
32dd840
Fixed audio test cases
NicoleYarroch Mar 6, 2020
bad3301
Fixed warning
NicoleYarroch Mar 6, 2020
f8ff3dc
removed dealloc
NicoleYarroch Mar 6, 2020
7a1c0f5
Added streaming media manager tests
NicoleYarroch Mar 6, 2020
a8e2781
removed focus from tests
NicoleYarroch Mar 6, 2020
619103b
Renamed private methods
NicoleYarroch Mar 6, 2020
d5582b4
Moved secondary trans. delegate to separate file
NicoleYarroch Mar 9, 2020
682b18c
Fixed documentation
NicoleYarroch Mar 9, 2020
1fe5dbd
Removed unneeded documentation
NicoleYarroch Mar 9, 2020
f4599fc
Added test cases
NicoleYarroch Mar 9, 2020
47478ee
Added secondary transport tests to lifecycle mgr
NicoleYarroch Mar 9, 2020
8314002
Fixed documentation
NicoleYarroch Mar 9, 2020
160602d
Fixed doc formatting
NicoleYarroch Mar 9, 2020
834797c
Added more documentation
NicoleYarroch Mar 9, 2020
791273c
Undo removal of methods from public header
NicoleYarroch Mar 9, 2020
7e41359
Fixed docs
NicoleYarroch Mar 9, 2020
e7be40a
Renamed method
NicoleYarroch Mar 9, 2020
b282a6f
Update SmartDeviceLink/SDLH264VideoEncoder.m
NicoleYarroch Mar 10, 2020
be041d6
Update SmartDeviceLink/SDLH264VideoEncoder.m
NicoleYarroch Mar 10, 2020
3b939c0
Update SmartDeviceLink/SDLLifecycleManager.m
NicoleYarroch Mar 10, 2020
4de2746
Update SmartDeviceLink/SDLLogFileModuleMap.m
NicoleYarroch Mar 10, 2020
c60f574
Update SmartDeviceLink/SDLLogFileModuleMap.m
NicoleYarroch Mar 10, 2020
7982163
Update SmartDeviceLink/SDLSecondaryTransportManager.h
NicoleYarroch Mar 10, 2020
bc011ba
Update SmartDeviceLink/SDLStreamingMediaManager.h
NicoleYarroch Mar 10, 2020
dd49854
Update SmartDeviceLink/SDLStreamingAudioLifecycleManager.h
NicoleYarroch Mar 10, 2020
7b14aff
Update SmartDeviceLink/SDLSecondaryTransportManager.m
NicoleYarroch Mar 10, 2020
a54b88c
Update SmartDeviceLink/SDLStreamingMediaManager.m
NicoleYarroch Mar 10, 2020
dd7f118
Update SmartDeviceLink/SDLStreamingMediaManager.m
NicoleYarroch Mar 10, 2020
c0a9112
Update SmartDeviceLink/SDLStreamingMediaManager.m
NicoleYarroch Mar 10, 2020
26f2251
Update SmartDeviceLink/SDLStreamingMediaManager.m
NicoleYarroch Mar 10, 2020
db393f7
Update SmartDeviceLink/SDLStreamingMediaManager.m
NicoleYarroch Mar 10, 2020
4781c9d
Update SmartDeviceLink/SDLStreamingVideoLifecycleManager.m
NicoleYarroch Mar 10, 2020
a93921b
Apply suggestions from code review
NicoleYarroch Mar 10, 2020
c4a0fd2
Combined test cases
NicoleYarroch Mar 10, 2020
7fe7d15
combining test cases
NicoleYarroch Mar 10, 2020
09bd41a
Fixed test description
NicoleYarroch Mar 10, 2020
7d692d3
Fixed test cases
NicoleYarroch Mar 10, 2020
c36db62
Fixed test description
NicoleYarroch Mar 10, 2020
87e9c61
renamed method and added logs
NicoleYarroch Mar 10, 2020
9887ea5
Apply suggestions from code review
NicoleYarroch Mar 10, 2020
6fd66a7
Moved secondary transport logic to stream mgr
NicoleYarroch Mar 11, 2020
6f3a175
Refactored nested blocks to use dispatch group
NicoleYarroch Mar 11, 2020
215bd7e
Refactored check for streaming app
NicoleYarroch Mar 11, 2020
d3e463e
Removed one-line method
NicoleYarroch Mar 11, 2020
60bab5c
Removed SecondaryTransportPrimaryProtocolHandler
NicoleYarroch Mar 11, 2020
d4000cc
Fixed doc grammar
NicoleYarroch Mar 11, 2020
977d788
Renamed variable
NicoleYarroch Mar 11, 2020
1f4f384
Fixed deprecations and function formatting
NicoleYarroch Mar 11, 2020
da7fcef
Renamed protocol method
NicoleYarroch Mar 11, 2020
b923c89
Relocated where notification is sent
NicoleYarroch Mar 11, 2020
c3087ff
Fixed debug logs
NicoleYarroch Mar 11, 2020
4af1c76
streaming media manager now destroys protocols
NicoleYarroch Mar 11, 2020
7b78839
Refactored methods
NicoleYarroch Mar 12, 2020
612a8f9
Refactored closing & opening new sessions
NicoleYarroch Mar 12, 2020
ed861d6
Consolidated streaming media manager tests
NicoleYarroch Mar 12, 2020
a7190df
Removed broken code that closes secondary transport
NicoleYarroch Mar 17, 2020
25e4d39
Fixed broken secondary transport disconnect
NicoleYarroch Mar 17, 2020
5c6a4ba
Removed race condition disconnects
NicoleYarroch Mar 17, 2020
13daaa6
Fixed transport not starting after erroring out
NicoleYarroch Mar 17, 2020
5ea4457
Updated documentation
NicoleYarroch Mar 20, 2020
6a16fe9
Renamed private method
NicoleYarroch Mar 20, 2020
245ba0c
Made public variable private
NicoleYarroch Mar 20, 2020
ac992e8
Made public methods private
NicoleYarroch Mar 20, 2020
631c9b4
Apply suggestions from code review
NicoleYarroch Mar 20, 2020
6636b87
Refactored dispatch_group code
NicoleYarroch Mar 20, 2020
788b74d
Merge branch 'bugfix/issue_1551_video_end_service_not_sent_secondary_…
NicoleYarroch Mar 20, 2020
27292f4
Merge branch 'develop' into bugfix/issue_1551_video_end_service_not_s…
NicoleYarroch Mar 20, 2020
e227bf4
Added documentation
NicoleYarroch Mar 23, 2020
81b4c34
Added documentation to stream managers
NicoleYarroch Mar 23, 2020
ef9adb3
Streams now opened and closed on same thread
NicoleYarroch Mar 24, 2020
244b540
Added weakSelf/strongSelf handling
NicoleYarroch Mar 24, 2020
7b5c862
Apply suggestions from code review
NicoleYarroch Mar 31, 2020
9cfcbd2
Added documentation to method
NicoleYarroch Mar 31, 2020
b77c02c
Refactored cancel timer method
NicoleYarroch Mar 31, 2020
fa2aaaa
Removed unnecessary shutdown code
NicoleYarroch Mar 31, 2020
6d0ca85
Added logs to TCPTransport start/stop funcs
NicoleYarroch Apr 1, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions SmartDeviceLink-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1395,6 +1395,7 @@
888DBAF022D528DE002A0AE2 /* SDLCloseApplicationResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = 888DBAEE22D528DE002A0AE2 /* SDLCloseApplicationResponse.m */; };
888F86FE221DEE200052FE4C /* SDLAsynchronousRPCOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 888F86FD221DEE1F0052FE4C /* SDLAsynchronousRPCOperation.m */; };
888F8700221DF4880052FE4C /* SDLAsynchronousRPCOperationSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 888F86FF221DF4880052FE4C /* SDLAsynchronousRPCOperationSpec.m */; };
88A118272412ACAD00B45FB5 /* SDLStreamingMediaManagerSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = DA661E2B1E553E7E001C1345 /* SDLStreamingMediaManagerSpec.m */; };
88A1CF1E21669AC7001ACC75 /* SDLLifecycleConfigurationUpdateSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 88A1CF1D21669AC7001ACC75 /* SDLLifecycleConfigurationUpdateSpec.m */; };
88A4A0FA22242AB400C6F01D /* SDLNavigationServiceDataSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 88A4A0F922242AB400C6F01D /* SDLNavigationServiceDataSpec.m */; };
88A5E7F4220B57F900495E8A /* SDLOnSystemCapabilityUpdatedSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 88A5E7F3220B57F900495E8A /* SDLOnSystemCapabilityUpdatedSpec.m */; };
Expand Down Expand Up @@ -1606,7 +1607,6 @@
E9C32B9E1AB20C5900F283AF /* EAAccessoryManager+SDLProtocols.h in Headers */ = {isa = PBXBuildFile; fileRef = E9C32B9A1AB20C5900F283AF /* EAAccessoryManager+SDLProtocols.h */; };
E9C32B9F1AB20C5900F283AF /* EAAccessoryManager+SDLProtocols.m in Sources */ = {isa = PBXBuildFile; fileRef = E9C32B9B1AB20C5900F283AF /* EAAccessoryManager+SDLProtocols.m */; };
EE28F9E3209802A500B1B61D /* SDLStreamingProtocolDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = EE6CBF872064CAEE00EEE0CA /* SDLStreamingProtocolDelegate.h */; };
EE38C0C3211C440400E170AD /* SDLSecondaryTransportPrimaryProtocolHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = EE38C0C2211C440400E170AD /* SDLSecondaryTransportPrimaryProtocolHandler.m */; };
EE460E082066B5F20006EDD3 /* SDLControlFramePayloadTransportEventUpdateSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = EE460E072066B5F20006EDD3 /* SDLControlFramePayloadTransportEventUpdateSpec.m */; };
EE460E0A2066B6E40006EDD3 /* SDLControlFramePayloadRegisterSecondaryTransportNakSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = EE460E092066B6E40006EDD3 /* SDLControlFramePayloadRegisterSecondaryTransportNakSpec.m */; };
EE5D1B33208EBCA900D17216 /* SDLTCPTransportSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = EE5D1B32208EBCA900D17216 /* SDLTCPTransportSpec.m */; };
Expand Down Expand Up @@ -3352,8 +3352,6 @@
E9C32B991AB20C5900F283AF /* EAAccessory+SDLProtocols.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "EAAccessory+SDLProtocols.m"; sourceTree = "<group>"; };
E9C32B9A1AB20C5900F283AF /* EAAccessoryManager+SDLProtocols.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "EAAccessoryManager+SDLProtocols.h"; sourceTree = "<group>"; };
E9C32B9B1AB20C5900F283AF /* EAAccessoryManager+SDLProtocols.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "EAAccessoryManager+SDLProtocols.m"; sourceTree = "<group>"; };
EE38C0C1211C43E100E170AD /* SDLSecondaryTransportPrimaryProtocolHandler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SDLSecondaryTransportPrimaryProtocolHandler.h; sourceTree = "<group>"; };
EE38C0C2211C440400E170AD /* SDLSecondaryTransportPrimaryProtocolHandler.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDLSecondaryTransportPrimaryProtocolHandler.m; sourceTree = "<group>"; };
EE460E072066B5F20006EDD3 /* SDLControlFramePayloadTransportEventUpdateSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDLControlFramePayloadTransportEventUpdateSpec.m; path = ControlFramePayloadSpecs/SDLControlFramePayloadTransportEventUpdateSpec.m; sourceTree = "<group>"; };
EE460E092066B6E40006EDD3 /* SDLControlFramePayloadRegisterSecondaryTransportNakSpec.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = SDLControlFramePayloadRegisterSecondaryTransportNakSpec.m; path = ControlFramePayloadSpecs/SDLControlFramePayloadRegisterSecondaryTransportNakSpec.m; sourceTree = "<group>"; };
EE5D1B32208EBCA900D17216 /* SDLTCPTransportSpec.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDLTCPTransportSpec.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -6513,8 +6511,6 @@
children = (
EE798CA32056120F008EDE8E /* SDLSecondaryTransportManager.h */,
EE798CA520561217008EDE8E /* SDLSecondaryTransportManager.m */,
EE38C0C1211C43E100E170AD /* SDLSecondaryTransportPrimaryProtocolHandler.h */,
EE38C0C2211C440400E170AD /* SDLSecondaryTransportPrimaryProtocolHandler.m */,
);
name = "Secondary Transport";
sourceTree = "<group>";
Expand Down Expand Up @@ -7700,7 +7696,6 @@
EED5CA021F4D18EC00F04000 /* SDLRAWH264Packetizer.m in Sources */,
9FE2471622D77AD500F8D2FC /* SDLWindowType.m in Sources */,
5D61FC851A84238C00846EE7 /* SDLDeviceLevelStatus.m in Sources */,
EE38C0C3211C440400E170AD /* SDLSecondaryTransportPrimaryProtocolHandler.m in Sources */,
5D9FDA981F2A7D3F00A495C8 /* emhashmap.c in Sources */,
5D61FD1E1A84238C00846EE7 /* SDLOnTBTClientState.m in Sources */,
5D0C29FD20D93D8C008B56CD /* SDLVideoStreamingState.m in Sources */,
Expand Down Expand Up @@ -8104,6 +8099,7 @@
162E83371A9BDE8B00906325 /* SDLResetGlobalPropertiesSpec.m in Sources */,
162E82DF1A9BDE8B00906325 /* SDLGlobalProperySpec.m in Sources */,
88DF998F22035D1700477AC1 /* SDLIAPSessionSpec.m in Sources */,
88A118272412ACAD00B45FB5 /* SDLStreamingMediaManagerSpec.m in Sources */,
5DD8406520FCE21A0082CE04 /* SDLElectronicParkBrakeStatusSpec.m in Sources */,
162E82F61A9BDE8B00906325 /* SDLRequestTypeSpec.m in Sources */,
5DE35E4520CAFC5D0034BE5A /* SDLChoiceCellSpec.m in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion SmartDeviceLink.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,6 @@ sdefault.public_header_files = [
'SmartDeviceLink/SDLSeatLocationCapability.h',
'SmartDeviceLink/SDLSeatMemoryAction.h',
'SmartDeviceLink/SDLSeatMemoryActionType.h',
'SmartDeviceLink/SDLSupportedSeat.h',
'SmartDeviceLink/SDLSecurityType.h',
'SmartDeviceLink/SDLSendHapticData.h',
'SmartDeviceLink/SDLSendHapticDataResponse.h',
Expand Down Expand Up @@ -378,6 +377,7 @@ sdefault.public_header_files = [
'SmartDeviceLink/SDLSubscribeVehicleDataResponse.h',
'SmartDeviceLink/SDLSubscribeWaypoints.h',
'SmartDeviceLink/SDLSubscribeWaypointsResponse.h',
'SmartDeviceLink/SDLSupportedSeat.h',
'SmartDeviceLink/SDLSyncMsgVersion.h',
'SmartDeviceLink/SDLMsgVersion.h',
'SmartDeviceLink/SDLSyncPData.h',
Expand Down
13 changes: 12 additions & 1 deletion SmartDeviceLink/SDLCarWindow.m
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,14 @@ - (void)syncFrame {
CGImageRef imageRef = screenshot.CGImage;
CVPixelBufferRef pixelBuffer = [self.class sdl_pixelBufferForImageRef:imageRef usingPool:self.streamManager.pixelBufferPool];
if (pixelBuffer != nil) {
[self.streamManager sendVideoData:pixelBuffer];
BOOL success = [self.streamManager sendVideoData:pixelBuffer];
if (!success) {
SDLLogE(@"Video frame will not be sent because the video frame encoding failed");
return;
}
CVPixelBufferRelease(pixelBuffer);
} else {
SDLLogE(@"Video frame will not be sent because the pixelBuffer is nil");
}
}

Expand Down Expand Up @@ -191,6 +197,11 @@ - (void)sdl_applyDisplayDimensionsToRootViewController:(UIViewController *)rootV
return;
}

if (CGRectEqualToRect(rootViewController.view.frame, self.streamManager.videoScaleManager.appViewportFrame)) {
SDLLogV(@"The rootViewController frame is already the correct size: %@", NSStringFromCGRect(rootViewController.view.frame));
return;
}

rootViewController.view.frame = self.streamManager.videoScaleManager.appViewportFrame;
rootViewController.view.bounds = rootViewController.view.frame;

Expand Down
2 changes: 1 addition & 1 deletion SmartDeviceLink/SDLH264VideoEncoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ extern NSString *const SDLErrorDomainVideoEncoder;
/**
* The pixel buffer pool reference returned back from an active VTCompressionSessionRef encoder.
*
* @warning This will only return a valid pixel buffer pool after the encoder has been initialized (when the video session has started).
* @warning This will only return a valid pixel buffer pool after the encoder has been initialized (when the video session has started).
* @discussion Clients may call this once and retain the resulting pool, this call is cheap enough that it's OK to call it once per frame.
*/
@property (assign, nonatomic, readonly) CVPixelBufferPoolRef CV_NULLABLE pixelBufferPool;
Expand Down
64 changes: 50 additions & 14 deletions SmartDeviceLink/SDLH264VideoEncoder.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ @interface SDLH264VideoEncoder ()
@property (assign, nonatomic) NSUInteger currentFrameNumber;
@property (assign, nonatomic) double timestampOffset;

@property (assign, nonatomic, readwrite) CVPixelBufferPoolRef CV_NULLABLE pixelBufferPool;

/// Width and height of the video frame.
@property (assign, nonatomic) CGSize dimensions;

@end


Expand Down Expand Up @@ -54,6 +59,7 @@ - (instancetype)initWithProtocol:(SDLVideoStreamingProtocol)protocol dimensions:
_compressionSession = NULL;
_currentFrameNumber = 0;
_videoEncoderSettings = properties;
_dimensions = dimensions;

_delegate = delegate;

Expand All @@ -63,9 +69,8 @@ - (instancetype)initWithProtocol:(SDLVideoStreamingProtocol)protocol dimensions:
status = VTCompressionSessionCreate(NULL, (int32_t)dimensions.width, (int32_t)dimensions.height, kCMVideoCodecType_H264, NULL, self.sdl_pixelBufferOptions, NULL, &sdl_videoEncoderOutputCallback, (__bridge void *)self, &_compressionSession);

if (status != noErr) {
if (!*error) {
*error = [NSError errorWithDomain:SDLErrorDomainVideoEncoder code:SDLVideoEncoderErrorConfigurationCompressionSessionCreationFailure userInfo:@{ @"OSStatus": @(status) }];
SDLLogE(@"Error attempting to create video compression session: %@", *error);
if (error != NULL) {
*error = [NSError errorWithDomain:SDLErrorDomainVideoEncoder code:SDLVideoEncoderErrorConfigurationCompressionSessionCreationFailure userInfo:@{@"OSStatus":@(status), NSLocalizedDescriptionKey:@"Compression session could not be created"}];
}

return nil;
Expand All @@ -78,8 +83,8 @@ - (instancetype)initWithProtocol:(SDLVideoStreamingProtocol)protocol dimensions:
CFDictionaryRef supportedProperties;
status = VTSessionCopySupportedPropertyDictionary(self.compressionSession, &supportedProperties);
if (status != noErr) {
if (!*error) {
*error = [NSError errorWithDomain:SDLErrorDomainVideoEncoder code:SDLVideoEncoderErrorConfigurationCompressionSessionSetPropertyFailure userInfo:@{ @"OSStatus": @(status) }];
if (error != NULL) {
joeljfischer marked this conversation as resolved.
Show resolved Hide resolved
*error = [NSError errorWithDomain:SDLErrorDomainVideoEncoder code:SDLVideoEncoderErrorConfigurationCompressionSessionSetPropertyFailure userInfo:@{@"OSStatus":@(status), NSLocalizedDescriptionKey:[NSString stringWithFormat:@"\"%@\" are not supported properties.", supportedProperties]}];
}

return nil;
Expand All @@ -88,9 +93,8 @@ - (instancetype)initWithProtocol:(SDLVideoStreamingProtocol)protocol dimensions:
NSArray* videoEncoderKeys = self.videoEncoderSettings.allKeys;
for (NSString *key in videoEncoderKeys) {
if (CFDictionaryContainsKey(supportedProperties, (__bridge CFStringRef)key) == false) {
if (!*error) {
NSString *description = [NSString stringWithFormat:@"\"%@\" is not a supported key.", key];
*error = [NSError errorWithDomain:SDLErrorDomainVideoEncoder code:SDLVideoEncoderErrorConfigurationCompressionSessionSetPropertyFailure userInfo:@{NSLocalizedDescriptionKey: description}];
if (error != NULL) {
NicoleYarroch marked this conversation as resolved.
Show resolved Hide resolved
*error = [NSError errorWithDomain:SDLErrorDomainVideoEncoder code:SDLVideoEncoderErrorConfigurationCompressionSessionSetPropertyFailure userInfo:@{NSLocalizedDescriptionKey:[NSString stringWithFormat:@"\"%@\" is not a supported key.", key]}];
}
CFRelease(supportedProperties);
return nil;
Expand All @@ -104,9 +108,8 @@ - (instancetype)initWithProtocol:(SDLVideoStreamingProtocol)protocol dimensions:

status = VTSessionSetProperty(self.compressionSession, (__bridge CFStringRef)key, (__bridge CFTypeRef)value);
if (status != noErr) {
if (!*error) {
NSString *description = [NSString stringWithFormat:@"Setting key failed \"%@\"", key];
*error = [NSError errorWithDomain:SDLErrorDomainVideoEncoder code:SDLVideoEncoderErrorConfigurationCompressionSessionSetPropertyFailure userInfo:@{NSLocalizedDescriptionKey: description, @"OSStatus": @(status)}];
if (error != NULL) {
NicoleYarroch marked this conversation as resolved.
Show resolved Hide resolved
*error = [NSError errorWithDomain:SDLErrorDomainVideoEncoder code:SDLVideoEncoderErrorConfigurationCompressionSessionSetPropertyFailure userInfo:@{@"OSStatus": @(status), NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Setting key failed \"%@\"", key]}];
}
return nil;
}
Expand All @@ -117,8 +120,8 @@ - (instancetype)initWithProtocol:(SDLVideoStreamingProtocol)protocol dimensions:
} else if ([protocol isEqualToEnum:SDLVideoStreamingProtocolRTP]) {
_packetizer = [[SDLRTPH264Packetizer alloc] initWithSSRC:ssrc];
} else {
if (!*error) {
*error = [NSError errorWithDomain:SDLErrorDomainVideoEncoder code:SDLVideoEncoderErrorProtocolUnknown userInfo:@{ @"encoder": protocol}];
if (error != NULL) {
NicoleYarroch marked this conversation as resolved.
Show resolved Hide resolved
*error = [NSError errorWithDomain:SDLErrorDomainVideoEncoder code:SDLVideoEncoderErrorProtocolUnknown userInfo:@{@"encoder": protocol}];
}
return nil;
}
Expand All @@ -129,6 +132,9 @@ - (instancetype)initWithProtocol:(SDLVideoStreamingProtocol)protocol dimensions:
}

- (void)stop {
_currentFrameNumber = 0;
_timestampOffset = 0.0;

if (self.compressionSession != NULL) {
VTCompressionSessionInvalidate(self.compressionSession);
CFRelease(self.compressionSession);
Expand Down Expand Up @@ -176,11 +182,28 @@ - (CVPixelBufferRef CV_NULLABLE)newPixelBuffer {
}

- (CVPixelBufferPoolRef CV_NULLABLE)pixelBufferPool {
return VTCompressionSessionGetPixelBufferPool(self.compressionSession);
// HAX: When the app is backgrounded, sometimes the compression session gets invalidated (this can happen the first time the app is backgrounded or the tenth). This causes the pool and/or the compression session to fail when the app is foregrounded and video frames are sent again. Attempt to fix this by recreating the compression session.
if (_pixelBufferPool == NULL) {
BOOL success = [self sdl_resetCompressionSession];
if (!success) {
return NULL;
}

_pixelBufferPool = VTCompressionSessionGetPixelBufferPool(self.compressionSession);
}

return _pixelBufferPool;
}

#pragma mark - Private
#pragma mark Callback

/// Callback function that VideoToolbox calls when encoding is complete.
/// @param outputCallbackRefCon The callback's reference value
/// @param sourceFrameRefCon The frame's reference value
/// @param status Returns `noErr` if compression was successful, or an error if not successful
/// @param infoFlags Information about the encode operation (frame dropped or if encode ran asynchronously)
/// @param sampleBuffer Contains the compressed frame if compression was successful and the frame was not dropped; null otherwise
void sdl_videoEncoderOutputCallback(void * CM_NULLABLE outputCallbackRefCon, void * CM_NULLABLE sourceFrameRefCon, OSStatus status, VTEncodeInfoFlags infoFlags, CM_NULLABLE CMSampleBufferRef sampleBuffer) {
// If there was an error in the encoding, drop the frame
if (status != noErr) {
Expand Down Expand Up @@ -312,6 +335,19 @@ + (NSArray *)sdl_extractNalUnitsFromSampleBuffer:(CMSampleBufferRef)sampleBuffer
return nalUnits;
}

/// Attempts to create a new VTCompressionSession using the dimensions passed when the video encoder was created and returns whether or not creating the new compression session was created successfully.
- (BOOL)sdl_resetCompressionSession {
// Destroy the current compression session before attempting to create a new one. Otherwise the attempt to create a new compression session sometimes fails.
if (self.compressionSession != NULL) {
VTCompressionSessionInvalidate(self.compressionSession);
CFRelease(self.compressionSession);
self.compressionSession = NULL;
}

OSStatus status = VTCompressionSessionCreate(NULL, (int32_t)self.dimensions.width, (int32_t)self.dimensions.height, kCMVideoCodecType_H264, NULL, self.sdl_pixelBufferOptions, NULL, &sdl_videoEncoderOutputCallback, (__bridge void *)self, &_compressionSession);
return (status == noErr);
}

@end

NS_ASSUME_NONNULL_END
Loading