vlc | branch: master | Marvin Scholz <[email protected]> | Sat Jun 24 20:15:26 
2017 +0200| [18b78cca3141c98cde1969f84b3f4f36fd2e87a6] | committer: Marvin 
Scholz

rd/bonjour: Use Chromecast name and model from TXT record

Extract the Chromecast name and model from the TXT records ("md", "fn")
and use them as name, if available, to make it easier to identify the
Chromecast.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=18b78cca3141c98cde1969f84b3f4f36fd2e87a6
---

 modules/services_discovery/bonjour.m | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/modules/services_discovery/bonjour.m 
b/modules/services_discovery/bonjour.m
index 03552aec54..6f7261e5d6 100644
--- a/modules/services_discovery/bonjour.m
+++ b/modules/services_discovery/bonjour.m
@@ -301,9 +301,19 @@ NSString *const VLCBonjourRendererDemux         = 
@"VLCBonjourRendererDemux";
 
     NSString *uri = [NSString stringWithFormat:@"%@://%@:%ld", protocol, 
netService.hostName, netService.port];
     NSDictionary *txtDict = [NSNetService 
dictionaryFromTXTRecordData:[netService TXTRecordData]];
-
+    NSString *displayName = netService.name;
+
+    if ([netService.type isEqualToString:@"_googlecast._tcp."]) {
+        NSData *modelData = [txtDict objectForKey:@"md"];
+        NSData *nameData = [txtDict objectForKey:@"fn"];
+        if (modelData && nameData) {
+            NSString *model = [[NSString alloc] initWithData:modelData 
encoding:NSUTF8StringEncoding];
+            NSString *name = [[NSString alloc] initWithData:nameData 
encoding:NSUTF8StringEncoding];
+            displayName = [NSString stringWithFormat:@"%@ (%@)", name, model];
+        }
+    }
     // TODO: Detect rendered capabilities and adapt to work with not just 
chromecast
-    vlc_renderer_item_t *p_renderer_item = vlc_renderer_item_new( 
"chromecast", [netService.name UTF8String],
+    vlc_renderer_item_t *p_renderer_item = vlc_renderer_item_new( 
"chromecast", [displayName UTF8String],
                                                                  [uri 
UTF8String], NULL, "cc_demux",
                                                                  "", 
VLC_RENDERER_CAN_VIDEO );
     if (p_renderer_item != NULL) {

_______________________________________________
vlc-commits mailing list
[email protected]
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to